Vous êtes sur la page 1sur 10

Copyright 2008, Wimborne Publishing Ltd

(Sequoia House, 398a Ringwood Road, Ferndown, Dorset BH22 9AU, UK)
and TechBites Interactive Inc.,
(PO Box 857, Madison, Alabama 35758, USA)

All rights reserved.

ThematerialsandworkscontainedwithinEPEOnlinewhicharemadeavailableby
WimbornePublishingLtdandTechBitesInteractiveIncarecopyrighted.

TechBitesInteractiveIncandWimbornePublishingLtdhaveusedtheirbesteffortsinpreparingthesematerialsandworks.However,TechBites
InteractiveIncandWimbornePublishingLtdmakenowarrantiesofanykind,expressedorimplied,withregardtothedocumentationordata
containedherein,andspecificallydisclaim,withoutlimitation,anyimpliedwarrantiesofmerchantabilityandfitnessforaparticularpurpose.

Becauseofpossiblevariancesinthequalityandconditionofmaterialsandworkmanshipusedbyreaders,EPEOnline,itspublishersandagents
disclaimanyresponsibilityforthesafeandproperfunctioningofreaderconstructedprojectsbasedonorfrominformationpublishedinthese
materialsandworks.

om

InnoeventshallTechBitesInteractiveIncorWimbornePublishingLtdberesponsibleorliableforanylossofprofitoranyothercommercial
damages,includingbutnotlimitedtospecial,incidental,consequential,oranyotherdamagesinconnectionwithorarisingoutoffurnishing,
performance,oruseofthesematerialsandworks.

.c

READERSTECHNICALENQUIRIES
ag
Weareunabletoofferanyadviceontheuse,purchase,repairormodificationofcommercialequipmentortheincorporation
ormodificationofdesignspublishedinthemagazine.Weregretthatwecannotprovidedataoranswerqueriesonarticlesor
projectsthataremorethanfiveyearsold.Wearenotabletoanswertechnicalqueriesonthephone.
m
PROJECTSANDCIRCUITS
pe

Allreasonableprecautionsaretakentoensurethattheadviceanddatagiventoreadersisreliable.Wecannot,however,
guaranteeitandwecannotacceptlegalresponsibilityforit.AnumberofprojectsandcircuitspublishedinEPEemployvoltages
.e

thatcanbelethal.Youshouldnotbuild,test,modifyorrenovateanyitemofmainspoweredequipmentunlessyoufully
understandthesafetyaspectsinvolvedandyouuseanRCDadaptor.
w

COMPONENTSUPPLIES
w

Wedonotsupplyelectroniccomponentsorkitsforbuildingtheprojectsfeatured;thesecanbesuppliedbyadvertisersinour
publicationPracticalEverydayElectronics.Ourwebsiteislocatedatwww.epemag.com
w

Weadvisereaderstocheckthatallpartsarestillavailablebeforecommencinganyproject.


Toorderyoucopyforonly$18.95for12issuesgotowww.epemag.com
Constructional Project

PIC BIG DIGIT


DISPLAY
JOHN BECKER
Microcontrolling giant 7-segment displays D3
+12V D4
1N4001
1N4001 k a
a k
ECENTLY Dave Fisher of Display come to mind are sporting scoreboards,

R Electronics told EPE that he had


acquired several thousand electro-
mechanical big digits. These had previ-
ticket draw results, display of outdoor tem-
perature in public arenas well, youve
seen where large digits can be used, think a
ON

D1 AND D2 ARE BUILT


OFF

a
ously graced the platforms of British Rail up your own applications!

m
D1 INTO DIGIT UNIT D2
as 6-digit 7-segment clocks. Yes, they were k k
the familiar click... click... digits that MONSTERS EACH COIL 43 APPROX

surely any would-be passenger has Since the digits were only large versions

o
0V
watched mesmerised while waiting for that of 7-segment displays, reasoned the author
(where IS it?) train to arrive.
In the course of conversation, the question
of EPE designing a suitable electronic inter-
.c
before starting the design, they could be
simply driven by a PIC through a minimal
bit of multiplexing. No problem or so it Fig.1. Basic circuit for controlling one
ag
face for these digits came up. Would Tech seemed until two arrived! segment.
Ed be interested? Certainly, was the authors The digits are monsters in several sens-
timely response to a novel design idea. es. Overall, they measure 12in high, 9in +12V
wide and 225in deep (305cm 23cm
m

DISPLAY RESULTS 55cm). The angled display area is effec- ON A OFF A


The resulting basic design is capable of tively 10in high 7in wide (255 18cm) A
pe

ON B OFF B
driving from one to eight digits, with and comprises seven bright-yellow hinged F B
expansion up to 64 digits possible, as dis- segments. ON C OFF C
G
cussed later. They can be controlled via a In the absence of fully informative data, ON D OFF D
standard 4 4 data entry keypad, or via a the first task was to establish some criteria
.e

PC-compatible computer running under about controlling the display segments. ON E


E C
OFF E

MS-DOS or Win95/98/ME. Basically all that was known from a rudi- ON F


D
OFF F
A PIC16F84 microcontroller is the con- mentary data sheet was that a pulse of 12V
w

ON G OFF G
trolling device between the PC or keypad d.c. for about 025secs was required to turn
and the multiplexed digits. The PC soft- segments on and off, and that the pinouts
w

ware is written in QBasic/QuickBASIC but of a built-in connector were shown. There


can be run as a standalone program with- was no mention of the current required, Fig.2. Each digit has 15 connections,
12V power input and two on-off con-
w

out the need for QB to be installed. although there was a warning not to con-
The digits are ideal for use in any situa- nect d.c. to the segments for long periods trols for each segment.
tion that requires a large electronically otherwise damage/heating will occur.
controlled display where the data is to be The original manufacturers name was along with the message Made in France.
input intermittently. Applications that printed on the rear of the digits, Bodet, Doing a www.google.com search revealed
the company at www.bodet.com, but no
electronic specifications could be located,
other than a schematic for one segment
(see Fig.1 and Fig.2). An email to Bodet
for data produced no response. Time for
experiments!
Briefly connecting an ammeter between
a segment and a 12V power supply
revealed the current required to activate the
mechanical flap around 280mA. What?!
Surely not? An ohms check across the var-
ious controlling coils showed a typical d.c.
resistance of 439. Wow, yes indeed, that
unscientific test had shown a current figure
in the right ball-park!
Furthermore, there were seven segments
to be controlled about 2A per digit, and
users would probably need several digits.
More used to dealing with liquid crystal dis-
plays needing only a handful of milliamps,
rather than two thousand milliamps, the

Everyday Practical Electronics, May 2002 325


author recognised that the digits were more It is a bipolar-fabricated Darlington
than just monsters in size. device that requires a positive voltage at 1A
2 3
1Y
INPUTS OUTPUT
each input to turn on the respective open-
RESEARCHING DESIGN
1
1,2 EN A EN Y
collector output. Conveniently, each input
H H H
Having numerous data books and CD- has its own 105kW series resistor, remov- 2A
7 6
2Y L H L
ROMs is always to be recommended. ing the need for external resistors (such as X L Z
These days, so is Internet access. Using a required in the control line feeding into the 10 11
3A 3Y
mixture of sources, a couple of evenings base of a normal discrete transistor). The H = HIGH
L = LOW
were spent researching the type of semi- inputs are also diode-protected. 3,4 EN
9
X = IRRELEVANT
conductors that were available to handle Using a 74HC237 multiplexer, the seven 15 14
Z = HIGH-IMPEDANCE
4A 4Y OUTPUT (OFF)
such currents in a multiplexed situation. It segments can readily be controlled direct-
was a foregone conclusion that they need- ly through the ULN2004A driver.
ed to be capable of being PIC-controlled.
Any idea of using any form of discrete COMMON ANODE Fig.4. L293DN pinouts and logic table.
transistor, power-FET or otherwise, was That took care of current sinking
rejected. Such techniques were fine years through the segments. The problem then Do not use any other type of L293
ago, but hardly todays technology when became that of providing multiplexed device. The L293DN (note the DN suffix),
multiplexing even less so regarding any power to each digit. If you relate the con- is a 16-pin device with diode protection.
suggestion of relay control. No, it had to be cept to a common-anode 7-segment l.e.d. Other L293 device types may not have the
semiconductors in integrated circuit form. matrix, the individual segment cathodes same characteristics (the L293E, for
Anyone familiar with controlling 4-digit had now been catered for it was the com- instance, has 20 pins and cannot be used).
7-segment light emitting diode displays will mon-anode current control that was now
know that they can easily be controlled by required. In other words, a current source MULTIPLEX CIRCUIT
multiplexed signals a common 7-line was needed, at a minimum of 280mA. A simplified block diagram of the con-
bus feeding identically to all segments of It had been expected that as multiple trol requirement is shown in Fig.5.
all digits, and then separate power supply high-current sinking paths were available The circuit diagram showing the multi-
lines, each feeding to its own digit. The in one i.c., as with the ULN2004A, so mul- plexing and digit drive devices is given in
technique required then is to send out seg- tiple high current sourcing devices would Fig.6. Control data originates from a
ment control data along the common bus, be equally common. PIC16F84 microcontroller (discussed

m
and to only turn on digit power lines indi- It was found that there were many presently in relation to Fig.7). Through
vidually at the appropriate moment. options available if a source current of no multiplexer IC1, 3-bit control data selects
However, data sheet browsing suggested more than 100mA were required, especial- which digit is to be powered via source

o
that switching seven segments simultane- ly as the current would be pulsed intermit- drivers IC2 or IC3.
ously at a total of 2A or so could present a tently. However, the requirement for at As shown in Fig.6, and designed on the
significant problem. Perhaps switching
segments individually at about 280mA
.c
least 280mA presented a seemingly
unsolvable problem, unless discrete tran-
printed circuit board to be described later,
eight digits (one bank) can be controlled
ag
would be more sensible? sistors were used which the author was by these two drivers. Additional digit source
There are many chips that can provide determined not to resort to. Quite simply, drivers can be added separately if required
1-of-8 output selection in response to a no ideal i.c. devices could be found. (on stripboard for example, although no
3-bit control code. Such chips include the Briefly, power op.amps such as the constructional details on this are offered).
m

74HC138, whose outputs are normally high, L272 dual device seemed a possible solu- If fewer that five digits are to be con-
but go low individually when selected by the tion, but that was not deemed tidy! trolled, IC3 can be omitted.
appropriate control code. The 74HC237 Eventually, it was decided to accept a less- The eight outputs of IC1 are common to
pe

operates with the opposite output logic, nor- than-optimum option, to use an L293DN all digit drivers, and IC1 does not need to
mally low but going high when selected. quadruple Half-H driver. be repeated if additional banks of drivers
Although the outputs of these devices This has four devices that can each be set are added.
.e

cannot handle the sinking or sourcing of to sink or source a current of up to 1A at a The software allows two additional
280mA, or a voltage of 12V, they are capa- voltage from 45V to 36V. It also has two banks of eight digits (a total of 24 digits) to
ble of driving intermediate high-current enable inputs which allow pairs of drivers to be controlled without modification to the
w

buffers. The question then became one of have their outputs placed into a high-imped- program. Readers who are familiar with
which buffers were available? ance state (see Fig.4). Additionally, it too PIC and QB programming could modify
w

has in-built diode protection. the software to cope with multiplexing up


LINE DRIVER The device is intended for reversible to 64 digits if an additional 74HC237 mul-
After considerable research, it was motor and solenoid control. The term Half- tiplexer is used (see later).
w

decided to use the 7-stage line driver type H refers to the bridge configuration in which Segment selection is provided by a 3-bit
ULN2004A to activate the segments. It the pairs of drivers can be operated. It code fed to multiplexers IC4 and IC5.
can sink 500mA per stage, and is capable seemed suitable for this application since no These in turn control segment sink drivers
of handling voltages up to 50V. other appropriate device format could be IC6 and IC7, respectively. Only seven out-
This device also has the benefit of hav- found. Consequently, two L293DN devices puts of these multiplexers are used.
ing built-in diodes across each output are used in the main circuit, each providing The two multiplexers are under chip
which inhibit back-e.m.f. generation when power for four multiplexed digits. They are select (CS) control by separate CS1 lines
switching inductive loads, such as the under combined control of another (pins 6), so that segment On or Off control
segment coils (see Fig.3). 74HC237 1-of-8 controller. is achieved not only in respect of the 3-bit
The L293DN, code, but also in terms of current-sinking
however, has the pulse duration (more later).
a k
COM
unfortunate side
ULN2004A effect of consuming SELECT BANK 1
OUTPUT
c
around 20mA even SELECT BANK 2
10k5
INPUT
b when the outputs are SELECT BANK 3

e
c
k
in a high impedance
b state. The enable SELECT
DIGITS
+12V POWER
7k2 3k e a
inputs do not place 3-BIT CODE
DIGIT
8-BIT CODE
CONTROL
the device into a qui-
k a
E escent state in high- 3-BIT CODE
SELECT
7-BIT CODE
7-SEGMENT
SEGMENT
impedance mode, DIGIT

unlike many logic


devices that you may
2-BIT CODE SELECT SEGMENT ON/OFF
be familiar with.
Fig.3. Schematic of one stage within a ULN 2004A 7-stage Regrettably, it is not
line driver. cheap. Fig.5. Multiplexed control logic.
326 Everyday Practical Electronics, May 2002
+12V +12V
+5V +5V
16
16 8
16 +VE 9
+VE VCC1 VCC2 ALL BANKS 6 15
6 15 2 3 CS1 Y0 NC k
CS1 Y0 DIGIT 1 +12V IC4 Y1
14 1 INT. 16
ON A
IC1 Y1 14 7 x4 6
DIGIT 2 +12V 1 74HC237 13 2 DIODE 15
1 74HC237 13 10 11 A0 Y2 a ON B
RB0 A0 Y2 DIGIT 3 +12V 2 12 3 14
c
SELECT 2 12 15 IC2 14
3
A1 Y3
11 4 13
ON C
DIGIT RB1 A1 Y3 L293DN DIGIT 4 +12V b
3 11 1 A2 Y4 ON D
FROM IC8 10 5 12
RB2 A2 Y4 EN1/2 x7
10 9 4,5,12,13 4 Y5 ON E
Y5 EN3/4 GND LE 9 6 11
4 Y6 e ON F
LE 9
Y6 5
CS2 Y7
7 7 IC6 10
ON G
5 7 GND ULN2004A
CS2 Y7
GND
16 8 8 8
8
VCC1 VCC2 ALL BANKS
2 3
DIGIT 5 +12V
7 x4 6
DIGIT 6 +12V
10 11
DIGIT 7 +12V
15 IC3 14
BANK SELECT L293DN DIGIT 8 +12V
RA0 FOR BANK 1 1
EN1/2
RA1 FOR BANK 2 9 4,5,12,13
RA2 FOR BANK 3 EN3/4 GND 16
+VE 9
6 15
ON/OFF RB7 CS1 Y0 NC k
FROM IC8 RB3 IC5 Y1
14 1 INT. 16
OFF A
1 74HC237 13 2 DIODE 15
RB5 A0 Y2 a OFF B
SEGMENT 2 12 3 14
SELECT RB6 A1 Y3 c OFF C
FROM IC8 3 11 4 b 13
RB7 A2 Y4 OFF D
10 5 12
4 Y5 OFF E
LE 9 6 11
1 2 3 4 5 6 7 8 Y6 e OFF F
5
CS2 Y7
7 7 IC7 10
OFF G
GND ULN2004A
DIGIT POWER CONTROL
TO IC2/IC3 OF OTHER BANKS 8 8

m
0V

o
Fig.6. Circuit diagram for the multiplexed control of the digits, basically for eight, but can be modified to control 64 digits.

MICROCONTROLLER .c
effects on the +5V power line are prevent-
ed during programming control by the
Whilst the 135V (or so) of a fully
charged battery seems acceptable, it would
ag
Because of the multiplexing arrange-
ment, a PIC16F84 microcontroller is read- inclusion of resistor R9 and diode D1. appear to be unwise to allow the supply to
ily suitable for this design, see Fig.7. It is significantly exceed this voltage. The volt-
capable of being user-controlled either via POWER SUPPLY age, current and pulse duration limits for
m

a 16-key (4 4) data entry keypad, or via a Power for the digits needs to be 12V d.c. the digits are not known since Bodet did
PC-compatible computer, running under This may be provided from any source not respond to the authors request for
MS-DOS or Win95/98/ME. capable of supplying at least 500mA (to information.
pe

The PIC is run at 4MHz, as set by crys- provide headroom when a segment is The digital control i.c.s require to be
tal X1. Port pins RB0 to RB2 control digit activated). It does not need to be stabilised. powered at +5V d.c. (which must not be
selection via IC1 (Fig.6), pins RB4 to RB6 A 12V car battery is suitable. exceeded). This is provided from the 12V
The prototype was found to operate with line via regulator IC9, which can supply up
.e

control segment selection via IC4 and IC5,


RB7 controls selection of IC4 (segment On a supply voltage as low as 9V (with resul- to 100mA of sustained current. Be aware,
control), and RB3 controls selection of IC5 tant reduction in current consumption). though, that on the prototype it was
w

(segment Off control).


Port pins RA0 to RA2 perform bank +12V +12V
w

selection. As shown, they can control up IN * IC9 OUT


+5V
to three banks of eight digits. If they are 78L05
used to control another 74HC237 1-of-8 VR1
w

COM 14
C2,C6, 100k
multiplexer, however, they could control C1 C7
+VE
RA0
17
IC2/3 PINS 1/9 BANK 1
PULSE
LENGTH
100n
eight banks (with suitable software 100n
RA1
18
IC2/3 PINS 1/9 BANK 2
IC8
modification). R9
1k
PIC16F84 RA2
1
IC2/3 PINS 1/9 BANK 3
2
Port B pins are also used for inputting C3 RA3 PC HANDSHAKE (SK1 "ERROR")
3
data from a 16-key keypad, or from a PC. *SEE TEXT
10p
16
TOCKI/RA4
OSC1/
Note that it is unwise to connect a keypad CLK IN
C5
100n
and PC simultaneously since one might INT/RB0
6
IC1 PIN 1
X1
adversely affect the other. The PIC itself is 4MHz RB1
7
IC1 PIN 2
SELECT
8 DIGIT
protected against its Port B pins being C4 RB2 IC1 PIN 3
9
undesirably affected by external PC/key- 10p RB3 IC5 PIN 6 SEGMENT OFF
15 OSC2/ 10
pad control by the inclusion of buffer resis- CLK OUT
RB4
11
IC4/5 PIN 1
SELECT
tors R1 to R8. D1 RB5
12
IC4/5 PIN 2
SEGMENT
1N4148
Pins RA3 and RB7 are used by the soft- a k 4
CLK/RB6
13
IC4/5 PIN 3
MCLR DI0/RB7 IC4 PIN 6 SEGMENT ON
ware to achieve handshaking with the PC
GND
when the unit is under computer control. 0V
5
Pin RA4 is used in a manner possibly
0V
not seen by readers before. It is used in
oscillatory mode under software control
and at a rate set by preset VR1 and capaci- TB1
R1 TO R8
tor C5. It allows the segment control pulse 0V MCLR DATA CLK
1k

width to be varied. The controlling soft-


ware routine will be discussed towards the TO 4 x 4 MATRIX KEYPAD
end of this article. OR PIN 1 2 3 4 5 6 7 8 9
As usual with the authors PIC designs, PC PARALLEL PORT DATA (DA) PINS 0 1 2 3 4 5 6 7 GND

on-board programming can be performed


via a 4-pin connection (TB1). Adverse Fig.7. Circuit diagram showing the PIC16F84 control connections, plus power supply.
Everyday Practical Electronics, May 2002 327
COMPONENTS 0V
TB1
a R9

CLK RB6 D1
C4 C3 C7
DATA RB7
Resistors See MCLR
k

R1 to R9 1k (9 off) SEGMENTS

All 025W 5% carbon film SHOP VR1


X1
IC4 A ON

TALK
BANK 3 CTL (RA1) B ON
Potentiometer BANK 2 CTL (RA2) C ON
VR1 100k min. page ERROR LINE SK1 IC6 D ON
C6 E ON
preset, C5 IC8 F ON
round G ON
KBD1/DA0 R1
Capacitors KBD2/DA1 R2
C1, C2, KBD3/DA2 R3
KBD4/DA3 R4
C5 to C7 100n ceramic, 02in pitch IC5
A OFF
KBD5/DA4 R5 B OFF
(5 off) KBD6/DA5 R6 C OFF
C3, C4 10p ceramic, 02in pitch KBD7/DA6 R7 IC7 D OFF
(2 off) KBD8/DA7 R8 E OFF
KBD9/0V X F OFF
Semiconductors BANK 1
G OFF
IC1, IC4, +5V LINK
IC5 74HC237 1-to-8
multiplexer (see text) 0V Y

(3 off) 0V
1
IC2, IC3 L293DN 16-pin Half-H IC9 2
OUT COM
driver (see text) (2 off) IC1 3
IC6, IC7 ULN2004A 7-way C2 4
Darlington line driver IN 5 IC2 IC3
C1 6
(see text) (2 off)
7
IC8 PIC16F84 +12V
8
microcontroller, +12V

m
preprogrammed
(see text)
IC9 78L05 +5V 100mA (or

o
7805 +5V 1A) regulator TO IC2/3 OF
(see text)

Miscellaneous
.c OTHER BANKS 1 2 3 4

+12V TO DIGITS
5 6 7 8
ag
X1 4MHz crystal
3.1IN (78.7mm)

Printed circuit board, available from


the EPE PCB Service, code 341; RW44
m

10-inch 7-segment electromechanical


display (big digit), quantity to suit (see
text); 4 4 data entry keypad (optional
pe

see text); stranded colour-coded con-


necting wire (individual wires or ribbon
cable); 12V d.c. power source, min.
500mA output; 1mm terminal pins or pin
.e

headers; 16-pin d.i.l. socket (7 off, see


text); 18-pin d.i.l. socket; printer port con-
nectors to suit (optional see text); sol-
w

der, etc.

Approx. Cost
20
w

4.0IN (101.6mm)

Guidance Only
excluding hardware
w

required to constantly provide around


40mA (due to the two L293DN devices). It
is thus likely to get a bit warm, especially
if the source power is 12V or greater.
If it is found to shut down through exces-
sive heat (it is thermally regulated), change it
to a standard 7805 +5V 1A device. It is per-
haps prudent to switch off power during long
periods of digit inactivity.
Note that the digits themselves only con- 341
sume power during the brief pulse that
changes their segment display position.
Capacitors C1, C2, C6 and C7 help to
maintain powerline stability.

CONSTRUCTION Fig.8. Component layout and full-size underside copper foil master track pattern.
Printed circuit board component and
track layout details are shown in Fig.8. positions. Follow with the d.i.l. (dual-in- There are two choices of data input, as
This board is available from the EPE PCB line) i.c. sockets and then continue in any said earlier. They are connected to the
Service, code 341. convenient order. Insert 1mm terminal pins board at the pins to the left of resistors R1
Assemble in order of link wires first, at the external connection points, but omit to R8.
including the one marked Bank 1 Link those alongside IC1 which are only needed If using the data entry keypad, connect
this will be discussed under Expansion. if more than eight digits are to be its pins, as shown in Fig.9, to the similarly
Note that some links go under the i.c. controlled. numbered points on the board. Keyboard

328 Everyday Practical Electronics, May 2002


PIN FUNCTION
1 NC
2 NC
3 D OFF
4 D ON
5 E OFF
6 C ON
7 E ON
8 C OFF
9 F OFF
10 B ON
11 F ON
12 B OFF
13 G ON
14 A ON
15 G OFF
16 A OFF

ARROW ON CONNECTOR
DENOTES PIN 1

15 1

16 2

VIEW LOOKING INTO 16-WAY CONNECTOR

Fig.12. Pinouts for the connector


mounted as part of the digit assembly.

DIGIT WIRING
Monstrous is again a term that can be
used in respect of the digit connection

m
requirements. The digits need to be wired
Prototype display controller board during development testing using a plug-in in parallel back to the control board.
breadboard to temporarily connect a data keypad and a PC via a Centronics con- However, although the manufacturers have

o
nector (mounted on the p.c.b. used with Teach-In 2000 Part 4 Feb 00). provided a single connector on each digit,
this only allows for one set of the 15 con-
pin 9 is a ground (0V) connection for the
pads frame.
.c
Alternatively, the unit can be hardwired
to a separate 25-way D-type male connec-
nection wires needed.
One would have expected two connec-
ag
If using a PC as the data source, it needs tor plugged into the back of the computer tors, one for the cable harness arriving
to be connected from its parallel printer 10-way ribbon cable would be ideal. The from the control board, another for the har-
port to the board. The easiest way is to use connectors pinouts are shown in Fig.11. ness that then has to be connected to the
a standard printer cable with pre-attached Note that the Error line connects to the next digit.
m

connectors. The printer end of the cable board pin situated near IC8. (Error is the The author offers no recommendations
has a 36-way male D-type Centronics con- name given in respect of that lines normal about using the digits own connector,
nector which requires a matching female purpose when interfaced to a printer.) although for the sake of good order, its
pe

type at the unit end. The latter should be Before inserting the d.i.l. i.c.s, do a thor- pinouts are shown in Fig.12.
hardwired to the board at the designated ough examination of the board for faulty It was decided that it was easier to hard-
points using short lengths of insulated assembly and soldering. Then only insert wire the connections to solder pads at var-
.e

stranded wire. The pinouts for a right- them after you have established that regu- ious positions on the back of the digits.
angled female connector are shown in lator IC9 is correctly supplying +5V at its They are the pads to which the manufac-
Fig.10. output. Check this again once the i.c.s have turers rectifier diodes (mounted inside the
w

been inserted. digit box) are soldered. The correct con-


Be aware that they nection points were found experimentally
w

TOP are CMOS devices and are shown in Fig.13. Ignore the unused
1 2 3 4
A) B) and require the nor- pads.
mal handling precau- Whereas the 14 segment wires of each
w

TOP 5 1 2 3 A
tions, discharging sta- harness are connected in parallel to each
6 4 5 6 B tic electricity from digit, each digit needs its own separate
9 8 7 6 5 4 3 2 1
your body by touch- +12V power supply wire, originating from
REAR VIEW
7 7 8 9 C ing the bare metal of the control unit p.c.b. as shown in Fig.8.
something earthed Make the +12V connections in numerical
8 0 D before handling them. order in relation to the digit positions in
PIN 9 - CONNECT TO 0V
Adjust preset VR1 the proposed display.
to a fully-clockwise Before you fully interwire the digits,
Fig.9. Keypad connection details. setting (maximum though, it is recommended that you just
pulse length) before wire-up for the first one and check out the
testing the system. system.
HANDSHAKE
IC8 RA3 UNDERSIDE VIEW LOOKING AT PINS
(ERROR)
SK1
D7 D5 D3 D1
D6 D4 D2 D0

36 19

18 1 13 1

25 15

DA6 DA4 DA2 DA0


0V
DA7 DA5 DA3 DA1
GND ERROR

VIEWED FROM REAR OF SOCKET PLUGGED INTO COMPUTER PARALLEL PORT

Fig.10. Connections to a 36-way D-type Centronics female


connector used in conjunction with a standard PC parallel Fig.11. Alternative connections via a 25-way male D-type
port cable. connector.

Everyday Practical Electronics, May 2002 329


KEYPAD OPERATION
The software has been written so that on
power being switched on the PIC sets its
Port B for input with the input pull-up
resistors active. A check is then made to
see if the inputs are connected to any B ON
B OFF
source that pulls them low. A ON
Under keypad control (with no keys A OFF
pressed) there is nothing to pull the pins B ON
B OFF
low and so the PIC assumes that a keypad A ON
is the data entry source. A OFF
G ON
Having established that fact, the soft- G ON
G OFF
G OFF
ware goes into a perpetual loop scanning F ON
F ON TO
OTHER
the keypad for keypresses. The software FROM F OFF
F OFF DIGITS
SEGMENT E ON
routine used is a variant of that described in CONTROL E ON
E OFF
the authors Using PICs with Keypads of I.C.s E OFF

Jan 01. ON FROM


IC6
In response to any keypresses, look-up
OFF FROM
tables are used to relate that input value to IC7
D OFF CONNECTOR D OFF
D ON D ON
the data to be sent to the digits. The first C OFF C OFF
table (VALUE) allocates the keypress data C ON C ON
to a numerical value between 0 and 15.
Another table (TABLE) then relates that
value to a binary sequence in respect of the
digit segments to be turned on.
The sequence is in the right-to-left order IGNORE UNMARKED
CONNECTION POINTS
(bit 0 to bit 7) of segment A to segment G. +12V
FROM SELECTED
For example, binary 01111111 turns on all POWER CONTROL I.C.
segments, resulting in the 7-segment dis-

m
play of numeral 8. Binary 00000110, on
the other hand, only turns on segments B Fig.13. Wiring details for a single digit.
and C, resulting in numeral 1 being dis-

o
played. The full table is shown in Listing 1.

LISTING 1 .c
ag
TABLE:
addwf PCL,F
retlw %00111111 ;0
retlw %00000110 ;1
m

retlw %01011011 ;2
retlw %01001111 ;3
retlw %01100110 ;4
pe

retlw %01101101 ;5
retlw %01111101 ;6
retlw %00000111 ;7
.e

retlw %01111111 ;8
retlw %01100111 ;9
retlw %01110111 ; 10 A
w

retlw %01111100 ; 11 b
retlw %00111001 ; 12 C
retlw %01011110 ; 13 d
w

retlw %10000000 ; 14 blank


retlw %01000000 ; 15 -
w

GFEDCBA

Note that bit 7 in the 14th jump is set at


1. This prevents the PIC from returning a Interwiring between the two digits used during development.
zero value from this location, which would
otherwise be recognised as no data
entered from keypad. make. You may recall that the authors LISTING 2
Whilst it is suggested that decimal dis- Teach-In 2000 series demonstration soft-
play values from 0 to 9 are retained, other ware illustrated the principle of 7-segment TABLE2:
segment arrangements could be provided control. addwf PCL,F
for the other six positions by readers hav- Having established the segment code retlw %01000000 ;a
ing their own PIC assembly-programming required, the PIC then has to send the cor- retlw %00100000 ;b
facilities, such as the authors Toolkit responding data to the segments individu- retlw %01100000 ;c
Mk3/TK3 (Oct/Nov 01). ally. From within a loop, the PIC reads retlw %00010000 ;d
It is also worth recognising that 7-seg- each data bit position to see whether a seg- retlw %01010000 ;e
ment displays cannot in many instances be ment should be On or Off. At each position retlw %00110000 ;f
used to represent alphabet characters. For it uses another look-up table (TABLE2 retlw %01110000 ;g
example, capital letter A can be represent- see Listing 2) for the code needed to send retlw %00000000 ;-
ed, but lower case a cannot. Conversely, b to multiplexers IC4 and IC5 in order to
can be, but B cannot (it would just look like control that bit. The code is output on the 3-line com-
an 8). The code also takes into account that the mon bus feeding to IC4 and IC5. Which of
Also note that any letters having diago- p.c.b. tracks are connected to the three con- these i.c.s is activated depends on whether
nals cannot be represented, such as K, M, trol pins in the opposite order than might the segment needs to be turned on or turned
N, Z, nor can T. It is worth experimenting normally be expected (this was done for off. To turn on IC4 (segment On), bit 7 in
to see what characters can be represented, p.c.b. design simplicity). Only bits 6 to 4 the code is set high. If IC5 is required (seg-
and what compromises you might have to are of importance in this table. ment Off) bit 3 is set high.

330 Everyday Practical Electronics, May 2002


It is also necessary to specify which of the keypad (but preferably in the keypads address by pressing 0, 1 or 2 (pressing any
the digits is the target for the segment absence). It is in a different coding format other key, including <ENTER>, always
information. This data is set into the codes to that used with the keypad, however. selects 0, i.e. address 378).
bits 0 to 2, representing the number (1 to 8) Because of the full range of keys on a If you do not know which address your
of the digit in the allocated bank, and des- PC keyboard, is it is possible to send a PC uses, try all three. The system will
tined for IC1 (see Fig.6). much greater variety of data to the digits. show you have the correct one when it
On recognition by the PIC that a PC is con- proves that it can send data to the displays.
DIGIT SELECTION VIA nected to it (see earlier), it goes into a dif- (The PIC board must be free of assembly
KEYPAD ferent monitoring routine (COMPROG). errors of course!)
Because the digits might be located Synchronisation between the PIC and Having selected the register, the screen
away from the controlling keypad, and not PC is maintained by using two handshake changes to that in Fig.14b. Underneath the
be visible to the user, it was decided to lines at the PIC end of the system, pins main title you are asked to enter the num-
allocate two keypad keys as digit stepping RA3 and RA7 as mentioned earlier. Port B ber of digits that you wish to be controlled,
controls. At switch-on digit 1 is the default pull-up resistors are turned off in this with a range of 1 to 24. Values outside this
target, and any numeric data keyed in con- mode. range are not accepted.
tinues to be routed to it. The first significant handshake action At the bottom of the screen are dis-
To choose Digit 2 instead, press keypad the PIC takes following switch on for PC played the characters which can be sent for
D (Digit step). This changes the control mode, is to set pin RA3 high. This indi- display via the 7-segment digits. With the
code fed to IC1, incrementing it from cates to the PC that the PIC is ready to exception of the control keys mentioned
binary 000 to binary 001, so selecting digit receive data. The PIC then sits in a holding next, this represents the full range of keys
2. Display data is now repeatedly fed to loop until acknowledgement from the PC is that are functional. Any others will be
this digit. Pressing D repeatedly steps received. ignored by the program (although you can
through each digit position in turn, irre- The PC software in its turn holds its add to the range as discussed later).
spective of whether the digit physically printer port output DA7 low and waits for To either side of the screen are quoted
exists in the system. the RA3 = high signal to arrive via its the commands available when the program
To return to Digit 1 at any time press C printer port Error line. Having received is in full control mode. The <ESC>
(Clear back to start). It is not possible to step this signal, however, it takes no immediate (escape) key causes the program to restart
back individually from digit to digit. This, action, but waits for a keyboard key to be from its beginning and may be used at any
though, is a facility for which PIC-wise users pressed. time. Pressing the <CTRL> and <BRK>

m
could write a software routine. In this case it Having received a keypress, the PC keys simultaneously causes the program to
is suggested that key B is intercepted relates it to a lengthy look-up table that end. This is the only way in which it can be
(Backwards) in a similar way to which letters holds segment data in respect of keypress- halted and exited.

o
C and D are intercepted. es. If segment data has been allocated to Otherwise, all keyboard characters
Each time the digit number is stepped for- that key, it is output as seven bits (same shown in the bottom line are available for
ward, the software increments a 24-value
counter (rolling over to 1 again following
.c
relationship as with keypad data) plus bit 7
set high. It then remains in another holding
output to the digits. Acceptable keypresses
are responded to immediately, and data is
ag
24). This not only provides information on loop until the Error line goes low. output to the digits in sequence, the PICs
which digit is selected (from 1 to 8), but also The PIC, recognising that its RB7 pin digit count being incremented following
on which Bank it is in (Bank 0 to 2), using has gone high, accepts the incoming 7-bits receipt of each character. When the final
yet another look-up table. This results in Port of RB0-RB6 data as valid. It immediately digit in the sequence has been triggered,
m

A pins RA0, RA1 or RA2 being selected as acknowledges this to the PC by setting line the count automatically recommences from
appropriate (in Bank order). RA3 low. Digit 1.
Referring back to Fig.6 again, it will be The PC, having accepted this acknowl- When entering data for output to the dig-
pe

seen that IC2 and IC3 are shown to be under edgement, is now free to wait for another its, pressing <ENTER> causes the PIC to
selection control by pin RA0. If additional keypress, but will not send it until the PIC reset the digit count back to Digit 1.
IC2 and IC3 devices are used they would be signals that it is ready. Pressing the space bar causes the next digit
.e

allocated to one of the other Port A pins, Between accepting bytes of data, the to be cleared (no segments showing).
RA1 or RA2, in that order of Bank. PIC sends the segment data serially to the
In this way, 24 digits can be stepped selected digit in a similar fashion to that PC FIRST, PIC SECOND
w

through by pressing key D the required described earlier. On completion of each In the mid-screen area you are told that
number of times. Yes, it tests the users digits output, the PIC again sets hand- you should switch on the PIC unit now.
w

counting ability, but seemed the best solu- shake line RA3 high, asking for more PC As said earlier, when the PIC program is
tion considering the limited number of data. first switched on, the PIC examines Port B
keys available. to see whether its pins are high or low. If
w

The provision of monitoring via an DIGIT COUNT high, keypad control is assumed. On run-
alphanumeric liquid crystal display was SELECTION ning the PC program, however, its first
considered, but was rejected on the The PC program has been written so that activity is to set its printer port lines low.
grounds of adding complexity to a moder- it can be set to the exact number of digits in On reading Port B being low, the PIC
ately simple design. use, unlike the keypad software which knows that PC control is required.
PIC-knowledgeable readers could prob- always expects 24
ably add l.c.d. facilities if needed. There digits. It also provides
are numerous examples of l.c.d. control in the facility to select
many of the published EPE PIC projects which printer port
(especially in the authors designs). Such a register address is
routine could be integrated almost as a used.
library file. On running the
It is suggested that l.c.d. control is basi- program, the screen
cally via Port B with the exception of the shown in Fig.14a will
l.c.d. E line, which is better suited to con- be displayed. The
trol by the otherwise unused pin RA3 (it is three possible printer
only used when under PC control). port registers address-
Line E cannot be satisfactorily con- es are displayed at the
trolled by Port B as all pins are in use for top. It is necessary to
other purposes, which would cause unde- select the one appro-
sirable l.c.d. response. It is only Line E that priate to your PCs
is critical in this context. configuration. Most
likely it will be
COMPUTER CONTROL address 378 hex, but
When under computer control, data is could be hex 278 or Fig.14. Sections of Big Digit PC program setup screens, (a)
fed to the PIC via the same connections as 3BC. Select the printer port selection, (b) digit quantity selections.

Everyday Practical Electronics, May 2002 331


LISTING 3 Another option open to those who are
familiar with QB programming is to write
DATA 01111110 a code routine that allows a string of char-
DATA 10110000 acters to be entered via the keyboard as a
DATA 21101101 sentence (using INPUT instead of
DATA C1001110 INKEY$). This would not be transmitted
DATA c0001101 to the PIC until the <ENTER> key had
DATA D0000000 been pressed. Each character would then
DATA d0111101 be sent automatically in sequence to suc-
DATA K0000000 cessive digits as required.
DATA k0000000
DATA 0000000 SETTING PULSE
DATA ^1100011 LENGTH
So far the discussion has assumed that
When the program the length of the control pulse that activates
is started, all data the segment coils is correct. Setting preset
statements are Read VR1 earlier to a fully clockwise position
Fig.15. Example of PC screen during and analysed. The first character in each sets the length to the maximum design
digit control. data string holds the keyboard character limit. It is likely that the pulse can be short-
that represents the following 7-bit segment ened, so speeding segment changes.
data. Its ASCII value is taken and the The simple data sheet received indicated
Consequently, do not switch on the PIC remaining seven bits in the data are stored that a pulse length of about 025 seconds
unit until you see the screen now being dis- in a string array, seg$(x), at the address was required. Experiments with the digits
cussed. When you have switched on the corresponding to the ASCII value. showed that it could be much shorter.
PIC, then enter the number of digits to be For example, in the first case, Although there was a slight variation in
controlled and press <ENTER>. 01111110, the leading 0 is the first minimum operational pulse length for the
The program then enters its full opera- character. Its ASCII value is 48 and so the various segments, the requirements were
tional mode, first drawing on screen the rest of the data string (1111110) is stored typically found to be about 70 millisec-
same number of boxes as the number of at string array position seg$(48). In the onds, but cannot be guaranteed in other

m
digits specified. These boxes represent the fourth case, C is the character, having the assemblies (hence the need for user-adjust-
7-segment digits and display the same ASCII value 67, so its 7-bit string data is ment rather than specifying the length as
an accurate timing within the software).

o
characters. stored at seg$(67).
Next the program sends data for numer- Note that some data statements have had A 70ms pulse length is generated with
al 8 to all digits required. It then sends a
reset command to the PIC, resetting it for
Digit 1, after which it sends data to clear all
.c
to be enclosed in quotes so that the pro-
gram recognises the associated character
correctly (the last character in the above
preset VR1 at a roughly midway setting.
The maximum pulse length that can be set
is about twice that. These figures are based
ag
required digits, again followed by a reset list cause the degrees symbol to be dis- on the PIC being run at 4MHz.
command. played when the ^ is pressed (as in Once you have ascertained the correct
This action has three functions, to syn- 20oC). The one before it is for the space bar response of the segments using a long
pulse set via VR1, it is worth experiment-
m

chronise the PIC with the computers (turns off all segments in a digit).
order of digits, to prime the PIC so that it You will see instances where the charac- ing to find the lowest VR1 setting at which
knows which segments are in which state, ter may be in upper or lower case, and in the segments will respond. This will speed
pe

and thirdly to clear any existing display some cases both. If the value following the the rate at which the displays can be
data. character contains one or more 1s, the changed.
In the latter context it is worth recog- equivalent character can be generated on a The digits will not respond if the resis-
nising that the segments can be set by 7-segment display. In the other cases, all tance is set too low. An intermediate stage
.e

hand without damaging them. They are zeros, the character cannot be formed may also be found in which some digits
only balanced on light-duty pivots, freely using a 7-segment display. respond but not others. Avoid setting VR1
to a nil resistance position which will over-
w

responding to the electromagnetic fields If a character is not included in the table,


generated by their coils. It is quite possi- a value of zero is returned if its key is load RA4 when it is in output-low mode
ble that someone could have set them by pressed. All unacceptable keypresses are (the PIC is internally protected against
w

hand to random positions. (In a field ignored. brief overloads but do not sustain this
condition).
situation, it is advisable to enclose the
ALLOCATING
w

digits to prevent this happening and of It is worth noting that the software has
course to protect them from the SEGMENTS also been written to speed segment
elements.) For such unacceptable keys, however, a changing. The status of each segment is
From this point onwards, pressing any segment or PIC control code can be allocat- recorded in the PICs memory. When a new
recognised key causes the data to be dis- ed separately. For instance, the program allo- character is to be displayed on a particular
played sequentially, with the count return- cates the code 00000001 when the digit, the digits current segment status is
ing to zero (Digit 1) after the final digit (or <ENTER> key (ASCII 13) is pressed. The checked against the segment requirement
on pressing <ENTER> as described PIC has been programed to recognise this bit for the new character. If any segments
earlier). An example PC screen display is combination as the command to reset the match, they are ignored by the output rou-
shown in Fig.15. digit number count to Digit 1, in a similar tine, so saving one pulse duration which
way to that in which it responds when the can be a significant saving when many
PC CONTROL DATA D key on the 4 4 data keypad is pressed. digits are in use.
OPTIONS You could, for example, allocate specif-
Because of the greater variety of seg- ic codes for the PCs forwards/backwards SCHMITT PULSING
ment codes that can be generated via the cursor keys. The PIC could then be told to This now brings us to a software/hard-
PC than with the keypad, there is the step the digit count value backwards or ware aspect that has not been used before
option to program the PC software with forwards without causing the display data in an EPE project analogue control of
any segment combination required. to change. Then, on pressing another key, frequency via a digital input.
The data is held in a look-up table its character would be displayed at the new You are no doubt familiar with the type
which can be added to by readers who digit address. of circuit in which a single Schmitt trigger
have QBasic or QuickBASIC resident on Such a facility would be of help in a dis- inverter is used with a resistor and capaci-
their PC. The data is held as in the format play having many digits and where only tor in order to generate a frequency (an RC
extract example shown in Listing 3, in the one or two might need to be changed at any oscillator). The technique used in Big Digit
bit order of segments ABCDEFG (the time. This would remove the need to key in is similar.
opposite order used by the PIC softwares data for all digits in the full display when The PIC16F84 has a Schmitt trigger
table). only a few might need changing. input, pin RA4. Referring to Fig.7, the

332 Everyday Practical Electronics, May 2002


resistance is provided by preset VR1, and To such experi- LISTING 4 Send pulse to segment control
the capacitance by C5. Initially software enced programmers,
sets RA4 as an output set for logic 0. This the changes required PULSEIT:
discharges C5. RA4 is then set as an input, should be obvious, movlw %00010000 ; number of cycles required
allowing current to charge up C5 via VR1. but the author cannot movwf PULSECNT
When the Schmitt threshold is reached, offer advice on it. Nor PULSE2:
the software responds to this as an input can advice be offered btfss PORTA,4 ; has bit 4 gone high (cap charged
change from logic 0 to logic 1. It immedi- on a breadboard lay- up enough)?
ately sets RA4 as an output at logic 0 out for any additional goto PULSE2 ; no, repeat check
again, discharging C5, and then resets RA4 chips added. bcf PORTA,4 ; yes, set bit 4 low to discharge cap
as an input once more, and so the cycle can Note that it will be again
continue for as long as the software necessary to change PAGE1
requires it. regulator IC9 to a bcf TRISA,4 ; set bit 4 as output
In this design, 16 waveform cycles are standard 7805 +5V PAGE0
used, which allows a lower value capacitor 1A type if additional nop ; brief wait discharge capacitor
to be used than with a single cycle. It also copies of IC2/IC3 are PAGE1
increases the capacitors discharge rate and added (each extra bsf TRISA,4 ; set bit 4 as input
reduces current flow when RA4 is briefly chip adds about PAGE0
set low. Listing 1 shows the full pulse delay 20mA to the power decfsz PULSECNT,F ; repeat for set delay loop time
generation routine. drawn from the +5V goto PULSE2
The frequency of oscillation can be line see earlier). return
changed by varying VR1 or by using a QB programmers
different value for C5. will recognise that the multiplexing circuit provides a reasonable method of controlling
could be controlled directly from the PCs the digits, whether just one is used, or many
EXPANSION printer port data lines, omitting the PIC more. We would be interested to know how
As said earlier, additional banks of eight entirely. The ports other control lines many you use and in what applications.
digits can be controlled. In this case IC2 could then be used in place of the RA0 to
and IC3 need to be duplicated on a strip- RA2 connections. The QB software would RESOURCES
board layout. Their pins should be con- largely need to be rewritten, of course. The software for this design is available

m
nected identically to those in Bank 1, refer- on 35in disk (for which a nominal han-
ring to Fig.6. The connection points on the VALEDICTUM dling charge applies) from EPE Editorial
p.c.b. are those alongside IC1, previously DIGITALIS! office, or free via the EPE ftp site (path

o
left unused. Two digits were sent to the author for PUB/PICS/bigdigit). The easiest route to
The difference is that their enable pins (1 experimentation. As described in this arti- the ftp site is via the link at the top of the
and 9) need to be controlled by a different
Port A pin, RA1 for Bank 2, and RA2 for
.c
cle, the resulting design is intended to drive
up to at least 24 digits, and up to 64 with
main EPE web page at www.epemag.
wimborne.co.uk.
ag
Bank 3. It is permissible to omit IC3 in the modification. Obviously this ability has not The PIC software is supplied as a source
final bank if the digit count does not been fully proved in practice. However, code (ASM TASM grammar), HEX code
require it. extensive bench-tests and simulations have (MPASM) and OBJ code (TASM). It was
If more than three Banks are needed been made using the two digits and it is developed using EPE Toolkit Mk3/TK3.
m

(more than 24 digits), pins RA0 to RA3 believed that the claims are valid. If you The PC program is supplied as a stand-
should be wired into another 74HC237, find any aspect that does not justify this alone program (EXE) and as
mounted on stripboard, at its pins A0 to belief, let the author know via EPE HQ QBasic/Quick-BASIC source code (BAS).
pe

A2. The outputs would then be used as the (NOT via the Chat Zone as messages post- The PIC configuration required is XTAL
Bank Select lines for up to eight pairs of ed there may be overlooked). XS, POR on, WDT off. This is embedded
IC2 and IC3. The author hopes that readers will find in the ASM and HEX codes, but readers
.e

If using the extra 74HC237, remove the ways in which the PIC and QB programs can using the TASM OBJ code must configure
p.c.b. link wire marked Bank 1 Link. be enhanced and write additional routines to the PIC in the usual separate manner.
Connect point Y to pin Y0 of the new mul- suit their own needs. His intention has been Ensure that you read this months
w

tiplexer. Point X then becomes the point to to show with this design how the Big Digits Shoptalk page for details of component
be regarded as the RA0 connection. can be controlled, and to provide an elemen- buying for this project.
w

The software for the PIC and the PC will tary framework within which readers can
need to be modified to cope with more than work to suit their own needs and the number ACKNOWLEDGEMENT
three banks of digits. For this reason, only of digits actually used. The author thanks Display Electronics
w

readers highly familiar with programming Readers who do not wish to tailor the pro- (www.distel.co.uk) for providing the Big
in both PIC and QB languages should grams, though, will find that the software is Digits for experimental use in the develop-
undertake this option. perfectly usable as it stands, and that it ment of this project.

Signed.............................................................................

Name and Address.........................................................

........................................................................................

NEWSAGENTS ORDER FORM ........................................................................................


Please reserve/deliver a copy of Everyday
Practical Electronics for me each month Post Code ..........................

Everyday Practical Electronics is published on the second Thursday of each month and distributed S.O.R. by COMAG
Make sure of your copy of EPE each month cut out or photostat this form, fill it in and hand it to your newsagent.

Everyday Practical Electronics, May 2002 333