Binary numbers and their use in DCC and model railroading

Binary numbers are used in all computer systems and are base 2 numbers. Digital means number and binary means two. The smallest unit of data in digital processing is called a bit. Four bits are called a nibble and eight bits are called a byte. A bit can have two values, usually specified as 0 or 1. A digital logic gate, depending on its input signals, will turn on or off and produce a 0 or 1 bit.

Logic Bi

Our everyday number system is called the decimal system and is composed of the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Any number, such as 123, can be expressed as a power of ten. (123 = 1.23 x102) Binary numbers are composed of only two numbers, 0 and 1, and are therefore expressed as a power of 2 such as: 22= 4, 23= 8, 20= 1, etc… Digital command control decoders are configured with bytes which can have 256 values from 0 to 255. The eight bits which make up a byte are configured as shown below.

Binary Byt

A binary number of 0 0 0 0 0 0 0 0 when entered into the positions above would be: (o x 27=0, + 0 x 26 =0, + 0 x 25 =0, + 0 x 24=0,+ 0 x 23=0, + 0 x 22 =0, + 0 x21 =0, 0 x 20 =0). If the binary number was 0 0 0 1 0 0 1 0 then: (o x 27=0, + 0 x 26 =0, + 0 x 25 =0, + 1 x2 4=16, 0 x 23=0, 0 x 22=0, 1 x 21=2, 0 x 20=0)

( 0 + 0 + 0 + 16 + 0 + 0 + 2 + 0 ) = 18

If all bit values are 1’s then: ( 1 x 27 =128, + 1 x 26 =64, + 1 x 25 =32, + 1 x 24 =16,+ 1 x 23=8, + 1 x 22=4, + 1 x 21=2,+ 1 x 20 =1, ( 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 ) = 255

If the number 255 was an address, the computer would go to address 255 and carry out the instruction that was stored there.

Look at the last example and notice that, from right (position 1) to left (position 8) the value doubles for each position from right to left. If position 7 and positions 2 and 1 all had 1 bits stored then the value for this arrangement would be: 64 + 2 + 1 = 67.

Once the decimal value of a number becomes large, say 100,000, the binary table becomes bulky and difficult to handle. A simpler way to handle this large value is to use Hexadecimal, or hex, to represent the value. The hexadecimal system is used to represent each nibble or 4 bits of binary data. As an example the decimal number 100,000 in binary is 00011000011010100000. The hex representation of this number is 186A0.

The hexadecimal number system is a positional number system with a base of 16. Just to make life interesting the 16 symbol system is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Note that the numbers 10 through 15 are represented by the first 6 letters of the alphabet. If we look at the binary number for 100,000 we can divide it into 4 bit nibbles like this: 0001 1000 0110 1010 0000. The first nibble is 0001 (binary=1) and the hex number is represented by 1 also. The second nibble is 1000 and is hex 8. The third is 0110 is hex 6. The fourth is 1010 which represents the binary number 10 but is A hex. And finally the last 4-bits are binary 0 and hex 0 also.

The idea here is to give the reader an example of how these number systems work and what they are used for. The most practical way to convert values from one system to another (and the one I use) is to go on the internet and do a search for conversion tables, binary to hex, or vice versa. I have read many technical manuals for command control systems, especially decoders, where programming information is specified as hexadecimal values.

Return from Binary Numbers to Electronic Circuits

Return to Home Page