Getting Started

(lily) #1

Chapter 7: Microcontroller Interrupts and Timers


Speedometer............................................................................................

We used an optoisolator to separate the motor power circuits from the Butterfly to
help lessen the likelihood of blowing something up. A device similar to an
optoisolator is an optointerrupter, which has an air channel between the IR light
emitting diode and the IR detector transistor, see Figure 23. An opaque object
passed between the diode and the detector causes the transistor to turn off thus
‘interrupting’ the current. We can tie the transistor to a pin on the Butterfly and
detect the interruption. Did you notice the opening cut in the wheel in Figure 22?
(when you cut out the slot, glue it just under the inner side of the slot to help keep
the wheel balanced) If you rig up the motor base so that the wheel spins thru the
slot in the optointerrupter, each time the opening passes; the transistor turns on
and back off when the slot has passed. If we write our software so that a voltage
change on the pin attached to the optointerrupter causes an interrupt in the
Butterfly, we can count those interrupts. If we count for exactly one second we
have the number of times the wheel rotates per second, which is the rotational
speed in Hz. Cool!


Solder long wires to the optoisolator, and then add electrical tape to prevent the
legs from shorting. Next carefully glue it to the motor base in a position so that
the wheel rotates thru it. Make sure the wheel is balanced and will turn cleanly
(easier said than done) and fully block and unblock the optoisolator slot as the
wheel turns, Figure 22.

Free download pdf