EE 308 - LAB 11

Final version for 2000

Final Project - Motor Control

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

Figure 1: Block diagram for final project lab.

The HC12 will have a pot connected to it, which will be used to set the motor speed. The speed of the motor should be 10 RPS at 0 volts, and 50 RPS at 5 V. As in Lab 7, you will use the HC12 Timer Imput Capture subsystem to measure the motor's speed, and the HC12 PWM subsystem to control the speed,

If the actual speed is slower than the desired speed, the HC12 should increase the duty cycle of the pulse width modulation until the speed of the motor equals the desired speed. If the actual speed is faster than the desired speed, the HC12 should decrease the duty cycle until the desired speed is reached. How to do this will be discussed in class.

Program the HC12 in the following way:

The desired speed, 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 also be an unsigned character for 8-bit PWM.

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

The HC12 should control the speed of the motor by pulse width modulation, as in Lab 7.

About once every 10 ms (using an RTI interrupt) the HC12 should do the following:
Read the voltage on the pot from the A/D converter to determine the desired speed.

Calculate a new PWM duty cycle based on the current duty cycle and the difference between the actual and desired speeds:

DCn = DCo + k (Sd - Sa)

where DCn is the new duty cycle, DCo is the old duty cycle, Sd is the desired speed, and Sa is the actual speed. (k is a constant - an appropriate value can be found by experimentation. In class we will discuss how to find a good initial guess.)

Update the PWM duty cycle register.

In the main program loop, you should print some information to the screen, such as the desired and actual speeds, and the duty cycle.

Bill Rison