Simulating Artex ELT functions

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Message
Author
JackZ
Posts: 2183
Joined: Mon Feb 22, 2016 1:02 pm

Re: Simulating Artex ELT functions

#11 Post by JackZ »

Felt a bit guilty of dismissing your findings about the sequence, so here's my catch at it.
The code either flashes continuously the led and sound if switch is set to ON, or it launches the selftest sequence if the switch is brought back to ARM within 1 second after being set to ON (as per the manual)
Notice the use of hw_switch_add() here

Code: Select all

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



------------------ blinking state when ON -----------------
blink=true -- status of the led (ON or off)
beep_is_on=false -- state of the beacon

function blink_callback()
    blink=not(blink) -- every time the function is called the state of the LED is changed
    if beep_is_on then
    	hw_output_set(LED, blink)
    	sound_play(Beep)
    else
    	hw_output_set(LED, false)
   	sound_stop(Beep)
    end
end
    
tmr_blink=timer_start(0,250,blink_callback) -- always on timer for blinking sequence

-------------------------self test sequence if switch ON then OFF under 1 sec-----------
function self_test()
    test=false
    if beep_is_on==false then -- the switch has been brought to ARM, we initiate the self test sequence
    	print("test")
    	timer_start(0,1000,4, function()
    	test=not(test)
    	hw_output_set(LED, test) -- alternates ON/OFF 4 times within 4 seconds (two seconds total)
    	if test then 
    	        sound_stop(Beep)
        	sound_play(Beep)
    	end
    	end) -- timer
    end       
end

function input_change (state)
   print(state)
  if state == 1 then-- Switch moved to "On"
     beep_is_on=true -- we start blinking and sound
     timer_start(1000,self_test) -- we check after 1 second whether the switch is back to ARM (beep is --> self test sequence     
  else -- The switch is back to ARM
      beep_is_on=false
  
  end       
end

inp_id = hw_switch_add("ELT Switch", 2,input_change)
Jacques
Last edited by JackZ on Thu Jun 16, 2022 4:45 am, edited 2 times 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
Keith Baxter
Posts: 3779
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Simulating Artex ELT functions

#12 Post by Keith Baxter »

Cousin Jacques,

Line 9
blink=true status of the led (ON or off)
has the missing --causing an error.

Also would be nice if the .wav file was included. This missing wav file causes, when testing, an error and never to load the hardware switch.

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
pkwaite
Posts: 11
Joined: Sun Dec 09, 2018 4:24 am
Location: Smithfield, VA, USA

Re: Simulating Artex ELT functions

#13 Post by pkwaite »

Thank you all for your interest and input.

@Keith Baxter I set up a Discord account but I think I can work through this with a few nudges (or a couple of large whacks!) in the right direction. I'll keep the offer in my back pocket if I should need it.
Also would be nice if the .wav file was included.
I'm sure that you are aware that any wav file renamed to "beep.wav" and placed in the resource folder will do, so, just think, you could groove to [insert favorite band here] while waiting to be rescued! Now why didn't Artex think of that??

@JackZ thank you for pointing out the error of my ways! I'm truly embarrassed that I misinterpreted the YT video--and I was so proud of myself, too! But I am also ashamed to admit that I did peruse the manual and apparently skimmed right by the self test error codes! Oh well, it certainly isn't the first thing that I have redone on this simulator project and probably won't be the last! Twice the fun, right?

And there was no need to feel guilty but I do appreciate the work you put in with the code. I will give a try and get back to you all.
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
jph
Posts: 2099
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Simulating Artex ELT functions

#14 Post by jph »

pkwaite wrote: Wed Jun 15, 2022 1:31 am
Also would be nice if the .wav file was included.
I'm sure that you are aware that any wav file renamed to "beep.wav" and placed in the resource folder will do, so, just think, you could groove to [insert favorite band here] while waiting to be rescued! Now why didn't Artex think of that??
I can think of some better error messages than a beep or series of ................... ;)
Some are also totally universal / multilingual.. certain 'words' are understood in any country . :lol:
“Everything in moderation, including moderation.”
“Experience is merely the name men gave to their mistakes.”
Joe (CISSP) -IT security consultant

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

Re: Simulating Artex ELT functions

#15 Post by pkwaite »

certain 'words' are understood in any country
How touching, Joe! Que music: "Love In Any Language" . . . that IS what you meant, right Joe? . . . right?? :lol:

Jacques, you've brought me back to my flight school days when my instructor would pull a circuit breaker or some other devious deed just to see if I would catch it in the preflight. Your code didn't run for me at first so it forced me to really concentrate on the composition -- remember, I'm while I am beginning to enjoy the coding process it is still a very new environment for me. Once changing "beep" to "beep_is_on" on lines 14 and 28 it works! So, whether intentional or not, you really made me think it through rather than just copy, paste, move on . . .

I have to wait to get home this afternoon to try it with the Arduino. I'll let you know if I have any issues with the hardware attached. But thanks again for all the help.
Paul Waite
Virginia, USA

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

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

Re: Simulating Artex ELT functions

#16 Post by JackZ »

Well the missing « _is_on » was an afterthought.

This was a quick and dirty (mostly dirty) code I didn’t took the time to really curate to its finest. Upon reading my post, I figured it would be best to have a more meaningful variable name than a simple name such as « beep », and instead of modifying the code in AM, test and then copy/paste, I modified the code directly in the message.

Wrong move, but I’m glad I did it, like this you had to dive and try to understand the code rather than using it as is.

Of course my own test instrument had no wav file attached for the beep sound, so when run on my PC I got runtime errors, so as I said my code is not thoroughly tested. The idea being for you to get the gist of it, and I’m glad you did.

Thanks for you kind words, appreciated.
I am sometimes fed up with people crying for help on this very forum, and who don’t even bother to say thank you once satisfied. Call me old school if you wish, but…

Jacques

Could you post here your wav.file for the sound please?
Last edited by JackZ on Wed Jun 15, 2022 5:39 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

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

Re: Simulating Artex ELT functions

#17 Post by JackZ »

Keith Baxter wrote: Tue Jun 14, 2022 10:14 pm Cousin Jacques,

Line 9
blink=true status of the led (ON or off)
has the missing --causing an error.

Also would be nice if the .wav file was included. This missing wav file causes, when testing, an error and never to load the hardware switch.

Keith
Yes I know, I hadn’t any wav file to use for this test, but the OP code included one so I kept it as it.

I have asked the OP to publish his sound file to further my code testing.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

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

Re: Simulating Artex ELT functions

#18 Post by pkwaite »

Beep.txt
(1.12 MiB) Downloaded 15 times
Call me old school if you wish, but…
I am with you 100% there, Jacques! Old school by age and attitude . . .

And I had to chuckle at your code being "quick and dirty" because at this stage mine is "slow and messy"!

Now if I could just figure out how to upload a file . . . something about old [school] dogs and new tricks comes to mind!!

The file is attached! And just for future reference to all who follow here: uploading WAV files is not allowed on the forum. The work around is to change the extension to TXT. After downloading simply rename the file to Beep.wav and you're good to go!

Paul
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
pkwaite
Posts: 11
Joined: Sun Dec 09, 2018 4:24 am
Location: Smithfield, VA, USA

Re: Simulating Artex ELT functions

#19 Post by pkwaite »

On second thought . . .

I wasn't happy with the sound file that I uploaded earlier. There seemed to be a dead spot in the playback at the beginning of the file and when AM looped the clip at 250ms intervals it sounded more like chirping rather than a continuous beep. I tried another audio file that I had and it sounded much better. It loops seamlessly, emitting a continuous tone. It is also a higher frequency which more closely matches the tone in the Artex video. I'm not sure if the discontinuous/choppy playback is machine dependent?? I found that adjusting the interval would make the second file sound choppy, too. 250ms seems to be the sweet spot on my machine for that sound file. I'll share the second sound file here if anyone is interested.

Anyway, I'm pleased to report that the code works as intended with the hardware. The problem that I had with my code running when the panel loaded is not an issue with Jacques' code. Nice!

Beep-02.txt
(51.4 KiB) Downloaded 15 times
Paul Waite
Virginia, USA

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

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

Re: Simulating Artex ELT functions

#20 Post by JackZ »

Glad you had it working as intended.

Continuing with the « as real as it gets » dream chase, to be fair, the five additional beep/blink sequence should nonetheless be played IF the self test is conducted with the GPS off.

This as in that case no NMEA data is transmitted to the ELT, by the GPS,NMEA data that is namely the plane’s location and a unique identifier that is included in the message data that is sent over the 406Mhz distress signal for the SARSAT-COSPAS satellite network to catch and forward to the SAR authorities.
That’s the reason why the YT video of the ELT test shows the five beep sequence, probably because the Avionics master is not ON in the Aircraft.

So to be as accurate as possible there should be another bit of code for the self test result that should blink five times if ever the GPS is unavailable, ie either the Avionics Master is OFF (the sim state should be queried) or the GPS is off.

You said “obsessed with details”?
Me? Noooo….
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply