New project - MSFS C++ USB interface


+ Reply to Thread
Page 1 of 4 1234 LastLast
Results 1 to 40 of 154
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598

    Default New project - MSFS C++ USB interface

    My new project is slowly taking shape; all the buttons, knobs and switches for a Cessna 152 in MicroSoft Flight Sim 2020.



    That was using a utility to get to Lvars, but I can't use it for all my objectives. It doesn't look like much, but I had to get familiar with Visual Studio 2022, learn C++ and get familiar with SimConnect.

    I've since moved on to my own standalone Windows GUI in C++. I can finally get to the SimConnect Events, SimVars as well as those dreaded Lvars.



    I can get to all the FlightSim controls via my program. Now I have to get the USB communication going between a 18F4550 and my program.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I can only say WOW! In a sort time you did miracles Robert!

    Ioannis

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Quote Originally Posted by Ioannis View Post
    I can only say WOW! In a sort time you did miracles Robert!

    Ioannis
    On the down side, I have to buy a new motorcycle helmet...

    Name:  Talosian.png
Views: 10082
Size:  116.0 KB

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Smile Re: New project - MSFS C++ USB interface



    I feel you!

    Ioannis

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: First attempt in over a decade at USB - HIDmaker FS2

    Quote Originally Posted by Ioannis View Post
    Looking forward to your progressing on this.

    Ioannis
    Ok, well here's an update for you.


    First I've learned that MS FS buttons and switches are spread over 3 types of data: events, variables and Lvars. I got to get familiar with C++, I can get to events and variables using one "technology", or I can get to Lvars using another, but I can't mix both. I kept reading comments on forums about "just use the SDK also for the Lvars", except I never saw examples.

    So after a gazillion attempts at using the SDK to get to the Lvars (I can get to the events and variables just fine), I finally find the SDK support forum and post there. DING! I get a really quick reply to "just do this, it'S in the docs". Yeah, sure, the instructions were crystal clear, but there was a bug in the sample code, and that's exactly what I had been using blindly.

    I eventualy gave up, read the instructions word by word, cross-checking against the sample code word-by-word, and it struck me, a variable was missing. Damn! I don't wanna say how long it took me to find that, it's embarassing. But hey, at least the Dev didn't know there was a bug in the sample either.


    Then, got the PICkit 4, spent a ridiculous amount of time to get it working, but it's still not quite right. Turns out I found my U2 USB programmer and it works just fine, in fact, it's faster than the PK4. So the PK4 is going into a TO-DO-ONE-DAY drawer...

    Been setting up a room into a small shop, putting up all my cabinets and stuff. Turns out I really need to make an inventory system caause now I'm ordering parts I already have, somewhere, that I find the very next day a shipment comes in from DigiKey.

    My Aoyue 738 soldering station crapped out; the bits weren't heating at the very tip, even brand new ones. Wasted too much time on that too, gave up and got a Weller WE1010NA from Amazon. Looks decent, haven't tried it much yet except turning on and seeing how fast it heats; real heavy transformer, digital display, comfy non-slip tool that can't fall out the holder (like my antique Weller), and heats super fast.


    EasyHID generated obsolete VB6 code, and of course I can't find my VB6 Development CDs. You can't just slap VB6 code into VS2022, so I paid the money and got an upgrade to HIDmaker FS2 cause it seemed to be the answer to my prayers; it can generate PBP3, and .Net C++ WinForm code. Turns out WinForms isn't what I wanted, I just ran off in the wrong direction with that.

    Buried in the documentation for the MS FS SDK, there's this requirement:
    "To build SimConnect add-ons, the recommended Visual Studio version is Visual Studio 2019, with a minimum version of 2005. To build the project, make sure you have completed the following steps.

    For out-of-process applications, start a new Console Application project if the add-on will have no user interface. Start a new MFC Application if the add-on will have a user interface. In either case, set the platform as x64. In order to use the SimConnect functionality, it is required to include the SimConnect.h header file."
    Now to me, I saw Visual Studio, and figured VS2022 would work just fine. Turns out, there's more to those requirements than just a need for 64-bit compiling. I had totally forgotten about that MFC part, mainly cause it meant absolutely nothing to me when I read it earlier this year, and started generating C++ WinForms code. Turns out, that was wrong.


    So now I'm generating C++ MFC code, but there's a problem, I only notice now that it's generating in Win32 code (x86), and I need Win64 (x64). So I google, and learn to convert from Win32 to x64 straight from inside VS2022, except it ain't that simple, there's an error generated....

    And that's where I am today; overcame a truckload of hurdles, learned a bunch of new stuff, got a better idea of what I need and where I'm going. But I don't know enough about Windows to convert, so I'm waiting for support from HIDmaker to guide me along (no complaints about support, he's a one-man show as far as I know, and I have ZERO complaint).

    But I will say this, when I compile the PIC code in the 18F4550 on my Lab X1 while the PIC is connected to my PC, DING! The new device is detected instantly; that is such a reassuring sound that I hadn't heard in a long time. Switch over to VS2022, compile the C++ code and Tadaa! The darn thing works, except it's in Win32.

    I just have to figure that part out, and then I can start testing against MS FS.

    Robert
    "Yes, I'm bored cause I'm sitting on my thumbs, instead of going outside to mow the lawn like I'm supposed to before I lose a dog in there"
    Last edited by Demon; - 15th May 2023 at 21:17.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: First attempt in over a decade at USB - HIDmaker FS2

    How to tailor that Windows form to my needs is another problem. It's not the standard super-simple GUI with text boxes and buttons. It uses a formatted Windows system that I'm not familiar with. That's another thing I have to muddle through.

    Like this:

    Name:  FS2 GUI.png
Views: 9621
Size:  70.8 KB

  7. #7
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I have Visual Studio Pro 2015 (paid), VS 2017 Community (free), and VS 2022 Community on my computer. I've noticed many of the YouTube tutorials are using 2017, even though it is 2 versions old. Even though I loaded VS 2022, I have yet to play with it. I have, however, started using the free VS 2017 which does things my Pro VS 2015 cannot.

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Actually, it creates the main window, and splashes a familiar sub-window if I'm not connected. As soon as I'm recognized, that pop-up disappears, looked through the code and haven't found it yet.

    Name:  Cessna 152 GUI.png
Views: 8183
Size:  30.4 KB

    I have figured out that the "main window" is controlled by Manifest in the project Configuration properties and the Resource file. Gotta google to learn more, never touched that stuff before.

    Robert

  9. #9
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I'm still in limbo without access to my other laptop, but I modified the code so that if I wanted to debug the VB side without actually connecting, I would click "Cancel" and a new pop-up (which I created) would ask if I wanted to work off-line. I remember what I modified was one of the HIDmaker main page routines near the top having to do with On Opening or On Connect or something like that. Look for the code that includes the pop-up and start there.

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Quote Originally Posted by mpgmike View Post
    I'm still in limbo without access to my other laptop, but I modified the code so that if I wanted to debug the VB side without actually connecting, I would click "Cancel" and a new pop-up (which I created) would ask if I wanted to work off-line. I remember what I modified was one of the HIDmaker main page routines near the top having to do with On Opening or On Connect or something like that. Look for the code that includes the pop-up and start there.
    Will do.

    Also going to google how to call a 64-bit program from a 32-bit and exchange data (never done that). I fear asking Dr. Miller to generate C++ MFC in x64 is not a simple task at all. There's a hell of a lot of code generate, it's not just descriptors, constants and variables. There's a lot of USB manipulation going on as well.

    Robert

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: First attempt in over a decade at USB - HIDmaker FS2

    Quote Originally Posted by Demon View Post
    ...
    So now I'm generating C++ MFC code, but there's a problem, I only notice now that it's generating in Win32 code (x86), and I need Win64 (x64). So I google, and learn to convert from Win32 to x64 straight from inside VS2022, except it ain't that simple, there's an error generated....

    And that's where I am today; overcame a truckload of hurdles, learned a bunch of new stuff, got a better idea of what I need and where I'm going. But I don't know enough about Windows to convert, so I'm waiting for support from HIDmaker to guide me along (no complaints about support, he's a one-man show as far as I know, and I have ZERO complaint).
    ...
    Holy moly, talk about a rabbit hole, searching for "communicating between x86 and x64 C++ programs".

    I've narrowed it down to IPC Shared Memory using Boost (staying away from pipes, sockets, RPCs and what-nots). It's been used successfully by a lot of programmers.
    https://www.boost.org/doc/libs/1_82_...processes.html

    This guy got it working:
    https://stackoverflow.com/questions/...24381#63224381

    So far, BOOST has come up the most in the threads I've gone through. Now I just have to find a really basic working code. Usually it's just bits and pieces here and there, just enough to get me all excited, but not enough to compile without knowing things like "how to adapt code to your needs without having had a C++ course in your life".

    But at least I have an option if HIDmaker can't be adpated to x64 in the near future. It just adds a layer of complexity I could do without.

    Robert


    EDIT: So how fast can data be transferred using IPC shared memory?

    Name:  IPC shared memory speeds.png
Views: 8203
Size:  232.6 KB

    And this is on a Pentium 4, I'm running something slightly faster with a bit more RAM.

    I was planning on sharing about that volume of bytes too, 1 or 2 K.
    Last edited by Demon; - 16th May 2023 at 22:55.

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Step 1, made 2 identical programs in 32 and 64 bits, that turn the light ON/OFF only on their side.

    Name:  IPC x86 and x64.png
Views: 8147
Size:  7.4 KB


    Step 2, get them to turn ON/OFF both sides.

    ... insert cool pic here on soonday ...

    Robert

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Wow, talk about a roller-coaster (memory getting fuzzy now about exact sequence):

    - back in early 2023, I get a basic C++ WinForm GUI running with MSFS SDK, not even knowing what type of program I create (from youtube video).

    - decide on upgrading to HIDmaker FS2 to generate PIC and C++ USB code.

    - generate USB C++ code, I chose C++ MFC cause I recently saw that in the MSFS SDK docs, compile in x86 ok.

    - compile in x64, cause I just saw that again in the MSFS SDK docs, compile failed!

    - google migrating C++ x86 to x64, looks like the apocalypse to me.

    - figure I'll make a x64 program between the x86 C++ code and the MSFS SDK code.

    - start googling, quickly narrow in on Inter Process Communication.- eventually IPC Shared Memory between x86 and x64 stands above the crowd.

    - turns out the BOOST group have been working on that, some programmers report success, but never sharing a complete sample.

    - I try it using the sample from Boost.org, fail miserably, so I made a rather lengthy post on Stack Overflow asking for help.

    - as backup, I find out Adontec produces exactly what I need, just for $400USD, sent then a message to confirm it'll work under my criteria.

    - as I'm reviewing the MSFS SDK docs, I notice they say x64 MFC app if you're interfacing "directly" with MSFS, but you can use an ordinary console app if you don't.

    - Nothing to lose, so I switch back to C++ Winform, turns out I'm not, I'm just playing with a DLL.

    - generate the C++ x86, then compile using x64, and BOOM! The darn thing compiled.


    So yeah, been an up-and-down last few days. Hopefully things keep going my way.

    Robert


    "just a blind man running with a huge smile on his face!"
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Seems you are very persistent person! And wow, you did an amazing trip through all these environments...!

    Respect from me.

    Ioannis

  15. #15
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I prefer the term "obnoxiously stubborn and willfully oblivious".

    Note to future-self, ALWAYS put the Windows INCLUDE at the top of the list. Argh, the multitude of insane errors and hours of google searches...


    Status of the day; didn't get as far as I planned with that stupid include problem, but I did get to compile the generated code with USB components in 64-bits, and connect to MSFS, that last part was my do-or-die moment of the day.

    Name:  Connected to FS with USB code.png
Views: 8163
Size:  717.1 KB

    EDIT: Oh yeah, the single button in the interface works fine; changing between a 0 and a 1 when I press a button on the Lab-X1. Haven't implemented anything else yet.
    Last edited by Demon; - 19th May 2023 at 22:17.

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Men can find joy from the simplest things.

    Landing light ON-OFF from the Lab-X1 via USB.

    Name:  Landing light ON-OFF from Lab-X1.png
Views: 8142
Size:  447.8 KB

    Robert

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Quote Originally Posted by Demon View Post
    Men can find joy from the simplest things.

    Landing light ON-OFF from the Lab-X1 via USB.
    Oh, yeah! I understand that feeling... Especially after the long trip to finally manage that damn thing to flip!

    Ioannis

  18. #18
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    YAY! I can finally detect a change in Engine RPM. And this is why I absolutely wanted to have Code Debugging working.

    Name:  Engine RPM change detected.png
Views: 8066
Size:  498.7 KB

    Now I just have to learn how to use structures and variables in C++. I kept trying to peek at that data, but I just couldn't get to see anything meaningful.

    Good thing we have google tutorials. Worse case, I'll ask on the Dev forums, but I want to try to get there on my own.

    Robert

  19. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    You did all that in C++ with no knowledge of structures and variables?

    For me C was difficult when I tried to learn and then C++ was 10 fold worse...

    Well, I have to try again I guess.

    Well done Robert.

    Ioannis

  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Thanks. Yup, tried C For Dummies 20+ years ago and got nowhere fast.

    I'll refer you one youtube video later. The dude speaks clearly, and in no time you have a basic window with buttons and stuff.

    Best part, Visual Studio 2022 Community is free. It's way better than what we had for Visual Basic way back when.
    Last edited by Demon; - 22nd May 2023 at 00:08.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  21. #21
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Here, download and install VS2022 Community. It's free.

    Then follow his instructions to the letter. You have a simple Windows form in no time.

  22. #22
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Thanks for the link.

    Ioannis

  23. #23
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    It's so frustrating. "Experts" on forums assume you know C++ nearly as much as they do, or point to sample code that is exactly like what you've already put together, or say "hey, just use this conversion routine" - except that routine doesn't work against that sort of variable.

    Name:  Engine RPM read.png
Views: 7940
Size:  432.8 KB

    I'm so close, I can see the data in the structure and it matches what's displayed on the instrument panel. I guess I'm off to "C++ structure tutorials" in hope of finding something useful.

    Robert

  24. #24
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Argh, it's like extracting teeth; slow and painful. Thanks to google I was able to "address" the structure element properly and copy it into a double variable.

    Name:  Engine RPM read into DBL.png
Views: 7956
Size:  328.8 KB

    I may have got just a tad smarter by learning this, but I just moved the problem into another pile; I can't seem to be able to do anything with a double variable. Can't display it on screen, can't convert it to a string; I tried but commented out the attempts to keep track of what I did.

    Robert
    "At least I'm not going backwards."

  25. #25
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    WOOT!

    It helps when you know what questions to ask google, AND you get very well-explained pages.

    Name:  Engine RPM displayed in TextBox.png
Views: 8014
Size:  370.4 KB

    Now I have to return that value to the PIC, but in the meantime, I'm getting a beer.

    Robert


    EDIT: Hmmm, maybe I don't deserve that beer yet. There's a 15 second lag before throttle changes are reflected in my app. I'm hoping it's because I used "option 2" on how you can poll SimConnect for variables; it also contains the USB code (not sure yet if that can impact the SimConnect logic).

    Really hoping "option 1" works as promised by the Devs (it's a callback routine, not my type of code, but hey, if it works as promised).
    Last edited by Demon; - 23rd May 2023 at 01:06.

  26. #26
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    About 7 years ago I decided to get serious about Visual Basic (as opposed to C++) and bought 5 different books on the subject. I'm an old fart (56) and still like paper books. At any rate, about 90% of what I need to know is somewhere in at least 1 of those books. Occasionally I have to jump on YouTube for answers, but the books really helped me. Just sharing my experience.

  27. #27
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Yup, we should be able to find an answer to a question on just about any software issue today. Oddly, I'm starting to notice a trend of websites posting "relevant information" without going into the exact answer. I'm starting to think that web traffic (money for ads) is starting to dilute our source of information. And then the forums of egos arguing with each other, and not one of them give a complete code answer to the original question. It's taking a surprising amount of times on some issues; like the sheer volume of C# links popping up for C++ searches; driving me bananas.

    I had a serious lag issue with my USB generated code when I'd read variables from the MSFS SDK. So I started a new program from scratch, no USB, made just to read the Engine RPM and nothing else. Then I compared it with SimVar Watcher; it's the tool distributed along with the SDK to doublecheck our work. Turns out I had to add a delay feature to run beside SVW at full speed (I got extra practice on string manipulations and tweaking a Timer on the fly, so not a waste of time).

    This is with a 1ms delay timer on my program during max acceleration:

    Name:  RPM with 1ms delay.png
Views: 7403
Size:  107.3 KB


    I had to slow down to 5ms to be right at the same speed as SVW also during max accel:

    Name:  RPM with 5ms delay.png
Views: 7377
Size:  99.9 KB


    So I'm happy. At least I know that now I can run at an acceptable rate of speed. I have a theory why my code bogged down before, need to do another test.

    Robert
    Last edited by Demon; - 24th May 2023 at 02:47.

  28. #28
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Hot diggity dog! It's even better than I thought under real conditions.

    I could slow my program to 6ms even after adding USB and I'm still updating as fast as SimVar Watcher.

    Name:  RPM with 6ms delay with USB.png
Views: 7285
Size:  130.0 KB

    Problem was simple. I was piggy-backing my reads to the MSFS SDK on top of the USB Timer. I added a separate Timer (like I practiced in the previous post), and away it went.

    Freaking awesome! Another major hurdle, but the worst is tomorrow. I have to mow the lawn, badly...

    Robert
    "Darn tootin' right that I'm happy!"

  29. #29
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Not bad considering 4 days ago I was "pushing a button".

    Name:  4 days of progress.png
Views: 7367
Size:  11.9 KB

    Robert

  30. #30
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    One possible issue has been bugging me for a few days; my SimVar tests were all done with only a single variable. I wasn't sure if the code I was using could support multiple variables.

    Added the markers and both Kohlsman settings; the ADF frequency still isn't completely converted (gotta play with BCD, never done that), and bumped up my delay to 10ms. I'm still faster than SimVar Watcher under full throttle acceleration.

    Name:  RPM with 10ms delay w USB others.png
Views: 7353
Size:  38.3 KB

    I'd go mow the lawn in celebration, but it rained; I'd need a tractor to cut wet grass. Major relief; go I guess I'm finally getting that beer.

    Robert


    EDIT: Turns out I might be even a tad faster. I forgot something from the original code.

    Name:  Sleep.png
Views: 7346
Size:  56.2 KB
    Last edited by Demon; - 24th May 2023 at 20:38.

  31. #31
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I spent the day fleshing out the Form with all the variables to be Read from Flight Sim on the left, and all the controls to be sent up from the PIC on the right. I run SimVar Watcher just to be sure I'm still on par on engine RPM reads during full throttle acceleration.

    There's no added logic behind these new fields, it's just typing them in, lining them up in a meaningful manner, and compiling to make sure there's no serious typos. These fields aren't meant to stay visible; I'm gonna hide them once development is finished. I'd rather have them in the background ready to be reactivated if I have problems. The only thing expected to remain visible is that "Connect to Flight Sim" button and textbox.

    Name:  Added most fields to Form.png
Views: 7352
Size:  91.1 KB


    I did get to finish the conversion technique on that darned ADF Frequency earlier today. Check the number displayed at the top on the instrument panel, then compare it to the number stored in Flight Sim on the left. I did BinaryCodedDecimal conversions back in college; that was in late 70ies, never touched that since. LOL

    Name:  ADF frequency.png
Views: 7349
Size:  336.5 KB


    Nothing spectacular, got the bottom subroutine off google, figured out all the BCD32 manipulations after 1 good video on nibbles.

    Name:  Extracting high order nibbles from 4 byte number.png
Views: 7344
Size:  53.8 KB


    I keep thinking the worst is behind me; and then another day starts.

    Robert
    Last edited by Demon; - 26th May 2023 at 03:25.

  32. #32
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Those guys that maintain the Flight Sim SDK docs like to keep us on our toes. There's another error; the Transponder code is stored in Binary-To-Octal16, not in Binary-To-Decimal16; totally not the same thing. Took me a while to figure this one out.

    There's a design flaw in how the let us read COM frequencies; they drop that 3rd digit on the right. I have yet to see a way to "deduce" what it can be. So Plan B it is: I'm not gonna Read the Com frequencies, I'm gonna Tell Flight Sim what they are; case closed.

    Name:  Cannot read Coms.png
Views: 7358
Size:  879.5 KB

    And I'm still only scratching the surface of this project.

    Robert

  33. #33
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I really enjoy programming, and now even more so cause I hate being a buyer. Looking for an item, getting to field the same questions; comparing prices, it's so tedious. Really happy I know how to use a spreadsheet. And I have to be careful not to give wrong specs, I keep copy-paste of a lot of my replies. I've been doing supplier research for over 2 weeks now, and I'm royally fed up with this part of the project.

    I've been moving "my stuff" from a small room to half my basement; you know, that part of the house that you accumulate garbage over 30 years and 3 kids. Well I've cleaned up nearly 1/2 of my new area; PC and printer is back up and running. I didn't even take the time to paint the cement floor, or finish the gyproc walls; I've spent enough time moving my daughter in, then back out a few days later. :/

    I've got most of my shelves and storage bins set up, but I don't have a soldering workspace up yet and that really bugs me. I'm taking a bit of time to make a special area for the 3D printer, a secondary PC and my pet project; a custom CNC machine to fabricate PCB boards, plastic parts, that sort of thing.

    The cost of PCB boards is just insane now; even tiny ones. I figure I'll cover the cost fabricating my own milling machine with this first model. I don't need anything fancy; just X, Y and Z axis for now. I know I'll want pick-and-place one day, same with an automated tool changer, but those things can wait.

    It's nice to be able to test designs soooooo much faster. It won't be as nice a professional PCBs, but I know it'll work for a fraction of the cost. Darn, even if I go back to chemical etching, it's still cheaper and faster than waiting 1 week for the DigiKey special offer.

    I was getting "good enough" at PCB fabrication too; and this time I have a LOT of space to set myself up properly. Like install my own kitchen vent that evacuates fumes outside, instead of working on the kitchen stove. I can use that for a tiny paintbooth as well. And there's been progress in the DIY PCB fabrication world; guys are now finishing their boards green (that has to be cheaper and less "fumy" than the silver coating I was dipping mine in, some even doing silkscreen.

    Only downside, I had to disassemble my pool table. ;(

    Robert

  34. #34
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I am done with the DIY pcb, chemicals and drilling... Enough fumes, dust and stains!

    A CNC machine is nice to have, for various other uses also, among pcb and drilling, but not for me anymore.

    Now I use the dirty cheap and ultra fast JLCPCB for any pcb needs.

    Ioannis

  35. #35
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I'm gonna check out JLCPCB once I have a circuit ready.

    Right now I'm finishing up buying parts; just need those rocker switches and some graphic overlay for backlit text.

    On the positive side, I'm well on my way repossessing my basement from all that junk I've accumulated.

    Finally got to work on my new workbench debugging why that LED wasn't turning on as it should.

    Robert

    Last edited by Demon; - 22nd July 2023 at 02:44.

  36. #36
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I'm a visual person, I like to see what I'm doing as opposed to relying exclusively on drawings and schematics (although I do enjoy making them).


    This is what I'm doing right now; the communication & navigation panel (COM1, COM2, NAV1 and NAV2).




    This is a quick layout of the parts I've bought (that's about 9 inches wide, 8 inches tall).




    The TEST button was integrated in the volume button in-game. I couldn't afford potentiometers with a push-button, so I added a separate black button

    The rotary encoders I'm using to change frequency have a built-in push-button switch; that way I don't need a dual knob arrangement (again, more expensive).

    Yeah, those squiggly pink circles will be LEDs later in life.

    Robert
    Last edited by Demon; - 23rd July 2023 at 19:02.

  37. #37
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    All these pots, displays, switches etc, will be inerfaced to PIC microcontrollers and then to the PC running the simulator?

    Ioannis

  38. #38
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Quote Originally Posted by Ioannis View Post
    All these pots, displays, switches etc, will be inerfaced to PIC microcontrollers and then to the PC running the simulator?

    Ioannis
    That's the plan.
    🙃
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  39. #39
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    Wish I was closer to your location. An amazing project this will be!

    Ioannis

  40. #40
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: New project - MSFS C++ USB interface

    I've been up to my eyeballs with little time to browse the forum. I've been researching parts, accumulating inventory, learning C++ and the MS Flight Sim SDK, and now XML, finding decent software to convert Gerber RS-274-X to G-code (turns out my Gerber format is obsolete, but the dude modified his software for me).

    I've settled on all the controls for my console, and have all the variables and events to interface with the MSFS SDK. Cost forced me to make a compromise for this first model (targeting budget gamers); I've removed all gauges and displays and moved over to on-screen in-game XML gauges. So I'm back to a "button box" design. That lower screen is all the XML gauges I will be using; some downloaded, some tweaked, and some my own.


    I've just starting designing my first "real" circuits; hoping to machine them real soon (I've done basic router and drilling on the mini-CNC). So far I'm seeing about 0.001" to 0.002" vertical tolerance on 3/4 of the bed, with a slight warp in one corner moving up to 0.005". That could be anything on a budget machine; bed, bearings, rails, tidal forces.

    And of course I see StarField is about to launch on kickstarter on the 18th; 25μm XY precision, 350x200x350 resin 3D printer. My SLA 3D printer is ok, but I wouldn't print ABS on it and prints are gonna need a LOT of hand-finishing, then I have to mold cases (not a simple process). With a resin printer, I could go straight to ABS finished cases, removing a LOT of steps in my fabrication process, and removing all the costs with mold-making (need to get a vacuum chamber).

    Hoping to have nice pics of PCBs to share soon.

    Robert

Similar Threads

  1. USB interface
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th December 2011, 19:37
  2. Host for USB interface?
    By Carrasco in forum Off Topic
    Replies: 4
    Last Post: - 3rd August 2007, 23:59
  3. USB Interface using PIC
    By Tissy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd May 2006, 16:04
  4. USB interface from PIC16F877 to PC
    By headshouter in forum USB
    Replies: 0
    Last Post: - 26th February 2006, 04:58
  5. USB project
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th January 2005, 21:59

Members who have read this thread : 25

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts