Hello,
I’ve got some issues getting the combination of my Wago PLC 750-881 working stable via modbus.
When everything stays online, everything works perfect. The problem arises when my PLC is powered off.
When OpenHab server keeps running and I turn off my PLC, the modbus coils are not set again in the PLC when the PLC is running again. (they are ON in OpenHab, but not TRUE again in PLC).
I’m running openHAB 2.4.0 Release Build with the Modbus Binding on Ubuntu.
Below my config:
modbus.things:
//Declaratie van WAGO PLC (Modbus slave) op IP=192.168.1.150
Bridge modbus:tcp:wago [ host="192.168.1.150", port=502, id=1 ] {
//Binnenlezen van alle PLC outputs.
//Deze worden op %MW500-M599=99*16 = 1584 outputs gezet
//Modbus startadres voor bits: MX0.0 start op modbus adres 12288.
//500 woorden * 16 bits => +8000 ==> Dus modbus startadres: 20288
Bridge poller wagooutputsstat [ start=20288, length=1024, refresh=100, type="coil" ] {
Thing data mb_stat_output0 [ readStart="20288", readValueType="bit"]
Thing data mb_stat_output1 [ readStart="20289", readValueType="bit"]
Thing data mb_stat_output2 [ readStart="20290", readValueType="bit"]
Thing data mb_stat_output3 [ readStart="20291", readValueType="bit"]
Thing data mb_stat_output4 [ readStart="20292", readValueType="bit"]
Thing data mb_stat_output5 [ readStart="20293", readValueType="bit"]
Thing data mb_stat_output6 [ readStart="20294", readValueType="bit"]
Thing data mb_stat_output7 [ readStart="20295", readValueType="bit"]
}
//Controlebits om vanuit OpenHab de PLC aan te sturen
//Deze staan op MW600-M699 = 99*16=1584 controle bits
//Modbus startadres voor bits: MX0.0 start op modbus adres 12288.
//600 woorden * 16 bits => +9600 ==> Dus modbus startadres: 21888
Bridge poller wagooutputscon [ start=21888, length=1024, refresh=100, type="coil" ] {
Thing data mb_con_bit_0 [ writeStart="21888", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_1 [ writeStart="21889", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_2 [ writeStart="21890", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_3 [ writeStart="21891", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_4 [ writeStart="21892", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_5 [ writeStart="21893", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_6 [ writeStart="21894", writeValueType="bit", writeType="coil"]
Thing data mb_con_bit_7 [ writeStart="21895", writeValueType="bit", writeType="coil"]
}
}
modbus.items:
Switch mb_con_bit_0 "mb_con_bit_0" {channel="modbus:data:wago:wagooutputscon:mb_con_bit_0:switch", autopudate="false"}
Switch mb_con_bit_1 "mb_con_bit_1" {channel="modbus:data:wago:wagooutputscon:mb_con_bit_1:switch", autopudate="false"}
Switch mb_con_bit_2 "mb_con_bit_2" {channel="modbus:data:wago:wagooutputscon:mb_con_bit_2:switch", autopudate="false"}
Switch mb_con_bit_3 "mb_con_bit_3" {channel="modbus:data:wago:wagooutputscon:mb_con_bit_3:switch", autopudate="false"}
Variable declaration in Wago PLC:
(*Digital control via modbus (%MW600-M699 = 99*16=1584 controle bits) *)
(*#Modbus startadres voor bits: MX0.0 start op modbus adres 12288. *)
(*600 woorden * 16 bits => +9600 ==> Dus modbus startadres: 21888 *)
(*Used to change state of outputs *)
mb_con_bit_0 AT %MX600.0: BOOL := FALSE; (*Adres 21888*)
mb_con_bit_1 AT %MX600.1: BOOL := FALSE; (*Adres 21889*)
mb_con_bit_2 AT %MX600.2: BOOL := FALSE; (*Adres 21890*)
mb_con_bit_3 AT %MX600.3: BOOL := FALSE; (*Adres 21891*)
mb_con_bit_4 AT %MX600.4: BOOL := FALSE; (*Adres 21892*)
mb_con_bit_5 AT %MX600.5: BOOL := FALSE; (*Adres 21893*)
mb_con_bit_6 AT %MX600.6: BOOL := FALSE; (*Adres 21894*)
mb_con_bit_7 AT %MX600.7: BOOL := FALSE; (*Adres 21895*)
Code in Wago PLC:
(*Uitgangen Leefruimte*)
uitgang0:=mb_con_bit_0;
uitgang1:=mb_con_bit_1;
uitgang2:=mb_con_bit_2;
uitgang3:=mb_con_bit_3;
Example:
PLC + OpenHab both up and running.
I set mb_con_bit_1 to ON via OpenHab.
In PLC: mb_con_bit_1 becomes TRUE → uitgang0 switches to TRUE → My light turns on.
Now I turn off the PLC.
→ Light turns off ofcourse.
In OpenHab: mb_con_bit_1 is still ON.
When I now turn on PLC again, mb_con_bit_1 bit in PLC doesn’t become TRUE again.
When i set mb_con_bit_1 to OFF in OpenHab and back to ON, the bit becomes TRUE again in the PLC.
Does anyone know the solution to this? I want my lights to remain in the same state after a power cycle.
When I switch on via the sitemap, this is the log:
2019-05-12 10:34:15.820 [ome.event.ItemCommandEvent] - Item ‘mb_con_bit_1’ received command ON
2019-05-12 10:34:15.837 [nt.ItemStatePredictedEvent] - mb_con_bit_1 predicted to become ON
2019-05-12 10:34:15.844 [vent.ItemStateChangedEvent] - mb_con_bit_1 changed from OFF to ON
Does it act more like a “MOMENTARY SET command” instead of "switch this boolean to ON?
Really need to get this stable if I want to deploy this in my house.
Thanks already!
Robbe