Home Cockpit Hardware, FBW A320NX or Fenix A320, SimConnect and wasm - some help needed

I’m building my own home cockpit. I’m still in study phase. In the intro of the post here you can read what I have achieved so far.

I’m currently using FSX with the Jeehell A320 FMGS add-on. But I want to make the step to FS2020. Unfortunately, this add-on is not available on FS2020, so I have to look for another realistic A320 simulator. I’m impressed by FBW A320NX, which is even a free add-on. I’m also curious what the Fenix A320 will give once it is released (no date yet).

On the Jeehell A320 FMGS I had a nice SDK that allowed me to control the plane without the need of SimConnect. But when I want to use FBW A320NX, it’s time to acquire some knowledge on SimConnect, wasm, etc… I guess that the same will be required for Fenix A320. Or do these add-on creators also provide some proprietary SDK like Jeehell A320 FMGS?

I have found a lot of interesting articles on this forum, that explain in full detail how to deal with LVARs, HVARs, etc… See https://forums.flightsimulator.com/t/demo-lvar-write-access-for-any-aircraft-control/353443?u=hbilliet or https://forums.flightsimulator.com/t/lvar-read-and-write-through-custom-simconnect-events/389334?u=hbilliet for some good starting points.

The reason why I start this post is because I’m sure that there are a lot of cockpit builder hobbyists out there that, just like me, do a lot of reading, but are a bit lost in all the information. The reason is that a lot of information is not relevant for us. So I want to limit the scope.

I only need the knowledge on how to control a “non-native FS2020 airplane”. I don’t need to know anything about making my own airplane, adding scenery, interact with external stuff, etc… I think that already limits the study to only being able to connect with SimVars, LVARs and HVARs. Is that correct?

I make my own proprietary hardware based on a PIC microcontroller connected via USB. I don’t want to use tools like MobiFlight, FSUIPC, etc… because I prefer to build my tools myself (I don’t say that these tools are bad - in the contrary - but I just like to write software and have control myself). I’m used to work in C# using Visual Studio 2019. But for my PIC-controller using the MPLAB compiler I have to use C. Although I haven’t used it a long time, I have knowledge of C++ as well. So everything that starts with a C is fine for me (Chocolate as well :slight_smile:)

Based on the above scope, is the following correct? Here some feedback would be really appreciated.

  • Controlling non native FS2020 airplanes means I need to work with LVARs and HVARs. LVARs are the “Local” variables, means that these are “local” in the add-on airplane, and are fully defined by the creator of the add-on (FBW for example has information of that on their website Redirecting.... ) But this article also speaks about “Custom Events”. Is that what we call HVARs?
    Question1: Is the above correct?
    Question2: Can somebody explain me a bit more what HVARs are? Or what are these Custom Events?
    Question3: Am I correct that these are the only things needed - or do I need more?

  • I am obliged to use wasm, because that’s the only way to get in touch with LVARs and HVARs. SimConnect doesn’t give the possibility to connect with these variables.
    Question: Is this correct?

  • I also need SimConnect, because that is needed to allow wasm to connect with FS2020.
    Question: Is this correct?

  • I also need SimConnect to connect with SimVars, which are simulation variables available in FS2020. I don’t need to know anything about weather, position, etc… because I only want to interact with the airplane. But other variables might be neccessary like the status of the game (started, running, …), etc…
    Question: Is this correct?

  • My application is talking to both wasm and SimConnect. For this, there will be 2 callback functions with specific signatures.
    Question: Is this correct?

1 Like

So before we go any further, let this be clear:
Variables are data you get from the running sim
Events are data you send to the sim, which mostly cause some variables to change.

  1. Not quite: L:Vars and H:Events - SPAD.neXt

  2. HEvents are defined by the developer which are outside the scope of the default variables (which are accessible by SimConnect)

  3. No, you also need SimConnect for the default variables and events.

  4. Correct, for accessing L:Var and H:Events you need a WASM module

  5. Correct. Apart from sim status, basically al normal variables are available through SimConnect. I would go as far saying you can create a home cockpit for 95% with only SimConnect.

  6. Correct. For an example C# implementation, click here.
    For a list of available SimConnect variables click here.
    For a list of SimConnect events click here.

Being a 25+ year experienced developer myself, I fully understand that you like to program stuff yourself. However, I would personally never undertake the endeavor of coding a home cockpit, especially with the tools available like mobiflight :slight_smile:
But each to his own. Good luck!

1 Like

Thanks a lot for your answer @Pieter1982NL , and for the links. Will do my homework, and might then come back with more questions.
Question about MobiFlight. This is only compatible with Arduino, right? Below is what I found on the website.

Supported modules

The following arduino modules are currently supported:

I used MobiFlight before, and really liked it. But if I remember well, I quickly came across some limitations. And then came Jeehell FMGS with a nice SDK, and I jumped on that train.

But what you are saying is that I can build a full A320 FCU, including all rotary push pull encoders, Korry switches with all the LED’s, 7-segment displays and dimmable backlight just using a Mega 2560 R3 with MobiFlight, and connect this with the FBW A320NX or Fenix A320?

Probably not 1 arduino mega, since you won’t have enough pins. :smiley:
But yeah, pretty much. (Maybe apart from the dimmable light)
You might be limited by the VARs used by FBW, but you would be with any software implementation.

Since the new update is supports also any game controller. So as long as your controller/buttonbox/throttle quadrant, etc is showing up as a game controller, Mobiflight can map it.

Disclaimer: this is all second-hand knowledge. I don’t own a home cockpit myself.

Wait till you see the LoungePilot motherboard that you can plug your Mega2560’s into and use Mobiflight to run.

1 Like

Another question on how to control the sim through external hardware:

Imagine that I want to control the SPD on my FCU with the rotary encoder. You can use the UP and DN commands (reading the above, these are probably H:Events, or even standard events). After each UP or DN command, the sim updates the display, and sends the changed values back to the hardware, where the 7-segment displays are being updated. But if I remember when I was using MobiFlight more than a year ago, this way of working created (obviously) a lot of traffic and lag. Not very realistic.

With Jeehell FMGS I could update the value of the SPD directly by sending commands. Is that also possible with SimConnect/wasm? It would mean that my hardware controls the 7-segment display itself (very fast) and directly sends the display values to the simulator. This requires some clever tricks of course, which I implemented in my Jeehell FMGS system, because you can’t send the value for each click (would create the same traffic and lag), and you also have to allow the sim to update the values of your 7-segment display itself (some clever switch that gives the control of the 7-segment display to the encoder or to the sim). My implementation took care of this and it worked as a charm. (if somebody wants more details on the how, don’t hesitate to PM me)

I just wonder if this is possible with MobiFlight? And if it is possible at all to update absolute values of displays like SPD, HDG, etc…?

1 Like

I did found some interesting video on YouTube:
MobiFlight Video Tutorial - MSFS 2020 Custom Variables and Events - YouTube
MobiFlight Video Tutorial - A320 FCU Modes - YouTube

@Pieter1982NL So I have finally purchased FS2020. I purchased via Steam. I installed the SDK as well. After that I downloaded the latest version of MobiFlight. And I took my Arduino’s from below the dust. And finally I downloaded FBW A320NX. Took me from noontime until now to have everything up and running. But the adventure can start :slight_smile:

Luckily I have a 13-year old son that already has FS2020 for more than a year, and he knows how to deal with the FBW A320NX. He quickly showed me how to launch FS2020, we did a few tweaks, started then A320NX and made a short flight. I had some issues with sound, but after half an hour that was solved as well. Wow, the sound on this A320NX is great!

MobiFlight seems to connect with my Arduino and with FS2020. So I guess we are up and running.

Now starts the trial and error part. As you have 25+ years experience, I’m sure you could put me in the right direction?

What intrigues me the most is this “Behaviors” window (in FS2020 - DevMode). I would like to understand the concept of this tool. I would for example try to connect a button and an LED to my Arduino board, and control the APPT button with my button, and light the LED when the APPT indicator goes on. Simple start I guess? If I look in the Behaviors screen, and I select Root Component “AUTOPILOT”, and Child.0 “PUSH_AUTOPILOT_APPR”, then I see a ton of lines appearing. But no clue what to do with them.

Hmmmm, feels like there will be a lot to learn. But I have time :slight_smile:

You don’t need the tool for your specific example. But have a look here: :slight_smile:

@Pieter1982NL Bedankt Pieter! (I assume that NL means you are Dutch :slight_smile: ). This video also used this fameous “behaviors” screen. But I don’t seem to find any information on the concept of this screen. Do you know any documentation of it? It looks pretty cryptic for me.

Have a look through this article :slight_smile:

https://docs.flightsimulator.com/html/index.htm#t=Developer_Mode%2FMenus%2FWindows%2FBehaviors_Debug.htm

I have already looked into this, but honestly, I’m getting more and more frustrated. I can’t find any simple logic in all this! I can’t find any concept, logic, or whatever.

For example. How can I find what I need to do to control the SPD, HDG, ALT and VS knobs. I mean, if you use this Behaviors window, some entries give something back, and some are not. And what you get back is so cryptic. Why is this so complicated? Shouldn’t there just be a simple guide saying that you use command X for turning a knob up, and another command Y turning a knob down. Command A to push, Command B to pull. Of am I missing something?

@Pieter1982NL Aha, I think I start getting it. At least, I hope! Correct me if I’m wrong.

Finding the correct variables or events is indeed a puzzle - something that can only be done by real experts (not me - at least not yet :slight_smile:). But the results of that groundwork can be found in MobiFlight, because one of the nice features is that it contains a downloaded list of all known events and variables. This list is continuously been updated by the community, and can be downloaded with one click of a buton. Am I right?

Below for example, I could find all the INC events for SPD, HDG, ALT and VS.

Looking at the above screenshot, is it also correct to assume that some events are native FS2020 events (the ones starting with “A320”), and others are proprietary for the FBW A320NX (the ones starting with “A32NX”)? Means that FBW uses the FS2020 events if they can, but only replace the ones they need to adapt to their model?

Just trying to get my head around it. And if the above is true, then I start understanding your quote at the beginning of this post:

I start believing that you are a wise man @Pieter1982NL :slight_smile:

Nice! Do remember you’re now only specifically addressing A320NX values, so if you’re building a more general cockpit, you might want to look into the more general variables which would be generic SimConnect values :slight_smile:

Also: It is good practice to code on the release of a button, not on the press-in :wink:

I do want to use the A320NX, as this seems a far more realistic simulation than the native A320 NEO in FS2020. If ever the Fenix A320 is released, I might have a look at this one as well.

Doesn’t that feel a bit strange? I mean, you press a button so you expect to have a reaction. Why would you program the action on the release of the button? I’m curious for the reasoning behind this.

By the way, I just found a very handy trick with the Behaviors window. If you hover over a control in the sim until it becomes blue, and you press “CTRL G”, the Behaviors window shows immediately the data related to that control. This means you don’t need to search in these long lists with sometimes very ambiguous names. This means that I can use the codes in MobiFlight, but I can always cross-check in the sim afterwards. Reason is that I’m a bit suspicious about the quality of the data provided in MobiFlight. As I understand, everybody can contribute. But that means that there is no real quality check. So there might be a lot of mistakes in there. Better not to rely 100% on that data.

1 Like

With a fresh mind, I have done my first MobiFlight experiments. And it worked from the first time! I connected a button to the BAT 2 switch, and an LED to the BAT 1 Off indicator. When I press the switch, a fraction of a second later, the LED goes on. And I didn’t use FSUIPC, but the new FS2020 events/variables.

And this allowed me to dig into some detail. Probably all known stuff for you @Pieter1982NL , but I explain what I found here, because it will definitely help some other newbie’s like me (who are getting frustrated not finding what they are looking for). In fact, I “reversed engineered” some stuff.

In MobiFlight, I configured a push button, and I connected it with an input using the “MSFS2020 - Events”. The BAT switch can be found in the “Electrical” section, where I found the event “OVHD_ELEC_BATTERY_2_TOGGLE”:

image

I read somewhere that the events are found in the “events.txt” file that can be found somewhere in the “community folder”. To get to that folder, I went in FS2020 [DevMode] / Tools / Virtual File System, and from there you can open the Community Folder.

image

There you will find the folder “mobiflight-event-module” in which you have a folder “Modules”, and there is the “events.txt”. Now I opened that text file and search for “OVHD_ELEC_BATTERY_2_TOGGLE”.

Under “//Fly By Wire/A320-Dev/Electrical” (which seems to be the Group), I find the above event:

OVHD_ELEC_BATTERY_2_TOGGLE#(L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO, Bool) if{ 0 (>L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO) } els{ 1 (>L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO) } (L:XMLVAR_Momentary_PUSH_OVHD_ELEC_BAT2_Pressed) ! (>L:XMLVAR_Momentary_PUSH_OVHD_ELEC_BAT2_Pressed)

If I’m not mistaken, when the above event is triggered in MobiFlight, the “commands” behind the “#”-sign are executed via the WASM and/or SimConnect module.

But how do we know what commands need to be executed? Well, we have to rely on the contributors that create the “events.txt” file (file is updated regularly). But you can find things yourself if you make use of the FS2020 [DevMode] / Windows / Behavior window. For me, most of that window is mystery, and very intimidating. But if you have the window open, you can hover over a button in the sim cockpit, and when the button turns blue, you can press “CTRL G”. This immediately finds the button (you don’t need to look in the sometimes “fuzzy” names). I did that for the BAT 2 button on the ELEC panel of the A320NX, and it finds “PUSH_OVHD_ELEC_BAT2”.

image

If you now scroll down in the window, at the bottom, you will find an entry “Mouserect”. If I understand it correctly, this defines what should happen when the button is clicked by the mouse. Again, I don’t know the details, but what I’m interested in is the part “Logger”. And this is where you find exactly the same commands that are shown in the “events.txt” file. BINGO!!!

3 Likes

It actually isn’t. My programming experience is mainly on automated real life container terminals and projects for oil/gas and defense systems.

So for me the specifics for mobiflight are also new :smile:

And yes, with an encoder I can now also tune the SPD of the FCU, and get the result on a 7-segment display. Ok, I haven’t connected my MAX7219 yet, but I can see the numbers change in sync with the sim.

Later today I will finish my FCU mockup, which contains 3 digits (it’s only a mockup and I didn’t want to use all my 7-segment displays). The mockup contains some buttons (including my own Korry switches), a push-pull encoder (made the push pull mechanism myself) including the 100/1000 selector for the SPD dial, a 3-digit display, some more LED’s and backlighting. The below are some drawings in Sketchup.

Now that I seem to understand the basics, I will finish the hardware first, and then hook it up to MobiFlight. So you hear back from me!

This will make things much easier to find. I had an event (input) that I could not find. Can’t remember what it was off hand, but the nomenclature made absolutely no sense.
I may have to build someone a cockpit to scratch this itch I’m getting…

At the moment the UI and searching for the correct event is very rudimentary and it is not always easy to find the right event by looking at the name.

I am working on improving this so that it will be more user-friendly.

In the meantime it might help to look up event names on https://hubhop.mobiflight.com which is where we are collecting all events in the first place. It allows for better searching and you can find the event name there which you then can find in the drop down too in Mobiflight.