OH4 modbus binding to WAGO PFC200 communication error

HI.

I experience problem with modbus communication in openhab4.
Openhab4 Modbus binding try to get connection via modbus Tcp with WAGO PFC200 controller as slave. In WAGO created 2 virtual buttons and added to modbus slave as program variables. I would like to read position of this buttons and control them from OH.
Created first bridge MODBUS TCP slave looks like working but later on try to create regular poll THING and get error:

“Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveErrorResponseExceptionImpl: Slave responded with error=2 (ILLEGAL_DATA_ACCESS)”

If I change anything in TCP bridge then I got other error so I think bridge configured properly and there is some communication but looks like WAGO refuse answer.
Did someone had similar issue?

" COMMUNICATION_ERRORError with read: org.openhab.core.io.transport.modbus.exception.ModbusConnectionException: Error connecting to endpoint ModbusIPSlaveEndpoint [address=10.0.0.23, port=502]"

It could be thatyou poll invalid address from Wago PFC point of view. How does your poller definition look a like?

Pozdrawiam, Łukasz

1 Like

Looks like I all changed once I install ni WAGO structure Generic_Modbus_Master - then my Regular Poll get online. But indeed I have problem with reading addresses like I found this error 2 mean that there is address mismatch.
I have connected window sensors to 8DI module but I have no idea how to change input address - now is %IX1.0 - how I can link them to OH.
I have also in WGAO virtual buttons (for visualisation) to close and open shutters (virtual buttons control digital outputs) - I tried address “coil:32000” but looks like not working - I can not control this output from OpenHab.


This is how looks my switch in OH.

BlockquoteUID: modbus:data:71e001c287:4cb116de95
label: data switch 1
thingTypeUID: modbus:data
configuration:
readValueType: bit
readTransform: default
writeTransform: default
writeType: coil
readStart: “32000”
updateUnchangedValuesEveryMillis: 1000
writeValueType: bit
writeMultipleEvenWithSingleRegisterOrCoil: false
writeMaxTries: 3
writeStart: “32000”
bridgeUID: modbus:poller:7c739f6d9a:71e001c287

I think I need first of all to understand WAGO modules inputs and outputs addressing system. I’m looking for materials but still could not find any reasonable explanation which help me to understand dependencies between address and type coil/digital inout/ output.
Can someone support with any materials, link or guidance were I can find such info?

Can you try with address starting from 0 or 1? There are situations when function code is used as a part of register, especially in documentstion or examples. Also - give a try to desktop or command line tool. It will allow you to identify addressing structure faster than OH user interface.

1 Like

You mean addressing in WAGO start from 1 or OH search start from 1?

And should I set up WAGO address as Coil or Register with offset?

How can I do that? There are some software to scan addresses? I try CAS modbus scanner but no results.

I’ve used so far mbpoll which is good enough, example call:

mbpoll -v -1 -t 3 -r 2998 -c 60 192.168.2.10

Note, you will have to adjust options but this way it will be faster than through GUI.

I don’t know Wago systems good enough to help you with setup of it, however once you have working modbus configuration its a matter of getting addressing scheme (registers).

1 Like

Finally all working fine. Once I install in WAGO structure Generic_Modbus_Master all start working - look like it was missing element. Sensors start addressing from 100 because they only for read, but switches need to address from 32000 in WAGO because they are read/write looks like.
Nów my OH files looks like that:
WAGO_modbus.things

Blockquote
Bridge modbus:tcp:localhostTCP [ host=“10.0.0.22”, port=502, id=2 ] {

Bridge poller digital_input [ start=100, length=10, refresh=1000, type="discrete" ] {
    Thing data DI_1 [ readStart="101", readValueType="bit", category="window"]
    Thing data DI_2 [ readStart="102", readValueType="bit", category="window"]
    Thing data DI_3 [ readStart="103", readValueType="bit", category="window"]
    Thing data DI_4 [ readStart="104", readValueType="bit", category="window"]
    Thing data DI_5 [ readStart="105", readValueType="bit", category="window"]
    Thing data DI_6 [ readStart="106", readValueType="bit", category="window"]
    Thing data DI_7 [ readStart="107", readValueType="bit", category="window"]
    Thing data DI_8 [ readStart="108", readValueType="bit", category="window"]
    Thing data DI_9 [ readStart="100", readValueType="bit", category="window"]

    
}
Bridge poller digital_output [ start=32077, length=20, refresh=1000, type="holding" ] {
    Thing data DO_1 "shutter 1"[ readStart="32077.1", readValueType="bit", writeStart="32077.1", writeValueType="bit", writeType="holding"]
    Thing data DO_2 "shutter 2"[ readStart="32077.2", readValueType="bit", writeStart="32077.2", writeValueType="bit", writeType="holding"]
    Thing data DO_3 "shutter 3"[ readStart="32077.3", readValueType="bit", writeStart="32077.3", writeValueType="bit", writeType="holding"]
    Thing data DO_4 "shutter 4"[ readStart="32077.4", readValueType="bit", writeStart="32077.4", writeValueType="bit", writeType="holding"]
    Thing data DO_5 "shutter 5"[ readStart="32077.5", readValueType="bit", writeStart="32077.5", writeValueType="bit", writeType="holding"]
    Thing data DO_6 "shutter 6"[ readStart="32077.6", readValueType="bit", writeStart="32077.6", writeValueType="bit", writeType="holding"]
    Thing data DO_7 "shutter 7"[ readStart="32077.7", readValueType="bit", writeStart="32077.7", writeValueType="bit", writeType="holding"]
    Thing data DO_8 "shutter 8"[ readStart="32077.8", readValueType="bit", writeStart="32077.8", writeValueType="bit", writeType="holding"]
    Thing data DO_9 "shutter 9"[ readStart="32077.9", readValueType="bit", writeStart="32077.9", writeValueType="bit", writeType="holding"]
    Thing data DO_10 "shutter 10"[ readStart="32077.10", readValueType="bit", writeStart="32077.10", writeValueType="bit", writeType="holding"]
    Thing data DO_11 "shutter 11"[ readStart="32077.11", readValueType="bit", writeStart="32077.11", writeValueType="bit", writeType="holding"]
    Thing data DO_12 "shutter 12"[ readStart="32077.12", readValueType="bit", writeStart="32077.12", writeValueType="bit", writeType="holding"]
    Thing data DO_13 "shutter 13"[ readStart="32077.13", readValueType="bit", writeStart="32077.13", writeValueType="bit", writeType="holding"]
    Thing data DO_14 "shutter 14"[ readStart="32077.14", readValueType="bit", writeStart="32077.14", writeValueType="bit", writeType="holding"]
    Thing data DO_15 "shutter 15"[ readStart="32077.15", readValueType="bit", writeStart="32077.15", writeValueType="bit", writeType="holding"]
    Thing data DO_16 "shutter 16"[ readStart="32078.0", readValueType="bit", writeStart="32078.0", writeValueType="bit", writeType="holding"]
    }}

WAGO_modbus.items

Blockquote
// windows
// --------------------------------------------------------------------
Contact DI_1 “Taras Drzwi” { channel=“modbus:data:localhostTCP:digital_input:DI_1:contact”}
Contact DI_2 “Kuchnia” { channel=“modbus:data:localhostTCP:digital_input:DI_2:contact”}
Contact DI_3 “Evo R” { channel=“modbus:data:localhostTCP:digital_input:DI_3:contact”}
Contact DI_4 “Closet” { channel=“modbus:data:localhostTCP:digital_input:DI_4:contact”}
Contact DI_5 “Evo L” { channel=“modbus:data:localhostTCP:digital_input:DI_5:contact”}
Contact DI_6 “Sypialnia L” { channel=“modbus:data:localhostTCP:digital_input:DI_6:contact”}
Contact DI_7 “Kubo” { channel=“modbus:data:localhostTCP:digital_input:DI_7:contact”}
Contact DI_8 “Drzwi wejściowe” { channel=“modbus:data:localhostTCP:digital_input:DI_8:contact”}
Contact DI_9 “Sypialnia R” { channel=“modbus:data:localhostTCP:digital_input:DI_9:contact”}
Switch DO_1 “Taras up” (shutters,shutters_ground_up) { channel=“modbus:data:localhostTCP:digital_output:DO_1:switch”}
Switch DO_2 “Taras down” (shutters,shutters_ground_down) { channel=“modbus:data:localhostTCP:digital_output:DO_2:switch”}
Switch DO_3 “Evo UP” (shutters,shutters_1st_up) { channel=“modbus:data:localhostTCP:digital_output:DO_3:switch”}
Switch DO_4 “Evo down” (shutters,shutters_1st_down) { channel=“modbus:data:localhostTCP:digital_output:DO_4:switch”}
Switch DO_5 “Sypialnia down”(shutters,shutters_1st_down) { channel=“modbus:data:localhostTCP:digital_output:DO_5:switch”}
Switch DO_6 “Sypialnia UP” (shutters,shutters_1st_up) { channel=“modbus:data:localhostTCP:digital_output:DO_6:switch”}
Switch DO_7 “Salon UP” (shutters,shutters_ground_up) { channel=“modbus:data:localhostTCP:digital_output:DO_7:switch”}
Switch DO_8 “Salon down” (shutters,shutters_ground_down) { channel=“modbus:data:localhostTCP:digital_output:DO_8:switch”}
Switch DO_9 “jadalnia up” (shutters,shutters_ground_up) { channel=“modbus:data:localhostTCP:digital_output:DO_9:switch”}
Switch DO_10 “Jadalnia down”(shutters,shutters_ground_down) { channel=“modbus:data:localhostTCP:digital_output:DO_10:switch”}
Switch DO_11 “Closet down” (shutters,shutters_1st_down) { channel=“modbus:data:localhostTCP:digital_output:DO_11:switch”}
Switch DO_12 “Closet UP” (shutters,shutters_1st_up) { channel=“modbus:data:localhostTCP:digital_output:DO_12:switch”}
Switch DO_13 “Kubo UP” (shutters,shutters_1st_up) { channel=“modbus:data:localhostTCP:digital_output:DO_13:switch”}
Switch DO_14 “Kubo down” (shutters,shutters_1st_down) { channel=“modbus:data:localhostTCP:digital_output:DO_14:switch”}
Switch DO_15 “Kuchnia down” (shutters,shutters_ground_down) { channel=“modbus:data:localhostTCP:digital_output:DO_15:switch”}
Switch DO_16 “Kuchnia up” (shutters,shutters_ground_up) { channel=“modbus:data:localhostTCP:digital_output:DO_16:switch”}
Switch shutter_ground_down
Switch shutter_ground_up
Switch shutter_1st_down
Switch shutter_1st_up
Switch okna
Group shutters
Group shutters_ground_down
Group shutters_ground_up
Group shutters_1st_down
Group shutters_1st_up

default.sitemap

Blockquote
Frame {

Group item=okna icon=window {   
Frame label="Żaluzje programy"{
    Switch item=shutter_ground_down label="Żaluzje parter down"
    Switch item=shutter_ground_up   label="Żaluzje parter UP" 
    Switch item=shutter_1st_down    label="Żaluzje piętro down"
    Switch item=shutter_1st_up      label="Żaluzje piętro UP" 
}


Frame label="Żaluzje pojedynczo" {   
    Switch item=DO_15 icon=rollershutter
    Switch item=DO_16 icon=rollershutter
    Switch item=DO_9 icon=rollershutter
    Switch item=DO_10 icon=rollershutter
    Switch item=DO_1 icon=rollershutter
    Switch item=DO_2 icon=rollershutter
    Switch item=DO_7 icon=rollershutter
    Switch item=DO_8 icon=rollershutter
    Switch item=DO_13 icon=rollershutter
    Switch item=DO_14 icon=rollershutter
    Switch item=DO_3 icon=rollershutter
    Switch item=DO_4 icon=rollershutter
    Switch item=DO_11 icon=rollershutter
    Switch item=DO_12 icon=rollershutter
    Switch item=DO_5 icon=rollershutter
    Switch item=DO_6 icon=rollershutter
}
Frame label="Czujki otwarcia" {
    Default item=DI_8 icon=frontdoor
    Default item=DI_1 icon=frontdoor
    Default item=DI_2
    Default item=DI_3
    Default item=DI_4
    Default item=DI_5
    Default item=DI_6
    Default item=DI_7
    Default item=DI_9
}}}

Thank you for support - I’ll try this tool also once get more familiar.