On our robot one motor will constantly spin, very slowly, but it still happens Is this a trim issue? If so, how do I fix it? If not what is it, and how do I fix it? Thank you very much.
With the old hand held transmitters you could do in with the menus and buttons on the tranmitter. With the new Vexnet Joysticks you have to but a deadband or theshold in the software to ignor small values on the joystick.
If it’s a 3-wire motor (the ones that use the green clutch) you might have plugged its PWM cable in backwards.
If the motor responds to controls fine except that it runs at a slow speed when you’re not pressing it, then yes it is the trim. As some one pointed out earlier, you can use a deadband or threshold to fix it. Here is how to use a threshold. When you program the controls for the joysticks (assuming that you’re using RobotC, but even is you’re not, the logic is the same), you most like do it like this:
task main(){
while(true){
motor[port1] = vexRT[Ch2];
}
}
To use a threshold, all you have to do is this:
task main(){
int thresholdValue = 7;
while(true){
if(vexRT[Ch2] > thresholdValue || vexRT[Ch2] < -thresholdValue){
motor[port1] = vexRT[Ch2];
}
else motor[port1] = 0;
}
}
This code just checks if the joystick is pushed to more than ‘tresholdValue’ in either direction. In this case, I set it to 7. Trim happens when the joystick springs get worn out, or the joystick is biased for some other reason. So depending on how bad your trim is, just change the value of ‘thresholdValue’. A more efficient way to do this would be:
task main(){
int thresholdValue = 7;
while(true){
motor[port1] = abs(vexRT[Ch2]) > thresholdValue ? vexRT[Ch2] : 0;
}
}
Well this is very common, I have programmed on my robotc code with trim.
heres what I use to do the trimming (but its not just for trimming):
// MathExtesion
// This class is designed to give more math functions in robotc.
int Math_Clamp(int Number, int minNumber, int maxNumber);
int Math_ClampToZero(int Number, int minNumber, int maxNumber);
int Math_Clamp(int Number, int minNumber, int maxNumber)
{
if (Number > maxNumber)
{
Number = maxNumber;
}
if (Number < minNumber)
{
Number = minNumber;
}
return Number;
}
int Math_ClampToZero(int Number, int minNumber, int maxNumber)
{
if (Number < maxNumber && Number > minNumber)
{
Number = 0;
}
return Number;
}