Welcome to Cockpitbuilders.com. Please login or sign up.

March 29, 2024, 07:28:42 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
154 Guests, 0 Users
Members
Stats
  • Total Posts: 59,639
  • Total Topics: 7,853
  • Online today: 179
  • Online ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 154
Total: 154

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

Where to begin with Arduino and flight sims

Started by fsaviator, December 11, 2014, 09:04:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fsaviator

Trevor (and other of course),
I have a suspicion I am going to receive an arduino starter kit for Christmas from one of the kids.  I'd be interested in seeing how I can apply arduino to a simpit but have zero experience with it and my last real dip into programming was basic back in the '80s.

Can you recommend a starting point for me, particularly in the "build your own FS interfaces" category?
Warren "FSAviator"
http://www.B737NG-Sim.com  |  https://www.facebook.com/fsaviator/
P3D45/ Prosim737 2/ ACE Dual-linked Yokes/ RevSim Proline TQ and Dual-linked Rudders/ CPFlight MCP PRO3 and EFIS'; MIP737ICS_FULL and SIDE737; Forward and Aft Overheads; Pedestal/ FDS MIP

Trevor Hale

#1
Sure can bud.

Depending on what it is you would like to do with it.  I dove into this myself but for really only creating my own gauges for some things.  I am not an expert by any stretch of the imagination.  (My gauges are jittery as heck, but I am sure I will figure that stuff out LOL).

In any case, what you need it to goto  http://www.jimspage.co.nz/intro.htm

HERE IS A GREAT VIDEO DESCRIBING THE SOFTWARE AND HOW EASY IT IS TO HOOK UP>
  https://www.youtube.com/watch?v=OSzE6hgFWCM&list=PLxyM2a_cfnzhevjDiZYjlZZJzAlmObRiq


Download Jims Software, and it is pretty self expl.  Install it on the FS machine and select the outputs you are looking for.

If you are interested in the basic code, have a look at my code in the Arduino forum here and you can steel it and play with it, the only thing to note is on my Arduino UNO Card, I have an expansion card called a PCA9685 card, it is 12 bucks and turns the Arduino into 16 Servo/PWM Outputs.  But if you just want to play with the Basic Arduino, the LINK2FS Software that you download, has "WORKING SAMPLE CODE" (Sketches) for Inputs, outputs and Servos.  Actually perfectly working versions.

If you get stuck I am here to help as best as I can, or I can put you in touch with some guys that can do that stuff in their sleep.

Trev
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

RayS

I can help you with the jitters. :-)

I ran into the same issue when I was playing around with aircore gauges (and I'm assuming the same methodology can be used to drive servos, etc...)

(Please pardon my horrible C++.. this will be more like human-readable code)

Let's use "RPM" as an example:

In your code you're probably reading/setting a variable called @RPM, then sending that value directly to your servo.

SetServo(@RPM)


However, by smoothing out how the gauge seeks it's new value, you can eliminate large changes (Jitter)

Declare your variables as you would normally:
@RPM INT;
@LastRPM INT;
...
...
if (@RPM > @LastRPM)   /* Gauge needs to INcrease */
{
     @LastRPM += 1;   /* or "@LastRPM = @LastRPM + 1" Increase lastRPM by 1, or other factor for bigger movements */
     
     SetServo(@LastRPM);

}
else /* Gauge needs to DEcrease */
{
     @LastRPM -= 1;   /* or "@LastRPM = @LastRPM - 1" DEcrease lastRPM by 1, or other factor for bigger movements */
     
     SetServo(@LastRPM);

}




This approach renders the servo as always having to "Chase" the @RPM value. This really smooths out the gauge movements by preventing huge changes to the gauge position. It can only ever change by a value of 1 (Or other value depending on how fast you want to gauge to seek it's current value)














Ray Sotkiewicz

Joe Lavery

Sounds like Warren and I are on the same path, the last time I did any programming was on my old BBC Micro. Probably only me and Jack would remember that particular machine.  8)

I've been playing with the Arduino modules for a few months now, I find programming these much easier than SIOC which still baffles me.  :(  So I jump on any Arduino data I can find. In fact I built the LCD multi-radio interface from Jim's site, happily it worked first time, but I'm afraid it was more parrot fashion than anything else. I have no idea how to program anything this complicated, yet nice to see it working none the less.

Joe
Life isn't about waiting for the storm to pass, it's about learning to dance in the rain

Journalist - writer for  PC Pilot Magazine

phil744

Arduino, yeah i blame Trevor for this one......

Where to start. I got my first arduino about 2 years ago and got hooked big time, started with an Uno, then a mega then onto the DUE that's making a nice job of running an ISFD, who needs a VGA port?? so  ran away with myself.

However, you soon realize that there is nothing you cant do with an arduino.. or any of these development boards that are available now.

however the problem remains the same, how the hell do you get an arduino to talk to FS?. there are several options, that Jims page one is something i used a lot, then u realize that most vendors hardware are not actually true USB but USB to serial converters.  If it uses one of these FTDI USB to serial converters, guess what, you can talk to it via arduino, CP flight is a good example of this, read there SDK and you soon figure it all out.

Problem for me personally, is im building a 767 based on the levelD software. Nico Kaan did a program called Lekseecon that gives a dedicated range of FSUIPC offsets when configured correctly. But the ranges of these offsets are well outside the range of any interface software i know of.

only option for 767 builders is SOIC, will be honest, i would rather have genital warts then use SOIC. at least with genital warts you can get medication that comes with instructions you can actually understand.

I am not a windows programmer, never programmed anything apart from arduinos in my life.

So.. i need an interface that i can read/write to any FSUIPC offet i can think of via a serial port.  Had a mooch within the SDK for FSUIPC and there are some good example programs there. Downloaded something called visual studio, opened up one of the example programs and read through the pages and pages of, well, i still don't know what any of it means.

That point i decided i will not go home until Ive figured it all out. ordered lots of pizzas, red bull, and anything else that contained illegal amounts of caffeine. turned phone off and locked myself away.

and amazingly, i got something working. never done this before, i don't even know what language im working with (C# i think??) all in all very proud of myself, now i can build my sim :)

How does it work? .. magic and witchcraft i think. its actually very simple.

If you print to serial from arduino "0262,1,1" this simply means "offset 0x0262","value to set","write".

in arduino you code it as "Serial.println("0262,1,1");" you must use the Serial.println function as this puts the carriage return on the end of the message, my program uses this as the end of message go annoy FSUIPC now command.

offset 0x0262 is the pause command, just using as example. the second number "1" is the actual value to write, 1 being on, 0 being off. the 3rd number is the option to read or write to FSUIPC, 1 being write value to FSUIPC, and 2 being read value from FSUIPC.

It is that simple. in arduino if you do this...

Serial.println("0262,1,1");
delay(1000);
Serial.println("0262,0,1");
delay (1000);

your simulator will pause for 1 second, then un-pause for 1 second. change "0262" to "028C" and now it will flash your landing light once a second.

It can also read values, the last number on the serial string you change to 2. the second number is now the data length that FSUIPC will respond with ( a switch is 1, because its either 0 or 1, airspeed is a bigger number. use FSInterrogate in your modules folder as it lists all the sizes there for you).

example would be..
Serial.println("2F80,1,2"); // 2f80 is autobrake switch

and my program will spit out back to arduino its current state either 0 or 1 or 2 depending on its current state.

my program also uses the carriage return/new line on the message so in arduino use

    if(Serial.available() > 0)           
    {
     String InChar ;                                         
     InChar = Serial.readStringUntil('\n');
    }

now InChar is the value of the offset you have just requested, obviously u need to convert a "String" to an "int" so u can do something with it.  but you already know this. i use "=(InChar.toInt());" function.

I have included a sample sketch, but its designed to work with LevelD 767 (monitors the L+R yaw damper inop annuns) , but where you see "serial.println" change the first 4 numbers to an offset of your choice, its all the same.

Remember ive made this program, so its a little rough around the edges, im only 3 days into learning C# on windows so bear with me a bit. and it does crash time to time upon exit, i know why, just need to figure out how to fix.

and, ive only ever tested it with FS9, no idea if it works with FSX or whatever.

anyway, have a play, will kill a few hours :)

---------------------------------------------------------------------
757-200, P3D, LD767,Arduino, panels by some british moron, pile of dead airplane parts and a hammer!

Yeah i got one of these facebook things too http://www.facebook.com/Simvionics

Trevor Hale

#5
Quote from: phil744 on April 09, 2015, 09:35:15 AM
Arduino, yeah i blame Trevor for this one......


LOL Sorry Phil, but you know...  If I could do it and figure it out.....  Anyone can  :rock: Best part is..  I should have done it waaaaaaay sooner it ended up being so easy.

I am happy to NOTE: though, since the writing of this post I no longer use Link2FS Software, I happily use my FSUIPC Lua Script I created and send the data directly to the arduino. :)


Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

quid246

I think Phil sums it nicely... well maybe not sums, it was a long post... but definitely echoes how I feel about Arduino's applicability in building.

I'm not going to ask how Phil know's about the instructions that come with that type of medication, suppose he overheard it in a pub somewhere!

phil744

"I'm not going to ask how Phil know's about the instructions that come with that type of medication, suppose he overheard it in a pub somewhere! "

yeah good point, was in a pub... in Thailand i think..
---------------------------------------------------------------------
757-200, P3D, LD767,Arduino, panels by some british moron, pile of dead airplane parts and a hammer!

Yeah i got one of these facebook things too http://www.facebook.com/Simvionics

quid246


Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate