PROGRAMMING's COMMON DATA FORMAT
The customization data that is to be passed back and forth between the decoder and the command station is done using 1 Byte "chunks" of data. A byte is a common computer term used to describe a group of 8 binary bits. The 8 bits collectively making up the 1 Byte can represent up to 256 unique decimal values ranging from 1 to 255. These bytes of data are stored in non volatile memory of the decoder. Non volatile memory is memory that does not forget anything when it loses power.
PROGRAMMING TRACK READING LIMITS
Although two way communication is established between the decoder and the command station on the programming track, the ability of the decoder to communicate back to the command station is limited. Unlike writing a byte all at once to the decoder, you cannot read a byte all at once. To be clear, there is no read command where the decoder sends the byte value back to the command station.
PROGRAMMING TRACK READING PROTOCOL
To read a value, the command station must play a game with the decoder consisting of "Yes or No" questions. The question and response goes like this. The command station first write a value to the decoder that it thinks the decoder has already programmed into a specific decoder memory location and then ask the decoder to tell the command station if the value matches the programmed value. It will be a simple Yes or No response. Technically your not reading anything when asking a question which is why the NMRA DCC standard call the reading process the verify process. You asking the decode to verify the value in a memory location matches the value provided by the command station. You modify the verify value to test against and repeat the verify process until you find a yes answer. How many questions it takes to determine all of the 8 bit values depends on which one of the 3 service mode programming formats you use.
PROGRAMMING TRACK MULTIPLE FORMATS
Programming a decoder can be done one of 4 ways. Below are the technical details of each of the 4 modes. To understand why each type exist, you must start at the beginning.
1) Register Mode (Obsolete and not recommended for new decoders)
Register mode was the very first Programming Mode offered by the DCC standards. It defined 8 registers. The term CV was not used at this time. The pre-defined registers are:
1 Short Address
2 Start voltage
6 Reserved (Later used with Page mode)
7 Decoder Version
8 Manufacture ID
Why only 8 Registers? Because when decoders first came out, they did not have a lot of memory and the functions were very simple. These decoders typically focused on implementing only the MINIMUM requirements of the NRMA standards. This resulted in the lowest cost decoders possible at a time when decoders were very expensive.
The DCC Register Mode programming command is the same for both read and write. There is only one bit reserved as the V/W (Verify/Write) and 3 bits that contain the binary address of the registers 1 to 8 to be verified or written too. The last part of the command contains the 1 byte value to be used with the register. With this one command, the decoder can verify or write the register.
Writing is very simple. A byte of data is sent to the decoder which is then stored in the register exactly the way it was sent. It is the fastest way to write a byte.
Reading in Register mode works at the representative numerical value level (0 to 255) of the register. Hence to read the specified register, one must play a game of 256 questions. Asking 256 verify questions can take some time to do. Fortunately in practice it does not take to long because some command stations have an educated guess what the typical values are for a popular register. In other words start with the easy values such as 0, 1 and 255. If the answer is no to these questions, then go through the remaining 253 possible values starting at a value of 2 and go on up to 254 till you find the value.
2) Page Mode (Most common and mature method of programming a modern decoder)
Page mode allows you to access more registers beyond the original 8 (Register Mode) allowing a maximum of 1024 registers. To eliminate confusion between registers used in register mode and registers used in Page Mode, the term Configuration Variable was introduced. So if we are talking about CV values, we NOT talking about register mode programming.
Pagemode starts with Register Mode and uses Register 6 as a address pointer in what is called Indirect Addressing. The value in Register 6 is a offset for the first 4 registers.
With a value of 1 in register 6, then registers 1 to 4 point to CV's 1 to 4.
With a value of 2 in register 6, then registers 1 to 4 point to CV's 5 to 8.
With a value or 10 in Register 6, then registers 1 to 4 point to CVs 37 to 40.
When programming is finished and the decoder enters normal mode, I believe Register 6 is set back to a default value of 1.
Page mode programming is basically the same as Register Programming in concept and allows one to leveraged a lot of the register mode software already developed inside the decoder. However it involves extra steps at the command station level to program the decoder. To read or write a given CV value, one must write to the page register 6 first in order to chose the range of CV values you want to access via Registers 1 to 4. It is then followed by a second command to verify (read) or write to the CV through registers 1 to 4 as required.
WRITING AND VERIFY(READING)
Writing and reading CV's work exactly the same way as Register mode and requires up to 256 questions. See register mode for more information. Given it is a mulit-step process, Page Mode is bit slower than Register Mode.
If I have the history correct, Digitrax drove the development of Page mode to add more features beyond the what are pre-defined in Register mode. Technology (more memory and processor capability) allowed advancement beyond register mode to support a lot more CV's and hence more feature all at the same cost as the previous generation of decoders.
3) Direct Byte mode (Preferred method and is intended to replace Page Mode)
Direct mode changes the game in terms of how the reading of data is handled. Instead of working at the byte value level that requires 256 questions, it works at the bit level asking 8 questions. One for each of the 8 bits that make up the byte. With all 8 bits read, the command station itself can then covert those 8 bit back into the numerical value with the same 256 possibilities. No more register mode based communication thinking.
Writing is very simple. A byte of data is sent to the decoder which is then stored in the register exactly the way it was sent. This is the fastest way to write a CV. It is the same speed as register mode.
This process involves asking 8 bit questions. This is the fastest way to read a CV. Compared to Register mode, this is 32 time faster and Page mode is slower the Register mode.
4) Direct Bit mode (new capability that does not replace direct byte mode.)
The advantage of bit mode becomes clear when you only want to deal with just one or a couple of bits in a complex CV such as CV29.
Writing can done one bit at a time. You send a command that says what the value of the bit will be and what position within the 8 bit it goes. Writing a bit takes as much time as writing a byte. It is not recommended to write a byte for it will be 8 times slower.
Reading can done one bit at a time. You send a command that says what you think the value of the given bit will be and what position it will be within the 8 bit it goes and ask the verify question. This is the fast way to read an individual bit but does not save any time over reading a byte.