Skip to main content

Project Based Engineering Instrumentation High Level Coding and Microcontrollers

Section 19.5 Assignment

This servo project can be split into 2 projects at your instructors discretion. The first part involves learning how to rotate the servo and then calibrating the servo so that degrees of rotation can be related to PWM in microseconds while the second part deals with feedback control. In part 1 ensure that you can rotate the servo and then experimentally determine the minimum and maximum PWM signal you can send to the servo before it stops rotating anymore. Then create a calibration equation and plot with degrees on the x-axis and PWM on the y-axis. Take at least 10 data points for your calibration equation and use a protractor on your computer screen to obtain angle in degrees of your servo. Your calibration equation needs to be linear. I’m also asking you to simulate a first order system to look at a simple feedback control problem. In part 2 you are to use the angle obtained by the accelerometer to feedback to the servo using proportional control. You are to do this for a \(k_p\) value of 1 and 2. In addition, you are to simulate the second order system above for 10 seconds with varying values of \(k_p\) and plotting the results. Note, for this lab, once you have the minimum and maximum values of your servo, you need to add a saturation filter into your code so that the value sent to your servo is always within these bounds. Otherwise you could damage or even break your servo.

Subsection 19.5.1 Part 1

  1. Title page with name,title and date - 5%
  2. Introduction with wiring diagram - 5%
  3. All figures must have appropriate annotations, figure captions, figure labels and a paragraph of supporting text - 10%
  4. Include 2 photos of your servo with one photo rotated to the maximum and the other photo rotated to the minimum degrees. Also, include a screenshot (entire computer screen) of Mu showing the PWM pulse in the serial monitor for both rotations. - 10%
  5. Report the minimum and maximum values of your servo in a table. Be sure to report the PWM signals in milliSeconds as well as the angle of the servo in degrees. - 10%
  6. Include your raw calibration data with PWM signal in one column and degrees in the other column - 10%
  7. Include a Figure of your calibration data plotted with your trend line on top. Put your \(r^2\) value in the title of the plot - 20%
  8. Write your regression equation as (servo_pulse = m*servo_angle + b) being sure to replace m and b with your actual values. Remember to round to appropriate significant figures - 10%
  9. Using your calibration equation imbedded in your Mu code, compute the pulse required to rotate your servo to 90 degrees. Report on how close it is to 1.5 ms. Include a photo of your servo rotated to 90 degrees and a screenshot (entire computer screen) of your calibration equation placed into Mu with your pulse value in the Serial monitor. The code must also show your saturation filter as well - 10%
  10. Simulate the first order system in Equation (19.3.8) for 10 seconds with \(k_p=1\) and \(k_p=10\) for a \(u_c=20 m/s\text{.}\) Plot \(u\) vs time for both values of proportional gain. - 10%
  11. Appendix A - Video Details - Film yourself and your entire screen with the Serial monitor open in Mu as you rotate the servo from 0 to roughly 180 degrees. Then show yourself plotting the regression line on top of your data on your laptop - Pass/Fail
  12. Appendix B - Code used to rotate servo and code used to plot data in plain text (no screenshots) - Pass/Fail
  13. If you are asked to fix something in the Appendices such as missing content in your video or screenshots of your code, you will lose 10% of your grade everytime you submit an update after the deadline.

Subsection 19.5.2 Part 2

  1. Title page with name,title and date - 5%
  2. Introduction - 5%
  3. All figures must have appropriate annotations, figure captions, figure labels and a paragraph of supporting text - 10%
  4. Include an annotated photo of your circuit showing the accelerometer, wiring, and servo. - 20%
  5. Include a photo of your CPX rotated to 45 degrees and your servo rotated with \(k_p=1\) and \(k_p=2\text{.}\) Have your servo held up to your protractor when rotated so readers can see the angle at which your servo is rotated. - 40%
  6. Simulate the second order system in Equation (19.3.6) for 10 seconds with \(k_p=-1\) and \(k_p=-10\) for a \(\theta_c=45^o\text{.}\) Plot \(\theta\) vs time for both values of proportional gain. - 20%
  7. Appendix A - Video Details - Film yourself and your entire screen with the Serial monitor open in Mu as you rotate the CPX/CPB +/-45 degrees and also showing the servo rotate IN SYNC (+/-45 degrees) with your CPX/CPB. - Pass/Fail
  8. Appendix B - Code used to rotate servo as well as simulation code in plain text (no screenshots) - Pass/Fail
  9. Appendix C - Screenshot of Excel or Sheets if applicable - Pass/Fail
  10. If you are asked to fix something in the Appendices such as missing content in your video or screenshots of your code, you will lose 10% of your grade everytime you submit an update after the deadline.