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
Non Linear Gauge Calculations
Re: Non Linear Gauge Calculations
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.
Re: Non Linear Gauge Calculations
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
Re: Non Linear Gauge Calculations
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
http://www.webmath.com/equline1.html
Re: Non Linear Gauge Calculations
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
OORAH!!!! Its a Marine Thing....USMC retired
Re: Non Linear Gauge Calculations
It's fairly simple, I think I should do a screencast on this, it causes a lot of questions.
Re: Non Linear Gauge Calculations
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.
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.
Re: Non Linear Gauge Calculations
That would be a great help for us old guys LOLRalph wrote:It's fairly simple, I think I should do a screencast on this, it causes a lot of questions.
OORAH!!!! Its a Marine Thing....USMC retired
Re: Non Linear Gauge Calculations
Do you have to calculate for each indication ie 40 knots 60 knots? do you start at 0 or 260?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.
OORAH!!!! Its a Marine Thing....USMC retired
Re: Non Linear Gauge Calculations
ShadyOwl,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
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
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ