Non Linear Gauge Calculations

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Message
Author
User avatar
shadyowl2
Posts: 176
Joined: Tue Dec 08, 2015 5:06 pm

Non Linear Gauge Calculations

#1 Post by shadyowl2 »

Hey Guys,
How do you go about calculating the needle image rotate for non linear gauges?? Here is an example out of the A2A T6 Texan
Attachments
Background.png
OORAH!!!! Its a Marine Thing....USMC retired

jml79
Posts: 87
Joined: Wed Jan 06, 2016 4:33 am

Re: Non Linear Gauge Calculations

#2 Post by jml79 »

I just use else if statements to sort out the regions of a non-linear gauge. You can see some of the code in my ATR engines gauges. I believe the oil temp/pressure gauge and the ITT gauge are not linear.

User avatar
shadyowl2
Posts: 176
Joined: Tue Dec 08, 2015 5:06 pm

Re: Non Linear Gauge Calculations

#3 Post by shadyowl2 »

jml79 wrote:I just use else if statements to sort out the regions of a non-linear gauge. You can see some of the code in my ATR engines gauges. I believe the oil temp/pressure gauge and the ITT gauge are not linear.

That I understand but how do you come up with the calculations for the rotation? Is there a formula or a method?
OORAH!!!! Its a Marine Thing....USMC retired

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: Non Linear Gauge Calculations

#4 Post by flyatr »

Note the angles and the corresponding values from your gauge. Each section will be linear, so either solve it yourself by using two known points or use this:
http://www.webmath.com/equline1.html

User avatar
shadyowl2
Posts: 176
Joined: Tue Dec 08, 2015 5:06 pm

Re: Non Linear Gauge Calculations

#5 Post by shadyowl2 »

flyatr wrote:Note the angles and the corresponding values from your gauge. Each section will be linear, so either solve it yourself by using two known points or use this:
http://www.webmath.com/equline1.html

can you give a visual example?? are the angles in degrees of the needle?? Sorry im not a programer :oops:
OORAH!!!! Its a Marine Thing....USMC retired

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Non Linear Gauge Calculations

#6 Post by Ralph »

It's fairly simple, I think I should do a screencast on this, it causes a lot of questions.

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: Non Linear Gauge Calculations

#7 Post by flyatr »

Example (roughly)

85 knots 90 degrees
180 knots 270 degrees

After putting it in the solver I get

y=36/19x-1350/19

or angle=36/19 * airspeed -1350/19

use that in your function to set the needle's rotatin angle. Hope that helps.

User avatar
shadyowl2
Posts: 176
Joined: Tue Dec 08, 2015 5:06 pm

Re: Non Linear Gauge Calculations

#8 Post by shadyowl2 »

Ralph wrote:It's fairly simple, I think I should do a screencast on this, it causes a lot of questions.
That would be a great help for us old guys LOL
OORAH!!!! Its a Marine Thing....USMC retired

User avatar
shadyowl2
Posts: 176
Joined: Tue Dec 08, 2015 5:06 pm

Re: Non Linear Gauge Calculations

#9 Post by shadyowl2 »

flyatr wrote:Example (roughly)

85 knots 90 degrees
180 knots 270 degrees

After putting it in the solver I get

y=36/19x-1350/19

or angle=36/19 * airspeed -1350/19

use that in your function to set the needle's rotatin angle. Hope that helps.
Do you have to calculate for each indication ie 40 knots 60 knots? do you start at 0 or 260?
OORAH!!!! Its a Marine Thing....USMC retired

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: Non Linear Gauge Calculations

#10 Post by JackZ »

shadyowl2 wrote:Hey Guys,
How do you go about calculating the needle image rotate for non linear gauges?? Here is an example out of the A2A T6 Texan
ShadyOwl,
Let's take your gauge, there are 3 sectors (speed range) in it:
1- from 40kts up to 60kts, a sector of approximately (you'll have to be more precise than me on this case!) 30degrees, starting from 15degrees(40kts) up to 45degrees(60kts), assuming that the origin is upwards at 0 degrees. (We are turning clockwise)
2- from 60kts (45 degrees) up to 180kts (267degrees) a sector of 222degrees(267-45)
3- from 180kts(267degrees) up to 260kts(350 degrees)a sector of (350-267)=83degrees(your mileage may vary;-))

The first sector spans a range of speed of (60-40)=20kts over an angular sector of 45-15=30degrees.
That means that if the current speed is within the 40 to 60 range, for every knot we will move the needle by 30degree/20knot of a degree(1.5degree), starting from 15degrees.
For example the current airspeed is 50kts.
Let's assume that your needle has been created facing upwards, in the 0 degree position, and you've added it in your code using the img_add_fullscreen() function.
The image of the needle has to be turned of 15 degrees using Img_rotate()to point to 40kts. So far, so good.
Then we add 10more knots to the initial 40knots to reach 50knts, which means that we have to turn the needle by 15degrees(the start of the sector), PLUS 30/20*10knots=15degrees which equates a 30degrees total.
If we rotate the needle by 30 degrees, it will point towards 50kts. The calculation for the number of degrees to turn the needle is (for the speed range of 40-60kts):
angle=15+((30/20)*(airspeed-40).
Let's verify:
Speed is 40kts, angle is 15+((30/20)*(40-40))=15degrees
Speed is 60kts, angle is 15+((30/20)*(60-40))=15+30=45degrees
Hence the general formula is:

Angle="Starting angle of the sector we're in"+((span of the Angular sector we're in, in degrees)/(range of speed of the sector we're in,in kts)*(current airspeed-First indicated airspeed of the sector we're in)

More precisely:
Angle=StartAngle+((FinalAngle-StartAngle)/(FinalSpeed-StartingSpeed)*)(Airspeed-StartingSpeed))
Of course, to speed up calculations, my advice is to pre-calculate the constants for each sector, i.e. the values that don't change such as (FinalAngle-StartAngle)=constant1 and FinalSpeed-StartingSpeed)=constant2,....
To wrap it up, your code should have three separate formulas for the angle of rotation of the needle, depending of the current airspeed.
As suggested by FlyAtr, in order to determine which sector(hence formula to use) you're in based on the current-airspeed, use tests in your code such as:
if (CurrentAirspeed>=StartingSpeedsector1 and airspeed<FinalSpeedsector1) then
Angle=<use formula1>
end
and so on...

Hope this helps
Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply