EE 308 -- LAB 13
Final Project - Motor Control

For your final project, you will use an HC11 board as a motor controller (Figure 1). A potentiometer connected to the HC11's A/D converter will be used to adjust a motor's speed. The HC11 will control the speed of the motor using pulse width modulation

Figure 1: Block diagram for final project lab.

The HC11 will have a pot connected to it, which will be used to set the motor speed. The speed of the motor should be 500 RPM at 0 volts, and 3,000 RPM at 5 V.

The HC11 will control the motor speed using pulse width modulation. It can control current through the motor by turning on and off an FET switch. The duty cycle (the percent of time the switch is turn on) controls the motor speed. A 100% duty cycle will yield maximum speed (about 3,000 RPM when Vmotor = 7 V), and duty cycles of about 10% or less will yield zero speed. An optical sensor attached to the motor will measure its speed. An LED sends light to an opto-transistor -- when the light from the LED can reach the transistor, the transistor will be turned on, current will flow through the 2.2 k Ohm collector resistor, and the voltage at the collector will be about 0.5 V. A blade on the motor will momentarily block the light from the LED from reaching the opto-transistor. When this happens, the transistor will turn off, very little current will flow through the transistor, and the voltage at the collector will be about 5 V. This collector voltage is inverted and turned into a clean digital signal by the 74HC14 Schmitt trigger. By using a timer input capture pin to measure the period of the signal from the Schmitt trigger, you can determine the speed of the motor.

The HC11 should slowly increase the duty cycle of the pulse width modulation until the speed of the motor equals that determined from the set point. When the the set point is reduced, the HC11 should slowly decrease the duty cycle until the set point is reached. How to do this will be discussed in class.

Program the HC11 in the following way:

1. The set point, actual speed and duty cycle should be global variables. The set point and actual speed should be unsigned characters, with a value of 0 representing 500 RPM, and a value of 255 representing 3,000 RPM. The duty cycle should be an unsigned int.

2. The HC11 should use a TIC interrupt to measure the motor period, convert it to speed, and save it in the speed global variable.

3. The HC11 should control the speed of the motor by pulse width modulation, using a TOC1 interrupt and both TOC1 and TOC2 to control the TOC2 output pin. The pulse width modulation frequency should be about 1 kHz. A successful TOC1 compare should force the TOC2 pin high, and a successful TOC2 compare should force the TOC2 pin low. This will allow you to easily program duty cycles from about 10% (at which point the motor should stop) to 100% (at which point the motor should operate at about 3,000 RPM).

4. Once a second (using an XIRQ interrupt from the Real Time Clock chip) the HC11 should read the voltage on the pot from the A/D converter and save it in a global variable.

5. In the main program loop, the HC11 should adjust the duty cycle of the pulse width modulation until the motor's speed equals the value determined from the pot setting.

6. Using a TOI interrupt the HC11 should decide what to display on the LEDs depending on what is set on the DIP switches:

PA2 PA1 PA0
PIA Port B Function
0 X 0
Motor Set Point
0 X 1
Motor Speed
1 0 0
Up Counter
1 0 1
Down Counter
1 1 0
Flasher
1 1 1
Turn Signal

Table 1: PIA Port A inputs to control the PIA Port B functions.

7. When the HC11 receives a IRQ interrupt from CA1 of the PIA, it should set a global flag in the IRQ interrupt service routine.

8. In its main program the HC11 should monitor the global flag set in the IRQ interrupt. When the flag is set, it should print the time, set point, motor speed (in RPM) and duty cycle to the PC display, and clear the global flag.

9. Once you get this system working, program it into the EPROM version of the HC11 chip you received with your kit. Here is some information about how to program your EPROM HC11.

Bill Rison, <rison@ee.nmt.edu >
Wed Apr 15 1998