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?
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
}
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;
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?
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.
Okay... thanks for the info.
Time to score a real wet compass now!