EM27_S_MN_R1

advertisement
NASA-Threads
Electricity and Magnetism
Lesson
Lesson 27: Analog and Digital
The term analog refers to signals, quite often voltages, which are continuous in both time
and value. That means that they can take on any value and they can exist at any point in
time. We live in an analog world and most of the signals we look at are analog signals.
Take temperature, for example, as measured by a thermometer hanging on the wall. The
thermometer is measuring and showing us the temperature continuously as there is no
time when it is doing anything else. The temperature value is also continuous as it can take
on any number; it is not restricted to any set of predefined numbers.
Digital values, such as those generated by the Boe-Bot (or any microprocessor or
microcontroller) are not continuous in either time or value. Although the Boe-Bot can
execute approximately 4000 instructions every second, it still can only execute one
NASA-Threads
Electricity and Magnetism
Lesson
instruction at a time and there is a fixed period of time between each instruction. So when
we talk about anything that the Boe-Bot does relative to time, we cannot talk about
continuous time but instead we must think about the time axis as being a series of tick
marks indicating when the Boe-Bot executes its instructions. This is known as discrete
time.
The numbers that the Boe-Bot can generate are also not continuous. As you have seen,
signals that can be generated by the Boe-Bot are limited to values of either “High” or “Low”.
Mathematically, these values are represented by 1 and 0 and every number inside the BoeBot is made up of digits that are limited to these values. Since there are only two values
this is a Base-2 or binary number system and each binary digit is called a “bit”. Compare
this against the decimal number system we work with every day where we have 10 choices
for the values we use for any digit of any number.
In the binary number system bits can be put together in groups of 4 called a Nib (which is
short for Nibble), or groups of 8 called a Byte, or groups of 16 called a Word. When
grouped together, each additional bit represents another power of 2, starting with 20 for
the bit that is furthest to the right (or the bit with the least significant value).
So, for a group of 4 bits we have the following:
NASA-Threads
Electricity and Magnetism
Lesson
So, for 8 bits there are 28=256 possible values that can be represented, ranging from 0 to
255. For 16 bits, there are 216=65,536 possible values, ranging from 0 to 65,535. As a
result, numbers inside the Boe-Bot are limited to only these discrete integer values created
by grouping together certain numbers of bits. Limiting the set of all possible continuous
values to a smaller set of discrete values is known as “quantization”.
In order to process analog signals, the Boe-Bot must first convert them into digital signals
and this is done with a device called, appropriately enough, an “analog to digital converter”
(abbreviated as ADC or ATD). These converters come in different sizes based on the
number of bits they use to represent the converted analog signal, typically using 8 bits, 10
bits or 12 bits for the digital values. We have seen that there are only 256 possible values
that can be represented by 8 bits, so an 8 bit ADC will take a continuous voltage signal, say
between 0 and 5 V, and turn it into one of only 256 possible discrete values. The voltage
value represented by one bit (or the gap between each discrete digital value) for an 8 bit
ADC is:
5𝑉
256 𝑏𝑖𝑡𝑠
= 0.01953125 𝑉 𝑝𝑒𝑟 𝑏𝑖𝑡 = 19.53 𝑚𝑉 𝑝𝑒𝑟 𝑏𝑖𝑡
NASA-Threads
Electricity and Magnetism
Lesson
Obviously, the more bits an ADC uses to represent a number will decrease the gap between
the discrete values. Thus the number of bits used to represent these quantized values
determines the “resolution”.
Tomorrow we are going to connect an 8 bit ADC converter to the Boe-Bot and use it to
convert some analog voltage signals to their equivalent digital values. The particular ADC
converter we will be using is the National Instruments ADC0831 and it uses a technique
known as “successive approximation” to make the conversion from analog to digital. For
an 8-bit conversion, the ADC will compare the incoming analog signal, again let’s say a
signal between 0 and 5 V, against 8 different values in order to set each of the 8 bits to
either 0 or 1. The first comparison will be against one half of the highest possible value of
5 V, so against 2.5 V. If the analog signal is greater than 2.5 V then the most significant bit
will be set to 1, otherwise it will be set to 0. The next comparison will be made against one
fourth of 5 V, or 1.25 V. If the first comparison showed that the analog signal is greater
than 2.5 V, then the next comparison will be made against 2.5 + 1.25 = 3.75 V, otherwise it
will be made against 2.5 – 1.25 V = 1.25 V. This sequence continues until all 8 bits of the
digital value have been determined. When the final comparison is made, then one of the
possible 256 values will be selected as the digital equivalent value for the analog signal.
Download