DOC PREVIEW
NMT EE 308 - Motor Control

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

• Notes on motor control• Preparation for final lab Motor ControlConsider a motor which has a maximum speed of 5000 RPM. The speedvs. duty cycle may look something like this:The motor doesn’t start rotating until it is driven with a 10% duty cycle, after which it will increase speed linearly with the increase in duty cycle.If the motor is initially stopped, and is then turned on (with 100% duty cycle), the speed vs. time might look something like this:We will control the motor by adjusting the duty cycle with the HCS12.We will do this by measuring the speed and updating the duty cycle on a regular basis. Let’s do the adjustments once every 8 ms. It means that we will adjust the duty cycle, wait for 8 ms to find the new speed, then adjust the duty cycle again. How much change in speed will there be in 8 ms? The motor behaves like a single time constant system, so the equation for the speed as a function of time is:S(t) = Sf + e−t/τ (Si − Sf ) (1)where Si is the speed at time 0, Sf is the speed at time ∞, and τ is the time constant of the system. With a duty cycle of D, the final speed will be:Sf = αD + S0(2)where S0 is the speed the motor would turn with a 0% duty cycle if the speed continued linearly for duty cycles less than 10%, and α is the slope of the speed vs. duty cycle line (5000/0.9 in this example).Here we will assume that the time constant of the small motors we are using is about 1 second — i.e., it takes about 5 seconds (5 time constants) for the motor to go from a dead stop to full speed. If T = 8 ms, the motor will have changed its speed from Si toS(T) = Sf + e−T/τ (Si − Sf ) (3)S(T) = (αD + S0)(1- e−T/τ)+ e−T/τ SiS[n] = (αD + S0)(1- e−T/τ)+ e−T/τ S[n-1]where S[n] is the speed at the nth cycle.Consider an integral controller where the duty cycle is adjusted accordingto:D[n] = D[n − 1] + k(Sd − Sm[n]) (4)(source: Wikipidia The free Encyclopedia)A control loop consists of three parts:1. Measurement by a sensor connected to the process (or the plant),2. Decision in a controller element,3. Action through an output device (actuator) such as a control valve.As the controller reads a sensor, it subtracts this measurement from the setpoint (desired) to determine the error. It then uses the error to calculate a correction to the process's input variable (the action) so that this correction will remove the error from the process's output measurement.The PID control scheme is named after its three correcting terms, whose sum constitutes the output.1. Proportional - To handle the immediate error, the error is multiplied by a constant Kp.2. Integral - To learn from the past, the error is integrated and multiplied by a constant Ki.3. Derivative - To anticipate the future, the first derivative of the error is multiplied by a constant Kd.Effects of increasing parametersParameter Rise Time Overshoot Settling Time S.S. ErrorKp Decrease Increase Small Change DecreaseKi Decrease Increase Increase EliminateKd Small Change Decrease Decrease NoneWe can simulate the motor response by iterating through these equations.Start with Sm[1] = 0, D[1] = 0, and Sd = 1500. Then we calculate:Sm[n] = (αD[n-1] + S0)(1- e−T/τ)+ e−T/τ Sm[n-1] (5)D[n] = D[n − 1] + k(Sd − Sm[n])Some code in MATLAB that can be used to simulate this:Sm(1) = 0;D(1) = 0;ee = exp(-T/tau);for n=2:1000Sm(n)=(alpha*D(n-1) + S0)*(1-ee) + ee*Sm(n-1);D(n) = k*(Sd - Sm(n)) + D(n-1);endBy changing the value of k we can see how this parameter affects theresponse. Here is the curve for k = 1.0 × 10−7:With this value of k, it will take about 1 minute for the motor to get to the desired speed.Here is the curve for k = 1.0 × 10−6:Now it takes about 10 seconds to get to the desired speed, with a little bit of overshoot.Let’s try k = 1.0 × 10−5:This gets to the desired value more quickly, but with a lot of oscillation. Let’s increase k to 1.0 × 10−4.For this value of k there is a significant oscillation. However, a real motor will not act like this. If we look at the duty cycle vs. time, we see:To get this oscillating response, the duty cycle must go to over 100%, and below 0%, which is clearly impossible. To get the response we expect in the lab, we need to limit the duty cycle to remain between 20% and 100%. Thus, we change our simulation to be:Sm(1) = 0;D(1) = 0;ee = exp(-T/tau);for n=2:1000Sm(n)=(alpha*D(n-1) + S0)*(1-ee) + ee*Sm(n-1);D(n) = k*(Sd - Sm(n)) + D(n-1);if (D(n) > 1)D(n) = 1.0;end;if (D(n) < 0.2)D(n) = 0.2;end;endWhen we use this to simulate the motor response, we get:In your program for Lab 5, you will use a Real Time Interrupt with an 8 ms period. In the RTI interrupt service routine, you will measure the speed, and set the duty cycle based on the measured speed. Your ISR will look something like this:void INTERRUPT rti_isr(void){Code to read potentiometer voltage and convert into RPMCode to measure speed Sm in RPMCode which sets duty cycle toDC = DC + k*(Sd-Sm)if (DC > 1.0) DC = 1.0;if (DC < 0.2) DC = 0.2;Code which writes the PWM Duty Cycle Register to generate duty cycle DC.Code which clears RTI flag}In the main program, you will print the measured speed, desired speed, and duty cycle to the screen.Your values of k will probably be different than the values in these notes because speed vs. duty cycle, time constant, and maximum speed will most likely be different than the values we used in this example.Using Floating Point Numbers with the Gnu C CompilerIt will be much easier to do the necessary calculations by using floatingpoint numbers. Here is an example of a program which uses floating point:#include "DBug12.h"main(){float x;x = 10.2;printf("x = %d\r\n",(short) x);}To use floating point numbers with the Gnu C compiler, go to the Options menu, Project options submenu, and add -fshort-double to the list of compiler options.You cannot use math functions such as sqrt(). The size of the code which will be created if you use the math library for the Gnu C compiler will be too large to fit in the memory of the 9S12. You can do standard arithmetic operations such as addition, multiplication and division. Also, you cannot print floating point numbers using DB12FNP->printf(). You must convert numbers to integer before printing


View Full Document

NMT EE 308 - Motor Control

Documents in this Course
Load more
Download Motor Control
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Motor Control and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Motor Control 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?