1 / 29

The Final Exam

The Final Exam. During the last week of classes In your lab period May 5-9 Tell your friends. Servo Motor Control. Basic computer control of motor position and velocity. Reading. Chapter 11. watch the motor movement.

Download Presentation

The Final Exam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Final Exam • During the last week of classes • In your lab period • May 5-9 • Tell your friends

  2. Servo Motor Control Basic computer control of motor position and velocity

  3. Reading • Chapter 11

  4. watch the motor movement http://www.youtube.com/watch?v=7coUcEHxnYA - notice the choppy movement between taught points http://www.youtube.com/user/CompassAutomation?v=lpY2P4lDYwg - notice that the movements have been smoothed out

  5. smooth movement starts slow, speeds up, finishes slow Position vs. time Velocity vs. time

  6. How do you teach a robot? • manually stepping through specific points • the results is often "choppy", because of the selection of just a few points of travel

  7. the problem You know "basically" where the robot arm should be, with a few points. Very choppy. To run smoothly in real time, you need thousands, actually a descriptive formula, p= f(t), and v= f(t)

  8. we must smooth out the curve to this taught manually derived from a formula

  9. how we solve it • Program 11 pts. Capture the (x,y) value of each point. x = [ 0 10 25 30 40 50 60 70 75 90 100 ] y = [ 0 7.5 20 30 45 50 45 30 20 7.5 0 ] remember that x represents time, and y represents velocity

  10. Find a polynomial equation that generates the same y's, from those x's (that is, an equation that matches the x,y curve). y = ax2 + bx + c • Generate 100s of x,y points using the formula to smooth out the curve

  11. polynomials • 2nd order: y = ax2 + bx + c • 3rd order: y = ax3 + bx2 + cx + d • 4th order: y = ax4 + bx3 + cx2 + dx + e number of coefficients = order+1

  12. step 1 y = [0 7.5 20 30 45 50 45 30 20 7.5 0 ] x = [0 10 25 30 40 50 60 70 75 90 100 ] figure(1) plot( x, y) reflect on this.... it's very poor vel vs time, and results in choppy movement

  13. coeff = polyfit(x, y, n) • find a polynomial of the nth order that fits the x vs y vectors • coeff will be a column vector of n+1 values • if n = 2, then MATLAB will return coeff(1), coeff(2), and coeff(3) so that • vel = coeff(1) * x2 + coeff(2) * x + coeff(3) • remember : x = [0 10 25 30 40 50 60 70 75 90 100 ] vel = [ desired 11 new pts ]

  14. order = 2 coeff = polyfit(x,y,2) % x.^2 means x2 vel = (coeff(1)*x.^2) +(coeff(2)*x) + coeff(3) %coeff: -0.0182 1.8182 -5.0000 figure(2) plot(x, vel)

  15. with n = 2 (3 Coeffs)

  16. order = 3 coeff = polyfit(x,y,3) vel = (coeff(1)*x.^3)+(coeff(2)*x.^2)+(coeff(3)*x) + coeff(4) figure(3) plot(x, vel)

  17. order = 4 (5 coeffs) coeff = polyfit(x,y,4) vel =(coeff(1)*x.^4)+(coeff(2)*x.^3)+(coeff(3)*x.^2) + (coeff(4)*x) +coeff(5) figure(4) plot(x, vel)

  18. order = 5 (6 coeffs) coeff = polyfit(x,y,5) vel = (coeff(1)*x.^5)+(coeff(2)*x.^4)+(coeff(3)*x.^3)+(coeff(4)*x.^2)+(coeff(5)*x) + coeff(6) figure(5) plot(x, vel)

  19. order = 6 (7 coeffs) coeff = polyfit(x,y,6) vel = (coeff(1)*x.^6)+(coeff(2)*x.^5)+(coeff(3)*x.^4)+(coeff(4)*x.^3)+(coeff(5)*x.^2)+ (coeff(6)*x)+coeff(7) figure(6) plot(x, vel)

  20. pretty close

  21. now plot for 1000 values of X x = [1: .1 :100] vel = (coeff(1)*x.^6)+(coeff(2)*x.^5)+(coeff(3)*x.^4)+(coeff(4)*x.^3)+(coeff(5)*x.^2)+ (coeff(6)*x)+coeff(7) figure(7) plot(x, vel)

  22. practice for the exam: %define an x row vector of 5 pts: x = [1:20:100] %get any y function of 5 pts y = 40*( 1-sin(x*pi/180) ) figure(10) plot( x, y)

  23. polyfit to order = 2 coeff = polyfit(x,y,2) vel = (coeff(1)*x.^2)+(coeff(2)*x)+coeff(3) figure(11) plot(x, vel)

  24. test that curve with 100 pts. x = [1:100] y = (coeff(1)*x.^2)+(coeff(2)*x)+coeff(3) figure(12) plot(x, y)

  25. try 6th order %define an x row vector of 5 pts: x = [1:20:100] %get a y function of 5 pts y = 40*(1-sin(x*pi/180)) coeff = polyfit(x,y,6) vel = (coeff(1)*x.^6) + (coeff(2)*x.^5) +(coeff(3)*x.^4) + (coeff(4)*x.^3) + (coeff(5)*x.^2)+(coeff(6)*x)+coeff(7) figure(13) plot(x, vel)

  26. warning Warning: Polynomial is not unique; degree >= number of data points. NOTE: the polynomial order must be less than the number of data points that is, no more coefficients allowed than the number of data points. 5 pts. - 5 coefficients - 4th order

  27. try 4th order %define an x row vector of 5 pts: x = [1:20:100] %get a y function of 5 pts y = 40*(1-sin(x*pi/180)) coeff = polyfit(x,y,4) vel = (coeff(1)*x.^4) + (coeff(2)*x.^3) + (coeff(3)*x.^2)+(coeff(4)*x)+coeff(5) figure(14) plot(x, vel)

  28. smooth it out x = [1:100] y = 40*(1-sin(x*pi/180)) coeff = polyfit(x,y,4) y = (coeff(1)*x.^4) + (coeff(2)*x.^3) + (coeff(3)*x.^2)+(coeff(4)*x)+coeff(5) figure(15) plot(x, y)

More Related