Professional Documents
Culture Documents
(Sequoia House, 398a Ringwood Road, Ferndown, Dorset BH22 9AU, UK)
and TechBites Interactive Inc.,
(PO Box 857, Madison, Alabama 35758, USA)
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
MICRO PICSCOPE by JOHN BECKER
om
microcontrollers. This Micro- are offered by switch selection, in conjunction with shift registers
PICscope is a prime example of a covering the sampling rate, and and digital multiplexers to
design idea whose synchronization on/off for the portray a waveform across four
implementation was greatly scope display. The signal input 5 x 7 bit matrixed LEDs. It was
.c
simplified by using one of these is switchable to provide different very effective, although
devices. maximum peak voltage
ag somewhat power hungry.
The Micro-PICscope is a monitoring ranges. Selection of At the time though,
handy little item of test gear and AC or DC input is provided. microcontrollers were an
of benefit to anyones workshop. The entire design requires unknown to the author and a
m
Using an alphanumeric liquid only two ICs, a PIC micro and method by which an LCD screen
crystal display (LCD), it is an opamp, plus a 2-line by 16- could be similarly used eluded
basically a signal tracer, but one character LCD. An optional third
pe
being monitored, and its peak-to-ago, when the author first only memory). This technique
peak voltage. The frequency became familiar with intelligent had already been successfully
range covered is basically for alphanumeric LCDs, it became used by the author in a real-time
apparent that by Morse Code Decoder (EE Jan
using the internal 87), but did not lend itself to
programmable circuit board signal tracing and
character generator, monitoring.
their screens might The introduction of the
be capable of versatile PIC16x84
displaying a simple microcontroller re-sparked
representation of a interest in the idea, and it could
signal being have been done using that PIC
monitored. (There is with a separate analogue-to-
a GREAT article on digital converter (ADC). Then
these displays in the along comes the PIC16F87x
Example of the screen display obtainable EPE Online Library family with built-in ADC. Bingo,
on the LCD module. at the idea was now as good as
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 263
Maxfield & Montrose Interactive Inc
Constructional Project
constructed to full workshop
working order as a single chip
design apart from writing the
command program, of course!
CIRCUIT DETAILS
In fact, as you will see from
the complete circuit diagram for
the Micro-PICscope in Fig.1, the
practical implementation of the
idea has been expanded a bit to
use more than just a
microcontroller (IC2). A buffering
and gain setting opamp (IC1a) Completed Micro-PICscope showing
has been included as well. So general layout of display and controls.
too has a 5V regulator (IC3),
om
gain can be selected by switch 1/10.
allowing the unit to be powered S1 to be x1 (unity via R2) or
from 9V or 12V supplies. If you Switch S2 provides selection
x10 (via R1). Other gain-setting of AC or DC signal coupling,
have an existing well-stabilized values could be chosen instead.
5V supply, IC3 may be omitted. switching capacitor C1 in and out
.c
For example, a 10kW resistor of circuit. The output from IC1 to
The signal being monitored could be used for R3 instead of the microcontroller is DC coupled.
is brought into opamp IC1a. As a 100kW. This would provide
ag You will spot that the opamp is
set by resistors R1 to R3, the switchable gains of unity and
IN IC3 OUT +5V
m
78L05
C7
COM 100n
6 2
*SEE TEXT N.C.
*+IC1b 7 +VE
pe
N.C. 7
D0
5
*R1
10k
AC/DC N.C. 8
D1
S2
X10 TB1 9
D2
SK1
S1 *R2
100k
C1
10 *R3
100k
20 +VE 10
D3
+VE
.e
2 21 D4 11
RA0/AN0 INT/RB0 D4
X1 3 22 D5 12 X2
RA1/AN1 D5 LCD
2
8
*IC1 MAX492 4
RB1
23 D6 13 MODULE
RA2/AN2/VREF RB2 D6
w
3
*+IC1a 1
5
PGM/RB3D
24 D7 14
D7
RA3/AN3/VREF+
6 25 RS 4
4 R4 RB4 RS
10k RA4/TOCKI
w
7 26 E 6
RB5 E
RA5/AN4/SS
27 5
PGCLK/RB6 R/W
28 0V GND CX
PGDA/RB7
w
C3 IC2 1 3
10p
9
PIC16F876-20P * 11
T1OSO/TICK1/RC0
OSC1/CLKIN CX
12
X1 T1OSI/CCP2/RC1
5MHz 13
CCP1/RC2 S3
C4 14 ADC RATE
10p SCK/SCL/RC3
S6 ON/OFF 10 15
R5 SDI/SDA/RC4 SYNC
OSC2/CLKOUT S4
10k 16
SDO/RC5
D1 R6
1N4148 1k 17
1 TX/CK/RC6
a k S5 FREQ
MCLR 18
RX/DT/RC7
B1 GND GND
C6 C5 C2
9V 22 22 8 19
100n
R7 VR1
10k 10k
CONTRAST
*PROGRAMMER
TB2
VPP DATA
0V CLK
Fig.1. Complete circuit diagram for the Micro-PICscope. The voltage regulator IC3
is optional see text.
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 264
Maxfield & Montrose Interactive Inc
Constructional Project
used in inversion configuration. when the input to RA0 is at the all his future PIC designs to use
Software ensures that the signal positive supply line level of 5V. A this same pin configuration for
is seen the right way up! result of zero occurs when the LCD and programming
A MAX492 dual opamp is RA0 input is at 0V. connections.)
used for IC1, with the second Output to the LCD (X2) is via
half ignored. This device is part PORTB, using lines RB0 to RB5 CONSTRUCTION
of the authors stock library to control the display in
and has proved itself for its conventional 4-bit mode. Details of the PCB
nearly rail-to-rail output swing. Connections to the LCD are via component and track layouts
The circuit has also been used the terminal pin block TB1. The are shown in Fig.2. This board is
with a TL082 device, which order of the pins, both physically available from the EPE Online
provides good frequency range, on the printed circuit board (PCB) Store (code 7000259) at
although does not offer full rail- and in terms of program control, www.epemag.com
to-rail output (typically more like is identical to that used by the Regular readers will know
4V swing for a 5V split supply as author in many of his recently this authors preferred
used here split by resistors R4 published designs. Display constructional order: wire links,
and R5). contrast of the LCD screen is set
om
resistors, diodes, small
by preset VR1. capacitors, IC sockets and then
on upwards in order of
MICROCONTROLLER component size.
EXTERNAL CONTROL
.c
Microcontroller IC2 is a Dual-in-line sockets should
PIC16F876 device, operated at External control of the PICs be used for IC1 and IC2. Note
a clock rate of 5MHz, as set by monitoring and timing functions is
ag that microcontroller IC2 is the
crystal X1. Because of this clock actioned via PORTC, through pins narrow version (03in width
rate, the 20MHz version of the RC0 to RC2. The functions
between pin rows, as opposed
PIC should be used. The controlled are the ADC sampling
to 06in).
m
standard version has a rate (via S3), waveform
maximum guaranteed clock rate synchronization on/off (S4), and Details of the switch and
pe
limit of 4MHz. However, you frequency counter display on/off signal input connections are also
may find it interesting to note (S5). These will be discussed shown in Fig.2. Socket SK1 may
that the author has successfully later. be a different type to that shown
used the 4MHz version at rates if preferred.
.e
been discussed at length in via a suitable programmer, such connection arrangements. They
previous issues of EPE and the as PIC Toolkit Mk2 (May-June are shown in Fig.3.
w
876 will not be described in 99). The MCLR pin (master reset) As always, do a thorough
detail here. Suffice to say that it is normally powered at 43V (5V check of the component
w
has three input/output (I/O) 07V) via diode D1 and buffering positioning, orientation and
ports, one of which, PORTA, resistor R6. This allows solder joint integrity before
can be used for analog-to-digital programming voltage control applying power. Do not insert
conversion via five of its pins without disturbing the normal 5V IC1, IC2 or the LCD until the
(RA0 to RA3, plus RA5). In this supply rail from voltage regulator output from regulator IC3 has
design, only RA0 (pin 2) is used, IC3. been validated, exactly 5V
its input being taken directly (within a few millivolts) for a
Terminal pin block TB2
from the output of opamp IC1a supply between 7V and 12V.
provides access to MCLR, RB6,
at pin 1.
RB7 and the 0V common line. An output voltage from IC3
Internally, the PIC is The pin order on the PCB is the other than 5V will usually
programmed by the software so also same as that used by the indicate a fault in construction
that the voltage reference for the author in previous designs. This too high and IC3 is wrongly
ADC is taken as 0V to 5V (the will be welcomed by those who inserted, too low and there may
power line voltage range). have established a plug-in link be a short circuit somewhere on
Consequently, an A-D between Toolkit Mk2 and such the board.
conversion value of 255 results designs! (The author intends for
FIRST RUN
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 265
Maxfield & Montrose Interactive Inc
Constructional Project
When happy about the
power supply, test the circuit
MCLR
with IC1, IC2 and the LCD DATA RB7
VR1
plugged in (correctly!). Set CLK RB6
0V
switch S4 (Sync) off and S5 TB1
(Frequency) on. When power is CX
+ VE
S2
applied, the PIC first goes into 0V
+
an LCD initialization routine, in AC/DC C1 R3
0V
R
which it sets the LCD for 2-line 6
R R
E
4-bit mode. 1 2
RS
k
X10 D7
Following this, text D1
D6
S1 a
messages similar to those in the R4 D5
R5 D4
photographs should appear. The
+
C3
X1
signal trace display in the top left C2 C4 X1
R
LCD character cells should SK1 C6
+ C 7
5 IN
show as a straight line about 0V IC3 OUT
BATTERY
om
half way up the screen. Adjust S1 C7
COM
.c
Having read the sections all
about the control program, you ag
can then feed in an audio signal,
play with the switches, and see S3
the results on screen. The input
signal amplitude should be S5 S4
m
FREQ SYNC
selected so that the majority of
the LCD vertical pixel range is
pe
used.
ENCLOSURE
.e
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 266
Maxfield & Montrose Interactive Inc
Constructional Project
not quite instantaneous and the Normally, the LCD module
program repeatedly polls the GO places pre-programmed (as part
bit until it goes low, signifying an of the modules control chip
end to the conversion process. manufacturing process)
There are several subroutines alphanumeric data into these
which are used in the program cells according to command
to perform this task, one of them codes from an external source,
being: a PIC in this case.
WAITS1: BTFSC However, the module has
ADCON0,GO the facility to allow eight
characters to be designed by
GOTO WAITS1 the user and called as well as
MOVF ADRESH,W the standard alphanumeric set.
These characters are stored at
When the GO bit is clear,
module address locations 0 to 7.
Fig.3. Pinout arrangement of the command MOVF
ADRESH,W retrieves the high At first sight, when
the two basic LCD formats.
om
byte of the 2-byte conversion examining the LCD data sheet,
Basic A-to-D conversion result. Because the display is it might appear that address
using a PIC was discussed in only eight pixels high, the low locations 8 to 15 can also be
the Mini PIC16F87x Tutorial of byte is not needed (see the Mini used to hold custom characters
.c
Oct 99. A simplified version of Tutorial, or the PIC16F87x data as well. Regrettably for an
the routine described there is book, for details of the application such as this
used here:
ag
conversion result format
options).
PICscope, addresses 8 to 15
only hold repeats of the data at
In the START routine while addresses 0 to 7. Thus only
in PAGE1, register ADCON1 is The value held in ADRESH eight addresses can be used for
m
set with the binary value of (and now also in W) is that alternative character data,
%00000101, which tells the PIC which represents the voltage hence the PICscope only having
pe
that the 2-byte ADC register is to level of the signal being eight cells for waveform display.
be justified left, with RA0 as an sampled. It cannot yet, however,
analog input referenced to +VE be put out to the LCD screen, Eight cells each having five
and 0V. theres a great deal of work to pixels horizontally allows 40
.e
an oscillator rate of one-eighth storage is performed 128 times samples are taken even though
of the clock rate (Fosc/8). before further action is needed. only 40 will be displayed from
w
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 267
Maxfield & Montrose Interactive Inc
Constructional Project
position turns on the equivalent
pixel, while logic 0 turns it off. COMPONENTS
Having established which Resistors Miscellaneous
bits are to be active, the 5-bit R1, R4, R5, R7 10k (4 off) S1, S2, S4, S5 miniature s.p.d.t.
binary number for each row R2, R3 100k (2 off) toggle switches (4 off)
R6 1k S3 miniature push-to-make switch
(expanded to 8-bit with zero in All 0.25W 5% carbon film S6 miniature s.p.s.t. (or s.p.d.t.)
bits 7 to 5) is sent to the toggle switch
required character generator Potentiometer SK1 BNC socket (see text)
address, of between 0 and 7. VR1 10k miniature round preset X1 5MHz crystal
The same procedure can be X2 2 line x 16 characters per line
Capacitors
used for the other seven alphanumeric crystal display
C1 radial electrolytic, 16V
possible addresses, each of C2, C6 22u radial electrolytic,
Printed circuit board available from
them storing different data, as 25V (2 off)
the EPE Online Store (code 7000259)
appropriate. C3, C4 10p ceramic, 5mm pin
www.epemag.com; powere supply
spacing (2 off)
connector (see text); plastic case,
When character data is C5, C7 100n ceramic, 5mm pin
150mm x 80mm x 50mm; 8-pin DIL
being generated in this way, the spacing (2 off)
socket; 28-pin DIL socket; 1mm
om
LCD is first told that the data Semiconductors terminal
about to arrive is destined for D1 1N4148 signal diode pins (or strips) for TB1 and TB2; PCB
the character generator rather IC1 MAX492 dual opamp and LCD supports (8 off); connecting
IC2 PIC16F876-20P microcontroller wire; cable ties; solder, etc.
than for the screen display. In
.c
(20MHz version, 0.3-inch width)
the program the initial command preprogrammed See also the
is given by: IC3 78L05 +5V 100mA voltage
ag SHOP TALK Page!
regulator (see text)
MOVLW %01000000
Approx. Cost
CALL LCDLIN
Guidance Only $31
m
BSF RSLINE,4
which sets the character designed data is to be stored, LCD. The LCDLIN call is to one
the address incrementing each of several standard routines,
pe
module.
For all eight character cells
w
to be fully programmed, 8 x 8 =
64 bytes of data are written to
w
om
character newly programmed For instance, suppose the
into address 3, the commands waveform is alternating rapidly Although there is a great
would be MOVLW 3, CALL between high and low levels at a deal of processing being carried
LCDOUT. rate faster than the sampling out, each batch of sampled data
can keep pace with. Without is displayed in rapid succession
.c
The data held at character
corrective action, you might only and really does give a real-
generator addresses 0 to 7 can
see pixels on the upper and
ag time display of what is
be changed as often as
lower lines, those between happening in a monitored circuit.
required. In this design it is
remaining blank.
typically changed about twice
per second (faster with S4 and The corrective action fills in FREQUENCY AND
m
S5 off). All data at these those blank pixels so that they
addresses is lost when power is AMPLITUDE
pe
amplitude values.
CHARACTERS Amplitude is easily
w
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 269
Maxfield & Montrose Interactive Inc
Constructional Project
other than unity.
Frequency is assessed by
counting the number of times
the voltage level crosses a
preset threshold value. The
result is then divided by two to
obtain the equivalent number of
cycles per batch, the rate of data
acquisition being pre-
determined by the sampling
rate, which in turn is relative to
the master clock rate.
Much effort went into writing
the software so that relative
timings were maintained
consistently, irrespective of
om
conditional branch timings in the
sampling routines.
There are three rates at
Completed circuit board mounted on self-adhesive
which the ADC can be set to plastic stand-off pillars.
.c
sample waveforms, selectable readily calculated (friend and Most and Least Significant
by pressing switch S3. The rates EPE author Andy Flind has
ag Bytes, respectively.)
cycle as a repeating group of researched heavily into this we
three, numbered from 0 to 2. During prototype testing, the
hope hell one day share it with unit was fed with a frequency of
The number of the selected rate us all!). 4000Hz and the fraction values
m
is shown at the top right of the
screen. It is not a representation The solution here was to repeatedly adjusted by trial and
of the frequency range covered. count the swings above and error until the LCD also showed
pe
ADCON0 register. Rate 0 sets Using a subtractive maintained, the results were:
Fosc/2, rate 1 sets Fosc/8, rate technique, the conversion
Rate Generator Display
w
om
speeds up the rate at which the WAITAD0.
screen is fed with a fresh
waveform display. IN THE PIPELINE
.c
That, in a nutshell, is really
SYNCHRONISATION all there is to tell about this
ag
Switch S4 turns the astonishingly simple signal
waveform synchronization monitor (simple in hardware
facility on and off. When terms but certainly not
regarding software writing!).
m
synchronization is on, before
each sampling batch is started Designing it has fulfilled one of
the software waits until the the authors ambitions. Software
pe
sampling the rest of that batch. based scope, which will give far
This facility allows the greater resolution to the
w
Copyright 2000 Wimborne Publishing Ltd and EPE Online, April 2000 - www.epemag.com - 271
Maxfield & Montrose Interactive Inc