Use AFL Data Ref to modify guage

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Posts: 2
Joined: Sat Sep 17, 2022 12:54 pm

Re: Use AFL Data Ref to modify guage

#11 Post by silentfrog »

Hi, new user here, I might be totally off the mark.

Nik201 can you confirm your gauge is accurate?

I've just stated playing with the AFL KA350 as well, having problems with a couple of DataRefs including KA350/ianim/gauges/lEngITT

Multiplying the value by a single constant and then feeding it into the logic of the KA300 gauge doesn't give accurate results for me.

I gave Keith's suggestion a try and it seems to work, it feels dirty but it works :)

Code: Select all

local temp_map = { {.529, 560},
             {.540, 575},
             {.656, 678},
             {.739, 745},
             {.753, 758} }
-- Functions
function new_itttemp(itttemp)

    temp = interpolate_linear(temp_map, itttemp)
    if temp >= 1001 then
        rotate(img_needle, 30 / 200 * (temp - 1001) + 270)
    elseif temp >= 601 then
        rotate(img_needle, 180 / 400 * (temp - 601) + 90)
    elseif temp >= 401 then
        rotate(img_needle, 60 / 200 * (temp - 401) + 30)
    elseif temp >= 200 then
        rotate(img_needle, 30 / 200 * (temp - 200) )

temp_map is in the format {KA350/ianim/gauges/lEngITT, value of the ITT gauge seen rendered}

Might need more data points for temp_map but it's quite good already.. I would love to figure out how to properly transform the KA350/ianim/gauges/lEngITT value though.

User avatar
Keith Baxter
Posts: 3936
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Use AFL Data Ref to modify guage

#12 Post by Keith Baxter »


Yes the "interpolate" can be expressed as dirty in your opinion.
However it is a table and can have many layers.

There are math alternative, We would all welcome and appreciate these should anyone have input.

AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Posts: 2265
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Use AFL Data Ref to modify guage

#13 Post by jph »

It's not a dirty solution at all, it is perfectly acceptable as there is not a mathematical relationship in most of these gauges due to either the sensor or gauge scale non linearity. The sensors and transducers are almost always provided with lookup tables from the manufacturer of the sensor due to the readings being consistently non linear and consistently irregular in progression ;)
Even if you drill down to some semi magical math formula that mostly works then it will almost certainly not on the next unit.
Arrays (table in lua) and interpolation is absolutely fine.
“Everything in moderation, including moderation.”
“Experience is merely the name men gave to their mistakes.”
Joe (CISSP) -IT security consultant

Posts: 6
Joined: Fri Aug 19, 2022 10:23 am
Location: Alicante

Re: Use AFL Data Ref to modify guage

#14 Post by Nik201 »

Hi Nik201 here...
Sorry for my delay... Been redecorating the house!! So, to answer your question about accurate readings... I did look and as I recall it's with limits.. since you asked I'll have another check.. will advise.
Will be back .

Posts: 2
Joined: Sat Sep 17, 2022 12:54 pm

Re: Use AFL Data Ref to modify guage

#15 Post by silentfrog »

"Dirty" may not have been the best word to have used, I wasn't expecting a workable solution to be presented so quickly and assumed there would be a deep rabbit hole of new knowledge what would take me hours to figure out, no offensive intended :)

I was impressed at how accurate the results were with only a few data points, though I need do need to make sure the max and min values are covered so nothing odd is observed during startup and shutdown. Cheers for the info, it's going to be a useful tool :D

Post Reply