Hello,
I'm new to the Sim Innovations community and built an AOA Indexer using an Arduino Nano and am using P3Dv5. I have 3 LEDs connected to my Nano (pins D2, D4 & D6). I have created the following script to interface with Air Manager and will be testing it out this evening. Take a look at it and let me know if you see any issues! During testing I will tweak the values (in radians) to match the virtual cockpit's AOA Indexer. I'll post pictures of my project to this thread later this evening as well:
led_AOAlow = hw_led_add("ARDUINO_NANO_A_D2", 1) --starts LED 'ON'
led_AOAnorm = hw_led_add("ARDUINO_NANO_A_D4", 1) --starts LED 'ON'
led_AOAhigh = hw_led_add("ARDUINO_NANO_A_D6", 1) --starts LED 'ON'
function new_data_fsx(AOAlow, AOAnorm, AOAhigh)
-- SLOW indicator
AOAlow <= 2.3
if AOAlow <= 2.3 then
hw_led_set(led_AOAlow, 1)
else
hw_led_set(led_AOAlow, 0)
end
-- ON SPEED indicator
AOAnorm <= 2.55 and AOAnorm >=2.25
if AOAnorm <= 2.55 and AOAnorm >=2.25 then
hw_led_set(led_AOAnorm, 1)
else
hw_led_set(led_AOAnorm, 0)
end
-- FAST indicator
AOAhigh >= 2.6
if AOAhigh <= 2.3 then
hw_led_set(led_AOAhigh, 1)
else
hw_led_set(led_AOAhigh, 0)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Radians", new_data_fsx)
AOA Indexer Project
-
- Posts: 5346
- Joined: Thu Jul 27, 2017 12:22 am
Re: AOA Indexer Project
I've made a small fix for FAST Indicator, where you said it would be >= 2.6 and the check is showing : "if AOAhigh <= 2.3 then"DH14300 wrote: ↑Mon Sep 26, 2022 7:42 pm Hello,
I'm new to the Sim Innovations community and built an AOA Indexer using an Arduino Nano and am using P3Dv5. I have 3 LEDs connected to my Nano (pins D2, D4 & D6). I have created the following script to interface with Air Manager and will be testing it out this evening. Take a look at it and let me know if you see any issues! During testing I will tweak the values (in radians) to match the virtual cockpit's AOA Indexer. I'll post pictures of my project to this thread later this evening as well:
led_AOAlow = hw_led_add("ARDUINO_NANO_A_D2", 1) --starts LED 'ON'
led_AOAnorm = hw_led_add("ARDUINO_NANO_A_D4", 1) --starts LED 'ON'
led_AOAhigh = hw_led_add("ARDUINO_NANO_A_D6", 1) --starts LED 'ON'
function new_data_fsx(AOAlow, AOAnorm, AOAhigh)
-- SLOW indicator
AOAlow <= 2.3
if AOAlow <= 2.3 then
hw_led_set(led_AOAlow, 1)
else
hw_led_set(led_AOAlow, 0)
end
-- ON SPEED indicator
AOAnorm <= 2.55 and AOAnorm >=2.25
if AOAnorm <= 2.55 and AOAnorm >=2.25 then
hw_led_set(led_AOAnorm, 1)
else
hw_led_set(led_AOAnorm, 0)
end
-- FAST indicator
AOAhigh >= 2.6
if AOAhigh <= 2.3 then
hw_led_set(led_AOAhigh, 1)
else
hw_led_set(led_AOAhigh, 0)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Radians", new_data_fsx)
Code: Select all
led_AOAlow = hw_led_add("ARDUINO_NANO_A_D2", 1) --starts LED 'ON'
led_AOAnorm = hw_led_add("ARDUINO_NANO_A_D4", 1) --starts LED 'ON'
led_AOAhigh = hw_led_add("ARDUINO_NANO_A_D6", 1) --starts LED 'ON'
function new_data_fsx(AOAlow, AOAnorm, AOAhigh)
-- SLOW indicator AOAlow <= 2.3
if AOAlow <= 2.3 then
hw_led_set(led_AOAlow, 1)
else
hw_led_set(led_AOAlow, 0)
end
-- ON SPEED indicator AOAnorm <= 2.55 and AOAnorm >=2.25
if AOAnorm <= 2.55 and AOAnorm >=2.25 then
hw_led_set(led_AOAnorm, 1)
else
hw_led_set(led_AOAnorm, 0)
end
-- FAST indicator AOAhigh >= 2.6
if AOAhigh >= 2.6 then
hw_led_set(led_AOAhigh, 1)
else
hw_led_set(led_AOAhigh, 0)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Radians", new_data_fsx)
Re: AOA Indexer Project
Thank you for looking at my code and finding that! Here's a couple pics of my project. I've re-mounted my Indexer on the left side of the HUD since these were taken and it's straighter as well. On to testing the new code! I'll post my results once I have them.
Re: AOA Indexer Project
Progress!
I've remarked out 2 of the 3 LEDs to focus on just the 'AOAhigh' LED. I'm able turn it on but not off when it should. Here's the code and the read value. At this point I want the LED off but it's still on:
I've remarked out 2 of the 3 LEDs to focus on just the 'AOAhigh' LED. I'm able turn it on but not off when it should. Here's the code and the read value. At this point I want the LED off but it's still on:
Re: AOA Indexer Project
Hi and welcome to Air Manager.
Your code has a couple of obvious issues at a quick glance.
1 - You have subscribed to a single variable but are using 3 different arguments in the associated callback. I’d suggest you just call this AoA.
2 - You are declaring the comparison variable before your if..else with a fixed value so it will always do the same thing (turn on the output).
Another thing that may help is if you make the subscribe type “Degrees” as these are easier to work with and comprehend.
If you are getting to grips with how the individual API functions are used I’d suggest studying the wiki API pages and the video tutorials linked in my signature below.
Hope this helps.
Your code has a couple of obvious issues at a quick glance.
1 - You have subscribed to a single variable but are using 3 different arguments in the associated callback. I’d suggest you just call this AoA.
2 - You are declaring the comparison variable before your if..else with a fixed value so it will always do the same thing (turn on the output).
Another thing that may help is if you make the subscribe type “Degrees” as these are easier to work with and comprehend.
If you are getting to grips with how the individual API functions are used I’d suggest studying the wiki API pages and the video tutorials linked in my signature below.
Hope this helps.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: AOA Indexer Project
One more thing. If you're not going to dim the LED's, then you can use hw_output_add and _set. Then you can do your statement within the set. So for example hw_output_set(led_a, aoa >= 10)
Re: AOA Indexer Project
Thank you guys both for your input! This is my first attempt at writing code so this helps me tremendously. Will make edit later today & test.
Re: AOA Indexer Project
Ralph, regarding using degrees instead of radians, the sim variable is in radians by default so I would need a conversion line of code somewhere correct?
Re: AOA Indexer Project
If you subscribe to degrees then you would just get different values from the simulator.
Re: AOA Indexer Project
I'm rewriting the code based on the helpful feedback I've received so far. Changes include:
1. Using only 1 argument in the callback (just 'AOA') instead of 3 arguments previously
2. Changed Radians to Degrees
3. Using "hw_output_add" & "hw_output_set" instead of "hw_led_add" & "hw_led_set" (I don't need to adjust LED brightness)
4. Removed the fixed AOA values previously called out
Focusing on just 1 LED for now (AOAhigh), I want the LED to turn On for values >=8.8, otherwise Off. My revised code is as follows:
led_AOAhigh = hw_output_add("ARDUINO_NANO_A_D6", true)
function new_data_fsx(AOA)
if AOA >=8.8
hw_output_set(led_AOAhigh, true)
else
hw_output_set(led_AOAhigh, false)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Degrees", new_data_fsx)
I will be testing this out tonight and will post my results. Feel free to provide feedback as I continue development.
Thank you for all of your help!
Dan
1. Using only 1 argument in the callback (just 'AOA') instead of 3 arguments previously
2. Changed Radians to Degrees
3. Using "hw_output_add" & "hw_output_set" instead of "hw_led_add" & "hw_led_set" (I don't need to adjust LED brightness)
4. Removed the fixed AOA values previously called out
Focusing on just 1 LED for now (AOAhigh), I want the LED to turn On for values >=8.8, otherwise Off. My revised code is as follows:
led_AOAhigh = hw_output_add("ARDUINO_NANO_A_D6", true)
function new_data_fsx(AOA)
if AOA >=8.8
hw_output_set(led_AOAhigh, true)
else
hw_output_set(led_AOAhigh, false)
end
end
fsx_variable_subscribe("INCIDENCE ALPHA", "Degrees", new_data_fsx)
I will be testing this out tonight and will post my results. Feel free to provide feedback as I continue development.
Thank you for all of your help!
Dan