-
-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This binding for openHAB 3 has ability to connect Simatic PLC over Ethernet with isoTCP. So it is possible to connect to the Simatic PLC S7-200, S7-300, S7-400, S7-1200 and S7-1500 series. H-system is not supported.
Binding uses libnodave library to provide connection (https://sourceforge.net/projects/libnodave/).
Copy binding release in ${OPENHAB_HOME}/addons folder.
A Simatic Bridge is needed to connect to PLC. It provides exactly one communication channel to single PLC.
Basic bridge configuration requires to know PLC address, rack and slot. Additional parameters can be defined.
Parameter | Required | Notes |
address | Yes | Network IP/Host address of PLC. |
rack | Yes | The rack number in which CPU is presented. |
slot | Yes | The slot number where CPU is inserted. |
pollRate | No | Read period [ms]. Default is 1000ms. |
charset | No | Define code page for communicated strings (e.g. ISO-8859-1, cp1250). If blank or wrong code page is defined, system code page is used. Used code page is printed into log file as INFO. |
communicationType | No | Type of communication that should be established. Possibilities are PG, OP, S7 (default). |
isS7200 | No | Communication partner is CP243 (Simatic S7-200) |
Bridge definition together with things can be defined in text files. See generic bridge configuration for details. In short text files .things are located in ${OPENHAB_CONF}/things folder. Basic bridge configuration with required parameters looks like this:
Bridge simatic:bridge:<plc_id> "Label" @ "Location" [ address="<host/ip address>", rack="<rack>", slot="<slot>" ]
Example with optional parameter:
Bridge simatic:bridge:S7-416 "My PLC" [ address="192.168.1.36", rack="0", slot="2", charset="ISO-8859-1" ]
To any individual bridge things could be added. Things are user defined so only generic_device thing is available.
Things definition can be defined in text files. Easiest way is to put it inside bridge definition:
Bridge simatic:bridge:<plc_id> "Label" @ "Location" [ address="<host/ip address>", rack="<rack>", slot="<slot>" ] {
Thing generic_device <thing_id> "Thing label" {
}
}
For generic_device thing binding supports channels types listed in the table below. Individual channel type are converted to simple data types such as bit, byte, word, double word, float, array.
Channel type | Simatic data type | Address example | Notes |
chNumber | bit, byte, word, dword, float | IB0, E0.0, MW5, MD10, DB1.DBD4F | Numbers are represent in signed form. Their maximum value depends on the used type. Floating point number is stored in 4 bytes formatted according to IEEE 754. PLC address for float must be specified as DWORD with 'F' sign at the end of address. |
chColor | dword | MD100, DB1.DBD20 | All color parts are transferred in one double word. Each color component corresponds to one byte. Bytes assignment: RGB - byte 0 - Red, 1 - Green, 2 - Blue, 3 - Not used |
chString | byte array | MB100[32], DB1.DBB0[20] | Array of bytes represent null terminated string. Length of array is specified in square brackets behind type definition (e.g. MB100[32] defines byte array at address MB100 with length 32 bytes) |
chContact | bit, byte | IB0, MB10.0, DB1.DBX0.0 | 0 - off, 1 - on |
chSwitch | bit, byte | IB0, MB10.0, DB1.DBX0.0 | 0 - off, 1 - on |
chDimmer | byte | MB100, DB1.DBB10 | Value range is 0-100 |
chRollershutter | byte, word | MB5, MW5 | If word for state is specified lower byte is for position, upper byte for StopMove/UpDown (1-Move,2-Stop,4-Up,8-Down). Otherwise only position is expected. |
Every channel has two parameters stateAddress and commandAddress. At least one must have a defined value. Supported PLC areas are inputs I(E), outputs Q(A), memory M and datablocks DB. Symbolic addressing is not supported.
Channel text file definition as part of thing:
Bridge simatic:bridge:<plc_id> "Label" @ "Location" [ address="<host/ip address>", rack="<rack>", slot="<slot>" ] {
Thing generic_device <thing_id> "Thing label" {
Channels:
Type <channel_type> : <channel_id> [ stateAddress="<simatic address>", commandAddress="<simatic address>" ]
}
}
Bridge simatic:bridge:S7-416 "My PLC" [ address="192.168.1.36", rack="0", slot="2", charset="ISO-8859-1" ] {
Thing generic_device plcState "PLC state" {
Channels:
Type chNumber: watchdog [ stateAddress="MB0" ]
}
Thing generic_device weather "Weather station" {
Channels:
Type chNumber: temperature [ stateAddress="DB1.DBD0F" ]
Type chNumber: pressure [ stateAddress="DB1.DBW4" ]
Type chNumber: humidity [ stateAddress="DB1.DBB6" ]
}
Thing generic_device hall "Hall" {
Channels:
Type chContact: door_contact [ stateAddress="I0.0" ]
Type chSwitch: light_switch [ stateAddress="M5.1", commandAddress="M5.1" ]
Type chString: humidity [ stateAddress="DB1.DBB6" ]
}
Thing generic_device device "Special device" {
Channels:
Type chSwitch: run [ stateAddress="DB10.DBX0.0", commandAddress="DB10.DBX0.1" ]
Type chDimmer: rate [ stateAddress="DB10.DBB1", commandAddress="DB10.DBB2" ]
Type chString: text [ stateAddress="DB10.DBB3[20]", commandAddress="DB10.DBB3[20]" ]
}
}
Bridge simatic:bridge:S7-1210 "My second PLC" [ address="192.168.1.37", rack="0", slot="1" ] {
Thing generic_device rollers "Rollershutters" {
Channels:
Type chRollershutter: rs1 [ stateAddress="MB100", commandAddress="MB101" ]
Type chRollershutter: rs2 [ stateAddress="MW102", commandAddress="MB104" ]
}
}