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
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 500 RPM at 0 volts, and 3000 RPM 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:
where is the new duty cycle, is the old duty cycle, is the desired speed, and is the actual speed. ( is a constant - an appropriate value can be found by experimentation. In class we will discuss how to find a good initial guess.)