Simulating Artex ELT functions

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
User avatar
pkwaite
Posts: 11
Joined: Sun Dec 09, 2018 4:24 am
Location: Smithfield, VA, USA

Simulating Artex ELT functions

#1 Post by pkwaite »

Hello SI community! First a (re)introduction: Back in 2018 I began to build a C172 simulator cockpit with AM in mind and due to many of life's interruptions it has progressed at a glacial pace. The physical panel is finally nearing completion and I have begun adding the hardware to my custom Air Manager panel. I have had to adapt some of the instrument and hardware coding, which is new to me and I, like so many others, have really struggled to get a grasp on Lua to get the results I expect. But with the help of Tony's and Russ' YT videos, the WIKI, many Google searches, and the very helpful information found here in the forum (Thank You!) I am super pleased with how things are coming along. My attention at present is on the Artex ELT panel switch and simulating its functions. It won't actually interact with the simulator (X-plane) but I still want it to look and behave authentically as is depicted in this YT video:

[youtube]https://www.youtube.com/shorts/XwgmqtrSQyc[/youtube]

I have successfully written code that controls an LED and wav file at the appropriate sequences in response to the switch positions. Though it may not be pretty in the eyes of a programmer . . . it works . . . mostly! Consequently, there are a couple of issues that I am in need of help with. The first question regards the possibility of suppressing the coded functions initially when the ELT hardware loads with the panel.

The functions are programmed to be triggered by the movement of the switch and in the Create/Edit tab in AM everything works exactly as intended. After clicking on Run nothing happens until I click on the lightbulb depicting the input from the switch. This is how it should be, however, when I connect the Arduino (Mega 2560), with the switch (SPST) and the LED (with resister) load the panel it detects the position of the switch and runs through the series of beeps and blinks associated with the present position of the switch. This does not happen IRL.

In the grand scheme of things this is not a HUGE deal but I don't understand why it is happening (although it may be blatantly obvious to you coding wizards!) and I'd like to resolve it if possible. My understanding of using "input_change (state)" is that it would only trigger when AM detects MOVING the switch and thus CHANGING the state but it is also triggering the function when the panel is loaded and the state of the switch is first read. Why does it only happen with the hardware connected but not in Create/Edit and is there a way to keep it from running the function initially on start up?

Thanks, in advance, for any help!

Paul

Code: Select all

-- Load sound
    Beep = sound_add("beep.wav")
-- Add LED, extinguished
    LED = hw_output_add("ELT LED", false)

function input_change (state)
-- Switch moved to "On"
  if state == true then
     
--Stop any active running timers     
     print("SWITCH MOVED TO ON")
     if timer_running(Long_Blink) then
         timer_stop(Long_Blink) end
     print("Long_Blink Timer Stopped")
     if timer_running(Long_Blink_Out) then
         timer_stop(Long_Blink_Out)end
     print("Long_Blink_Out Stopped")    
     if timer_running(Four_Blink) then
         timer_stop(Four_Blink) end
     print("Four_Blink Stopped")
     if timer_running(Four_Blink_Out) then
         timer_stop(Four_Blink_Out) end
     print("Four_Blink_Out Stopped")    
     if timer_running(First_Beep) then
         timer_stop(First_Beep)end
     print("First_Beep Stopped")
     if timer_running(First_Beep_End) then
         timer_stop(First_Beep_End)end
     print("First_Beep_End Stopped")
     if timer_running(Second_Beep) then
         timer_stop(Second_Beep)end
     print("Second_Beep Stopped")
     if timer_running(Second_Beep_End) then
         timer_stop(Second_Beep_End)end
     print("Second_Beep_End Stopped")
     if timer_running(Third_Beep) then
          timer_stop(Third_Beep) end
     print("Third_Beep Stopped")     
     if timer_running(Third_Beep_End) then
          timer_stop(Third_Beep_End) end
     print("Third_Beep_End Stopped")
     if timer_running(Fourth_Beep) then
          timer_stop(Fourth_Beep) end
     print("Fourth_Beep Stopped")
     if timer_running(Fourth_Beep_End) then
          timer_stop(Fourth_Beep_End) end
     print("Fourth_Beep_End Stopped")
     if timer_running(Fifth_Beep) then
          timer_stop(Fifth_Beep) end
     print("Fifth_Beep Stopped")
     if timer_running(Fifth_Beep_End) then
          timer_stop(Fifth_Beep_End) end
     print("Fifth_Beep_End Stopped")
     
-- Fast flash LED, play wav file continuously     
     sound_play(Beep)
     Blink_Timer = timer_start(nil, 190, function(count)
           hw_output_set(LED, count%2 == 0)
           end)

-- Switch moved to "Arm"
  elseif state == false then
   
         print("SWITCH MOVED TO ARM")
-- Stop fast blink timer and stop playing wave file
          if timer_running(Blink_Timer) then
           timer_stop(Blink_Timer) end
         print("Blink_Timer Stopped")  
         sound_stop(Beep)
         print("Continuous Beep Stopped")

-- Timers set for LED and wav file to simulate ELT TEST mode
         function long_blink(count, max)
         hw_output_set(LED, true)
         end
         Long_Blink = timer_start(0, 1000, 1, long_blink)
          
         function long_blink_out()
         hw_output_set(LED, false)
         end
         Long_Blink_Out = timer_start(1000,0,1,long_blink_out)
              
         function four_blink(count, max)
         hw_output_set(LED, count%2 == 0)
         print("Blink " .. count .. " of " .. max)
         end
         Four_Blink = timer_start(1000, 350, 10, four_blink)
            
         function four_blink_out()
         hw_output_set(LED, false)
         end
         Four_Blink_Out = timer_start(6200,0,1,four_blink_out)
          
         function first_beep()
         sound_play(Beep)
         end
         First_Beep = timer_start(1350,first_beep)
          
         function first_beep_end()
         sound_stop(Beep)
         end
         First_Beep_End = timer_start(1700,first_beep_end)
          
         function second_beep()
         sound_play(Beep)
         end
         Second_Beep = timer_start(2050,second_beep)
               
         function second_beep_end()
         sound_stop(Beep)
         end
         Second_Beep_End = timer_start(2400,second_beep_end)
     
         function third_beep()
         sound_play(Beep)
         end
         Third_Beep = timer_start(2750,third_beep)
         
         function third_beep_end()
         sound_stop(Beep)
         end
         Third_Beep_End = timer_start(3100,third_beep_end)
         
         function fourth_beep()
         sound_play(Beep)
         end
         Fourth_Beep = timer_start(3450,fourth_beep)
     
         function fourth_beep_end()
         sound_stop(Beep)
         end
         Forth_Beep_End = timer_start(3800,fourth_beep_end)
     
         function fifth_beep()
         sound_play(Beep)
         end
         Fifth_Beep = timer_start(4150,fifth_beep)
     
         function fifth_beep_end()
         sound_stop(Beep)
         end
         Fifth_Beep_End = timer_start(6200,fifth_beep_end)
     
  end
end


inp_id = hw_input_add("ELT Switch", input_change)
state = hw_input_read(inp_id)

Paul Waite
Virginia, USA

I don't care what the aerodynamicists say . . . every takeoff is a miracle. And so were most of my landings!

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

Re: Simulating Artex ELT functions

#2 Post by Keith Baxter »

Hi,

The hardware state is always alpha. But that does not mean that the sim reads your code in AM on first pass. You have to write the hardware state to the sim on startup.

I am prepared to assist with this in the Discord. The link can be found here.
https://www.forums.siminnovations.com/v ... 927#p33927

I will point you in a more simpler way of achieving what you want in about 30 - 50 odd lines.

Keith
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 

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

Re: Simulating Artex ELT functions

#3 Post by JackZ »

Once finished with Discord, would you mind publish the resulting code with your version?. For the post to be complete for any person searching for a solution simulate to this one.

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

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

Re: Simulating Artex ELT functions

#4 Post by Keith Baxter »

JackZ wrote: Tue Jun 14, 2022 6:25 pm Once finished with Discord, would you mind publish the resulting code with your version?. For the post to be complete for any person searching for a solution simulate to this one.

Thanks
Jacques
Sure my cousin.
All interested are welcome to pop in and follow on the discord. The discord and it"s public channels and threads are open to all.

A quick thought for direction, would be using tables for one timer.



Keith
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
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Simulating Artex ELT functions

#5 Post by jph »

JackZ wrote: Tue Jun 14, 2022 6:25 pm Once finished with Discord, would you mind publish the resulting code with your version?. For the post to be complete for any person searching for a solution simulate to this one.

Thanks
Absolutely agreed.
Joe. CISSP, MSc.

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

Re: Simulating Artex ELT functions

#6 Post by Keith Baxter »

jph wrote: Tue Jun 14, 2022 6:49 pm
JackZ wrote: Tue Jun 14, 2022 6:25 pm Once finished with Discord, would you mind publish the resulting code with your version?. For the post to be complete for any person searching for a solution simulate to this one.

Thanks
Absolutely agreed.
Joe,

Just for you brother, I will make sure I post a Discord link to the outcome. All files and chat will be available for comment. HaHa :lol:
I have a sadistic scene of hummer not. ;)

All my help and code is opensource to all privet AM users.

Keith
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 

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

Re: Simulating Artex ELT functions

#7 Post by JackZ »

Well....

Sorry to be the bearer of bad news (kinda), but unless I'm mistaken, I'm afraid that the sequence of beeps you programmed for the ELT Self test are wrong from the beginning. Saying that of course regarding the "true to life" behaviour of the ELT you're after OFC.

I had a look at your YT video you published as a reference and found it weird that the test was that long and so noisy.
Didn't recall that lengthy led blinking sequence on the ELT ARTEX equipped planes I flew with.

So I went on and searched for the ARTEX ELT 345 Manual and Bingo!
5 beeps are an error code for "NO navigation data" as per the manual. Not a standard successful selftest sequence

her's an excerpt of the manual
ARTEX PRODUCTS / ACR ELECTRONICS, INC.
DESCRIPTION, OPERATION, INSTALLATION AND MAINTENANCE MANUAL
ELT 345 (P/N: A3-06-2880)
Y1-03-0282 Rev. P Company Confidential 25-62-35 Page 32 of 59
Table 6 Self-test Error Codes
BEEPS &
FLASHES TEST RESULTS INDICATION
1 System OK One pulse two seconds long of the status LED, remote
light, and buzzer. This pulse is suppressed if problems
are found during self-test.
2 Code not used in the ELT 345
3 Code not used in the ELT 345
4 Low output power
Bad load or faulty ELT 1) Terminate antenna cable at antenna
connection end w/50Ω load. Repeat self-test.
If error clears, proceed to step 3).
2) Terminate ELT output w/50Ω load. Repeat
self-test. If error persists, return to factory for
servicing – cannot field repair. If error clears,
replace antenna cable.
3) Check coax cable and connectors for shorts
and opens, bad center pin, etc. Disconnect,
then reconnect cable. Repeat self-test.
4) Check antenna ground for low resistance
(should be <100 m Ω)
5) Antenna should be 3’ away from any vertical
metal.
6) Have antenna checked by factory.
5 No position data present (long message protocol only. Error is suppressed for short
messages)
Aircraft navigation system “OFF” Turn on navigation system.

Verify that ELT and navigation system baud rates
match. NMEA baud is 4800, AB Protocol baud is 9600.
Faulty system interface wiring or
connections.
Check integrity of wiring and connections
6 G-Switch loop between pins 5 and 12 is not present
Jumper open Verify D-Sub receptacle jumper is installed by
checking for less than 1Ω between pins 5 and 12.
Repair as necessary.
NOTE: When the installed jumper is removed, wait
at least 60+ seconds before a test is done to get a
G-switch ‘open’ on the Self-Test (6 flash error)
Jumper missing Install G-switch enable jumper between pins 5 and 12
in D-Sub harness receptacle.
7 Battery Check
Battery operating time is > 1 hr Replace battery pack
Battery voltage low Replace battery pack
Battery memory read-write error Repeat self-test. Replace battery pack if 7-flash
persists.
8 Protocol programming data
Missing data such as ELT S/N or
aircraft tail number
ELT requires reprogramming w/appropriate data
So the YT video illustrates a very specific error code when the GPS is not turned ON when the self test is performed.

Usually the result of a Self test is 1 beep & flash over a duration of two seconds, that's it.
Perform a self-test by moving the switch to “TEST”, then release. (Cockpit remote switch to the “TEST”
position.)
7) Listen for 2 audible sweeps on the receiver, which takes about 1 second.
8) Verify the buzzer sounds upon activation.
9) Note the LED activity on the cockpit remote switch. If the ELT is working properly, the LED will stay on for
approximately 1 second and then turn OFF.
NOTE: This test also completes the requirement to check ELT controls by verifying operation of the
remote switch.
10) Refer to Table 6 if the LED displays error code flashes.
To sumup, your code can be way simpler since the code sequence is simpler.

And for the sake of realism, remember that IRL, you are supposed to perform self test during the first five minutes of every hour ONLY, in order not to drag all the SAR forces looking for your signal.
Last edited by JackZ on Tue Jun 14, 2022 9:33 pm, edited 1 time in total.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

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

Re: Simulating Artex ELT functions

#8 Post by jph »

Keith Baxter wrote: Tue Jun 14, 2022 8:14 pm
jph wrote: Tue Jun 14, 2022 6:49 pm
JackZ wrote: Tue Jun 14, 2022 6:25 pm Once finished with Discord, would you mind publish the resulting code with your version?. For the post to be complete for any person searching for a solution simulate to this one.

Thanks
Absolutely agreed.
Joe,

Just for you brother, I will make sure I post a Discord link to the outcome. All files and chat will be available for comment. HaHa :lol:
I have a sadistic scene of hummer not. ;)

All my help and code is opensource to all privet AM users.

Keith
Absolutely not interested in ANY dicard links. Never will be. I keep telling you that. Your keeness to drag people over to your kingdom is getting a tad 'evangelical ' like a Jehova's Witness touting for custom. :lol: quite unbelievable really. I am personally not in the slightest way interested in your code, I am interested in keeping these forums sensible and logical for users.
Joe. CISSP, MSc.

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

Re: Simulating Artex ELT functions

#9 Post by Keith Baxter »

JackZ wrote: Tue Jun 14, 2022 9:02 pm
To sumup, your code can be way simpler since the code sequence is simpler.
Yes cousin Jacques. As I thought on first read of the code.

You are one of the best at manipulating tables and quickly spotted what thought.

Keith.
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
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Simulating Artex ELT functions

#10 Post by Keith Baxter »

jph wrote: Tue Jun 14, 2022 9:25 pm
Absolutely not interested in ANY dicard links. Never will be. I keep telling you that. Your keeness to drag people over to your kingdom is getting a tad 'evangelical ' like a Jehova's Witness touting for custom. :lol: quite unbelievable really. I am personally not in the slightest way interested in your code, I am interested in keeping these forums sensible and logical for users.
Joe,

Do you have any idea how many Discords out there are helping Air Manager users? I suspect that you think Air Man is the only one.

The AM guys are all over watching Discord channels. They simply do not have the time to run one themselves.

Have you noticed the decline in forum posts. That is because peeps get 1 on 1 help and friendly advice within the Discords.

I have not dragged anyone over to Discord. Peeps have found a happy place over there and a lot of amazing instruments and ideas are shared.

But hay, The steam train still works and the type writer still types, not many use them today.


Keith
Last edited by Keith Baxter on Tue Jun 14, 2022 10:02 pm, edited 1 time in total.
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 

Post Reply