The data packet containing the information needed to control a decoder
- 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
- 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
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 string of twelve "ONE" (or HIGH) bits as specified in the NMRA DCC standard, which tells every device listening on that a new packet is starting. No other DCC command can or will consist of a string of twelve ones.
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.
The Instruction 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.
Extended Packet Format
NMRA Standard S-9.2.1
|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 Stationary Decoders with 9 bit addresses and Extended stationary 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|
For extended addresses, a second byte will follow
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 one or more motors and/or accessories.
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. The MSB of the address is bit 5 of the first byte, bits 6 and 7 are 1 in this instance. When two bytes are present in address space, they must be separated by a 0 bit
Each Instruction is constructed using a 3 bit instruction type 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.
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.
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]