Using digital out over Modbus

Hi Modbus Gurus,

After my “exercise” on the energy meter the other day, I thought it will be easy to get my WP8027ADAM 16DO board working.

This is the link for the manual.

Reading through the documentation I set up the openhab config:
modbus:serial.wp8027adam.connection=/dev/ttyUSB0:9600:8:none:1:rtu
modbus:serial.wp8027adam.type=coils
modbus:serial.wp8027adam.valuetype=bit
modbus:serial.wp8027adam.length=1
modbus:serial.wp8027adam.start=0
modbus:serial.wp8027adam.id=1

My item is this:

Switch wp8027_1 "Output 1" <switch> (wp8027) {modbus="wp8027adam:0"}

I also added the switch to the sitemap. When I flick the switch nothing happens. There is no modbus communication initiated. I have gone through the log and I can see that the items get instantiated and communication is set up as it was working yesterday for the energy meter. But there is nothing in debug for a message being sent over RS485. I have an indicator LED on my USB-RS485 HUB and it does not blink either.

What did I miss?

Cheers,
Csongor

Your energy meter was set to 2400 baud on the same serial line. Confident about settings at both ends in this area?

modbus:serial.wp8027adam.type=coils
Type keyword is singular

I’m using some of those Wellpro modules, brilliant value at about 10% the cost of proper Avantech ADAMs.

Rossko is of course right, all your serial devices that are on the same bus should be set to the same baud. I would increase your energy meter to 9600 to match, 2400 is really slow… From the binding wiki - “Please note that the binding requires that all slaves connecting to the same serial port share the same connection parameters”

also I believe you have a typo, type should be “type=coil” not “coils”

also I would get rid of the whole “modbus:serial.wp8027adam.valuetype=bit” line, specifying valuetype isn’t needed for coils, it’s usually used for reading a certain bit out of a 16 bit register.

Besides that, everything else looks good. For reference this is what I have to monitor my AC compressor

# AC Cycle
modbus:tcp.slave1.connection=192.168.1.18:502
modbus:tcp.slave1.start=8192
modbus:tcp.slave1.length=1
modbus:tcp.slave1.type=coil

Stupid me. I typed “coils” instead of “coil”. Too bad that there is no warning or error message in the debug to spot this.

Back to your other comment on the speed, I have obviously commented out the config settings for the energy meter (but the items are still in the items file), so this board is alone on the bus.

So my config looks like this how:

modbus:serial.wp8027adam.connection=/dev/ttyUSB0:9600:8:none:1:rtu
modbus:serial.wp8027adam.type=coil
modbus:serial.wp8027adam.length=1
modbus:serial.wp8027adam.start=0
modbus:serial.wp8027adam.id=1

Items is this:

Switch wp8027_1 "Output 1" <switch> (wp8027) {modbus="wp8027adam:0"}
Switch wp8027_2 "Output 2" <switch> (wp8027) {modbus="wp8027adam:1"}
Switch wp8027_3 "Output 3" <switch> (wp8027) {modbus="wp8027adam:2"}
Switch wp8027_4 "Output 4" <switch> (wp8027) {modbus="wp8027adam:3"}
Switch wp8027_5 "Output 5" <switch> (wp8027) {modbus="wp8027adam:4"}
Switch wp8027_6 "Output 6" <switch> (wp8027) {modbus="wp8027adam:5"}
Switch wp8027_7 "Output 7" <switch> (wp8027) {modbus="wp8027adam:6"}
Switch wp8027_8 "Output 8" <switch> (wp8027) {modbus="wp8027adam:7"}

The first two output is working fine. I toggle on the UI and it toggles on the slave. But from output 3 and up, I change on the UI to ON, the slave changes to ON as well, but the UI goes back to OFF immediately. And that is it. I cannot turn the slave output off. And it is working fine for bit 0-1 and not working from bit >2.

I am also keeping an eye on the debug output. There is a whole load of modbus traffic. Openhab is constantly checking the coils using function 1, and setting the items correspondingly:
Sent: 01 01 00 00 00 01 fd ca
Response: 01 01 01 00 51 88

I understand that this is controlled by the poll parameter, but is this really required for coils that would “normally” not changed by the slave? I have seen in the documentation that there is an optional “updateunchangeditems” parameter, but that is false by default.

My guess would be it’s because you only have the slave info setup to read and control a length of 1, but are trying to control the first 8 coils. Change the length to 8 in the slave config, restart openhab and see if that’s any better

Hi Jon,

Thanks, that was the trick. I changed to 8 and it was working. After that update to 16 and I control all 16 outputs as expected. I have to admit reading the binding documentation again it does state that length is always data items depending on the slave type.

Tomorrow I am testing the 8DI 8DO, so I will probably ask again.

That is the nature of Modbus, due to the master-slave(s) strategy. As soon as you have a non-trivial configuration, you’ll be wanting polling for inputs and updates obviously. But there are slaves that can independently change coil states (manual override, end of run condition, faults, etc.) and you’d be wanting to monitor those too. There’s little overhead really in just going ahead and polling everything routinely.

Apart from, in OH terms, the logging - which you turn off when confident in your setup.

1 Like