Skip to content
Advertisement

Can someone help me understand how to use pyModbus to encode string data to a digital display board?

Using: python3, pyModbusTCP, Linux, Raspberry pi 4, ViewMarq by Automation Direct

I have a digital display board that can receive ModBusTCP ascii packets. The information below is similar to what I am trying to send as a test message.

<ID 30><CLR><WIN 0 0 287 31><POS 0 0><LJ><BL N><CS 0><GRN><T>Test</T>

I am new to python Modbus and am trying to use a pyModbus client to send data to its holding register of 411000 via port 502 which I believe is just 11000 by dropping the 4. I have set up a simple client script that can communicate with the board but I have to encode the message to send it to the register. In the world of PLCs this is much simpler but that isnt an option here.

Using the windows application to populate the board, my Wireshark modbus data was detected as follows:

JavaScript

From here, I am a bit confused as to what to do next. I tried reading those register addresses but saw nothing there.

JavaScript

and received…

JavaScript

Can someone help me understand if I’m moving in the right direction and what should I be doing next? I’m trying to keep this as simple as possible and I appreciate the help.

Thank you in advance.

Update:

After a suggestion I looked deeper into the documentation. The documentation of the display does these registers immediately go back to 0 when the execution is complete. From the docs *

c) Word Swap and Byte Swap should be checked assuming the selections are Off (default) in the ViewMarq display. d) Slave Modbus Memory Starting Address is the location of the Command Block within the ViewMarq display (400000+11000 = 411000). e) The Function Code should be set to 16 – Write Multiple Registers.

I have to admit. I have no idea how to write a payload. I rewrote the code and tried a payload construction approach.

JavaScript

This didnt work. It ran but the board didn’t update. Suggestions are very welcome.

Advertisement

Answer

This is not a complete solution for your problem, but only a suggestion what to do next.

  • Read the documentation of the display.

    • Maybe the command buffer registers are write only?
    • Or maybe you will read all 0 when the display has processed the command?
  • Try to read the response buffer registers.

  • Convert the data from your Wireshark log to hex:
    18748=0x493c -> 0x49='I' 0x3c='<' -> little endian "<I"
    8260=0x2044 -> 0x20=' ' 0x44='D' -> little endian "D "
    12339=0x3033 -> 0x30='0' 0x33='3' -> little endian "30"

These 3 values written to registers correspond to "<ID 30" etc.

So every Modbus register seems to correspond to 2 bytes of the buffer in little-endian byte order.
Most probably it is the same for the response buffer.

Edit after question has been edited:

If your program does not work, compare the data sent from your program with the data sent from the Windows application, e.g. using Wireshark.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement