Decoding DCC Addresses

THIS IS A VERY ADVANCE TECHNICAL TOPIC THAT ONE DOES NOT NEED TO READ TO ENJOY OR USE DCC. IT IS HERE TO SHOW WHY DCC ADDRESS RANGES ARE WHAT THEY ARE.

The NMRA standards that deal with DCC Decoder Address Limits and Decoding are found in NMRA DCC Standards (S) and Recommended Practices (RP):

S-9.2 Communication Standard for DCC (AKA Baseline DCC Packets)

RP-9.2.1 Extended Packets

(RP-9.2.2 Configuration Variables for DCC. This RP, although contains some addressing information, is focus in on the definitions of all of the NMRA CV's. It does not discuss all the technical limits and the reasons behind them in detail. The Standard and RP's above are the true documents to reference in addressing. The docments may or may not consistently include Decimal Numbers in the addressing description. The details are found in the Binary Number domain which is what the DCC Design Engineer needs to know.)

Addressing Limits:

RP-9.2.1 ties all decoder addressing together (Mobile and Accessory) at the DCC binary packet level so the Decoder can figure out what is what as the packets are received from the track. Specifically "Section A" says:

A: Address Partitions

The first data byte of an Extended Packet Format packet contains the primary address. In order to allow for different types of decoders this primary address is subdivided into fixed partitions as follows.

1) Address 00000000 (0): Broadcast address

2) Addresses 00000001-01111111 (1-127)(inclusive):

Multi-Function decoders with 7 bit addresses

3) Addresses 10000000-10111111 (128-191)(inclusive):

Basic Accessory Decoders with 9 bit and Extended Accessory

Decoders with 11-bit addresses

4) Addresses 11000000-11100111 (192-231)(inclusive):

Multi Function Decoders with 14 bit addresses

5) Addresses 11101000-11111110 (232-254)(inclusive):

Reserved for Future Use

6) Address 11111111 (255): Idle Packet

Copyright 1999-2006 by National Model Railroad Association, Inc. NMRA Technical Department #635

Definitions:

A) BaseLine Packet. The simplest DCC Packet that decoders accept.

B) Extended Packet. A more complicated DCC packet that expands addresses space and other options beyond what the Baseline Packet can offer.

C) Primary Address. The First 8 bits of ANY DCC packet be it Baseline or Extended. It contains ID bits plus Address information.

D) Extended Address: A combination of a subset of the Primary Address PLUS all 8 bits of the second follow on address of the Extended Packet. It is 14 bits long.

E) Short Addresses: A subset of the Primary Address when the ID process has been completed. It is 7 bits long. The final value is compared to the value programmed in CV1.

F) Long Addresses: A subset of the Extended Address when ID process and limit rules have been completed. The final values is compared to values programmed in both CV17 and CV18.

Discussion:

1) S-9.2 covers #1 and #2 which are part of "Baseline Packets". S-9.2 does NOT support Extended Addresses since that requires an Extended Packet which is what RP-9.2.1 is all about. Extended Packet formats start at #4.

2) From a mobile decoder's point of view, the Primary Address is NOT initially assumed to be a Short or a Long address. It is just the very first byte that contains an address through which the decoder will read and THEN determine if it a short address or part of a long address.

3) The way the mobile decoder knows the DCC packet is an Extended DCC Packet as opposed to a Baseline DCC Packet is by first looking at the most significant bit (MSB) of the primary address. If it is a "0", then the primary address is a Short Address for Locomotives. See #2 above in the address limit section.

4) If the MSB is NOT a "0", then the decoder looks the first TWO MSB bits of the Primary Address combined. If they are a "11", then the Decoder is looking at a larger Extended Packet format which supports Extended Addresses. See #4 above in the address limit section.

5) Since the upper two MSB bits of the Primary Address must be "11" to Id the address as part of the Extended Packet, then these "ID bits" by definition are NOT PART of the actual Extended Address itself and must be striped out to obtain the upper portion (byte) of the Extended Address. That means the primary address format 11XXXXXX must be stripped down to XXXXXX to get the upper portion of the extended address. Hence we have only 6 bits available for defining extended address.

6) All Extended Packet addressing is SPLIT over two addresses bytes. The Primary Address contains the upper Address byte. The lower Address Byte is contained in the follow on 2nd Byte in which all 8 bits are pure address. This is where the term 14 bit addressing comes from. 6 Bits of the Primary Address plus all 8 Bits of the lower Address. 6 + 8 = 14 Bits.

7) Looking at the Primary Address again, it is sub divided into two ranges:

"Long Address" #4 -> 11000000-11100111 (192-231)

"Future Use" #5 -> 11101000-11111110 (232-254)

CV17's value includes the ID bits and hence the value stored in CV17 is directly comparable to the Primary Address. If it is a match, then the upper part of the Long Address has been identified for the given decoder.

8) These values still show the ID bits "11" and must be removed to extract the long address leaving:

"Long Address" -> 11000000-11100111 (192-231) becomes --> 000000-100111 ( 0 to 39)

"Future Use" -> 11101000-11111110 (232-254) becomes --> 101000-111110 (40 to 62)

We are not concerned about "Future Use" other than to note it sits right above the highest Long Address. In other words if you attempt to go above the Long Address limit, mobile decoders will NOT recognize it.

9) The upper portion of the long address is now 000000 (0 decimal) to 100111 (39 Decimal) inclusive. Inclusive means that 000000 is also a valid value which adds 1 more valid address to the upper limit and must be accounted for to get the Total Address Range.

1 + 39 = 40 which is entire range of unique values for the Upper Portion of the Long Address.

10) Since there is also another byte or 8 bits of lower address. 8 Bits represents 256 values running between 0000000 (0) to 11111111 (255) inclusive.

1 + 255 = 256 total range of unique values.

CV18's value is directly comparable to the Lower Extended Address. If it is a match, then this Lower part of the Long Address has been identified for the given decoder.

11) Calculation of Total Long Address Space: Since total long address consist of upper usable 6 bits + lower 8 bits, we multiply them together to get the grand Total address range.

40 * 256 = 10,240 unique values.

12) To convert back to a inclusive value, we must now subtract the valid Address "0" from the grant total.

10,240 - 1 = 10,239.

Hence the entire Long Address range is 0 to 10239 inclusive.