V5 Gyro - Full circle goes to 20-30 Degrees

  1. 2 weeks ago

    rwood359

    Jan 4 Waialua, Hi 359

    Using the code snipped in the API for the gyro, I get the same reading for all three values (all appear to be degrees). Additionally at visually, 90 degrees the reading is about 97 degrees. Moving the Gyro in a full circle with it as centered as possible, the final reading is 20 to 30 degrees. I have tried 3 different devices and three different ports. All have similar results. I have VEXos 1.0.5 installed.
    Some people seem to be getting good results. Is there some magic that I am missing.
    Thanks

    So you have a gyro that possibly needs a slightly different calibration than a typical gyro. You can either rescale the values you read in your code by 360/390 or change internal calibration by reinitializing the gyro.
    The "normal" calibration value is 130. Try this

    GyroH.startCalibration( 140 );

    at the top of main, see if that helps.

  2. lacsap

    Jan 4 Event Partner, V5 Beta Tester Massachusetts 9791[a-z]

    Overshoot due to inertia?

  3. rwood359

    Jan 4 Waialua, Hi 359

    I'm rotating manually to different positions.

  4. lacsap

    Jan 5 Event Partner, V5 Beta Tester Massachusetts 9791[a-z]

    @rwood359 I'm rotating manually to different positions.

    code?

  5. callen

    Jan 5 Braintree, MA, USA
    Edited 2 weeks ago by callen

    When you set it, are you sticking a number into the parentheses? If so, you're probably accidentally scaling it.

    That 20 something degrees is just like 97 degrees. 97x4=388. Then reset at 360 to get 28 degrees, give or take a little, depending on how far off that 90 degrees is.

  6. rwood359

    Jan 5 Waialua, Hi 359

    This is the code I copied from the API doc. With a couple of corrections.

    int main() {
    // loop forever to always update the information displayed on the screen
    while(1) {
    Brain.Screen.clearScreen();

    // display the gyro rotation value on the screen
    Brain.Screen.printAt(1, 20, "rotation: %f degrees", GyroH.value(vex::rotationUnits::deg));

    // display the gyro percent value on the screen
    Brain.Screen.printAt(1, 40, "percent: %f %%", GyroH.value(vex::percentUnits::pct));

    // display the gyro analog value on the screen
    Brain.Screen.printAt(1, 60, "analog: %f mV", GyroH.value(vex::analogUnits::range8bit));

    //Sleep the task for a short amount of time to prevent wasted resources.
    vex::task::sleep(500);
    }

    }

    I have taken a gyro held the 3 wire connector flat against a straight edge and started the program. I held the gyro still for a couple of seconds to allow for calibration. All three values on the screen are zero.
    I rotate the gyro 180 degrees while keeping it as centered and flat as possible and end with the connector against the straight edge.. All three values are identical and read about 190 degrees. I complete the rotation with the connector flat against the the straight edge. All three values are identical they go through 359 and display as at least 15 most of the time 30 at the end.
    This is consistent with what I see when I do the same basic operations rotating the robot with gyro attached manually on the ground.

  7. jpearman

    Jan 5 Moderator, ROBOTC Tech Support, V5 Beta Moderator Answer Los Angeles 8888

    So you have a gyro that possibly needs a slightly different calibration than a typical gyro. You can either rescale the values you read in your code by 360/390 or change internal calibration by reinitializing the gyro.
    The "normal" calibration value is 130. Try this

    GyroH.startCalibration( 140 );

    at the top of main, see if that helps.

  8. rwood359

    Jan 5 Waialua, Hi 359

    jpearman: Thank You! That made all the difference.
    Now I can get some sleep before we have to be at school at 4:00 AM tomorrow to drive into town for the FRC kickoff.

  9. lacsap

    Jan 5 Event Partner, V5 Beta Tester Massachusetts 9791[a-z]

    @rwood359 jpearman: Thank You! That made all the difference.
    Now I can get some sleep before we have to be at school at 4:00 AM tomorrow to drive into town for the FRC kickoff.

    good luck!

    Jpearman is the epitome of robot expert!

 

or Sign Up to reply!