HT Gyrosensor : How to extract degrees of turn
 Software and Programming Related   Started by Merijnn S   2015-09-11 11:44:58 -04:00   Comments: 1    Viewed: 415

  1. Merijnn S
    Merijnn S Member

    Postby merijn0301 » Tue Dec 16, 2014 4:50 am

    Hi,

    I purchase a HT Gyrosensor for my NXT brick. I want to use to assist moving robot in steering.
    As Always, I first want to figure out how things work.
    My problem is that I can never get an accurate reading because, even absolutely still and with the right off-set value the value read fluctuates slightly.
    I paste my code below.
    ----------------
    int iGyroValue,iAngle;
    string sGyroValue,sAngle;

    task ShowGyroValue()
    {
    while(true)
    {
    // OffSet-value value has been calculated in bij
    // keeping sensor absoulutly still while executing 10
    // readings with an off-set of zero an then calculate
    // the average.

    // I get erratic reading, even when absolutely still

    iGyroValue = SensorHTGyro(IN_1, 6);
    sGyroValue = NumToStr(iGyroValue);
    sGyroValue=StrCat(sGyroValue," ");
    TextOut(0, LCD_LINE1, sGyroValue);
    iAngle = iAngle +iGyroValue;
    sAngle = NumToStr(iAngle);
    TextOut(0, LCD_LINE3, sAngle);
    Wait(500);
    }

    }
    //--------------------------------------------------------------------------
    task main()
    {
    iAngle = 0;
    blnOS = true;
    SetSensorHTGyro(IN_1);
    Precedes(ShowGyroValue);

    }
    Merijnn S, 2015-09-11 11:44:58 -04:00
  2. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!
Help!