Problema con un flow

buongiorno sono un principante premetto , avrei bisogno di un aiuto . Tentando di scrivere un valore negativo su una variabile s7 write mi genera questo errore :"RangeError: The value of "value" is out of range. It must be >= 0 and <= 65535. Received -2". Qualcuno puo' gentilmente aiutarmi a risolverlo .grazie anticipatamente

You may need to filter out any negative values, or to convert them to their absolute value with a function like:

let value = -2
msg.payload = Math.abs(value);
return msg;

This will return

msg.payload = 2

ciao Harold il forse non mi sono spiegato bene scusa io ho bisogno che scriva su s7 il valore negativo .
Se il dato che mi arriva e' positivo allora lui scrive nella variabile correttamente se invece arriva negativo ed io ho bisogno che lo scriva negativo mi da' l'errore che ho scritto nella richiesta d'aiuto e nella variabile del plc non scrive nulla .Premetto che la variabile del plc accetta sia numeri positivi che negativi . spero di essere stato piu chiaro grazie ancora

In that case I will need more information. What node is sending the error "RangeError: The value of "value" is out of range. It must be >= 0 and <= 65535. Received -2"?

Also could you post the flow that you are using that is causing this error? Here is a link explaining how to post flows: https://discourse.nodered.org/t/how-to-share-code-or-flow-json

ho seguito il metodo ma sono nuovo e non posso caricare dati :frowning:

il nodo e' quello che scrive su variabile del plc s7
collegato

cerco di spiegarti ancora meglio : da un termostato collegato ad alexa quando chiedo di diminuire la temperatura tipo abbassa di 2 gradi lei invia -2 io quel dato lo devo trasferire a variabile plc per comandare un alro device ma mi da' l'errore se invede chiedo di aumentare la temp quindi un valore positivo questo viene scritto nella variabile senza problemi

Just select the nodes of interest, press CTRL+E then copy to clipboard, then paste into a reply between 3 backticks

```
like this
```

E per favore, scrivi in inglese, se non lo conosci bene puoi usare Google translate, questo è un forum in lingua inglese ed è una cortesia usare questa lingua. :wink:

First of all, I assume you're using the S7 node (you did not specify).

Check how you declared the variable. Depending on how you did it, the S7 assumes your variable is an unsigned int, and will throw an error if you feed it a negative number:

So if you used WORD or DWORD, it will throw an error.

Assuming you are using INT or DINT, you have to check in the PLC DB if the tag is defined as signed or unsigned int (Siemens PLCs are picky when it comes to storing tags, and the way they store them is a bit backwards). It could be that you assume the tag accepts negative numbers but it is defined as unsigned int.

i tried all type of combination like INT DINT insegned or signed but nothing same error

can u say me how i can put the value 30 on dashboard tx a lot for answer{"topic":"","payload":{"signal":"db1","path":"DB1,WORD2","error":0,"value":[30]},"_msgid":"528d32c3a9469f31"} .

the problem with s7 node i resolved in another way [
{
"id": "64148085f2b216b3",
"type": "change",
"z": "1460fb417d89c17f",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "-2",
"fromt": "num",
"to": "152",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "-1",
"fromt": "num",
"to": "151",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "-3",
"fromt": "num",
"to": "153",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "-4",
"fromt": "num",
"to": "154",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "-5",
"fromt": "num",
"to": "155",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 680,
"wires": [
[
"38f9b9741b31bd28"
]
]
}
]
so if recive -1 write to s7 151 and after i reconvert 151 into -1 in tia portal

Can you post a TIA screenshot from the DB where you have your tag? Also, the S7 node variable configuration for that value?

In your example, you are reading "WORD2", but WORD variables are unsigned, so you can't store the integer values.

You must:

  1. Use INT or DINT in the S7 node

  2. Define the tag as INT or DINT in TIA-Portal
    image

i cant upload imagine maibe couse im new

GREATTTT i done like u wtrite and bingo tx a lot much better now . now i have another question if u can answer me .
i need to know i can i extract this value on dashboard
topic: ""

payload: object

signal: "db1"

path: "DB1,WORD2"

error: 0

value: array[1]

0: 34

_msgid: "9c5f2ddc06ea1ac3"

What value?

Can you put a debug node on there and show me an expanded screenshot of the object (including the array)?

To show the value you can use a Dashboard ui-text node, but you have to write the correct path in the msg that you receive.

You may also want to avoid numeric properties and give it a name instead (i see you have a property called 0).

For screenshots, you can use the snipping tool if you're on windows, it will copy the screen (or part of it) to your clipboard, then when you are writing, just press Ctrl+V (paste) and it will upload and paste the image.

i tried few times to upload screenshoot but the forum cant do that have u a mail ?
image

Just use copy + paste directly into a reply. Or copy a snip image from explorer and paste into reply.

id like to see thin value on dashboard thanks for help and sorry all