The digital world of the PICAXE is all lows and highs, zeroes and ones. The deceptively easy- to-use IR receiver we used last time is actually a sophisticated little module with lots of internal circuitry optimized for receiving nicely controlled digital control signals. Of course, most things in the real world have analog values. Temperature, light, and distance are constantly
changing numbers spanning a range. Fortunately for us,
analog sensors for measuring these quantities are cheap
and abundant (Figure 1).
Our PICAXE 08M2 has three built-in analog/digital
converters (ADCs) on pins C.1, C. 2, and C. 4 (Figure 2)
which can readily measure from 0-5 volts. Actually, they can
measure up to the battery voltage; so, 0-4.5 volts in our
case. READADC C. 2,B5 reads a voltage on pin C. 2, scales it
to a proportional eight-bit value from 0 and 255, and stores
it in variable B5. If higher resolution is needed,
READADC10 C. 4,W3 reads a voltage on pin C. 4, scales it
to a proportional 10-bit number from 0-1023, and stores it
in word variable W3. (Yes Virginia, you can change the pins
and variables around; those are just random examples.)
In order to measure voltages higher than four or five
volts and to use variable resistance sensors, we need to
understand how voltage dividers work. Google and
You Tube can do a far better job than I can, so I won’t
waste much space here.
Two resistors in series connected across a voltage
source will develop a proportional voltage at their center
junction. The resistors’ values determine the voltage as
shown in Figure 3. A rotary potentiometer is a three-terminal variable resistor — much like a volume control.
Connecting the pot’s end terminals to our battery forms a
voltage divider. The pot’s movable wiper changes position
as the knob is rotated — effectively splitting the total 10K
resistance into two continuously changing resistor values.
As one gets bigger, the other gets smaller, and their
sum always remains 10K. Thus, the voltage at the
wiper can be anywhere from zero up to the battery
voltage as shown in Figure 4B.
SERVO 11.2015 69
Post comments on this section and find any associated files and/or downloads at