Basics of Programming
are only two bit values, it takes more digits to represent a number using binary. The decimal number 127, for example, is written as 01111111 in binary notation. A ‘byte’ is a binary number made up of eight bits. And a ‘nibble’ is half a byte or four bits. Really! We didn’t make that up.
Coincidentally, each CV is made up from one byte or eight bits and can store any number between 0 and 255. Most of the CVs contain a single piece of data that can be easily represented in any of the three forms, i.e., CV 3, the acceleration rate, can be loaded with any value from 0 to 255 and it always affects the same thing - the acceleration rate.
On the other hand, some CVs use individual bits to control different features. This allows up to eight individual features to be controlled by a single CV and is done to conserve the number of CVs. As the bit variables can take on only one of two values (0 and 1) they are usually used for simple variables that are either On or Off, enabled or disabled or something similar. Unfortunately, bit variables are difficult to represent in any form other than binary and still preserve any meaning. Because most DCC system user interfaces don’t use binary representation, these numbers are the most difficult to work with and require a tedious series of additions to convert to the decimal or hex form used by most systems.
We have tried to use the decimal number system in this manual when describing the proper values to program into a given CV; however, you will occasionally find values listed in the Technical Reference in binary, hex and decimal values. Hex numbers can be distinguished from a decimal number by noting a 0x prefix. Thus 0x10 is the hex version of sixteen and not ten as one might guess. Binary numbers are represented using a ‘b’ suffix. 100b is really the number four and not one hundred. To further assist the math- impaired, we have provided a handy-dandy conversion table in Appendix A that allows one to quickly convert between decimal, hex and binary.
When working with individual bits such as in CV 29, we suggest the following procedure for determining the correct value to program. Referring to the CV description, write down the value desired for each individual bit. Consider for example, the case of CV 29. We would like to set this CV so that speed tables are enabled and the 28 speed-step mode is in effect. Referring to the Technical Reference, we see that bit 4 and bit 1 should be set to 1 and all other bits are cleared to zero. Remembering that we are dealing with binary, write down the individual bit values and we get:
We then look up the binary value 00010010b in Appendix A and see that it corresponds to the decimal value 18 (0x12 in hex). This is the value to use when programming the CV.
Tsunami Steam Sound User’s Guide