Page 194 - Making PIC Microcontroller Instruments and Controllers
P. 194
TACHOMETER
i90 coul|rl c PULSES: A PROGRAMITIABLE
A2
vss VDD
BO B7
B1 B6
92 B5
B3 B4
i:i!!!.!!!.ii:tf{gl Pulse generator circuil diasram.
this molor. We c:m read these wilh a photosensitive deteclor, and the output from the
detector is suitable for direct input into our PICMCU. This is a reasonable ass mption
in that most photofansistors will feed dhectly into a PIC pol1 (The encoder on our motor
meets this specifi cation.)
For low-speed accuracy, the 20 markers must be placed accurately around the shaft
At high rpm, this would not natter because we would be reading many rcvolutions every
0.25 seconds and the relative placement of the 20 markers around the shaft would be
jntegrated out over trmc,
We can use the COUNT command in the PBP language to do the counting- For a
0.25-second period, the command would be:
coul{r PoRfa.2, 2 50, lfl
shere PORIA.2 i' lhe line Ihe 5rgnil i. .joming in on
or 0.25'second counting interval
250 is ior a 2sO-millisecond
IV1 is lhe variable the count will be placed in