Simulating Artex ELT functions

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

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

Re: Simulating Artex ELT functions

#21 Post by jph »

Hi,
Being pedantic, :) (probaby I just misinterpreted what you wrote), but the NMEA protocol does not have a unique identifier that can be used for system or device ID. It is the ELT itself that has a the unique identifier and registration with the appropriate authorites. The NMEA protocol does uses sentance identifiers, but that is only for the data type following. A very simple but extremely useful and robust standard.
Pedantic attention to detail hat off lol :D
And I fully agree, you must have the error messages that can be simulated.
Joe
Joe. CISSP, MSc.

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

Re: Simulating Artex ELT functions

#22 Post by JackZ »

@jph you’re right I was oversimplifying it.
The unique ID is programmed into the ELT itself, and added to the GPS’s position in the distress signal sent, probably along with some other infos that I am not aware of.
The GPS communicates with the ELT via a cable and data is sent using the NMEA protocol, a standard.

This ID code identifies the aircraft the ELT is currently installed in, and is duly registered. The addition of a 406Mhz coded signal with location and aircraft identification, broadcast to a dedicated satellite network in case of emergency is quite an improvement over the mere “beep beep” provided by the earlier 121.5 signals of the first generations of ELT beacons. Even though the modern ELT still produce this signal.
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

#23 Post by jph »

Great description Jacques.
Yes, the system is operatioally analogous to our yachting EPIRB. We used a superb GME unit for 10 years. Built in GPS but on a yacht they are not 'on' as standard. They are manual and water activated and use the exact same comm net on 406 and even 121.5. UID data along with gps is sent on 406 UHF but 121.5 airband VHF is uncoded and designed to be a DF signal only. Remarkable kit. Bit of a price difference to aircraft ones :o yet basically same tech apart from power sources.
Registration was with OFCOM in the UK and also the Coastguard. I believe aircraft are ofcom and CAA same as DGAC /CAA. the same international main databases are used for all uses , air sea and land.
Joe
Joe. CISSP, MSc.

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

Re: Simulating Artex ELT functions

#24 Post by JackZ »

Here's the new version, with both error codes (2 and 5 flashes)available.
I query the state of the avionics bus and act accordingly during the selftest sequence.
The same principle can be applied to other error codes if you feel inclined so, but that's probably overkill, so I'm out for now.

Code: Select all

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

------------------ status Variables --------------------------
avionics_is_on=false -- state of the avionics bus
code_number=2 -- default selftest code result (2: Ok, 5: GPS data is missing)

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

function blink_callback()
    blink=not(blink)
    if beep_is_on then
        hw_output_set(LED, blink)
        sound_stop(Beep)
        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
    if avionics_is_on then
            code_number=2 -- 2 flashes over 2 seconds (ie 4 on/off cycle)
        else
            code_number=5 -- 5 flashes over 5 seconds (ie 10 on/off cycle)
    end
    print("Self test")
    timer_start(0,1000,code_number*2, function()
    test=not(test)
    hw_output_set(LED, test) -- alternates ON/OFF 4 times within 4 seconds (two seconds total)
    if test then 
        print("ON")
        sound_stop(Beep)
        sound_play(Beep)
    else
        print("OFF")
    end
    end)
end
        
end

function input_change (state)
print(state)
-- Switch moved to "On"
  if state == 1 then
     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

--- Hardware Switch
inp_id = hw_switch_add("ELT Switch", 2,input_change)

-- This function will be called when new data is available from X-plane
-- requests the state of the avionics bus
 function avionics_callback(avionics_on)
   if avionics_on==1 then
              avionics_is_on=true 
         else
              avionics_is_on=false
          end
 end

 -- subscribe X-plane datarefs on the Avionics bus
 xpl_dataref_subscribe("sim/cockpit/electrical/avionics_on", "INT", avionics_callback)
 
 request_callback(avionics_callback) -- forces at least one query of the avionics status at startup of the instrument
 
Btw with the sound file, the result is great.
I added a sound_stop() just before the sound_play(), to make sure the sound effectively stops in between two flashes

Jacques
Last edited by JackZ on Wed Jun 29, 2022 4:27 am, edited 3 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
pkwaite
Posts: 11
Joined: Sun Dec 09, 2018 4:24 am
Location: Smithfield, VA, USA

Re: Simulating Artex ELT functions

#25 Post by pkwaite »

Great work, Jacques! Adding the GPS out error code was a sweet bonus. Once again, I appreciate your work. A working ELT switch will be a very nice addition to my panel and hopefully others will benefit from the code as well.

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

#26 Post by pkwaite »

So . . . I finally got a chance to try Jacques' latest code with the hardware attached and sim running. Everything works correctly in AM's create/edit tab with the hardware attached. But when the ELT hardware loads with my AM C172 panel the ELT returns the 5 sequence error code (GPS off) no matter whether the avionics switch is in the on or off position. Just FYI, I have had no issues with AM/Arduino interacting with X-plane with any other hardware I have tested (i.e., flap lever, wet compass, etc.). It appears that the dataref subscribe is being ignored?? Any thoughts of why this might be the case?

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!

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

Re: Simulating Artex ELT functions

#27 Post by JackZ »

Hmmm. This one’s on me I’m afraid.
I was kinda mixing up the type of data returned by the sim between P3D and XPlane. In XPlane there is no Boolean type for data (ie true/false), but integer only (1/0). Sorry about that.

Could you replace the bottom part of the code by this one?
This should hopefully fix the problem.

Code: Select all

-- This function will be called when new data is available from X-plane
-- requests the state of the avionics bus
 function avionics_callback(avionics_on)
   if avionics_on==1 then
         avionics_is_on=true 
else
         avionics_is_on=false
end

 end

 -- subscribe X-plane datarefs on the Avionics bus
 xpl_dataref_subscribe("sim/cockpit/electrical/avionics_on", "INT", avionics_callback)
 
 request_callback(avionics_callback) -- forces at least one query of the avionics status at startup of the instrument
 
Not tested at all, as mentioned elsewhere, My PC gave up on me a few days ago and was sent back for repairs ATM.

The code in the original post has been modified as well
Last edited by JackZ on Wed Jun 29, 2022 4:21 am, edited 3 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
pkwaite
Posts: 11
Joined: Sun Dec 09, 2018 4:24 am
Location: Smithfield, VA, USA

Re: Simulating Artex ELT functions

#28 Post by pkwaite »

Thanks Jacques! Once again the snag in the code really made me dig in to understand things a little better; this time on the different types of X-plane datarefs. And, as it turns out, I was on the right track . . . but couldn't quite fill the gap between what I knew and what I didn't know. I'll give it a try when I get home tonight.

Hope you get your computer back soon!

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

#29 Post by pkwaite »

Works great (with the one exception of "If" being capitalized in: "If avionics_on==1 then")!

Thanks again, Jacques!
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: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: Simulating Artex ELT functions

#30 Post by JackZ »

Nice catch!

I can say “thanks” to my iPhone, with its automatic spellchecker, that capitalizes automatically the first letter in every phrase you type.

This phone doesn’t know anything about Lua language apparently…. :lol:

I modified the code in my previous message, glad to see it worked at last.

When my PC is back I will create a standalone graphical instrument to complete the drill.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply