Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing with Microsoft Flight Simulator — Parallax Forums

Interfacing with Microsoft Flight Simulator

LurkerLurker Posts: 8
edited 2007-05-29 12:04 in General Discussion
Anyone interested in tinkering with Microsoft Flight Simulator and BASIC stamps?

I developed a DLL in 1999 to send the pitch and bank values from FS98 to the printer port. I designed some cool circuitry with dual latches (pitch and bank), summing amps, and comparators to drive a pneumatically-controlled moving cockpit. Being an ex-EE/ current developer, the software and electronics is as far as it got. Maybe one day I'll get a welder friend to help with the rest.

Anyway, on to the story... I recently got the WAM kit from Radio Shack to build a light controller for church. The stamp is so robust that I finished that in no time and began to realize the potential of these things. I pulled up my old FS98 code and modified for serial out. I then wrote a little code for the stamp to display the hex values on the 7-segment LED readout and saw that it was working fine. Then I went a little further and digitized a pot input and compared with the pitch/bank required from FS98 and controlled I/O pins to drive the relays for the air cylinder control valves. This little board replaces all the other hardware and works great! Wow!

This DLL presently sends out "KDPPBB{CR}" with PP and BB being 2-digit hex pitch and bank values at 2400 8N1 on COM2. It could be modified to include acceleration/g-force, flap location, engine speed, whatever...I'll gladly give away the DLL as it is now and I'll even modify it to a certain degree, but I don't want to share the DLL source code right now. The BASIC stamp code is definitely a gimmee and is really simple. I just hate sitting on this for so long without letting someone benefit.

If there's an interest and an agreement to use it for non-commercial use only, I'll share. hop.gif

Comments

  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-14 10:44
    I would be glad if you send me the Microsoft Flight Simulator DLL you mentioned! I already using·a microsoft joystick with force-feedback a lot, and i was wandered if there whas any way of connecting my chair with this type of feedback also, until you showed up!!

    I'd love to give it a try... hop.gif

    My email is:·· Tronikod@yahoo.com


    Thanks in advance.
    159 x 100 - 247K
  • LurkerLurker Posts: 8
    edited 2005-04-14 13:04
    Cool. I'll email you directly within a few days. It only outputs pitch and bank to the BASIC stamp at this time, but I'll find my SDK docs and give you a list of exactly what we can pull out of FS and I'll output whatever you'd like to try. You'll also need to let me know which COM port you'd like to use. I plan to eventually use an ini file so this is modifiable by a user. I think this will be fun and I'd like to know what someone could do with this.

    I mentioned FS98 in my original post and probably led some to believe that it won't run on the newer ones. I use this on FS98 and the original Combat Flight Simulator and it works fine. I'm quite sure it will work on the newer versions of Flight Simulator, I just haven't tested. The DLL is also Win32 and should work on 98 through XP just fine.

    As an example, here's the code I presently use to get the pitch and bank info into the stamp:

    ' Flight Sim interface
    ' Receives 2400 8N1 on serial interface
    
    
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    
    recd VAR Word
    pitch VAR recd.HIGHBYTE
    bank VAR recd.LOWBYTE
    
    
    Begin:
    SERIN 16,396,60000,timedOut,[noparse][[/noparse]WAIT("KD"),HEX recd]
    
    ' pitch and bank are now set
    
    
    
    GOTO Begin
    
    timedOut:
    END
    
    



    Simple, huh? Remember, give me a few days to find the SDK and I'll email you from home (presently at work).
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-15 07:23
    Yes i can see that the code for the bs2 is pretty simple!!! Pitch and Bank is fine as·I want to move my chair in 2 axis (not up-down vertical yet... smile.gif ). For com port its best to use COM1 although i have and a second com port...

    I have almost all the editions of FS from· FS5 thru FS2002!! but i think FS98 is best for speed reasons...
    I'll just check it for compatibility on all editions for you if you want.
    PS. You'll have feedback·about my progress·on the construction of the chair pretty soon·jumpin.gif

    Thanks again.
    ·
  • LurkerLurker Posts: 8
    edited 2005-04-15 12:57
    I'll recompile for COM1 today and just deliver it with pitch and bank outputs for now. Yeah, that code is easy and what's more amazing is that I was able to digitize a pot and drive outputs and still have time to return to the serin line before the next output comes. FYI, FS sends the outputs every 54.95 ms so there's no reason to pump out the data any faster than 2400 baud (which is also best for the stamp). Also, outputs are 00-FF with 00 corresponding to 45° nose up/45° bank right and FF to 45° nose down/45° bank left.

    It's going to fun to have someone else playing with this.
  • BeanBean Posts: 8,129
    edited 2005-04-15 18:05
    This is one of coolest projects I've seen. I can't believe noone sells something like this (maybe they do).
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "A problem well defined, is a problem·half solved."
    ·
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-18 12:28
    I have tested it and its working great!!!! I have no words to thank you for this!!!
    For the test run I connected two normal servos I had spare with a little green puppet having springs on its legs that is moved by the feedback of the FlightSim98 front-back and from side to side!!!!
    I've included video with the operation of the little fellow moving around. I can hardly wait until I'll be ready to connect it with the "special" chair-cockpit I'm planning to build.

    Here is the modified code (I added some lines)

    ' Flight Sim interface   (servo test)
    ' Receives 2400 8N1 on serial interface
    '{$STAMP BS2}
    '{$PBASIC 2.5} 
    recd VAR Word
    pitch VAR recd.HIGHBYTE
    bank VAR recd.LOWBYTE
    DO
    FOR i = 1 TO 100         'Initially centering servos on power up so the pitch-bank are
      PULSOUT 12, 750  'set to 0 degrees before FS gaining control.
      PULSOUT 13, 750  
    PAUSE 5
     NEXT
    Begin:
    INPUT 15
    SERIN 16,396,5000,timedOut,[noparse][[/noparse]WAIT("KD"),HEX recd]
    ' pitch and bank are now set
     PULSOUT 12, 620 + pitch      'servo values: [noparse][[/noparse]-127]  [noparse][[/noparse]750(center)]  [noparse][[/noparse]+127]
     PULSOUT 13, 620 + bank       'servo values: [noparse][[/noparse]-127]  [noparse][[/noparse]750(center)]  [noparse][[/noparse]+127]
    GOTO Begin
    timedOut:
    HIGH 15     'Light a Led on p15 if connection is timeout
    PAUSE 10
    GOTO Begin
    LOOP
    
    


    Post Edited (Tronic (Greece)) : 4/18/2005 12:56:51 PM GMT
  • LurkerLurker Posts: 8
    edited 2005-04-18 13:41
    You're da man - a perfect one to play with this! I showed the video to some guys at work and everyone got a kick out of it. When the puppet sways to the banking of the plane, everyone laughs. lol.gif

    I have the pitch and bank maxing out at 45° because I figured that's as far as my cockpit would ever need to move. Remember that this is all modifiable, just let me know.
  • brokebobbrokebob Posts: 1
    edited 2005-04-20 22:33
    Been thinking about a simple console for FS98.· How do you get the info sent to the com port and where can I find a list in the FS files about the locations of the data?· Simple and probably stupid questions!

    brokebob
  • NewzedNewzed Posts: 2,503
    edited 2005-04-21 00:02
    I have been running FS98 for a long time and now have FS2004 - I run them both.· I would very much like to record· my flight path periodically as soon as someone tells me how I get the data from FS so I can serout it to my Stamp and EEprom.

    Thanks

    Sid
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-21 04:01
    Newzed said...

    I have been running FS98 for a long time and now have FS2004 - I run them both.· I would very much like to record· my flight path periodically as soon as someone tells me how I get the data from FS so I can serout it to my Stamp and EEprom.

    Thanks

    Sid

    Why not using an internal·utility for recording your flight path? Before years I've found a Flight planner called: NAV 23, A FREEWARE MS Flight Simulator 95/98/2000 scenery viewer, printer, flight planner, flight track analyzer. (By: Ignacio Hernαndez-Ros, Based on NAV18 from Ted Wright)

    But you have to search for it as its too big to post it for you (30Megs unziped!!)
  • NewzedNewzed Posts: 2,503
    edited 2005-04-21 12:01
    Tronic, I found the file, downloaded it and it appears to be running OK.· There are no help files - I can't figure out how to use it.· Could you help?· Suppose I want to fly from Orlando, Florida to Atlanta, Georgia.

    Thanks a lot.

    Sid
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-21 12:30
    Have a look in link below for everything about NAV23:

    http://www.avsim.com/hangar/utils/nav/#Download_beta_



    The direct link to the NAV23c installation files are

    http://www.avsim.com/hangar/utils/nav/Nav23c.zip


    If you've found nothing to help you in these, you have to wait until tommorow cause I may have·a help file about·at my·home computer...
    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-04-21 13:31
    Tronic, I went to the link you suggested.· It said FSNav 23c had a user's manual, so I downloaded 23c but there was no user's manual.· If you can just ell me how to create a flight plan for FS98 from Orlando to Atlanta I would really appreciate it.

    Thanks

    Sid
  • LurkerLurker Posts: 8
    edited 2005-04-21 13:34
    Brokebob,

    These aren't stupid questions, most don't know how to interface with FS or that it's even possible. Download the FS2000 console SDK from Microsoft and you'll have all the info. But to develop a dll for FS, you'll need c programming experience and visual studio.

    All,

    I'm always asked how to get data INto FS and this won't satisfy that. I have a sidewinder joystick and it came with a nice gui app that allows assignment of any control on the stick to any keypress or FS control. That's the easiest way to control FS from outside and is my suggestion. Maybe a stamp app that sends data through the USB port that can emulate this?

    My method of interface is good for what I'm doing and that's about it. It was never designed for output to the real world and is something I just thought I'd try when I was really into FS several years ago. The SDK does not cover any of this and serial port programming experience is helpful.

    Just wait around until Tronic and I work out all the bugs and I'll post the resulting work. I'm presently adding acceleration and deceleration and once the bugs are worked out I'll be finished.

    Lurker
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-04-21 14:12
    Newzed said...

    Tronic, I went to the link you suggested.· It said FSNav 23c had a user's manual, so I downloaded 23c but there was no user's manual.· If you can just ell me how to create a flight plan for FS98 from Orlando to Atlanta I would really appreciate it.

    Thanks

    Sid

    From what i remember I Just Pressed F9 to switch to Map mode, the I Zoomed in the area i wanted to assign as Start airport and then just right-click on the apropriate airport (of Orlando)·airway to add it as "take off from" or something·(its name added in Flightplan list). Then I get to the landing airway of·an airport (of Atlanta in your example) and right-click· again to add it as "land" or "fly to", I really can't remember details...

    You can also add waypoints in the between of the flight path... Its not so hard to figure it out since it has GUI!!
  • Ryan C. PayneRyan C. Payne Posts: 38
    edited 2005-05-06 12:42
    Lurker,

    This is awesome. Just a few months ago a coworker and I were discussing how cool it would be to make a "force feedback" chair. Did you use Visual C++ to create the DLL that hooks up to flight simulator? I'd also be interested in giving the DLL a whirl if you are still "releasing" it into the wild.

    Ryan
  • PJMontyPJMonty Posts: 983
    edited 2005-05-06 16:17
    The device you guys are talking about is a called a motion simulator. Here's a link to a company developing a commercial version of a motion simulator designed for home use with video games.

    www.force-dynamics.com/index.shtml

    There's some good video showing the device in action. There's also some very good descriptions about the chair design and how it compares to what other companies normally do. It might give you some ideas about the physical implementation of this.
      Thanks, PeterM
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-05-09 10:45
    Thanks for the link!

    Their design is close to mine, except that·in my·design·I'm using·four air cylinders...
    ...and the big difference is the low cost of parts and construction which is less than 1000 dollars.





    Post Edited (Tronic (Greece)) : 5/9/2005 10:49:34 AM GMT
  • LurkerLurker Posts: 8
    edited 2005-05-09 18:36
    Ryan,

    Yes, I did use visual studio to develop the dll. Tronic and I are trying to tweak it and get it ready for the masses. He's done a lot of testing and made suggestions for g-force and rollover handling.

    I've been riding "motion simulators" for years and have some dvds of my favorites (even 3D glasses). I've looked underneath several for ideas for this thing. I first developed the dll in 1999 and just sat on it. Finding the stamp renewed my interest and made the interface to the pneumatics a lot easier. I thought by now someone else would've marketed something like this so I could just buy the physical implementation. But all I see out there is a messy implementation connected to some very expensive hardware. Tronic and I are going to get this figured out and post it for the world (for free). I just set up a forum at forum.wr.ca/?id=2523. You can keep a watch there and at flightsim.com.

    Lurker
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-05-11 07:08
    Here is an updated video of the system in action(flight)... on servo at the moment.

    Yeah the man on top is a LEGO man... hop.gif
  • LurkerLurker Posts: 8
    edited 2005-05-11 16:48
    I just sent the production beta version to tronic.· If anyone else is interested in playing with this almost-ready-for-the-masses version, visit the forum at http://forum.wr.ca/?id=2523.· This is a new forum for anyone wanting to play with the dll and is where I'll provide support.· I'll eventually release to flightsim.com, but I'm offering to all of you first.

    This version sends 3 bytes - pitch, bank, and dashlights.· The pitch and bank max, baudrate, comport#, and acceleration settings are now controllable through a cfg file.· As icing on the cake, the dashlights byte outputs status of landing lights, plane on ground, stall, overspeed, autopilot, brakes, landing gear, and flaps.· So this may be of interest to someone wishing to light indicators in their non-moving cockpit - it isn't necessary to use the 1st two bytes.

    Here's some sample code to show how to use it to light the dashlights:

    ' Get the 3 bytes from FS
    ' This version runs at 2400 baud
    
    '{$STAMP BS2}
    '{$PBASIC 2.5}
     
    pitch VAR Byte
    bank VAR Byte
    dashlights VAR Byte
     
    DIRL = %11111111
    OUTL = %00000000
     
    Begin:
    SERIN 16,396,60000,timedOut,[noparse][[/noparse]WAIT("KD"),HEX2 pitch,HEX2 bank,HEX2 dashlights]
    ' pitch and bank are now set
    ' send out the indicator signals
    OUTL=dashlights
    
    GOTO Begin
    timedOut:
    DIRL = %00000000
    END
    
    


    I'll be limiting my activity on this forum from this point forward since this is almost a completed project and I have a dedicated forum set up.

    -Lurker
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-05-11 19:11
    This is slightly tangental, but here is a project that converted an actual car into a driving simulator. BTW Lurker, thats a very cool project you've undertaken.
  • LurkerLurker Posts: 8
    edited 2005-05-17 14:55
    I uploaded the production version of the dll to FlightSim.com last night. I don't know how long it takes for them to move uploads from ftp to the file downloads section or if they'll even accept this, but it's named portdrvr.zip if you'd like to search their site and get your hands on it.

    Again, here's the Support Forum. I'm now going to concentrate on the pneumatics and will post stamp code and info as I progress.
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2005-06-06 12:16
    Remember this project? Its still in progress and here are the latest update:

    A basic stamp based wash-out effect for simulating true direction of the G-forces during a bank roll !!

    Great stuff!!· hop.gif


    Thanos
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2007-05-25 14:20
    Its more than two year now developing this project, and now I really have results. I used the joyrider cockpit design and attached two car wiper motors on it with simple pulley system to move it. To drive the motors I used two HB-25 and a Basic Stamp2 controller. The BS2 receives thru serial the angle data from the computer that is running FS2004 with a newer version of Lurker's Portdrvr gauge.

    The power for the motion cames from two 350 watt computer PSU that provides the 12 volt needed from the motors.

    It needs no end-stop switches as the feedback potentiometer automatically ramp-down when max angle is reached for either axis. The servo code that BS2 is running is proportional with a 5 times Kp (Proportionality constant) to keep the motion soft. Increasing the Kp up to 8 or 10 times it reacts really fast but draws lots of current from the PSU (I measured more than 10 ampere) and burns the power cables...



    See in·the video how the cockpit moves in two axis.

    motion flight simulator 2 axis operational:

    http://youtube.com/watch?v=JDOSoz1QL9A




    I yet have to add an LCD display in the front of the pilot seat, the custom USB rudders (you see·it lying down on the floor) and the microsoft ff2 sidewinder stick in it.

    Lurker has more info on the progress of his great utility on the link below:
    http://www.etherealsounds.com/


    See ya, Thanos
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Greekbotics: Greek Robotics Forum

    (Translate it using Babelfish)


    Post Edited (Tronic (Greece)) : 5/30/2007 6:54:36 AM GMT
    800 x 600 - 104K
    800 x 600 - 78K
    800 x 600 - 123K
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2007-05-29 12:04
    Here is an updated video of it in full motion!!! Flying an F16 with TrackIr4 Pro head tracking!

    http://www.youtube.com/watch?v=TBD9Juqx7PI

    Thanos


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Greekbotics: Greek Robotics Forum

    (Translate it using Babelfish)
    ·
Sign In or Register to comment.