Bits and bytes and Hex, and their meaning.



Description on how to interpret the decoder manual bits and bytes.


The decoder manuals are often showing the meaning of the CVs by refering to different bits. A bit is a binary digit, and can be a 0 or a 1. Eight bits are refered to as a byte. The bits are numbered from right to left, with the most significant bit value to the left. In all decoders I know of, exept the Lenz decoders, the bits are numbered from 0 to 7. Lenz numberes the bits from 1 to 8. Here is an example of a byte.
10111001
If we spread out this byte a little and under each bit put the bit number it will look like this

...1.......0.......1.......1.......1.......0.......0.......1.......This is the byte
...7.......6.......5.......4.......3.......2.......1.......0.......Bit numbers
...8.......7.......6.......5.......4.......3.......2.......1.......Lenz bit numbers

Each bit in the byte has a value, like this
...1.......0.......1.......1.......1.......0.......0.......1.......This is the byte
128......64....32.....16......8.......4.......2.......1.......This is the bit values (decimal values).

When we enter a CV value to TMWDCC, we use the decimal value of the byte, and here is how to calculate the decimal value.
If we add together the bit values of the "1" bits in the example, we get 128+32+16+8+1=185 which is the decimal value of this byte. 185 is the value to enter to TMWDCC for a CV value that should look like the byte in our example. That is, 10111001 binary = 185 decimal.


Hexadecimal representation.

Some decoder manufactorers are talking about Hex values when describing their CVs. A Hex digit is a group of four bits. If we look at the same example as above, it looks like this:

...1.......0.......1.......1.......1.......0.......0.......1.......This is the byte
.....First Hex digit...... |... Second Hex digit...

If we look at the first hex character in the same way we looked at a byte before, it looks like this:

...1.......0.......1.......1.......This is the first Hex digit.
...8.......4.......2.......1.......This is the bit values (decimal values).

If we add the "1" bits together it will be 8+2+1=11 (decimal.) But what we want is to represent the Hex digit with one character and not with two, so we must invent some more figures to do this. Actually, we use the letters in stead of inventing some more figures. Like this:

0000(bin) = 0(hex) = 0(dec)
0001(bin) = 1(hex) = 1(dec)
0010(bin) = 2(hex) = 2(dec)
0011(bin) = 3(hex) = 3(dec)
0100(bin) = 4(hex) = 4(dec)
0101(bin) = 5(hex) = 5(dec)
0110(bin) = 6(hex) = 6(dec)
0111(bin) = 7(hex) = 7(dec)
1000(bin) = 8(hex) = 8(dec)
1001(bin) = 9(hex) = 9(dec)
1010(bin) = a(hex) = 10(dec)
1011(bin) = b(hex) = 11(dec)
1100(bin) = c(hex) = 12(dec)
1101(bin) = d(hex) = 13(dec)
1110(bin) = e(hex) = 14(dec)
1111(bin) = f(hex) = 15(dec)

If we now look at the example above, the first Hex digit, 11(dec), makes b(hex), and the second Hex digit, 9(dec), makes a 9(hex.)

So this is what we get from the example byte:
10111001(bin) = b9(hex) = 185(dec)


Digitrax Manufacturer ID.



Here is one last example on the binary, hexadecimal and decimal represetations. The Digitrax Manufacturer ID, stored in CV8 in all Digitrax decoders, looks like this:

10000001(bin) = 81(hex) = 129(dec)



© 1996 - 2006 Lars Lundgren