Page 208 - Making PIC Microcontroller Instruments and Controllers
P. 208
204 cou Tll{G PULSES: a PnOGnAlt aElE TACHoMEIEB
De6ne the RPM variable and oth€rs with Ore ftst of the vsriables. (S€e Pmgam l5'4')
Then after tbe LCDOUT line in the loop add the code segment in Program 15'4'
:S{Citle$S*illi:j code segment for slmple declsion maklng
IF (RPM>1?{9) AND (RPM<1801) TITEN
EIJSE
END IF
We now know how to rcad a frequency and display it either oI! the LCD or on a sel
displays-
of seven-segment
Here (Program 15.5) is dn other wtsion ofthatprcgmmlha.tactually couttts how nany
prhes are rtceived in 0.25 seconds, and then multiplies the value by 4 and displays it
iour times a second. Since it ukes the processor 0.25 seconds to count the pulses' you
cannot avoid the flicker iII a program as written in PBP
displavs
$lmiiinitm{$ code lor using the 4 seven-segment
; The foltowinq are the inases of the nrmltrers
; slored in nenorv before we do anvthinq- These wilt
; be used in PoRTB to READ the nunber in each digit
CI.EAR
DEFINE OgC 4
llRrrE 1999, %11111111 blank, no LED is lit
wRrrE 2000, %00000110 rhe nunber 0 in our case
9tRrrE 2001, %10111110 lhe nulrber 1 in our case
lfRrrE 2002, %01001100 lhe number 2 in our case
9lRrrE 2003, %00011100 lhe nunber 3 ln our case
$RrrfE 2004, %10110100 lhe nuilrer 4 in our case
wRrrE 2005, %00010101 lhe nuniber 5 in our case
wRrEE 2005, %00000101 lhe number 6 in our case
!!Rr![E 2007. %10011110 bhe nunber 7 in our case
9tRrrrE 2008, %00000100 lhe nuliber 8 in our case
wRrrE 2009, %00010100 the nunber 9 in our case
ERIsA-%o0010000
tRtsB=%00000000
P VIR BYIE
)I VAR BYTE counter variable
' VAR BATE counrer variable
Z VAR BTTE counter variable
O VAR BYTE counter: variabLe
PULSES VAR IIORD
VII-U! VAR WORD value of neLronone
tlOlTA! V'IR $IORD walue of netronone