AOA Indexer Project
Re: AOA Indexer Project
Thanks for the info Ralph! I will definitely explore that further.
Here's a couple of pics of the flight sim room for those interested:
Here's a couple of pics of the flight sim room for those interested:
Re: AOA Indexer Project
Ok...after perusing the forum and Wiki, I've decided to try to incorporate a timer into my AOA indexer code whereby the tailhook position (stowed vs deployed) makes the LEDs flash or not (seems there are a number of ways to do this but, as a beginner, I was unsuccessful at finding a clear path forward). I will test this code this evening:
Code: Select all
led_AOAlow = hw_output_add("ARDUINO_NANO_A_D2", false) -- Fast, Red Chevron
led_AOAnorm = hw_output_add("ARDUINO_NANO_A_D4", false) -- On Speed, Amber Donut
led_AOAhigh = hw_output_add("ARDUINO_NANO_A_D6", false) -- Slow, Green Chevron
function new_data_fsx(AOA, HookPos)
if HookPos >1 then
hw_output_set(led_AOAhigh, AOA >=11.1)
hw_output_set(led_AOAnorm, AOA >=9.75 and AOA <=11.53)
hw_output_set(led_AOAlow, AOA <=10.17 and AOA >5.0)
else
function timer_callback(-1) --callsback infintely every 1 sec?
hw_output_set(led_AOAhigh, AOA >=11.1)
hw_output_set(led_AOAnorm, AOA >=9.75 and AOA <=11.53)
hw_output_set(led_AOAlow, AOA <=10.17 and AOA >5.0)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Degrees",
"TAILHOOK POSITION", "Percent", new_data_fsx)
timer_start(1000, 1000, timer_callback)
Re: AOA Indexer Project
You cannot place a timer callback function within another function. I'll make an example tomorrow.
Re: AOA Indexer Project
OK. Considering that then...
Code: Select all
function new_data_fsx(AOA, HookPos)
if HookPos >1 then
hw_output_set(led_AOAhigh, AOA >=11.1)
hw_output_set(led_AOAnorm, AOA >=9.75 and AOA <=11.53)
hw_output_set(led_AOAlow, AOA <=10.17 and AOA >5.0)
end
function timer_callback(-1) --callsback infintely every 1 sec?
if HookPos <1 then
hw_output_set(led_AOAhigh, AOA >=11.1)
hw_output_set(led_AOAnorm, AOA >=9.75 and AOA <=11.53)
hw_output_set(led_AOAlow, AOA <=10.17 and AOA >5.0)
end
end
Re: AOA Indexer Project
It becomes 'complicated' very quickly It is flashing at 250 ms right now, you can change that to something else if you want.
Code: Select all
led_AOAlow = hw_output_add("ARDUINO_NANO_A_D2", false) -- Fast, Red Chevron
led_AOAnorm = hw_output_add("ARDUINO_NANO_A_D4", false) -- On Speed, Amber Donut
led_AOAhigh = hw_output_add("ARDUINO_NANO_A_D6", false) -- Slow, Green Chevron
function new_data_fsx(AOA, HookPos, bus_volts)
local power = bus_volts >= 10
if HookPos > 1 and power then
if not timer_running(timer_aoa_flash) then
timer_aoa_flash = timer_start(nil, 250, function(count)
hw_output_set(led_AOAhigh, count % 2 == 0)
hw_output_set(led_AOAnorm, count % 2 == 0)
hw_output_set(led_AOAlow, count % 2 == 0)
end)
end
elseif HookPos < 1 and power then
timer_stop(timer_aoa_flash)
hw_output_set(led_AOAhigh, AOA >= 11.1)
hw_output_set(led_AOAnorm, AOA >= 9.75 and AOA <= 11.53)
hw_output_set(led_AOAlow, AOA > 5.0 and AOA <= 10.17)
else
timer_stop(timer_aoa_flash)
hw_output_set(led_AOAhigh, false)
hw_output_set(led_AOAnorm, false)
hw_output_set(led_AOAlow, false)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Degrees",
"TAILHOOK POSITION", "Percent",
"ELECTRICAL MAIN BUS VOLTAGE", "Volts", new_data_fsx)
Re: AOA Indexer Project
Yes, I see it certainly does! Thanks Ralph. I'll test the code this evening and continue to read up and learn here in the forums.
Dan
Dan
Re: AOA Indexer Project
Be careful with starting timers within a flight simulator callback function. If you don't check if it is running, then it'll spawn a new timer each time the flight sim callback function gets new data. Therefore there's a 'timer_running' check there.
Re: AOA Indexer Project
I finally was able to fly with the new AOA code courtesy of Ralph. The indexer lights now blink if the arrestor hook is not deployed warning the pilot accurately! I adjusted the timer delay to half a second which seems to work nicely. In the meantime, I'm continuing to learn the nuances of LUA scripting and have plans to add a second device (built exactly like the AOA indexer) for the right side of my HUD which will have a nose wheel steering light, master arm and another indicator (missile warning?) of some sort.
Thanks Ralph!
Thanks Ralph!
Re: AOA Indexer Project
Glad I could help. Let us know if you need assistance with the next project.
I've just noticed that the script can be made a little bit more compact, but it works either way.
I've just noticed that the script can be made a little bit more compact, but it works either way.
Re: AOA Indexer Project
Using another Arduino Nano I created a new instrument on Channel B and the code works perfectly for my newest indicators. The only trouble is, in Air Manager, I can only seem to run 1 Nano at a time (either A or B). I tried using the 'Ctrl' key to select and run both Instruments but this doesn't work. What am I missing?