Make Electronics

(nextflipdebug2) #1

Experiment 35: Checking the Real World


306 Chapter 5


Experiment 35: Checking the Real World
Often we want a microcontroller to measure something and respond in an
appropriate way. For instance, it can measure a low temperature and sound an
alarm, as I suggested in the example that I gave earlier.
The PICAXE has three analog-to-digital converters (ADCs) built in, accessible
via logic pins 1, 2, and 4, as shown in Figure 5-139. The best way to use them is
by applying a potential somewhere between 0 and 5 volts. In this experiment,
I’ll show you how to calibrate the response of the chip.
You will need:


  • Trimmer potentiometer, 2K. Quantity: 1.

  • PICAXE 08M chip and associated USB cable and socket. Quantity: 1 of
    each.


Procedure
Take the same trimmer potentiometer that you used in Experiment 32 and
wire its center terminal to Logic Pin 2 of the PICAXE (which is hardware pin
5). The other two terminals of the 2K trimmer go to positive and to negative,
respectively. So depending how you set the trimmer, the pin of the PICAXE is
directly connected to positive (at one end of the scale), or directly connected
to negative (at the other end of the scale), or somewhere in between. See Fig-
ure 5-144 for the revised schematic, and Figure 5-145 for a photograph of the
breadboarded circuit.

330


2K


10K


1
2
3
4 5

6

7

8

PICAXE
08M

b c

a

22K


Figure 5-144. This schematic, drawn in a layout suitable
for breadboarding, shows how a 2K potentiometer can be
used to apply a varying voltage to one of the pins of the
PICAXE that is capable of converting an analog signal to a
digital value.

Figure 5-145. The trimmer potentiometer added to the previ-
ously breadboarded circuit.
Free download pdf