RobotC not reading Encoder Values

  1. 11 months ago
    Edited 11 months ago by viper_52_08

    So multiple groups in my class are having this same problem. We are simply trying to use our quadrature encoders to drive a set distance then stop and return to the starting point. Sample code looks like this

    SensorValue[leftEncoder] = 0;
    SensorValue[rightEncoder] = 0;
    while(SensorValue[leftEncoder] < 360)
    motor[rightMotor] = 93;
    motor[leftMotor] = 93;
    SensorValue[leftEncoder] = 0;
    SensorValue[rightEncoder] = 0;
    while(SensorValue[leftEncoder] > -360)
    motor[rightMotor] = -93;
    motor[leftMotor] = -93;

    When we run the code, the Values in the Debugger window show up correctly and count up correctly but the loop doesn't stop until almost twice the desired Encoder counts. If the group puts 360 in it won't stop until like 700 encoder counts. If the group puts 500 in for the value of encoder counts it won't stop until around 1000 encoder counts. It is almost like RobotC is just ignoring the encoder values until almost twice the value, we run the same code to back up and place the same number in and it will stop at the desired encoder counts. I have updated firmware multiple times, tried different cortexes and encoders all with no improvement.


    OK this is going to sound really stupid but why can I not post a new reply to this thread. I hit the post a reply button and nothing happens? I can edit my original post but not add a new reply????????

  2. jpearman

    11 Oct 2017 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    Can you post the whole program.

    In general, the robot will never stop on exactly the encoder count you use in a loop like that. The robot has momentum and will continue to move after you send stop (which I assume you do somewhere later in your code). But post all the code and I will have a look.


or Sign Up to reply!