DOC PREVIEW
NMT EE 308 - Motor Control

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 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 8 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 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2009Motor ControlConsider a motor which has a maximum speed of 5000 RPM. The speed vs. duty cyclemay look something like this:0 10 20 30 40 50 60 70 80 90 1000500100015002000250030003500400045005000Duty Cycle (%)Speed (RPM)Motor Speed vs. Duty CycleThe motor doesn’t start rotating until it is driven with a 10% duty cycle, after which it willincrease speed linearly with the increase in duty cycle.If the motor is initially stopped, and is then turned on (with 100% duty cycle), the speedvs. time might look something like this:0 1 2 3 4 5 60100020003000400050006000t (seconds)Speed (RPM)Step Response of Motor1EE 308 Spring 2009We will control the motor by adjusting the duty cycle with the HCS12. We will dothis by measuring the speed and updating the duty cycle on a regular basis. Let’s do theadjustments once every 8 ms. This means that we will adjust the duty cycle, wait for 8 msto find the new speed, then adjust the duty cycle again. How much change in speed willthere b e in 8 ms? The motor behaves like a single time constant system, so the equation forthe speed as a function of time is:S(t) = Sf+ e−t/τ(Si− Sf)where Siis the speed at time 0, Sfis the speed at time ∞, and τ is the time constant of thesystem. With a duty cycle of D, the final speed will be:Sf= αD + S0where S0is the speed the motor would turn with a 0% duty cycle if the speed continuedlinearly for duty cyclces less than 10%, and α is the slope of the speed vs. duty cycle line(5000/0.9 in this example).Here I 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 tofull speed. I f T = 8 ms, the motor will have changed its speed from SitoS(T ) = Sf+ e−T/τ(Si− Sf)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 nthcycle.Consider an integral controller where the duty cycle is adjusted according to:D[n] = D[n − 1] + k(Sd− Sm[n])We can simulate the motor response by iterating through these equations. Start withSm[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]D[n] = D[n − 1] + k(Sd− Sm[n])In MATLAB we can simulate this as:2EE 308 Spring 2009alpha = 5000/0.9; % Max speed 5,000 RPM; turns on at 10% duty cycleSd = 1500; % Desired SpeedS0 = -alpha*0.1; % Speed motor would turn at 0% duty cycle if lineartau = 1; % One second time constantT = 8e-3; % Update rate is 8 msk = 1e-7; % Constant for integral controlSm = 0; % Measured speed starts at 0D = 0.1; % Duty cycle starts at 10%t = 0;ee = exp(-T/tau); % Precalculate this commonly used valuefor n=2:1000 % Make end value bigger if neededSm(n)=(alpha*D(n-1) + S0)*(1-ee) + ee*Sm(n-1);D(n) = k*(Sd - Sm(n)) + D(n-1);t(n) = t(n-1)+T;endplot(t,Sm);By changing the value of k we can see how this parameter affects the response. Here isthe curve for k = 1.0 × 10−7:0 10 20 30 40 50 60 70 80 90 1000200400600800100012001400160018002000T (seconds)Speed (RPM)Integral Control, k = 1 × 10−7With this value of k, it will take about 1 minute for the motor to get to the desired spee d.3EE 308 Spring 2009Here is the curve for k = 1.0 × 10−6:0 2 4 6 8 10 12 14 16 18 20020040060080010001200140016001800T (seconds)Speed (RPM)Integral Control, k = 1 × 10−6Now it takes about 10 seconds to get to the desired sp e ed, with a little bit of overshoot.Let’s try k = 1.0 × 10−5:0 1 2 3 4 5 6 7 8 9 1005001000150020002500T (seconds)Speed (RPM)Integral Control, k = 1 × 10−54EE 308 Spring 2009This gets to the desired value more quickly, but with a lot of oscillation. Let’s increase k to10−4.0 1 2 3 4 5 6 7 8 9 10050010001500200025003000T (seconds)Speed (RPM)Integral Control, k = 1 × 10−4For this value of k there is a significant oscillation. However, a real motor will not act likethis. If we look at the duty cycle vs time, we see:0 1 2 3 4 5 6 7 8 9 10−150−100−50050100150200250T (seconds)Duty CycleIntegral Control, k = 1 × 10−4To get this oscillating response, the duty cycle must go to over 100%, and below 0%, whichis clearly impossible. To get the response we expect in the lab, we need to limit the dutycycle to remain between 20% and 100%. Thus, we change our simulation to be:5EE 308 Spring 2009alpha = 5000/0.9; % Max speed 5,000 RPM; turns on at 10% duty cycleSd = 1500; % Desired SpeedS0 = -alpha*0.1; % Speed motor would turn at 0% duty cycle if lineartau = 1; % One second time constantT = 8e-3; % Update rate is 8 msk = 1e-7; % Constant for integral controlSm = 0; % Measured speed starts at 0D = 0.1; % Duty cycle starts at 10%t = 0;ee = exp(-T/tau); % Precalculate this commonly used valuefor n=2:1000 % Make end value bigger if neededSm(n)=(alpha*D(n-1) + S0)*(1-ee) + ee*Sm(n-1);if (Sm(n) < 0) Sm(n) = 0; end; % Motor speed cannot be less than 0D(n) = k*(Sd - Sm(n)) + D(n-1);if (D(n) > 1.0) D(n) = 1.0; end; % Keep DC between 20% and 100%if (D(n) < 0.2) D(n) = 0.2; end;t(n) = t(n-1)+T;endplot(t,Sm);When we use this to simulate the motor response, we get:0 2 4 6 8 100500100015002000T (seconds)Speed (RPM)Integral Control, k = 1 × 10−40 2 4 6 8 10020406080100120T (seconds)Duty CycleIntegral Control, k = 1 × 10−4In your program for Lab 5, you will use a Real Time Interrupt with an 8 ms p eriod. Inthe RT I interrupt service routine, you will measure the speed, and set the duty cycle basedon the measured speed. Your ISR will look something like this:6EE 308 Spring 2009void 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 Registerto generate duty cycle DC.Code which clears RTI flag}In the main program, you will display the measured speed, desired speed, and duty cycleon the LCD display.Your values of k will probably be different than the values in these notes because speedvs. duty cycle, time constant, and maximum speed will most likely be different than thevalues I used.7EE 308 Spring 2009Using Floating Point Numbers with the Gnu C CompilerIt will be much easier to do the necessary calculations by using floating point 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


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?