Help To Send Hex Modbus Command using TCP Port

#1

Hi All,

I've want to send Modbus command using Hex on payload, this picture is screen shoot from Modbus Poll for test send and receive command.

This is my flow, because I'm in beginning to start read modbus using RTU Modem.

with this function i can't get data like the Modbus Poll/Real Data.
Many Thanks for your help!

0 Likes

#2

i think you should use https://flows.nodered.org/node/node-red-contrib-modbus

0 Likes

#3

For debugging purpose, have you tried:

msg.payload = new Buffer([0x01,0x03,0x0C,0x82,0x00,0x01,0x27,0x72]);

0 Likes

#4

I've try it, but it didn't work, maybe i'mnot directly connect to Modbus Slave.

0 Likes

#5

This is result when i'm check in TCP Net Assistant.

image

The command not send as "SEND HEX" command, but send as "RECV HEX" so i'm not receive any data. The command should be send as "SEND HEX" then reply as "RECV HEX" (this pic when i send command use Net assistant)

image

0 Likes

#6

Hi All,

How to get an reply from tcp request node? I'm still not receive data, even my stimulate binary is correct.

Here is my flow:

[{"id":"1c231160.b9495f","type":"function","z":"f31e75e1.ac9308","name":"","func":"//msg.payload =Buffer.from([0x01,0x03,0x0C,0x82,0x00,0x01,0x27,0x72]);\nmsg.payload  = Buffer.from('01030c8200012772', 'hex');\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":680,"wires":[["a1f20b3e.07ec68"]]},{"id":"48f7cf41.f1f9e","type":"debug","z":"f31e75e1.ac9308","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":680,"wires":[]},{"id":"a1f20b3e.07ec68","type":"tcp request","z":"f31e75e1.ac9308","server":"103.253.113.56","port":"1","out":"time","splitc":"1000","name":"","x":640,"y":720,"wires":[["48f7cf41.f1f9e"]]},{"id":"b6cb3736.feacd","type":"inject","z":"f31e75e1.ac9308","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":720,"wires":[["1c231160.b9495f"]]}]
0 Likes

#7

Your tcp node is set to point at port 1... that is very unlikely to be the correct tcp port to connect to. I would expect something above 1024 to be honest - but I don't know the device you are talking to.

0 Likes

#8

Hy @dceejay , thanks for your advice. But i've change the port to 9260, still got same result.

So, i want to read VFD parameters using an RTU Modem (four faith f214). If i using TCP net assistant to send command, i can received the data from the vfd. For example, i want to read the output frequency. I send this command using TCP Net Assistant:
01 03 0C 82 00 01 27 72

and the response, i got this:
01 03 02 02 58 B8 DE

But, when i send command from TCP Node in node-red, I cant receive any data.

Regards,

0 Likes

#9

I guess it is worth to make a trial using the following code inside the function (just adding a \n for string termination, or eventually a \r or \n\r)

msg.payload  = Buffer.from('01030c8200012772', 'hex') + '\n';
return msg;
1 Like

#10

Port 502 is a dedicated port number specifically for ModbusTCP.

https://support.industry.siemens.com/cs/document/34010717/which-ports-are-released-for-modbus-tcp-communication-and-how-many-modbus-clients-can-communicate-with-a-simatic-s7-pn-cpu-as-modbus-server-?dti=0&lc=en-WW

0 Likes

#11

Hi Andrei,

Still send as RECV Hex after adding \n or \r. And i'm try adding CR in Hex, still same result. The payload that i'm send still in RECV monitored from Net Assistant Monitor.

regards,

0 Likes

#12

This is my topology, so my plan is read the data form site and connect to Node-red. I can read it from TCP Net Assistant, but until now still not working in node-red.

0 Likes

#13

Where you show the F2414 you need a "Protocol Converter" to convert from serial ModbusRTU over RS485 to ModbusTCP.

I have found that often these devices do not correctly "convert" the Modbus protocol from RTU to TCP. They simply pass it through in a TCP package. If this is the case It needs to be processed as ModbusRTU using a virtual Com port. This involves loading and configuring Virtual COM Port software on the receiving device. This does not allow the simplicity and flexibility of proper conversion to ModbusTCP.

NodeRED could be the protocol converter, or you will need a device that performs this specific task. Often these devices have a few different modes and numerous settings.

This is one I have used in many applications.

2 Likes

#14

Hello All,

Thank you very much for all advice. @Andrei your payload is working great!.
Here is some pic of my project:

My node:
image

RTU Monitor using SSCOM
image

Reply debug from RTU modem
image

Thank you all, & Have A Nice Day!

1 Like