Commanche LVAR Offsets STEC Autopilot

Fly high, fast, and far in first class comfort
new reply
Glenn
Airman Basic
Posts: 9
Joined: 21 Feb 2018, 12:04

Commanche LVAR Offsets STEC Autopilot

Post by Glenn »

I could use some help with this as I've run out of ideas... basically, I'm trying to get LEDs to light depending on the autopilot mode selected, alt hold, for example, using MobiFlight but the pre-loaded preset Autopilot-Altitude Hold is obviously not the one being used by the Commanche STEC. I can set the mode using the LVARs and a physical switch (and confirm this on the VC) via FSUIPC

I know this works in principle because if you pick one of the generic FSUIPC functions like Pitot Heat from the MobiFlight drop down, the LED will light when I move the physical switch.

It looks like you can enter an offset value manually but I'm afraid I can't find a list of the offsets that the A2A Commanche LVARs use. Still very much a noob so any help gratefully received. Thanks

alioth
Senior Airman
Posts: 162
Joined: 01 Feb 2017, 17:05

Re: Commanche LVAR Offsets STEC Autopilot

Post by alioth »

Hi, I have made a physical Stec30 for my home cockpit. These are de Lvars I use:

Lights (only read variables)
L:ApTrimUpLight -- trim up light
L:ApTrimDnLight --trim down light
L:ApAltHold -- alt light
L:ApMode -- depending on this lvar value you know which mode is active so you switch on the light you need:
0:ready or Off
1:ST
2:HD
3:Trak Low
4:Track High or Power up sequence.

There are variables for each light, but they are not really needed if you play with the variables above. You can use them anyway. There are different ways to get it work:
ApAltLight, ApRdyLight, ApStLight, ApHdLight, ApTrkHiLight, ApTrkLoLight...


Buttons: (write on them)
ApTurnKnob -50 to 50
ApMaster 1 on, 0 off
ApDisconnectSwitch 1 to push, 0 to release
ApModePushSwitch 1 to push, 0 to release
ApAltSwitch 1 to push, 0 to release

A vid for my stec:

[youtube]http://www.youtube.com/watch?v=dLYafAxSRM0&t=10s[/youtube]

Arturo.

User avatar
Lewis - A2A
A2A Lieutenant Colonel
Posts: 33301
Joined: 06 Nov 2004, 23:22
Location: Norfolk UK
Contact:

Re: Commanche LVAR Offsets STEC Autopilot

Post by Lewis - A2A »

Thanks for popping in here alioth, I think any answer in here wouldn't be complete without a link to your build thread 8) 8)

Hope alioth has you covered there Glenn, I total recommend a go over his great Comanche simpit build thread that's under construction.

thanks,
Lewis
A2A Facebook for news live to your social media newsfeed
A2A Youtube because a video can say a thousand screenshots,..
A2A Simulations Twitter for news live to your social media newsfeed
A2A Simulations Community Discord for voice/text chat

Glenn
Airman Basic
Posts: 9
Joined: 21 Feb 2018, 12:04

Re: Commanche LVAR Offsets STEC Autopilot

Post by Glenn »

Hi Arturo,

Many thanks for your input. I'm probably still have a gap in my understanding of this but I suspect that I can't do this using MobiFlight as it's list of preset FSUIPC variables does not include these variables. As I said, within MobiFlight you can input an offset address and perform actions based on the value of it's contents. Each of these LVARS must have fixed offsets that they use and if could determine those, maybe I could do this using MobiFlight? My LUA skills are sparse to say the least so I'm a bit worried that may be the only way to go? Any pointers as to how you achieved this at a low level would be welcome.

{Lewis, thanks for your input. Any ideas?}

Many thanks

Glenn

alioth
Senior Airman
Posts: 162
Joined: 01 Feb 2017, 17:05

Re: Commanche LVAR Offsets STEC Autopilot

Post by alioth »

Let's try to switch on a led:

It is not vey difficult. But there are more involved components than you can think at first.
Using mobiflight is ok. I dont use it, but I know more or less how it works. It can not read custom lvars natively, so you need a small LUA script.

So, you need:

STEP 1.

LUA script that reads the lvar and puts the value in a custom offset (and offset is a memory direction where you can write and read bytes. You can use from 66C0 to 66FF)
When there is a change in the value of the custom lvar, the lua script reads the new value and write it in the offset:
if ApRdyLight = 1 then write 1 in 66C0 offset
if ApRdyLight = 0 then write 0 in the 66C0 offset.

The lua script will look like this. You will need to read and study fsuipc docs to fully understand:
function st30states (var, value)
ipc.writeUB(0x66C0, value)
end
event.Lvar("L:ApRdyLight", 500, "st30states")


--UB means Unsigned byte, and it is the size of the variable. One byte is (much more than) enough to store a 0 or 1.
-500 is the delay between readings the custom lvar to see if there ir a change, in miliseconds. so, 0.5seconds... enough for this.


STEP 2

-Mobiflight can read offsets! So, go to mobiflight, tell it to read the offset 66C0, with 1 byte size, and switch on/off a led depending of the offset value.

You have done it! congrats!



For buttons, the process is backwards:

1.- read the button with mobiflight, and put it in a free offset
2.- with a lua script, read the offset value and write the needed custom lvar

In this case, the lua script will look like this:

function APpowerSwitch(offset, value)
ipc.writeLvar("ApMaster", value)
end
event.offset(0x66C1, "UB", " APpowerSwitch")




Try one led, when works, try a switch, when works, try a push button...
Don't try to make everything at once. This is not the way to go.
You need small winnings in ths most simple things first.

Arturo.

Glenn
Airman Basic
Posts: 9
Joined: 21 Feb 2018, 12:04

Re: Commanche LVAR Offsets STEC Autopilot

Post by Glenn »

Thanks Arturo,

I'll give it a go! I have tried to write the Lua after looking at other examples but it didn't seem to work. I monitored 66C0 but it wasn't getting updated. I then used the FSUIPC built in facility to set the 66C0 offset to 1 and hey presto, it worked... and I got the led to light via MobiFlight so I can only assume that there was something wrong with my Lua script. However I'll try your suggestion which I'm sure will be great! If I do manage to get that working, is there anyway of getting the script running in the background so the offsets are constantly being monitored and the offsets updated as the various AP modes are selected?

Many thanks for your help Arturo, much appreciated.

Glenn

Glenn
Airman Basic
Posts: 9
Joined: 21 Feb 2018, 12:04

Re: Commanche LVAR Offsets STEC Autopilot

Post by Glenn »

Hi Arturo,

I think I've answered that one myself ! [Auto] section of FSUIPC.ini?

Cheers

alioth
Senior Airman
Posts: 162
Joined: 01 Feb 2017, 17:05

Re: Commanche LVAR Offsets STEC Autopilot

Post by alioth »

Glenn wrote: If I do manage to get that working, is there anyway of getting the script running in the background so the offsets are constantly being monitored and the offsets updated as the various AP modes are selected?

Yes, this is the way the scripts work. The script is running in memory, and everytime and offset change, the function of the script is called and do whatever you have coded (write and lvar, for example).

It is posible you are having problems to make the scripts start.

You must create a new file with the script with "lua" extension, and put it in the Modules folder of your folder simulator.
To launch the script, you can:
1.- assign a button or keystroke in the fsuipc utility inside de simulator.
2.- edit a run.lua file in the modules folder, so everytime the simulator loads, the script starts to work.
3.- edit fsuipc.ini

You can find how to do this in fsuipc docs.

Arturo.

new reply

Return to “Piper Comanche 250”

Who is online

Users browsing this forum: No registered users and 6 guests