New project - MSFS C++ USB interface


+ Reply to Thread
Results 1 to 40 of 170

Hybrid View

  1. #1
    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.

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


    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: 31322
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: 31429
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.

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


    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: 31364
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!"

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    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: 30964
Size:  11.9 KB

    Robert

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    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: 31148
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: 31208
Size:  56.2 KB
    Last edited by Demon; - 24th May 2023 at 20:38.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    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: 30336
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: 30861
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: 58588
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.

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    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: 30880
Size:  879.5 KB

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

    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 : 7

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