Coding Issues - Encoders

Hey all,

We have been writing code with Robot C for “Straight with Encoders”. Robot does not seem to adjust motor speeds or correct. If While Loop is removed and motor powers are adjusted to compensate for motor differences, the robot will go straight. Any suggestions out there?


Normally I would say that perhaps your gain (the constant you multiply the difference by before you apply it to the motor values) is too low and is therefore not adjusting enough, but because you said that the robot drives straight when you take off the control loop, I think it may be an issue with the sign (+/-) of the encoder values you’re using, which actually contributes towards the robot not driving straight.

Make sure that when you check the encoder values to use absolute value, so something like abs(SensorValue[encoder]). This makes sure you’re comparing two positive values, instead of the possibility of one positive and one negative (depending on the direction and wiring of your encoder) value, which could actually cause a tilt when driving.

Thanks for the response. I will investigate your suggestions. We’re having trouble getting some robots to perform properly with sample download programs. Even if you play around with motor powers.