PDA

View Full Version : Weird Offsets



Boeing 747 Flyer
09-13-2010, 04:22 PM
Hiya everyone,

I have, for my 767 Overhead, developed an IRS SIOC script which functions using both SIOC and the IOLCD.exe application (written for an LCD Display).

The script is designed to display my aircraft's current co-ordinates, GS, track, heading... etc

It is, for the most, 80% working. However, there are a few offsets that aren't working for me.

For example, Offset $0580. This is the Aircraft Heading coordinate. In the FSUIPC Offsets Status manual, it states that you must do some calculations... So, I oblidged. Here is my script:


Var 9117, name HDG, Link FSUIPC_IN, Offset $0580, Length 4
{
L0 = &HDG * 360
L1 = DIV L0 4294967296
V9872 = L1
}

However, on the LCD display, the heading is completely messed up! It often displays values such as -12 when I am on heading 272... etc

Can anyone try this offset and/or do you know of any alternatives I could try?

Thanks,

Jack:D

Peter Dowson
09-13-2010, 07:45 PM
Offset $0580. This is the Aircraft Heading coordinate. In the FSUIPC Offsets Status manual, it states that you must do some calculations.
Well, rather, it tells you what the FS units are. FS arranges for the largest possible number (359.99999 ... degrees) to occupy the available 32-bits to the maximum. That effectively means that the number "65536*65536" (one more than the maximum number which can be accommodated) represents 360 (the first heading out of the range 0-359.99999 ...). By doing this it is using those 32 bits to give maximum precision -- more precise, in fact, than a 32-bit Float would give because the latter uses several bits for an exponent.



Var 9117, name HDG, Link FSUIPC_IN, Offset $0580, Length 4
{
L0 = &HDG * 360
L1 = DIV L0 4294967296
V9872 = L1
}
I don't know this form of code, but my questions of it would be:

1. What is the capacity of the variables represented by L0 and L1? Are they floating point? If they only have 32 bit fixed point capacity, then you are losing much of the value when you multiply by 360, obviously.

2. Is all this operating with unsigned numbers? If not, if they are signed, then any heading of 180 or over will look negative, of course, as the top bit will be set. If you get a negative result as a consequence you'd have to add 360 to correct it.


However, on the LCD display, the heading is completely messed up! It often displays values such as -12 when I am on heading 272... etc
So, evidently, although the offset value you are reading is a 32 bit unsigned number you are treating it as signed. You need to correct for that.

Pete

Boeing 747 Flyer
09-18-2010, 07:04 PM
Hi Pete,

Good news. I've managed to fix the issue with the true heading Offsets; I used some code provided by Nico Kaan on his website, see here:


Var 3682 name HDG1 Link FSUIPC_IN Offset $0580 Length 4 // true heading
{
L0 = &HDG1 * 8.3819E-008
IF L0 < 0
{
L0 = L0 + 360
}
&D_HDG = ROUND L0
}
Where D_HDG value is the calculated unit. All working!!!

Now, I'm cracking on with the ambient wind offset. I'm using the following formula:



Var 9033, Name WINDDIR, Link FSUIPC_IN, Offset $0E92, Length 2
{
L0 = &WINDDIR * 5.9493164063E-03
&WINDDIRCALC = ROUND L0
}

Using the above formula (as per FSUIPC SDK Manuals), I'm getting some strange readings, like "735" and so forth. When completely still and on the ground, I get fairly inaccurate but believable results, like "042". Have I made a mistake?

Jack

Peter Dowson
09-24-2010, 10:48 AM
I've managed to fix the issue with the true heading Offsets
Yes, you are now simply correcting the calculation because you are handling a positive number as if it were signed. As I said.


Now, I'm cracking on with the ambient wind offset.
The wind direction at 0E92 is in exactly the same form as the heading, except using 16 bits instead of 32. I expect you've ignored the sign problem again.

Pete