Modbus tcp data type real

Hello everyone, I was learning about the modbus nodes for node red and as you will see in the images if I can make a communication, I am working with a siemens s7 1200 plc



up to there everything perfect, but that is when my modbus registers are integers (int) as you see in the image, but I want to put registers with floating point values ​​(Real)

but what I get when reading the logs is this

foto5
I obviously want to obtain the values ​​(12.4564 and 3.456) in the red node, which are the real type values ​​that I placed.
Maybe it's because now my registers are 32 bits instead of 16 bits, but I'm not sure.
I hope I made myself understood, thanks in advance

Have you tried the S7 node ? maybe you can read those variables directly without having to send them over modbus ?

1 Like

Of course I have used that node, but let's say I have that inconvenience, of course with the s7 node it is much easier, but I also want to learn modbus communication well to be able to use a schneider plc for example :slight_smile:

I see .. In that case .. yes Float values are usually 32bit .. and you read 2 x 16bit registers and use a handy node like node-red-contrib-buffer-parser to convert them

I dont know anything about Siemens or how you can send the values in 2 mob. registers
.. but if you already have that set then add a Debug node (set to complete msg object) after your Modbus Flex getter node, capture a msg and share it in a post, tell us what the expected value should be to help you convert it.


in this case I am reading 16 modbus registers since my variables are real and each one is equivalent to 2 registers, am I correct?

yeap :wink: .. and here is a flow with buffer-parser that makes it into a float
i used a buffer-maker to simulate data coming from your modbus node

[{"id":"5e512e1cfc7214dc","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":3700,"wires":[["0f6fb6f8c466c8b4"]]},{"id":"0f6fb6f8c466c8b4","type":"buffer-maker","z":"54efb553244c241f","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"int16be","length":1,"dataType":"num","data":"16711"},{"name":"item2","type":"int16be","length":1,"dataType":"num","data":"19818"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":450,"y":3700,"wires":[["8f91c7f34ad3bde6","e406862c9e6c737c"]]},{"id":"b4e162de82a6fcdb","type":"debug","z":"54efb553244c241f","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":3700,"wires":[]},{"id":"8f91c7f34ad3bde6","type":"buffer-parser","z":"54efb553244c241f","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","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":810,"y":3700,"wires":[["b4e162de82a6fcdb"]]},{"id":"e406862c9e6c737c","type":"debug","z":"54efb553244c241f","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":3620,"wires":[]},{"id":"273ac606199b13dd","type":"comment","z":"54efb553244c241f","name":"From Modbus node","info":"","x":470,"y":3760,"wires":[]}]

image

2 Likes

thanks, I was analyzing the flow, I changed the data and look what came out :c


wait .. your weren't meant to use the buffer-maker for your setup .. that was just to create the buffer to simulate your data .. since i dont have your device
just use the Buffer-parser node right after your Modbus node, set to convert to float(be)

[EDIT]

my mistake .. after looking at the error a bit more closely it was the buffer-maker that was out of range .. meaning the 2 x 16bit values should have been configured as unisigned UInt16

image

1 Like

now it works great and i can see the real data of my plc, thank you very much for taking your time and helping me :slight_smile:

1 Like

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