Testing 8CH relay modbus using modpoll on Raspberry Pi - cannot get past "Reply time-out!"

Hi, I am brand new to this forum, rs485, and modbus !!! I am trying to use WaveShare Modbus RTU 8-ch Relay Module connected to WaveShare USB to RS485 on Raspberry Pi, attempting to test over terminal - using ssh, to at least read the registers, using the tool modpoll on modbusdriver.com. I followed all instructions, like:

I have done the following (Raspberry Pi - 4B+ - with latest Buster OS):

  1. Connected products (Relay to Power 5V, Relay to USB 3 wires, GND, A+, B-; and USB)
  2. Check the drivers (already in the latest kernel of OS Buster) - checked this with command <lsmod | grep "usbserial"> gives the output: <usbserial 36864 1 ftdi_sio>
  3. Checked mounting of USB <ls -l /dev/ttyUSB0 >
  4. Added my uid to dialout, for my uid to have access to the /dev/ttyUSB0 (command groups includes dialout)
    5. sudo raspi-config / 5 Interfacing Options / a6 Serial / enable.
  5. Installed ModBus testing software to be run from ssh, with commands:
    a) wget https://www.modbusdriver.com/downloads/modpoll.tgz
    b) tar xzf modpoll.tgz && rm modpoll.tgz
    c) export PATH=$PWD/modpoll/linux_arm-eabihf:$PATH
  6. Tested the above config with modbusdriver modpoll.
    <modpoll -m rtu -a 1 -b 9600 -d 8 /dev/ttyUSB0> (I have tried another 100 commands, like including -a 1 ( for slave 1), etc. And, when I run the command modpoll, I can see the Tx / Rx lights flash on the 8CH relay.
Above command gives the following:

----------------------------------------------
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU, FC3
Slave configuration...: address = 1, start reference = 1, count = 1
Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
-- Polling slave...
Reply time-out!
----------------------------------------------

I do not know where to look anymore for getting it work. Have also sent waveshare support an email - no reply yet (maybe its the English).

- One area that I am still suspecting is the USB driver - the USB port ttyUSB0 seams fine - with all tests, using the built-in driver into the kernel. But - do I need to use a driver from WaveShare?
- Or does anyone know where I should be looking?

The protocol manual of the 8CH product is here. I also suspect my understanding of hex commands using modbus, can anyone give me a command that I can try to get at least some comms back?

In the protocol manual, section "read the state of all relays", they state that a command of "01 01 00 FF 00 01 CD FA" will give the state of all relays back. I assume this is hex.

So I tried the command <modpoll -a1 -1 /dev/ttyUSB0 010100FF0001CDFA>, which does not work, gives answer <modpoll: Illegal write data value!>, so I tried to translate this hex command into decimal using this translator, which gives the answer <72340164231417338>, but the command <modpoll -1 /dev/ttyUSB0 72340164231417338> also produces <modpoll: Illegal write data value!>.

Any other ideas?
 
Hi.

I don't know if modpoll also takes complete request telegrams as arguments but you should try to translate the "read the state of all relays"-request to the arguments which modpoll understands:
$> modpoll -a1 -t0 -r255 -0 -c1 -1 /dev/ttyUSB...

The request (01 01 00 FF 00 01 CD FA) split into the arguments gives:
  • 01 (slave address) -a1
  • 01 (function code 1 "read coils") -t0 (hopefully, documentation of modpoll not clear)
  • 00 FF (start address 255) -r255 -0 (use PDU addressing starting at 0 instead of 1)
  • 00 01 (quantity to read = 1) -c1
  • CD FA (checksum will be calculated and attached by modpoll)
+ "-1" for polling once

Please note that the implementation of 8CH is not compliant with Modbus specification:
Function code 1 with a quantity of 1 must only return the state of _one_ coil at the given address. But the 8CH returns the states of 8 coils. -> Should be quantity of 8 in the request.
 
Thank you @mercator , I have tried above, same result:

Code:
modpoll -m rtu -a 1 -b 9600 -d 8 -1 /dev/ttyUSB0

RESULT:
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC3
Slave configuration...: address = 1, start reference = 1, count = 1
Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
Anything else you can think of? I am also trying to get WaveShare support desk to assist, they do not seam to know anything else than Windows O/S's - to test etc, although their wiki does talk about workong with Raspberry Pi - their test codes etc are all for Windows. The only programme I can get for RPi is modpoll to test, and then Node-ED - which I am targeting after I get it to work.
 
I just found out that you can talk with serial communication to waveshare 8ch modbus relay. No need to use modbus client.
You need to convert hex ( 01 01 00 FF 00 01 CD FA ) to bytes format. Then send this bytes to Serial com port.

for example; What I send is from C# sample is follows.

string hexString= "01 05 00 00 00 00 CD CA";
byte[] b1 = HexStringToBytes(hexString);
serialPort.Write(b1, 0, b1.Length);

RelayModule will response what you sent ("01 05 00 00 00 00 CD CA").
That's working fine.
 

Attachments

Top