PICAXE PRIMER
that you need. You can directly insert
a DS18B20 (flat side down) into J1 for
simple temperature sensing
experiments. (We will do exactly that
in the next installment of the Primer.)
Connector J2 is used for a
programming adapter; its pinout
matches that of the Prog-03 adapter
that I have been using for all my M2
projects lately. If you don’t have one,
bare printed circuit boards are
available on my website, or you could
make a stripboard version just for the
fun of it. Double-ended male headers
can be inserted into J3 and J4 to
connect the LED-2x7 board to a
breadboard which is how we will
conduct our experiments with the
LED-2x7. As you can see, connector J3
supplies power from the breadboard
to the LED-2x7, and provides access to
I/O pin C. 7 if you’re not using a
DS18B20 in a project. Connector J4
provides access to I/O pin C. 6 (which
is input only) if you’re not using a
DS18B20 in a project, as well as
access to Rx (Serial In) and Tx (Serial
Out) if you want to program the 20M2
from your breadboard’s programming
adapter rather than from a separate
adapter attached to connector J2.
The 10-pin straight female headers
in the middle of the top and bottom
rows of the 20M2 stripboard are used
for inserting the reverse-mounted
straight male headers that you see on
the LED board, forming the “sandwich”
I mentioned earlier, and connecting
the necessary I/O pins to the LED
display, the PNA4602 (if used), and
the discrete LED on the LED display
board. (We’ll get into the details shortly.)
The 20M2 board includes a total of
17 resistors. The 100K resistor ties the
SerIn pin to ground so that the program
will run when no programming
adapter is attached. (If you trace the
connections from the 20M2 board to
the corresponding pin on the LED
board, you will see that the 100K
resistor is, in fact, grounded.) The 4.7K
resistor is optional; only include it if
you will be using the DS18B20
temperature sensor. (We will discuss
the DS18B20 in the next installment of
the Primer.) The remaining 15 330Ω
resistors are current-limiters for each
segment of the LED display: a total of
14 segments for the two digits,
plus one for the decimal point
for digit 1 (the ten’s digit). When
I first began designing the LED-
2x7 circuits, I wanted to be sure
not to exceed the maximum
current capabilities of the 20M2,
so I made a couple of measurements.
If I used a 220Ω resistor, the current
draw for one segment was about 13. 5
mA; a 330Ω resistor resulted in a
current-draw of 9. 2 mA. Figure 5
presents the safe current limits for a
20M processor. (I haven’t been able to
locate the corresponding data for a
20M2 processor, but I think it’s
reasonable to assume that it’s about
the same – famous last words!)
Let’s look at the “worst case”
scenario (i.e., the 220Ω resistor): A
current of 13. 5 mA is well within the
safe limit for a single I/O pin. If “ 8. 8”
is displayed, all eight port B pins are
driven high, so the current-draw on
port B is 8 x 13. 5 mA = 108 mA; well
within the safe limit for a port. Again,
if 8. 8 is displayed, the 15 outputs will
draw 15 x 13. 5 mA = 202 mA, which
is starting to get close to the safe limit
for the entire processor. Considering
that current is also drawn by the other
ICs — as well as the 20M2 itself — I was
starting to get nervous about 220Ω
resistors. Fortunately, in the process of
making my measurements, I realized
that I couldn’t discern any visible
difference in the brightness of an LED
segment regardless of which size
resistor I used, so I decided to go with
the 330Ω resistors. They produced a
total current-draw of about 140 mA
when all 15 outputs were driven high,
which made me feel much more
comfortable!
Max. Current
Each Individual I/O Pin 25mA
Total for Each I/O Port 200mA
Total for the Processor 250mA
■ FIGURE 5. Current limits
for a 20M processor.
labeled “P1” and decimal point 2 (to
the right of the display) is labeled “P2”
because that’s all I could fit. You can
use this information in conjunction
with the schematic of Figure 2 to
trace the connections from the 20M2
to the LED display. As you can see, the
PNA4602 IR receiver is in the upper-left corner of the LED board. Its data
pin — which is pulled high by the 4.7K
resistor on the 20M2 board —
connects to pin C. 6 of the 20M2.
The only other aspect of the LED
display board that may need clarification
at this point is the use of jumpers J6
and J7. None of my current projects
require the use of decimal point P1,
but you may find a use for it, so I have
included an optional connection.
Either the discrete LED in the upper
right-hand corner or P1 can be connected
to pin A.0 (a.k.a., Sout) by installing a
two-pin shunt on one of the two jumpers
(J6 = LED or J7 = P1). You can either
trace the wiring or refer to the schematic
in Figure 2 to see how this works.
If you don’t include a shunt on
either of the two jumpers, both the
discrete LED and decimal point P1 are
disconnected from pin A.0, making
that pin available for other purposes.
Finally, as you can also see in Figure 4,
decimal point 2 (P2) isn’t connected to
anything. I couldn’t think of a need for
it which is a good thing because we’ve
already used every I/O pin on the 20M2.
UNDERSTANDING
THE LED DISPLAY
STRIPBOARD LAYOUT
In the LED board layouts in
Figure 4, I have labeled the LED
display using the pinout
information presented earlier in
Figure 3. (Pin 1 of the LED
display is in its lower-left corner.)
On the layout, decimal point 1
(between the two digits) is
February 2012 17
■ FIGURE 6. Parts List for the LED board.
ID PART
- Stripboard, 16 traces x 16 holes
- Jumper wire
J5 PNA4602 IR receiver (Optional)
- LED, 3 mm or 5 mm, non-resistorized
- Capacitor, .01 µF
- LED display, two-digit, seven-segment (LDD5111-11 or equivalent pinout)
- Two headers, male, 10-pin straight (reverse-mountable)
J6,
J7
Two headers, male, two-pin straight
(Regular length)
- Two-pin shunt