Summary: The Digital Packet is created by the command station, containing all the data needed to control multifunction and accessory decoders.
- 1 A Digital Command Control Packet
- 2 Structure of a DCC Data Packet
- 3 Definitions
- 3.1 Extended Packet Format
- 3.2 Address Partitions
- 3.3 Accessory Decoder Packet Format
- 3.4 Putting It All Together
- 3.5 Decoder and Consist Control
- 4 Special Commands
- 5 Data Rate
- 6 See Also
A Digital Command Control Packet
A packet is a bundle of data sent over the wires or rails in the case of model railroading. The concept is similar to sending a message via email.
A data packet is made of up Binary digITs, or 'BITS'. A group of eight bits is referred to as a byte. A word is typically two bytes or sixteen bits. Bytes can be split into nibbles (four bit units),which represent numbers between zero and fifteen. To make them easier to read nibbles are often represented by hexademical (base 16) numbers, from zero to F. A byte can represent 256 values from $00 to $FF
In the model railroading control system called Digital Command Control, packets are made up of several "words", and most words are one or two bytes long.
Structure of a DCC Data Packet
NMRA Standard S9.2
The DCC data packet consists of a preamble, the address and instruction, followed by the post amble. The most common packets are four-word bundles.
- Preamble -- Tells all decoders a data packet is about to start.
- Address -- This sequence of bits contains the address of the decoder the packet it meant for.
- Instruction -- The command that is being sent to the addressed decoder.
- Error Detection -- This allows the decoder to check that the packet is valid, and if it is corrupted, the decoder will just ignore the packet and wait for the next pramble.
The Preamble is a sequence of '"ONE'" (or HIGH) bits as specified in the NMRA DCC standard, which tells every device listening on that a new packet is starting. A decoder must not accept a sequence of 10 complete one bits as valid, or require more than 12 bits. Command stations must transmit a minimum of 14 full preamble bits.
Packet Start Bit
The Packet Start Bit is the first bit with a value of zero transmitted after a valid preamble. The Packet Start Bit terminates the preamble and indicates an Address Byte is following.
Address Data Byte
The first data byte of the packet, consisting of eight bits of address information. Some addresses are reserved for special purposes. The first byte can also be an instruction byte in special cases.
The Address alerts the device the message is intended for, usually a decoder, or a consist (two or more locomotive decoders). It also tells all other devices to ignore this packet. The address can be one or two bytes in size. A two digit address is represented by a single byte, and two bytes are used for a four digit address. A decoder set for two digit addresses will ignore a two byte address. This allows compatibility with older systems that may not have four digit capability. If the address does not match the decoder, the decoder will simply ignore the data and wait for the next preamble to be transmitted.
Special Applications of the Address Byte
Data Start Bit
This is a single bit with a value of 0 which precedes the Data Byte
The DATA byte tells the device to set a function (light, bell, whistle, horn, coupler, etc.) on or off, to change to a specified speed step, to reverse direction, to emergency stop, etc. Systems using 14 or 28 speed steps only need one byte for the instructions. For 128 speed steps, two bytes are required. The structure of the bytes differs to indicate the speed steps used.
The final byte indicates the packet is complete. It also allows the decoders to check the validity of the packet. If the packet is corrupted, a decoder looking at the final byte would find the checksum included is wrong. It would ignore the packet and wait for an uncorrupted one to arrive. (This is one reason why the command stations keep repeating the packets over time.) A corrupted packet most commonly occurs if dirty wheels or track prevented the whole packet from being read properly.
The command station applies an XOR function to the address and instruction bytes, and this is appended to the packet to create the error detection byte. The decoder can perform the same function and compare the result to the error detection byte.
Packet End Bit
This bit indicates the termination of the packet, and has a value of 1. It may also count as the preamble of the next packet, if there are no alternate command control protocols inserted between packets. The DCC bitstream must continue for an additional 26µS (minimum) after the packet end bit.
Extended Packet Format
|0||Bit which has a value of 0|
|1||Bit which has a value of 1|
|U||Undefined bit, 0 or 1 are valid states|
|B||Bit position / Address|
|C||Instruction type field|
|F||Flag, determines Instruction Implementation|
|L||Low Order Binary State Control Address|
|H||High Order Binary State Control Address|
|S||Sub address of decoder|
|V||CV address bit|
|X||Signal Head aspect bit|
|E||Error detection bit|
Bits are numbered from left to right, Bit 0 is the least significant bit (LSB), bit 7 is the Most significant bit (MSB)
|Address Values||Decimal Value||Purpose|
|00000001-01111111||1-127 Inclusive||Multifunction decoders with a 7 bit address|
|10000000-10111111||128-191 inclusive||Basic Accessory Decoders with 9 bit addresses and Extended accessory decoders with 11 bit addresses|
|11000000-11100111||192-231 inclusive||Multifunction decoders with a 14 bit address|
|11101000-11111110||232-254||Reserved for future applications|
The first address byte contains 8 bits. if the most significant bits are 11 and the remaining bits are not 111111, a second address byte must follow. When two bytes are present in address space, they must be separated by a 0 bit.
Any instructions addressed to the broadcast address must be acted on. If the command is not supported the decoder can ignore it.
Instructions for Multifunction Decoders
Multifunction decoders are decoders intended to control motors and multiple functions. Each Instruction is constructed using a 3 bit instruction field preceding a 5 bit data field. The eight possible values are:
|000||Decoder and Consist control instructions|
|010||Speed and Direction for reverse operation|
|011||Speed and Direction for forward operation|
|100||Function Group 1|
|101||Function Group 2|
|111||CV Access Instruction|
Accessory Decoder Packet Format
Basic Accessory Decoder Format
Extended Accessory Decoder Packet Format
XXXXX is for a single head, a value of 00000 is an absolute stop aspect. Other values represent possible aspects as determined by the signalling system in use, and prototype being modelled.
Putting It All Together
DCC Packet Construction for a Multi Function Decoder with 7 bit Address
0 = Headlight
|XORed address and data bytes|
AAAAAAA 0 = Address. The trailing zero (MSB) can be for the headlight.
If this byte is in the range of 192-231, a second byte will follow.
Baseline Packet, Speed Instructions:
(Optional: Accessory Control)
Extended Packets can have an additional one or two data bytes.
The 01 indicates the start of the data byte. D is Direction (bit 5), U is undefined. SSSS is the speed control. If in 28 step mode, U is used for the LSB. The 01 can also be used for accessory control, such as couplers, bells, etc. The Speed control in this example is 4 bits, for the optional 128 step mode, another 4 bits would be included. The 4 bits allow for the mandated 28 speed steps. All decoders can switch to 28 steps if the command station transmits them.
If SSSS equals zero, that is a STOP command. The eSTOP is 0001. Values from 2 to 16 are the the fourteen speed steps. In 28 step mode, the values would go from 2 to 30. In this case, stop is 00000, eStop is 00001, and the first step is 00010.
E is the Error Correction.
Decoder and Consist Control
S-9.2.1 The Data Byte(s) have the following construction:
- 0000CCCF or 0000CCCF DDDDDDDD
For decoder control the data byte begins with four zeros. In most cases these processes will be handled transparently by the command station.
An additional data byte may follow this data byte.
|000||F=0, Decoder Reset. F=1, Hard Reset|
|001||Factory test, factory use only|
|011||Set Decoder Flags|
|101||Set Advanced Addressing (CV29, Bit 5)|
|111||F=1, Decoder Acknowledgment Req.|
- Reset: Decoder to erase all volatile memory and return to its initial state at power up
- Hard Reset: CV 29, 31 and 32 return to factory default, CV 19 cleared and set to 0, and a reset is performed.
Set Decoder Flags
This is an expanded decoder function which allows the command station to control various flags within a specific decoder or group of decoders.
A second data byte will contain the commands as well as the decoder sub address. Up to seven decoders can share the same primary address while allowing certain functions, such asCV changes, to be performed on an individual decoder within the group, or if the sub address is 0, all decoders in that group.
For consist control the data byte begins with 0001CCCC.
This controls consist setup, activation or deactivation.
When this mode is in effect, the decoder will ignore speed and direction instructions addressed to its normal locomotive address, except if the consist should have the same address as the locomotive. These instructions only apply to the consist address.
Functions controlled by instruction 100 and 101 (see table able) will continue to respond to the decoder's baseline address. Functions controlled by instructions 100 and 101 also respond to the consist address if the appropriate bits in CV21 and 22 have been activated.
When in this mode all forms of bi-directional communications are deactivated, unless activated specifically by a decoder control instruction. Ops Mode acknowledgements and data transmission are applies to the appropriate commands at the respective decoder addresses.
When CCCC = 0010, set consist address in second byte and activate consist. The consist address is then stored in CV19, bits 0-6, bit 7 is set to zero. The consist will travel in the normal direction.
When CV19 bit 7 is set to one, the conceit will travel in the direction opposite of normal.
If the consist address is set to 0000 0000 then the consist will be deactivated.
These instructions control advanced decoder functions. Only a single advanced operations instruction may be contained in a packet.
Format: 001C CCCC 0 DDDD DDDD
The five C bits allow for 32 instructions. Only three are currently in use.
- CCCCC = 11111 (31): 128 Speed Steps
- CCCCC = 11110 (30): Restricted Speed Step Instruction, restricts maximum speed of decoder
- CCCCC = 11101 (29): Analog Function Group
There are a couple of special commands that can be transmitted.
Digital Decoder Reset Packet
The Digital Decoder Reset Packet for All Decoders has an address and data value of zero and the XOR operation means the error byte has a zero value.
This packet allows the Command Station to clear some of its previous instructions. These include speed and direction data from any decoders. Upon receiving a reset packet a mobile decoder must bring a moving locomotive to an immediate stop.
- This packet does not reset the decoder to factory defaults.
In practice reset packets are normally sent as part of the programming or start up procedures to clear and power a decoder prior to transmission of programming packets. During the power up sequence the command station will broadcast a reset packet, which will erase all volatile memory, including speed and direction, returning it to its normal power up state. This prevents runaways and other unexpected events after a DCC system reset or during layout power up. This only happens if the command station is reset.
The contents of the decoder's programming can be altered immediately after receipt of the Decoder Reset Packet, as per Service Mode Recommended Practices.
Idle Packet / Digital Decoder Idle Packet For All Decoders
The Digital Decoder Idle Packet For All Decoders is a three byte packet which differs from the reset packet in that the address (first) byte is set to eight 1s, the second byte consists of eight 0 bits, and the third byte is eight 1s. Upon receipt the decoder shall perform no actions, and act as if this packet was addressed to another decoder.
The idle packet is used to provide power to the track when there are no trains in motion, or no locomotives have been addressed.
E-Stop / Digital Decoder Broadcast Stop Packets For All Decoders
The E-Stop command generates a broadcast packet (all decoders) which must be obeyed. Valid DCC data remains on the rails, meaning a runaway locomotive caused by the decoder switching to analog mode will remain in motion.
DCC packets are transmitted at the rate of approximately 8000 bits per second. The command station tries to use the bandwidth available as efficiently as possible.
Packets are prioritized by the command station to maximize the throughput.
Packets are only created and transmitted when the command station receives instructions to make a change. A locomotive running at a constant speed would not have any packets addressed to it unless the throttle was changed to increase or reduce speed, lights turned on or off, or in the case of sound, a button was pressed to blow the horn (or whistle). This reduces the amount of data traffic, which increases response. DCC systems can transmit hundreds of packets a second, which allows control of a large number of trains. A large amount of data traffic will negatively impact the responsiveness of your train.
A typical command station can queue up to 20 packets in the buffer, which are transmitted in sequence unless the system determines the need to transmit one packet sooner.
- One application that hogs bandwidth is operating an analog locomotive on a DCC system.
- For more information, refer to some of books on the Resources page.
Try the Wayback Machine here: [DCC Packets]