Table of Contents
Modbus TCP/IP
Introduction
The Siemens LOGO! devices do support Modbus over TCP/IP. Those devices are helpful in case 230VAC must be switched in context of the model railroad.
The Modbus protocol is very straight forward and therefor easy to implement.
Serial Modbus devices can be connected by a gateway.
Setup General
IP
The IP prefix. If not set, the IP of the Rocrail server will be used.
Port
The default Modbus registered port number 502 will be used in case of zero.
Poll options
Inputs
Poll discrete inputs.
Holdings
Poll holding registers.
Registers
Poll analog registers.
Coils
Poll coil output state.
Sleep
Pause in ms between the polling requests.
Setup Devices
Sub IP
The last part of the device its IP address.
Unit-ID
Unit-ID connected to the slave.
Range in Rocrail is 0…15.
Input/Coil range
Both ranges are automatically adjusted to multiples of 8.
Ranges
If a range is set from zero to zero the polling for that type is disabled.
Addressing
The addressing is based on the IP address of the Rocrail server.
If the server hast IP address 192.168.0.120, the base IP prefix is 192.168.0.
The Rocrail object Bus/Node-ID will be used as IP suffix, for example if an output bus is 44, the IP address will be 192.168.0.44.
Slaves are addressed by the Object port number.
Sensor
Modbus | Rocrail |
---|---|
SubIP | NodeID |
Module | High part of address |
Address | Low part of address |
Rocrail sensor address = Module * 256 + Address
Block Interface
The TrackDriver is addressed as follows:
Modbus | Rocrail |
---|---|
SubIP | NodeID |
Module | Port |
Register address | Address |
The 16bit register value range is 0…1000.
The direction is defined by bit 15.
Coils
A coil is a read/write output in the Modbus context, and is mapped to a Rocrail output/switch object.
The output bus is the IP suffix, and the address is the coil address.
Polling
Modbus inputs must be polled because of its master/slave architecture. (Originally RS485. Also new projects are based on RS485 like BiDiB where the GBMBoost master will do the polling.)
If a Rocrail sensor is defined for this Interface ID, the eight bit module range, 8, will be requested for this IP suffix at a fixed interval.
To activate polling the digint attribute fbpoll must be set to true. The psleep attribute is used for the polling interval in ms.
Discrete Inputs
Input registers are reported as sensor default type.
Coils
Coiuls are reported as output field events.
Input Registers
Input registers are reported as sensor register type.
Holding Registers
Holding registers are reported as sensor register type.
Service
If the port is set > 1024, a Modbus service will be started; Rocrail will accept Modbus request on this port.
Supported requests:
- Write Single Coil, this will be evaluated as an output field event.
For all other requests an exception response will be send back.
PLC Address Types
Mnemonic | Type | Size | Modbus | Rocrail |
---|---|---|---|---|
I | Digital Input | bit | Discrete Input | Sensor |
Q | Digital Output | bit | Coil | Output/Switch |
M | Memory | bit | Coil | Read Sensor, Write Output |
AI | Analog Input | word | Register | Sensor register type |
AQ | Analog Output | word | Register | Output analog port type |
AM | Memory | word | Holding Register | Sensor register type |