0
votes

I'm trying to establish a communication with a PLC via serial port Modbus RTU using javasccript, I found some libraries online, but I don't know how to manipulate the functions of this libraries in order to write and read data from specific register in the plc, I also guess that I have to do a format changing of data frame from text to hexa. I'm stuck with this for more than a week if you have a lead or explanations plz help me

images : enter image description here

enter image description here

1
It's easier to read and understand the question if the code is added directly into the body instead of picture. - Gabriel Lupu
and may I ask what libraries are those? There is a fully functional implementation of Modbus RTU written in JS. Just follow the examples and you won't have to manipulate much. - Marcos G.

1 Answers

0
votes

I would recommend get it working between your code and a Modbus emulator, not the PLC. Once you get YOUR code working, then you can work on the PLC.

What's cool about using an emulator initially, you could also use IT to be the Master to talk to the PLC (similar to how you got your code working as the Master to the emulator as the Slave). The emulator can provide good understanding of both sides before getting the 2 ends to talk to themselves (i.e. the actual Master and the actual Slave(s)). Emulators can also provide good diagnostic details. That's one issue when diagnosing comm - which side is causing the problem (or is it a physical layer issue, e.g. wired wrong). A good emulator can help diagnose issues before doing "real" comm.