going to the same pins. The only problem is that the direction of the LEDs
are reversed, but that’s just a code
change for the PIC. We just reverse the
level on the outputs on the same pins.
If you want a segment to light, you still
just apply a positive to the anode
(which is on the same pin as a cathode
for the common anode design) and a
negative to the cathode (which is on
the same pin as an anode on the common anode design). I know it sounds a
bit strange, but look at Figure 2 and
reverse the direction of the diodes.
Then pick a segment and a digit and
apply the logic levels. I’ve allowed for
either in the code (more on that later).
I have a collection of 16F648A PIC
microcontrollers. I bought these at a
quantity 25 price break and they are my
little “go to” microcontrollers. The design
could also use the 16F627 and 16F628
parts. The -A models just have twice as
much program Flash memory and they
only cost a couple of pennies more than
the lower capacity parts, so I typically
use these. But if you have some of the
other parts, by all means, change the
configuration word and the processor
type in the source code and use those.
For little designs like this, I often
do the printed circuit board design
first and then do the schematic. It’s a
little backwards, but allows for some
much simpler layouts. I first lock out
the special pins of the PIC (like MCLR,
the RS-232 pins, RB4, power, and
ground). Then with the pins left over, I
connect to the display. To keep the
small form factor for the board, I
mounted the display on the solder
side of the board and the rest of the
components on the other side. This
means that I could put the PIC inside
the footprint of the display. With a
little bit of thought, I got a single-sided
board without a jumper.
After doing the layout, I generated
the schematic (see Schematic 1). There
are four current-limiting resistors for
each of the anodes, the microcontroller, and a simple inverter made from
a 2N2222 or other general-purpose
NPN transistor. This is required for the
PIC’s serial input. The signal must be
inverted (have a low true signal for the
start bit). Note that this inverter circuit
is not within RS-232 specs, however I
have used this circuit with many different serial interfaces without a problem.
The power supply is just a full bridge
linear regulator design, and without it,
there is only the PIC, one transistor, the
display, and seven resistors. That’s a
pretty low parts count!
After the schematic was done, I
+5V +5V
+5V
R1
10K
R3
10K
4 DIGIT
7 SEGMENT
LED DISPLAY
R6 120
RS232-IN
R2
3
1
U1 16F648A
1 18
RA2 RA1
2 17
RA3 RA0
3 16
NC RA4 RA7/OSC1
4 15
MCLR/RA5 RA6/OSC2
5 14
Vss Vdd
6 13
RB0 RB7
7 12
RB1 RB6
8 11
NC RB2 RB5
9 10
RB3 RB4
R5 120
7
B
12
F
13
A
1
E
2
D
3
DP
4
C
5
G
12
CA4
9
CA3
8
CA2
6
CA1
5.1K
Q1
2N2222
2
R4 120
R7 120
D1 1N4148
ACIN
DCIN
D2 1N4148
+5V
ACIN
5VDC
C1
D4 1N4148 470 uF
VR1
1
1 IN OUT 3
C2 GND
2 7805
0.01 uF
C3
0.01 uF
2
GND
D3 1N4148
GND
OPTIONAL REGULATED
POWER SUPPLY
■ SCHEMATIC 1
40
June 2007