DIN Rail BUS Protocol
Contents |
Railbus Protocol
The Railbus Protocol is designed to be as flexible as possible while being as easy as possible.
All data is transmitted on the RS485 with a baudrate of 9600Baud; 8N1 as printable ASCII characters. Any data is converted into the corresponding hexadecimal notation.
Packet Layout
Every packet has a fixed length and is created as defined here:
MW | ADDR | CM | SADR | DATA | CHKS | CRNL |
---|
MW - Magic word
The Magic word is prepended to every package and always consists of the two characters 'R' and 'P'.
ADDR - Modul address
Each Modul on the bus has a unique address. If a Modul is in its delivery-state, it is set to address 0. On Modules which are equipped with a BCD-Display, the modules address is shown here.
The module address is one byte long; it is transmitted as two characters.
CM - command
the command consists of one byte, either an 'R', 'W', 'K', 'I' or 'N'. The value is not converted to hexadecimal notation. Any possible character is not possible to show up in the rest of the package. This way, a definitive start of packet is generated.
The different Words define the mode of the package, as shown in the following table:
'R' | Read Request. Asks the addressed device to send its register-content. |
---|---|
'W' | Write Request. Asks the addressed device to write the data into its register. |
'K' | Read Acknowledge. Acknowledges a preceding Read Requests and transmits the corresponding data. |
'I' | Write Acknowledge. Acknowledges a preceding Write Request and the transferred data to be written. |
'N' | Not Acknowledge. Is sent, if a read or write-request to an unknown or forbidden register was made. |
+-----+-----------------------------------------------------+ | 'R' | Read Request. Asks the addressed device to send its | | | register-content | | 'W' | Write Request. Asks the addressed device to write | | | the data into its register | | 'K' | Read Acknowledge. Acknowledges a preceding Read | | | Requests and transmits the corresponding data | | 'I' | Write Acknowledge. Acknowledges a preceding Write | | | Request and the transferred data to be written | | 'N' | Not Acknowledge. Is sent, if a read or | | | write-request to an unknown or forbidden register | | | was made. | +-----+-----------------------------------------------------+
SADR - Sub address or register address
The Sub address is interpreted device specific. Only the Sub-address 255 is defined by the stack and used for identifying a device and set a Modul address.
Every address can be read and written. Not implemented addresses should respond by an Not Acknowledge.
SADR255 - Modul identification
Layout :
31 - 8 7 - 0
+---------+-------------+ | ID | ADDR | R |=========| | W +---------+-------------+
Reading the register will transmit the Devices ID and its current address. On writing the address the 24 higher bits are set and only the address will be set to a new value
The Ids can be like "R66" for the Din Rail Relais 6I6S.
DATA - the register data
This field is only transmitted in the 'K' and 'W' modes. It consists of 32bit hexadecimal notated data and is transmitted in eight characters.
CHK - Checksum
The Checksum consists of one byte of data, transmitted as two hexadecimal notated characters. If the MSB is set, the checksumming is enabled, using CRC7 on all of the preceeding data. If the MSB isnt set, checksumming is disabled.
Railbus Protocol binary extension
the binary extension to the railbus protocol is for automated transmissions of data only.
Packet Layout
Packets using the binary extension do have a variable length and have the following layout:
+------+------+----+----------+------+----+------------------+------+ | MW | ADDR | CM | LENGTH | SRCA | SE | DATA | CHKS | +------+------+----+----------+------+----+------------------+------+
MW, ADDR and CHKS
the Magic Word and the destination address are encoded like in the railbus Protocol
CM - Command
The command for the binary extension always has the highest bit set to flag the variable packet length.
The defined commands are implementation specific. The command is transmitted as one character.
LENGTH - packet length
The Length field specifies the number of character transmitted for the complete packet. It is a 16bit integer transmitted in 4 hex-coded characters.
SRCA - source address
The source address is defined as the address of the sender. Like the ADDR-field is is transmitted in two characters.
SE - sequence number
An ongoing sequence number. Every packet in an ongoing stream has this field incremented to provide a unique packet identification. The number of the first packet in a stream should be used on a random base.
The sequence number is represented as a 8bit integer, transmitted unencoded in one character.
DATA - variable length data
the rest of the packet consists of unencoded databytes.