I am having trouble programming motor encoders for my base. I use easyC but I don’t use the drag and drop. I’ve tried to program them by presetting the encoders to the number of rotations(in ticks) I need then setting the motors I want to 127 until the motor winds the motor encoder down to 0 at which point the motors are set to 0. I want to know why it doesn’t work. Also if there is a better way to do this then a sample code/explanation of the method would be much appreciated.
Forward for all of my base motors is +127
My right motors are 2(front) 1(back)
My left motors are 3(front) 10(back)
All motors have motor encoders and I have made sure my settings in the controller configurations are correct.
If motor 2 is set to +127 then the IMEs go down.
If motor 2 is set to -127 then the IMEs go up.
MainAuto (); is what would be called in the autonomous tab.
void RightTurn ()
{
InitIntegratedMotorEncoders();
SetMotor(2,-127);
SetMotor(1,-127);
SetMotor(3,127);
SetMotor(10,127);
PresetIntegratedMotorEncoder(2,-600);
if (GetIntegratedMotorEncoder(2) > 0) return;
};
void LeftTurn ()
{
InitIntegratedMotorEncoders();
SetMotor(2,127);
SetMotor(1,127);
SetMotor(3,-127);
SetMotor(10,-127);
PresetIntegratedMotorEncoder(2,600);
if (GetIntegratedMotorEncoder(2) < 0)
{
SetMotor(2,0);
SetMotor(1,0);
SetMotor(3,0);
SetMotor(10,0);
};
};
void MainAuto ()
{
RightTurn ();
LeftTurn ();
};
Thanks!