S-TEC AP Works with Arduino HW?

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Post Reply
Message
Author
bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

S-TEC AP Works with Arduino HW?

#1 Post by bmooneyhan »

C172 cockpit build.

Building a AP panel for my cockpit. I have board A, analog input A4 mapped to a pushbutton. I can see my Print "button-press and release" in the console when I press and release the button, but nothing happens on the AP panel
(the default S-TEC 55) in the game. I have many other controls working just fine, this one is stumping me. Any suggestions? Thanks in advance.


-- Start AP Buttons --

function ap_hdg_pressed(position)
print("The AP HDG switch got pressed ")
end

function ap_hdg_released(position)
xpl_dataref_write("sim/cockpit2/autopilot/heading_mode" , "INT",1)
print("The AP HDG switch got released ")
end
------- End AP Buttons ----

my_button = hw_button_add("ARDUINO_MEGA2560_A_A4", ap_hdg_pressed, ap_hdg_released)

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: S-TEC AP Works with Arduino HW?

#2 Post by SimPassion »

Hi @bmooneyhan , rather try with "sim/autopilot/heading" command which works

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: S-TEC AP Works with Arduino HW?

#3 Post by bmooneyhan »

Thank you for the reply. I'm trying to sort that out. Would this dataref "Heading" not be the actual heading as set on the bug, vs. enabling the AP to use that value in the first place? maybe I'm over-thinking it.

I was thinking like this:

1. Turn on AP.
2. Set "sim/cockpit2/autopilot/heading_mode" to INT, 1 which should be "heading sel".
3. Adjust the bug as needed.
4. When needed, set "sim/cockpit2/autopilot/heading_mode" to INT, 2 for nav, or 13 for GPS.

This would allow me 3 modes of lateral control, HDG BUG, NAV, and GPS.

Referencing this:
sim/cockpit2/autopilot/heading_mode int y enum Autopilot lateral mode. (0=roll, 1=heading sel, 2=nav, 10=TO/GA, 11=Re-entry, 12=Free, 13=GPSS, 14=heading hold, 15=turn-rate, 16=rollout, 18=track) Writeable with override only (sim/operation/override/override_autopilot)

Perhaps I have it all wrong, maybe?

Thanks

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: S-TEC AP Works with Arduino HW?

#4 Post by Sling »

You have it wrong. As Gilles @SimPassion replied, the best way is to use commands to change the autopilot mode. Many of the datarefs are useful for confirming via a display of some type that the sim has received the command and actioned it.

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: S-TEC AP Works with Arduino HW?

#5 Post by Ralph »

Setting autopilot modes through datarefs does not work (reliably). I have tried that route for the Flight Illusion hardware, but we gave up and had to make a firmware upgrade to make it work with commands.

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: S-TEC AP Works with Arduino HW?

#6 Post by bmooneyhan »

I understand. Thank you everyone for the help. I'll try not to return to quickly with more questions.

Buddy

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: S-TEC AP Works with Arduino HW?

#7 Post by SimPassion »

bmooneyhan wrote: Tue Feb 07, 2023 1:43 pm I understand. Thank you everyone for the help. I'll try not to return to quickly with more questions.

Buddy
No issue at all with questions, this is the way to go for clarifying. Good Air Manager discovery and handling !

Post Reply