VEX PID Control
(→Motors Debug Window) |
(→Enabling PID (Simple)) |
||
| (15 intermediate revisions by one user not shown) | |||
| Line 25: | Line 25: | ||
Enabling basic PID control in ROBOTC is simple; navigate to the 'Robot -> Motors and Sensors Setup' window, find the motor you wish to enable PID control on, and check the 'PID Control' <br /> <br /> | Enabling basic PID control in ROBOTC is simple; navigate to the 'Robot -> Motors and Sensors Setup' window, find the motor you wish to enable PID control on, and check the 'PID Control' <br /> <br /> | ||
[[File:PID_Checkbox.png]]<br /> <br /> | [[File:PID_Checkbox.png]]<br /> <br /> | ||
| − | This will enable basic PID control for the specified motors using ROBOTC's default parameters. | + | '''This will enable basic PID control for the specified motors using ROBOTC's default parameters. If you do not wish to tweak your PID algorithm, you can stop here and ROBOTC will automatically handle the PID algorithm for you.''' |
== Enabling PID (Advanced) == | == Enabling PID (Advanced) == | ||
| Line 33: | Line 33: | ||
'''Caution: Changing the default PID parameters may cause motor behavior which can potentially damage your robot with unexpected movements. As such, we advise that all PID testing be done in a safe area to help mitigate any possible damage.''' | '''Caution: Changing the default PID parameters may cause motor behavior which can potentially damage your robot with unexpected movements. As such, we advise that all PID testing be done in a safe area to help mitigate any possible damage.''' | ||
| − | '''1.''' The first thing you need to do before you can use the advanced features of PID control is change the menu level type to 'Super User'. This is done by navigating to the 'Window -> Menu Level' option in ROBOTC and changing the selected level to 'Super User'. | + | '''1.''' The first thing you need to do before you can use the advanced features of PID control is change the menu level type to 'Super User'. This is done by navigating to the 'Window -> Menu Level' option in ROBOTC and changing the selected level to 'Super User'.<br /><br /> |
| − | + | [[File:Menu_Level_Super.png]]<br /><br /> | |
| − | ''' | + | '''2.''' Once the Menu Level has been changed to 'Super User', open the Motors and Sensors setup window (under the Robot menu). You will notice that there is now an additional tab for 'PID Settings'; click on it to open the PID Settings window.<br /><br /> |
| − | + | [[File:MSS_PID_Tab.png]]<br /><br /> | |
| − | ''' | + | '''3.''' All of the motors configured with VEX IME's that have PID enabled will appear in the "PID Settings for Motors in This Single Program" box. Double-clicking on one of the listed motors will bring up a separate 'Edit PID Settings' window that can be used to manually tweak the PID settings for that particular motor.<br /><br /> |
| − | '''6.''' To finalize the changes to PID control, click the 'Apply' button on the Motors and Sensors Setup window. To revert the individual or global PID settings, simply click the 'Reset to Standard Values' or 'Reset to Application Defaults' buttons, respectively. | + | [[File:Edit_PID_Settings.png]]<br /><br /> |
| + | |||
| + | '''4.''' There is also the option to change how ROBOTC handles PID for any particular motor setup, even if it is outside of that particular program. To view this menu option, click the 'More' button.<br /><br /> | ||
| + | |||
| + | [[File:MSS_PID_More.png]]<br /><br /> | ||
| + | |||
| + | '''5.''' Let's assume you would like to change the PID settings for any VEX 269 motor (without a Motor Controller 29) programmed in ROBOTC. Double click on the appropriate motor and change the settings as needed in the 'Edit PID Settings' box that appears. Remember, any changes to these setting will overwrite ROBOTC's defaults and will be applied to any program using PID control!<br /><br /> | ||
| + | |||
| + | [[File:MSS_PID_Types.png]]<br /><br /> | ||
| + | |||
| + | '''6.''' To finalize the changes to PID control, click the 'Apply' button on the Motors and Sensors Setup window. To revert the individual or global PID settings, simply click the 'Reset to Standard Values' or 'Reset to Application Defaults' buttons, respectively.<br /><br /> | ||
| + | |||
| + | [[File:MSS PID Revert.png]]<br /><br /> | ||
=== Motors Debug Window === | === Motors Debug Window === | ||
| − | When a program is running with the menu level set to 'Super User', the Motors Debug window will display the | + | When a program is running with the menu level set to 'Expert' or 'Super User', the Motors Debug window will display the parameters in the 'Expert and Super User Menu Levels' table. When the menu level is set to 'Super User', the parameters in the 'Super User Menu Level' table also become available: |
| + | |||
| + | ==== Expert and Super User Menu Levels ==== | ||
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0" class="wikiText" | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0" class="wikiText" | ||
| Line 55: | Line 69: | ||
! style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Comments | ! style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Comments | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 1px | + | | style="text-align:left; border-style: solid; border-width: 1px 1px 1px 0px"|Index |
| − | | style="text-align:left; border-style: solid; border-width: 1px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 1px 0px 1px 0px"|Displays the index value of the motor, e.g. port1, port2, port3, etc. This is read-only and cannot be changed via the debug window. |
| − | + | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Motor |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the user-defined alias, if any, for the specified motor. This is read-only and cannot be changed via the debug window. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Type |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the type of motor in the specified port, e.g. VEX 269 Motor. The value is able to be both read and written to. |
| − | + | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Power |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the current motor power being sent from ROBOTC to the Cortex microcontroller. The value is able to be both read and written to and its values range from -127 to +127. |
| style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Slew Power |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the speed the ramping functionality is currently sending to the PID algorithm. This can be used to check if the current "slew" movement has completed. This is read-only and cannot be changed via the debug window. |
| style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|PWM Power |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the current PWM value being sent to the motor from the PID Algorithm. The value is read-only and ranges from -127 to +127. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Encoder |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the current Integrated Motor Encoder's (IME) value for the specified motor. The value is able to be both read and written to |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Reversed |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays whether the motor on the specified port is reversed (mirrored) or normal. The value is able to be both read and written to. |
| style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Error |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the results of the PID algorithm that is used to control the speed of the motor. This is read-only and cannot be changed via the debug window. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Regulation |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"| | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the regulation mode (Speed, or Idle) for the specified motor. This is read-only and cannot be changed via the debug window. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Run State |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays whether the specified motor is running in an Open Loop or state. A value of false denotes no encoder is attached to the motor. This is read-only and cannot be changed via the debug window. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Deadband |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the deadband for the specified motor; if the absolute value of the motor power level is less than this, the motor will not move. E.g. a Deadband value of 10 means that any motor value between -10 and +10 will not cause the motor to move. This value can be both read and written to. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Pwr Limit |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the absolute (both negative and positive) limit for the generated PWM power level from the PID Algorithm. This value can be both read and written to. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Slew Up |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the rate in which the ramping functionality of the PID algorithm will set the motor power level (increasing). The frequency of the rate change is based on the PID Update Internal (set by the mtrPid_Period variable). This value can be both read and written to. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Slew Down |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the rate in which the ramping functionality of the PID algorithm will set the motor power level (decreasing). The frequency of the rate change is based on the PID Update Internal (set by the mtrPid_Period variable). This value can be both read and written to. |
|- | |- | ||
| − | | style="text-align:left; border-style: solid; border-width: 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Slop |
| − | | style="text-align:left; border-style: solid; border-width: 0px 0px | + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the tolerance (or slop) for the "Move to Position" commands in which the command will report back success. This value is in number of encoder counts and set on a per-motor basis. This value can be both read and written to. |
|- | |- | ||
| + | |} | ||
| + | |} | ||
| − | + | ==== Super User Menu Level ==== | |
| + | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0" class="wikiText" | ||
| + | |- | ||
| + | | | ||
| + | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:center; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000;" cellpadding="5%" | ||
| + | ! style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|''Debug Parameter'' | ||
| + | ! style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Comments | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 1px 1px 1px 0px"|EncdrVlcty | ||
| + | | style="text-align:left; border-style: solid; border-width: 1px 0px 1px 0px"|Displays the current rate of change for the specified motor's encoder. This is read-only and cannot be changed via the debug window. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|EncdTimeStmp | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the internal system clock that tracks the elapsed time between encoder reads to ensure accuracy with the PID algorithm. This is read-only and cannot be changed via the debug window. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Derivative | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Derivative (D) from the in the specified motor's PID algorithm. This is read-only and cannot be changed via the debug window. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Integral | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Integral(I) output from the specified motor's PID algorithm. This is read-only and cannot be changed via the debug window. | ||
| + | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|SynchErr | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the difference of two synchronized motors' encoder counts. This is read-only and cannot be changed via the debug window. | ||
| + | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|'''Overloads''' | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the number of times the PID algorithm has overloaded (returned values outside of the usable range of -127 to +127). This is read-only and cannot be changed via the debug window. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Cycles | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the number of times the PID algorithm has ran (cycles) since the start of the program. The rate that this value increases scales linearly with the Period parameter. This is read-only and cannot be changed via the debug window. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Period | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the update interval in milliseconds (period) for the PID algorithm. This is read-only and cannot be changed via the debug window. | ||
| + | | style="text-align:right; border-style: solid; border-width: 0px 0px 1px 0px"| | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kP (Speed) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Proportional (P) parameter used by the specified motor's PID algorithm for normal PID control. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kI (Speed) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Integral(I) parameter used by the specified motor's PID algorithm for normal PID control. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kD (Speed) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Derivative (D) parameter used by the specified motor's PID algorithm for normal PID control. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kP (Pos) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Proportional (P) parameter used by the specified motor's PID algorithm for 'driveToPosition' commands. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kI (Pos) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Integral (I) parameter used by the specified motor's PID algorithm for 'driveToPosition' commands. | ||
| + | |- | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|kD (Pos) | ||
| + | | style="text-align:left; border-style: solid; border-width: 0px 0px 1px 0px"|Displays the Derivative (D) parameter used by the specified motor's PID algorithm for 'driveToPosition' commands. | ||
| + | |- | ||
| + | |||
|} | |} | ||
|} | |} | ||
Latest revision as of 15:28, 7 December 2012
| For ROBOTC VEX PID Control Functions, see: VEX PID Control Functions. |
|
| |||||||
Getting StartedBefore you can start using PID control for the VEX Cortex in ROBOTC, you must make sure you have all of the required components. There are two main components required to get started: a VEX 269 or 369 motor with an Integrated Motor Encoder (IME) installed, and a copy of ROBOTC for Cortex/PIC version 3.6.1 or higher. If you wish to control more than one motor using PID (on a robot, for example), you will need to make sure each motor that is PID controlled has an IME installed and is connected to the Cortex correctly. If you are unsure of how to configure the IME's inside of ROBOTC, please see our IME programming guide before continuing. |
Enabling PID (Simple)
Enabling basic PID control in ROBOTC is simple; navigate to the 'Robot -> Motors and Sensors Setup' window, find the motor you wish to enable PID control on, and check the 'PID Control'

This will enable basic PID control for the specified motors using ROBOTC's default parameters. If you do not wish to tweak your PID algorithm, you can stop here and ROBOTC will automatically handle the PID algorithm for you.
Enabling PID (Advanced)
Motors and Sensors Setup
Caution: Changing the default PID parameters may cause motor behavior which can potentially damage your robot with unexpected movements. As such, we advise that all PID testing be done in a safe area to help mitigate any possible damage.
1. The first thing you need to do before you can use the advanced features of PID control is change the menu level type to 'Super User'. This is done by navigating to the 'Window -> Menu Level' option in ROBOTC and changing the selected level to 'Super User'.
2. Once the Menu Level has been changed to 'Super User', open the Motors and Sensors setup window (under the Robot menu). You will notice that there is now an additional tab for 'PID Settings'; click on it to open the PID Settings window.
3. All of the motors configured with VEX IME's that have PID enabled will appear in the "PID Settings for Motors in This Single Program" box. Double-clicking on one of the listed motors will bring up a separate 'Edit PID Settings' window that can be used to manually tweak the PID settings for that particular motor.
4. There is also the option to change how ROBOTC handles PID for any particular motor setup, even if it is outside of that particular program. To view this menu option, click the 'More' button.
5. Let's assume you would like to change the PID settings for any VEX 269 motor (without a Motor Controller 29) programmed in ROBOTC. Double click on the appropriate motor and change the settings as needed in the 'Edit PID Settings' box that appears. Remember, any changes to these setting will overwrite ROBOTC's defaults and will be applied to any program using PID control!
6. To finalize the changes to PID control, click the 'Apply' button on the Motors and Sensors Setup window. To revert the individual or global PID settings, simply click the 'Reset to Standard Values' or 'Reset to Application Defaults' buttons, respectively.
Motors Debug Window
When a program is running with the menu level set to 'Expert' or 'Super User', the Motors Debug window will display the parameters in the 'Expert and Super User Menu Levels' table. When the menu level is set to 'Super User', the parameters in the 'Super User Menu Level' table also become available:
Expert and Super User Menu Levels
|
Super User Menu Level
|





