The simFlight Network Forums

# Trying to get heading as a 4 digit number

## Recommended Posts

Hi,

I have converted a real RMI to use stepper motors and it is run through SIOC.

It all works correctly, I use the *360/(65536*65536) equation on offset \$0580 i get a 3 digit heading from -180 to +180 as I should.

This means my stepper motors move every degree, but during slow turns this looks quite jerky.

What I want is for the heading to be a 4 digit number, such as 263 & 1/2 degrees would read 2635.

How should the equation look if i want it to read -1800 to +1800?

This will give me 10x the resolution and make the movement smoother

The Stepper motor card uses a value of 0 to 36000 for the position of the motor.  My motors have 2048 steps for a full circle.

Cheers.

##### Share on other sites

It all works correctly, I use the *360/(65536*65536) equation on offset \$0580 i get a 3 digit heading from -180 to +180 as I should.

This means my stepper motors move every degree, but during slow turns this looks quite jerky.

What I want is for the heading to be a 4 digit number, such as 263 & 1/2 degrees would read 2635.

How should the equation look if i want it to read -1800 to +1800?

The Stepper motor card uses a value of 0 to 36000 for the position of the motor.  My motors have 2048 steps for a full circle.

Basic arithmetic. The heading provided by the offset you are reading is in units of 4,294,967,296ths of a full circle. That number is more easily remembered as 65536 x 65536. Nothing magic about that. You convert to whatever units you want. Obviously your should have units of 36,000ths of a circle, so you need to do the computation as

(unsigned value from offset)*36000/(65536 * 65536)

By using unsigned you get 0-35999. Do the computation in floating point then take the integer part of the result.

Then you can use the value directly.

Pete

##### Share on other sites

Cheers Pete.

I have since realized that i needed to do the same change of calculation for the Magnetic variation.

ii have now fixed that, and also both the VOR and ADF relative bearings, and it all works beautifully.

Thanks mate

## Create an account

Register a new account