Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
I want to make my robot travel in a straight line, I know the logic involved but I don’t know how to interface the encoder with the axon II. What I have read, using an external interrupt is the port I should use. I need help of how to accomplish this. Is there any already created function that have been tested
//set control constant - increase this number to get it to turn fasteruint8_t constant=1;//determine encoder errorencoder_difference=encoder_left-encoder_right;//reset speedsleft_motor_speed=DRIVE_SPEED_MAX;right_motor_speed=DRIVE_SPEED_MAX;//if left goes too fastif(encoder_left > encoder_right) left_motor_speed=CLAMP(DRIVE_SPEED_MAX-encoder_difference*constant,DRIVE_SPEED_MIN,DRIVE_SPEED_MAX);//slow left down//if right goes too fastif(encoder_left < encoder_right) right_motor_speed=CLAMP(DRIVE_SPEED_MAX-encoder_difference*constant,DRIVE_SPEED_MIN,DRIVE_SPEED_MAX);//slow right down//tell robot to moveact_setSpeed(&left, left_motor_speed);act_setSpeed(&right, right_motor_speed);