/dist/images/branding/favicon

Can't calibrate compass

Discussion in 'Electronics' started by Mark Melville, Dec 26, 2012.

  1. Andy Johnson-Laird

    Andy Johnson-Laird Administrator
    Staff Member

    Joined:
    Jul 31, 2012
    Messages:
    10,383
    Likes Received:
    1,164
    Hi Gary:
    Took me about 20 minutes, but here's the code from the FC board.
    Note: "Kanalbelegung is channel allocation, and "winkel" is angle. "Piep" is beep.


    void CalMk3Mag(void)
    {
    static unsigned char stick = 1;
    if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -20) stick = 0;
    if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) && !stick)
    {
    stick = 1;
    WinkelOut.CalcState++;
    if(WinkelOut.CalcState > 4)
    {
    // WinkelOut.CalcState = 0; // in Uart.c
    beeptime = 1000;
    }
    else Piep(WinkelOut.CalcState,150);
    }
    //DebugOut.Analog[19] = WinkelOut.CalcState; // MartinR wird in fc.c verwendet
    }

    I don't have time to do an in-depth reverse engineering of the code right now (DVD to work on!), but it appears that the first few lines are looking to see what the Nick stick angle. The variable "stick" is forced to zero if the stick angle is greater than -20. However, if the stick angle is less than -70, then stick is negated (that's the "!stick").

    That's as far as I've got. Not sure what the rest of the logic is doing.
    Steve (Maller): you speak C don't you? :)

    Andy.
     

Share This Page