Use the worksheet below to help understand how bits are used to represent analog values.
Click on the "Change" button below each bit to changes its value. The totals for each Byte, and the total for the entire Word will be listed below.
The current Word total is 0
The HI Byte total is 0, and the LO Byte total is 0
Hit F5 on your keyboard to reset this page
One thing you will notice is that the HI Byte total does not seem to equal what it should. For instance, clear the worksheet by hitting F5 on your keyboard, or right-click and select either Refresh or Reload. Now set only bit8. The value of the Word is now 256, as you would expect. But the published value of the HI Byte is listed as "1".
This is another case of the way things really are, versus how they are reported. In reality, the true value of bit8 is 1. After all, it is really bit0 of the respective Byte. However, when we format a Byte to be the HI Byte of Word, bit8 gets counted as 256.
When you see the native LO Byte values and HI Byte values, it is important to understand that they are not simply added together. The formula to combine the native value of two Bytes into a Word is as follows:
Total value = (HI Byte x 256) + LO Byte
In the formual above, 256 is used as a multiplier on the HI Byte values. Notice the when you relate LO Byte values to their respective position in the HI Byte, the HI Byte value is the LO Byte value multiplied by 256.
bit 8 = bit0 x 256 = 1 x 256 = 256
bit 9 = bit1 x 256 = 2 x 256 = 512
bit 10 = bit2 x 256 = 4 x 256 = 1024
bit 11 = bit3 x 256 = 8 x 256 = 2048
bit 12 = bit3 x 256 = 16 x 256 = 4096
bit 13 = bit3 x 256 = 32 x 256 = 8192
bit 14 = bit3 x 256 = 64 x 256 = 16384
bit 15 = bit3 x 256 = 128 x 256 = 32768
Thus, the native sum of all the set HI Byte bits can simply be multipled by 256 to determine its formatted value.
HI Byte = bit8 + bit9 + bit10 + bit11 + bit12 + bit13 + bit14 + bit15
Total value = (HI Byte x 256) + LO Byte