Specifications
25
4.3.2 Using interrupts to count odometer readings
The circuitry detailed earlier was designed to provide a 5v drop twice for every
revolution of the motors shaft. This 5 to 0 volt drop provides the perfect setup to use in
one of the many Motorola HC12 interrupts.
The Motorola has many different interrupts with varying priorities and ideal uses.
Some forethought was applied to the needs of interrupts and it was considered that the
odometry sensors would need the highest priority. This would allow other lower
priority interrupts to run without effecting the counting of motor revolutions. A first
attempt was to use IRQ and XIRQ to count each motor.
The first issue to deal with using this decision was that XIRQ is a level sensitive
interrupt. This meant that if the motor was rotating slower than the interrupt could
service (and obviously this would happen with an 8Mhz processor and the robot only
moving at about 0.2m/s), then the interrupt would run repeatedly whilst the IR LED and
the Receiving Diode where in line. To overcome this, a flip flop was set up to trigger
on the falling edge of the signal and then it would be reset by a wire coming from Port
A. The concept behind this seemed logical and straight forward however many
problems arose for various reasons. Figure 4.8 shows the Flip Flop configuration
implemented.
Figure 4.8: 4013 Flip-Flop configuration










