■ FIGURE 4.
outboard components.
Now, turn to Figure 4 for the
remaining circuitry. At the top, you’ll
find the analog sensors. Temperature
chip LM34DZ is a no-brainer; just
hook it up directly and away you go!
The output is already scaled to
Fahrenheit, so the source code
required for the microcontroller is
very short and sweet.
The light sensor is a cadmium
sulphide photoresistor, or light
dependent resistor (LDR). This is tied
in series with R38 to create a voltage
divider. The uncommitted
potentiometer, R31, is also a voltage
divider. Recalling that the PIC12F683
contains ADC circuitry, then it’s
equally easy to take a light reading or
peg the position of the pot.
As for the IR sensor, be sure to
double-check the pinout for whatever
unit you’re using. In my case, pin 2 is
hot while pin 3 is ground. Notice R2
and C4 which filter the supply
voltage somewhat. The output is
pulled up by resistor R23 and is
finally made available to socket J16.
The relay is a fairly high powered
device, so it’s controlled by means of
transistor Q2. Rectifier D2 snubs any
reverse-EMF, protecting both the
transistor and the microcontroller.
The motor and lamp are also
higher powered devices. In this case,
we’ll use the even beefier Darlington
transistor, Q3. The male header, J4,
lets you choose whether the
transistor controls the motor or the
lamp.
Second Step:
Collect the Parts
Many of the components in this
circuit are commonplace; things like
capacitors, resistors, and the like. You
probably already have the bulk of
them in your junk box but some of
the more unusual items might give
you pause. I had no trouble outfitting
my trainer using surplus parts. In fact,
one shopping trip did the trick. I
basically got everything I needed for
the entire project from All Electronics.
If you’d like to follow suit, I have
provided stock numbers in the Parts
List. Do keep in mind, though, that
most of these items are available
from a variety of surplus dealers.
Here are a few comments on several
of the parts.
The PIC trainer is powered by a
regulated +5V wall wart. The one I
stumbled on, however, had a weird
connector so I clipped it off and
replaced it with a standard 2. 5 mm
barrel type. This mates with PCB-mounted receptacle J1. A green LED,
D8, indicates power-on status.
The IR sensor in the trainer
expects to read a signal from a Sony
type remote control unit. I found just
such a hand controller at All
Electronics for two bucks, and it
works very well. Alternatively, you
could use one of those universal
remotes, as long as it puts out the
Sony codes.
Now about the sensor. It’s the
nature of the surplus business for
stock to change without warning. I
designed this circuit around a Vishay
TSOP2138 IR sensor I purchased
earlier. However, I’m now seeing one
manufactured by Sharp that is
probably a decent substitute. It’s
possible the pinout is different, so be
sure to check the datasheet before
building with it.
Just so you know, most of these
inexpensive IR sensors use a standard
38 kHz carrier frequency, so even if
the pinout changes the firmware will
remain much the same.
The sockets (J5 through J20)
actually all come from the same
36
February 2013