Difference between revisions of "DIN Rail BUS Protocol"

From InCircuit
Jump to: navigation, search
Line 26: Line 26:
  
  
==== MW - Magic word ====
+
=== MW - Magic word ===
  
 
The Magic word is prepended to every package and always consists of the two characters '''<nowiki>'R'</nowiki>''' and '''<nowiki>'P'</nowiki>'''.
 
The Magic word is prepended to every package and always consists of the two characters '''<nowiki>'R'</nowiki>''' and '''<nowiki>'P'</nowiki>'''.
  
==== ADDR - Modul address ====
+
=== 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
 
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
Line 37: Line 37:
 
The module address is one byte long; it is transmitted as two characters.
 
The module address is one byte long; it is transmitted as two characters.
  
==== CM - command ====
+
=== CM - command ===
  
 
the command consists of one byte, either an '''<nowiki>'R'</nowiki>''', '''<nowiki>'W'</nowiki>''', '''<nowiki>'K'</nowiki>''', '''<nowiki>'I'</nowiki>''' or '''<nowiki>'N'</nowiki>'''.
 
the command consists of one byte, either an '''<nowiki>'R'</nowiki>''', '''<nowiki>'W'</nowiki>''', '''<nowiki>'K'</nowiki>''', '''<nowiki>'I'</nowiki>''' or '''<nowiki>'N'</nowiki>'''.
Line 67: Line 67:
  
  
 
+
=== SADR - Sub address or register address ===
+-----+-----------------------------------------------------+
+
| '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
 
The Sub address is interpreted device specific. Only the Sub-address 255
Line 91: Line 76:
 
respond by an Not Acknowledge.
 
respond by an Not Acknowledge.
  
==== SADR255 - Modul identification ====
+
=== SADR255 - Module identification ===
  
 
Layout :
 
Layout :
  
  31 - 8   7 - 0
+
{| class="wikitable" style="text-align:left; "
+---------+-------------+
+
|-
| ID     | ADDR       | R
+
!style="width: 10em"| 31 - 8  
|=========|             | W
+
!style="width: 10em"| 7 - 0
+---------+-------------+
+
!style="width: 2em"|
 +
|-
 +
|style="width: 10em"| ID
 +
|style="width: 10em"| ADDR
 +
|style="width: 2em"| R
 +
|-
 +
|style="width: 10em"| ==============
 +
|style="width: 10em"|
 +
|style="width: 2em"| W
 +
|-
 +
|}
  
Reading the register will transmit the Devices ID and its current address.
+
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
 
On writing the address the 24 higher bits are set and only the address will
be set to a new value
+
be set to a new value.
  
The Ids can be like "R66" for the Din Rail Relais 6I6S.
+
The IDs can be like "R66" for the Din Rail Relais 6I6S.
  
==== DATA - the register data ====
+
=== DATA - the register data ===
  
This field is only transmitted in the 'K' and 'W' modes. It consists of
+
This field is only transmitted in the '''<nowiki>'K'</nowiki>''' and '''<nowiki>'W'</nowiki>''' modes. It consists of
 
32bit hexadecimal notated data and is transmitted in eight characters.
 
32bit hexadecimal notated data and is transmitted in eight characters.
  
==== CHK - Checksum ====
+
=== CHK - Checksum ===
  
The Checksum consists of one byte of data, transmitted as two hexadecimal
+
The Checksum consists of one byte of data, transmitted as two hexadecimal notated characters.
notated characters.
+
If the MSB is set, the checksumming is enabled, using CRC7 on all of the preceeding data.
If the MSB is set, the checksumming is enabled, using CRC7 on all of the preceeding
+
If the MSB is not set, checksumming is disabled.
data.
+
If the MSB isnt set, checksumming is disabled.
+
  
 
== Railbus Protocol binary extension ==
 
== Railbus Protocol binary extension ==
  
the binary extension to the railbus protocol is for automated transmissions of data
+
the binary extension to the railbus protocol is for automated transmissions of data only.
only.
+
  
 
=== Packet Layout ===
 
=== Packet Layout ===
Line 130: Line 122:
 
have the following layout:
 
have the following layout:
  
+------+------+----+----------+------+----+------------------+------+
+
{| class="wikitable" style="text-align:center; "
| MW   | ADDR | CM | LENGTH   | SRCA | SE | DATA             | CHKS |
+
|-
+------+------+----+----------+------+----+------------------+------+
+
!style="width: 3em"| MW  
 +
!style="width: 4em"| ADDR
 +
!style="width: 3em"| CM  
 +
!style="width: 5em"| LENGTH
 +
!style="width: 4em"| SRCA
 +
!style="width: 2em"| SE
 +
!style="width: 10em"| DATA  
 +
!style="width: 4em"| CHKS
 +
|}
  
==== MW, ADDR and CHKS ====
+
=== MW, ADDR and CHKS ===
  
the Magic Word and the destination address are encoded like in the  
+
the Magic Word and the destination address are encoded like in the railbus protocol.
railbus Protocol
+
  
==== CM - Command ====
+
=== CM - Command ===
  
 
The command for the binary extension always has the highest bit set
 
The command for the binary extension always has the highest bit set
Line 147: Line 146:
 
as one character.
 
as one character.
  
==== LENGTH - packet length ====
+
=== LENGTH - packet length ===
  
The Length field specifies the number of character transmitted for the
+
The length field specifies the number of character transmitted for the
complete packet. It is a 16bit integer transmitted in 4 hex-coded
+
complete packet. It is a 16bit integer transmitted in 4 hex-coded characters.
characters.
+
  
==== SRCA - source address ====
+
=== SRCA - source address ===
  
 
The source address is defined as the address of the sender. Like the
 
The source address is defined as the address of the sender. Like the
ADDR-field is is transmitted in two characters.
+
ADDR-field it is transmitted in two characters.
  
==== SE - sequence number ====
+
=== SE - sequence number ===
  
 
An ongoing sequence number. Every packet in an ongoing stream has this
 
An ongoing sequence number. Every packet in an ongoing stream has this
Line 164: Line 162:
 
The number of the first packet in a stream should be used on a random
 
The number of the first packet in a stream should be used on a random
 
base.
 
base.
 
 
The sequence number is represented as a 8bit integer, transmitted unencoded
 
The sequence number is represented as a 8bit integer, transmitted unencoded
 
in one character.
 
in one character.
  
==== DATA - variable length data ====
+
=== DATA - variable length data ===
  
 
the rest of the packet consists of unencoded databytes.
 
the rest of the packet consists of unencoded databytes.

Revision as of 16:01, 18 September 2013

Template:Under construction

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.


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 - Module 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 is not 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 it 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.

Personal tools