Modbus data swap

I have these data and i want to convert it on real value.
[16384,17372,55706,17374,49152,17359,0,16680,0,16696,39322,16729,45875,17224,29491,17352,49152,17363,32768,17237,45875,17236,26214,17255,52429,16966,52429,16204,19661,17302]

Total float tag on a plc side is 15 but on a node-red side I get output of 30 int value.

Install node-red-contrib-buffer-parser, feed the data into a parser node, then you can do whatever you need to the data (convert to string/float/int32/bit array/whatever) big/little endian swap 16/32 etc

I installed it but i have some doubt What's the ofset value i have to take to convert it again in float.

Read the built in help. Offset is the byte position to take from the buffer. It explains it better there.

If you get stuck, tell us where in the data you expect the float values to be and what you expect them to be.


swap

I did this configuration but data is not properly converted into float.

1 Like

As I said before...


original data is look like this on plc side

Swap16, FloatLE

image

[{"id":"ae45490c5740f4bb","type":"buffer-parser","z":"eaa6d97a6ede80ab","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"Meter_1_V_RY","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_V_RB","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_V_YB","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_C_R","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_C_Y","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_C_B","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_P_R","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_P_Y","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"Meter_1_P_B","offset":32,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1120,"y":560,"wires":[["62cc010bae21e18e"]]},{"id":"847a9249773972a5","type":"inject","z":"eaa6d97a6ede80ab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[16384,17372,55706,17374,49152,17359,0,16680,0,16696,39322,16729,45875,17224,29491,17352,49152,17363,32768,17237,45875,17236,26214,17255,52429,16966,52429,16204,19661,17302]","payloadType":"json","x":1090,"y":500,"wires":[["ae45490c5740f4bb"]]},{"id":"62cc010bae21e18e","type":"debug","z":"eaa6d97a6ede80ab","name":"debug 113","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1310,"y":560,"wires":[]}]
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.