VEX PID Control Functions
(→driveSynchronized) |
|||
| Line 335: | Line 335: | ||
|- | |- | ||
|- | |- | ||
| − | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Used to | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Used to synchronize two motors to move at the same speed and direction |
|- | |- | ||
{| | {| | ||
|- | |- | ||
|<syntaxhighlight lang="ROBOTC">driveStraight(port1, port10, 50); // Drives the robot straight forward by moving the motors on ports 1 and 10 at 50 power level. | |<syntaxhighlight lang="ROBOTC">driveStraight(port1, port10, 50); // Drives the robot straight forward by moving the motors on ports 1 and 10 at 50 power level. | ||
| + | </syntaxhighlight> | ||
| + | |- | ||
| + | |} | ||
| + | |- | ||
| + | |} | ||
| + | <br /> | ||
| + | |||
| + | === stopDriveSynchronized === | ||
| + | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
| + | |- | ||
| + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">driveSynchronized</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">tMotor </span><span class="bigCodeBasic">nMotor</span><span class="bigCodePunc">)</span> | ||
| + | |- | ||
| + | |- | ||
| + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Used to stop motor synchronization on the specified motor | ||
| + | |- | ||
| + | {| | ||
| + | |- | ||
| + | |<syntaxhighlight lang="ROBOTC">stopDriveSynchronized(port1); // Stops motor synchronization on on port 1 | ||
| + | </syntaxhighlight> | ||
| + | |- | ||
| + | |} | ||
| + | |- | ||
| + | |} | ||
| + | <br /> | ||
| + | |||
| + | === slaveMotor=== | ||
| + | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
| + | |- | ||
| + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">slaveMotor</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">tMotor </span><span class="bigCodeBasic">nSlaveMotor</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">tMotor </span><span class="bigCodeBasic">nMasterMotor</span><span class="bigCodePunc">)</span> | ||
| + | |- | ||
| + | |- | ||
| + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Used to specify a master and slave motor when pairing motors | ||
| + | |- | ||
| + | {| | ||
| + | |- | ||
| + | |<syntaxhighlight lang="ROBOTC">slaveMotor(port1, port2); // Sets the motor on port1 as the slave motor and the motor on port 2 as the master motor | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
Revision as of 13:25, 5 December 2012
Variables
motorPWMLevel
| short motorPWMLevel[motor_name] | |
| (short) Sets the PWM level on the specified motor. | |
|
mtrPid_Period
| short mtrPid_Period[motor_name] | |
| (short) Sets the PWM period for the specified motor port. | |
|
mtrPid_kP
| short mtrPid_kP[motor_name] | |
| (short) Sets the Proportional parameter (P) in PID control for the specified motor port | |
|
mtrPid_kI
| short mtrPid_kI[motor_name] | |
| (short) Sets the Integral parameter (I) in PID control for the specified motor port | |
|
mtrPid_kD
| short mtrPid_kD[motor_name] | |
| (short) Sets the Derivative parameter (D) in PID control for the specified motor port | |
|
mtrPid_Deadband
| short mtrPid_Deadband[motor_name] | |
| (short) Sets the deadband in PID control for the specified motor port | |
|
mtrPID_PowerLimit
| short mtrPid_PowerLimit[motor_name] | |
| (short) Sets the power limit (ceiling) for the specified motor port | |
|
mtrPID_SlewUp
| short mtrPid_SlewUp[motor_name] | |
| (short) Sets the slew rate when increasing motor speed for the specified motor port. | |
|
mtrPID_SlewDown
| short mtrPid_SlewDown[motor_name] | |
| (short) Sets the slew rate when decreasing motor speed for the specified motor port. | |
|
mtrPID_Slop
| short mtrPid_Slop[motor_name] | |
| (short) Sets the slop (tolerance level) when using PID control to move the specified motor a specific amount | |
|
mtrPID_PowerSlew
| short mtrPid_PowerSlew[motor_name] | |
| (short) Sets the slop (tolerance level) when using PID control to move the specified motor a specific amount | |
|
mtrPID_ErrorP
| const short mtrPid_ErrorP[motor_name] |
| (const) Used to read the Proportional (P) error difference of the specified motor |
int x = 0; // Creates a variable to store the Proportional error value x = mtrPid_ErrorP[port1]; // Reads the Proportional error value from motor port 1 and sets the integer x equal to it |
mtrPID_ErrorI
| const short mtrPid_ErrorI[motor_name] |
| (const) Used to read the Integral (I) error difference of the specified motor |
int y = 0; // Creates a variable to store the Integral error value y = mtrPid_ErrorI[port1]; // Reads the Integral error value from motor port 1 and sets the integer y equal to it |
mtrPID_ErrorD
| const short mtrPid_ErrorD[motor_name] |
| (const) Used to read the Derivative (D) error difference of the specified motor |
int z = 0; // Creates a variable to store the Derivative error value z = mtrPid_ErrorD[port1]; // Reads the Derivative error value from motor port 1 and sets the integer z equal to it |
mtrPID_SyncErr
| const short mtrPid_SyncErr[motor_name] |
| (const) Used to read the Synchronization error difference of the specified motor; used with the driveSynchronized() and driveSynchronizedToPosition() functions |
int x = 0; // Creates a variable to store the Synchronization error value z = mtrPid_SyncErr[port1]; // Reads the Synchronization error value from motor port 1 and sets the integer x equal to it |
mtrPID_DriveStraightErr
| const short mtrPid_DriveStraightErr[motor_name] |
| (const) Used to read the Drive Straight error difference of the specified motor; used with the driveStraight() and driveStraightToPosition() functions |
int x = 0; // Creates a variable to store the Drive Straight error value z = mtrPid_DriveStraightErr[port1]; // Reads the Drive Straight error value from motor port 1 and sets the integer x equal to it |
Functions
moveMotorToPosition
| void moveMotorToPosition(tMotor nMotor, int nMaxSpeedToUse, long nEncoderTargetPosition) |
| (void) Used to read the Drive Straight error difference of the specified motor; used with the driveStraight() and driveStraightToPosition() functions |
moveMotorToPosition(port1, 75, 1000); // Rotates the motor on port one forward at 75 power level until 1000 encoder counts are reached |
driveStraight
| void driveStraight(tMotor nLeftMotor, tmotor nRightMotor, int nSpeed) |
| (void) Used to drive the robot straight using the specified motors and power levels |
driveStraight(port1, port10, 50); // Drives the robot straight forward by moving the motors on ports 1 and 10 at 50 power level. |
driveSynchronized
| void driveSynchronized(tMotor nLeftMotor, tmotor nRightMotor, int nLeftSpeed, int nRightSpeed) |
| (void) Used to synchronize two motors to move at the same speed and direction |
driveStraight(port1, port10, 50); // Drives the robot straight forward by moving the motors on ports 1 and 10 at 50 power level. |
stopDriveSynchronized
| void driveSynchronized(tMotor nMotor) |
| (void) Used to stop motor synchronization on the specified motor |
stopDriveSynchronized(port1); // Stops motor synchronization on on port 1 |
slaveMotor
| void slaveMotor(tMotor nSlaveMotor, tMotor nMasterMotor) |
| (void) Used to specify a master and slave motor when pairing motors |
slaveMotor(port1, port2); // Sets the motor on port1 as the slave motor and the motor on port 2 as the master motor |