Welcome to Cockpitbuilders.com. Please login or sign up.

March 28, 2024, 03:48:48 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
118 Guests, 0 Users
Members
Stats
  • Total Posts: 59,639
  • Total Topics: 7,853
  • Online today: 130
  • Online ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 118
Total: 118

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

Arduino, Stepper Motors and a Wet Compass....

Started by RayS, April 01, 2015, 08:04:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RayS

Bound and determined I am to get a genuine vertical card compass to function as a wet compass using a stepper and Arduino.

I've solved the problem of crossing the "North Boundary" and am curious if anyone else has done it, and how...

Here's how I did it:

there are 4 separate conditions when slaving a wet compass

1. AC Heading > Compass heading (No 360-degree transition)
2. AC Heading < Compass heading (No 360-degree transition)
3. AC Heading > Compass heading (Includes a 360-degree transition)
4. AC Heading < Compass heading (Includes a 360-degree transition)

A brief explanation about "Includes a 360-degree transition": It means nothing more than the AC heading may be 010, while the compass still lags behind at 355 degrees, meaning there would be a transition through NORTH for the wet compass to finally arrive at the aircraft heading.

By calculating the reciprocal in each condition, I am able to discern how far, and in which direction, to slave the stepper motor, making the device behave exactly as a wet compass would.

Has anyone else tackled this problem? If so, how?




Ray Sotkiewicz

mickc

Hi Ray,

This is how I did mine in SIOC, I am going to convert the code over to Arduino at some stage, but this is another angle on how to do it.:

Quote

Var 0985, name CMP_HDG       
{
  &CMP_STEPPER = &CMP_HDG * 100           
}


Var 0990, name MAG_VAR



Var 0981, name FS_MAGVAR, Link FSUIPC_IN, Offset $02A0, Length 2
{
  L0 = &FS_MAGVAR * 0.005493164
  L0 = 360 - L0
  &MAG_VAR = L0   
}


Var 0988, name FS_HDG, Link FSUIPC_IN, Offset $0580, Length 4
{
  L0 = &FS_HDG * 8.3819E-008
  L0 = ROUND L0
  IF L0 < 1
  {
    L0 = L0 + 360
  }
  L1 = L0 + &MAG_VAR
  IF L1 > 360
  {
    L1 = L1 - 360
  }
  &CMP_HDG = L1   

}

RayS

My working C# Code: (Wrote a tiny app just to formalize & test the math)

            Aircraft_Heading = System.Convert.ToSingle(txt_Aircraft_Heading.Text);
            Compass_Heading = System.Convert.ToSingle(txt_Compass_Heading.Text);

            if (Compass_Heading < Aircraft_Heading)
                Compass_Heading += 360; // Denormalize headings to +/- 180 degrees

                Compass_Slew = Compass_Heading - Aircraft_Heading;

     
            if (Compass_Slew < 180)
            {
                               
                // Move_Motor_Left(Compass_Slew * -1)

            }

            else
            {
                             
                // Move_Motor_Right(360 - Compass_Slew)

            }

            Compass_Heading = Aircraft_Heading;
Ray Sotkiewicz

quid246

Hope I am not threadjacking here but I was thinking about converting a real wet compass (if I ever acquire one) .

I have never seen one dissected, but I wonder if it would be possible to mount the "ball" of a wet compass onto a mini-360 degree servo and control it with Arduino code similar to the above?

RayS

It is absolutely possible. I just chose to use a stepper to avoid the behavior of a 360-degree servo spinning back to continue a turn thru the servo limit.

A servo would be somewhat easier since the servo would always know where it's at, while a stepper initially seeks to a known position, then all bets are off if the programming is off by a few degrees. Heading errors would slowly increase over time.
Ray Sotkiewicz

quid246

Okay... thanks for the info.

Time to score a real wet compass now!

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate