1 / 68

Data Logging 4 PID Tuning

Data Logging 4 PID Tuning. By Hugh Meyer Red Alert Robotics FRC Team 1741 Center Grove High School Greenwood Indiana October 24, 2015. Compelling Reasons for Data Logging. Capture fast events Thoughtful evaluation process Verify repeatability. Compelling Reasons for Data Logging.

mpalma
Télécharger la présentation

Data Logging 4 PID Tuning

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. Data Logging 4 PID Tuning By Hugh Meyer Red Alert Robotics FRC Team 1741 Center Grove High School Greenwood Indiana October 24, 2015

  2. Compelling Reasons for Data Logging • Capture fast events • Thoughtful evaluation process • Verify repeatability

  3. Compelling Reasons for Data Logging • Establish normal operating range • Detect leading edge of failure before disaster • Verify design target

  4. Different Approaches for Logging Data • Use built in logging feature of the driver station. • Located on the “Charts” tab • Click “Launch Viewer” button for more detail • Windows on the left indicate the file and location of the data files

  5. Driver Station Charts Charts tab give a continuous display of many useful attributes If you click on the “Launch Viewer” button it opens the Log File Viewer

  6. Log File Viewer

  7. Different Approaches for Logging Data The supplied Driver Station Log File Viewer is helpful, but you really need data that is specific to your robot to be helpful I suggest you create your own logging system You have several options

  8. Different Approaches for Logging Data • Save the data on the driver station computer • Save the data on the RoboRIO • Save the data on an external memory card • Save the data on an external computer

  9. What you need for saving data on the RoboRIO Code that reads the data Writes the data to disk Move data from RoboRIO to processing system

  10. Code to open log file and write data

  11. Moving Data from the RoboRIO Use FTP to transfer the file back to the driver station after the match is concluded We create a batch file that does this This batch file is in the same folder destination where the data is to go The batch file renames the file to include the date and time in the file name

  12. Data Transfer Batch File # GetLogging.bat file cd C:\FIRSTrobotics\RA14_LogFileArchive\2014_HomeComing ftp -A -s:ftpcmds.txt 10.17.44.2 for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b rename "config.txt" "config-%XDate%-%XTime%.txt" rename "logging.csv" "logging-%XDate%-%XTime%.csv" # ftpcmds.txt file get logging.csv get config.txt bye

  13. Data Folder Example

  14. Analyzing the Data • Import into a spread sheet program • Create specialized evaluation program • Moving data from capture device to evaluation device • Archiving data into a subversion repository

  15. The Data File an Example

  16. Open Data in OpenOffice Calc

  17. Text Import to OpenOffice Calc

  18. ??? Questions ??? These are the steps to getting the data from the robot to a graph. Are there any questions about this process before we move on?

  19. PID Tuning Process • Need method to command a step response • Easy ability to change PID gain values

  20. Step Response • One must be able to command an immediate change to a different value • This should be done in a very controlled and precise manner • Essentially the command to the system should be a few cycles of square wave • This can be as simple as a button for the user to press, or as complex as an automation sequence

  21. Step Response We usually just add a button for testing and have the user command the change

  22. logging-Thu-09-18-09.12.csv

  23. Easy Method to change PID gain values Setup a configuration file on the RoboRIO Include in that configuration file the 3 gain values Develop a simple procedure to apply a changed configuration file to the system

  24. Configuration Code Config.h Config.cpp config.txt putconfig.bat ftpcmds.txt

  25. Config File Initialization void Tshirt::RobotInit() { //Start robot cout << "Starting up..." << endl; cout<<"Loading Config File..... "<<endl; Config::LoadFromFile("config.txt"); cout<<"Done!"<<endl;

  26. Using Config function to initialize PID values

  27. Reset code to reload new PID values

  28. Config File Example

  29. FTP Transfer System

  30. Questions We now have in place all we need to be able to easily change the PID gain variables Are there any questions at this point?

  31. PID Tuning Strategies Iteration by experience Ziegler-Nichols and other tuning strategies Several are mentioned on Chief Delphi http://www.chiefdelphi.com/forums/portal.php PID without a PhD by Tim Wescott

  32. Iteration by Experience After doing this for a while you will get to recognize different patterns and what will correct them P will make slower oscillations D will make fast high frequency oscillations I helps reach the target Not very scientific Can take really long time to find a solution

  33. Start with P Tuning Process For small, low torque motors with little or no gearing, one procedure you can use to get a good baseline tune is to probe it’s response to a disturbance. To tune a PID use the following steps: 1. Set all gains to zero. 2. Increase the P gain until the response to a disturbance is a steady oscillation. 3. Increase the D gain until the oscillations go away (i.e. it’s critically damped). 4. Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations. 5. Set P and D to the last stable values. 6. Increase the I gain until it brings you to the set point with the number of oscillations desired (normally zero but a quicker response can be had if you don’t mind a couple oscillations of overshoot) What disturbance you use depends on the mechanism the control is attached to. Normally moving the mechanism by hand away from the set point and letting go is enough. If the oscillations grow bigger and bigger then you need to reduce the P gain. If you set the D gain too high the system will begin to chatter (vibrate at a higher frequency than the P gain oscillations). If this happens, reduce the D gain until it stops.

  34. Start with D Tuning Process To tune a PID use the following steps: 1. Set all gains to 0. 2. Increase Kd until the system oscillates. 3. Reduce Kd by a factor of 2-4. 4. Set Kp to about 1% of Kd. 5. Increase Kp until oscillations start. 6. Decrease Kp by a factor of 2-4. 7. Set Ki to about 1% of Kp. 8. Increase Ki until oscillations start. 9. Decrease Ki by a factor of 2-4.

  35. Ziegler-Nichols & Other Tuning Strategies Set one of the variables to where the system just oscillates Measure the time period of the oscillation Calculate the PID values from some formula or look up table based on these measurements

  36. Ziegler-Nichols The Ziegler–Nichols tuning method is a heuristic method of tuning a PID controller. It was developed by John G. Ziegler and Nathaniel B. Nichols. It is performed by setting the I (integral) and D (derivative) gains to zero. The "P" (proportional) gain, KP is then increased (from zero) until it reaches the ultimate gain KU , at which the output of the control loop oscillates with a constant amplitude. KU and the oscillation period TU are used to set the P, I, and D gains depending on the type of controller used. Use the table to determine the final gains.

  37. Ziegler-Nichols

  38. Ziegler-Nichols & Others – Links 1. Ziegler-Nichols Method http://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method 2. Tyreus-Luyben Tuning http://www.chem.mtu.edu/~tbco/cm416/zn.html 3. Comparison of PID Controller Tuning Methods by Mohammad Shahrokhi and Alireza Zomorrodi

  39. Questions? Are there any questions regarding tuning methods?

  40. Steering System Example • Position control for an Ackermann steering mechanism • http://en.wikipedia.org/wiki/Ackermann_steering_geometry • Servo style motor control • Joystick position translates to steer angle

  41. Ackermann Steering Example

  42. Ackermann Steering Example

  43. First Pass at Tuning P = .125 I = .001 D = .00125

  44. Second Pass at Tuning P = .220 I = .005 D = .320

  45. Third Pass at Tuning P = .220 I = .005 D = .300

  46. Launching Mechanism Example • Position control for a Leonardo Da Vinci cam mechanism • Reflective index sensor for homing each cycle • Schmitt trigger (7414) for optical sensor • http://www.digikey.com/product-detail/en/SN7414N/296-33604-5-ND/1575159 • http://www.ti.com/lit/ds/symlink/sn7414.pdf

  47. De Vinci Cam Red Alert Cam

More Related