This question was originally posted by mykiscool in the ROBOTC Technical Support Q&A:
I believe the difference between the different motor types is for when you are using an integrated motor encoder with the natural language programing. When you use a command like line track for rotations, or move straight for rotation the IME would have a different tick count for the rotation for each setting on a 393 motor as well as the 269 motor.
Hmm interesting. Then if someone isn’t using the IMEs then is there any reason they have to pick the correct motor? How about 269 vs 393? Is there a difference other than for IME counts?
They are also used for RobotC’s built in PID functions (which are still in development). I am sure that each motor will have its own PID constants when/if RobotC finishes all of those functions.
It also helps for documenting purposes, and just for reference (two of the three main reasons that I have used the Motors and Sensors Setup).
You are all correct, the motor selection is used in some of the IME code, as well as having a different number of counts per rev, the 269 encoders also count the opposite way to the 393s. ROBOTC uses the motor type to reverse the IME counter on a 269, so does ConVEX, here is a snippet of code showing that.
/*-----------------------------------------------------------------------------*/
/** @brief Get the current motor position */
/** @param[in] index The motor index */
/** @returns The motor position */
/*-----------------------------------------------------------------------------*/
int32_t
vexMotorPositionGet( int16_t index )
{
int32_t position;
if( (index < kVexMotor_1) || (index >= kVexMotorNum))
return(0);
if( vexMotors index ].motorPositionGet != NULL )
{
position = vexMotors index ].motorPositionGet( vexMotors index ].port );
// 269 needs reversing
if( vexMotors index ].type == kVexMotor269 )
position = -position;
if(!vexMotors index ].reversed )
return( position );
else
return( -position );
}
else
return(0);
}
Code built on top of the IME functionality, like my smart motor library, also use the motor type for setting internal parameters.