Introduction: Microsoft FSX Flight Sim
This instructable will teach you how to build a motion flight simulator using an arduino and motors.
Step 1: Obtain Required Parts
-Either an Arduino Uno or Freeduino will work for this project
-Obtain a computer system that can run multiple monitors
-Obtain a copy of Microsoft flight simulator X
-Get a copy of Multi FSX v5 from Jim's page
http://www.jimspage.co.nz/Link2fs_Multi.htm
-12v battery
-2 12v linear actuators
-Sabertooth 2x25 motor shield v2
-18 gage wire
-Accelerometer Arduino shield
-Joystick
-Cool chair
-Led
-Small speaker
-Small servo motors for small scale
-push button
Step 2: Install Programs on Computer
The first step of this project is to install:
-Windows 7 (if not already on your computer)
-Arduino Programming software
-Microsoft Flight Simulator
-Multi Fsx from Jim's Page
Multi Fsx is a key part in this project. What this program does is it takes data from Microsoft Flight Simulator (such as pitch, roll, acceleration data, g force, stall warning etc) and sends it to the Arduino which we will then program to interpret that data and move motors / sound a speaker and make lights go off.
Step 3: Configure MULTI FSX
In this step we want to select the options for the program to rip from Microsoft Flight Sim X and send to the arduino
-Select stall warning
-acceleration body x and y
-gear position
Step 4: Program the Arduino
Here is the programming to control small servo motors as you fly a plane in real time. They will move as you turn. This programming also controls an led indicator for landing gear, a speaker for a stall warning and a push button to also toggle the landing gear.
It is up to you to program the full size actuators!
#include
#include
Servo pitchservo;
int rollVal = 0;
Servo rollservo;
int pitchVal = 0;
int CodeIn;
int flapsINT;
int rollInt;
int pitchInt;
int gForceInt;
int stallInt = 0;
String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;
String gearSimple, flaps, flapsOld, rollS, pitchS, gForceS, stallS;
void setup()
{
pinMode(2, OUTPUT); // gear nose LED
pinMode(5, OUTPUT); // gear nose in transition LED
pinMode(12,OUTPUT); //stall warning
rollservo.attach(8);
pitchservo.attach(11);
Serial.begin(115200);
}
void loop() {
Serial.println(stallInt);
stallInt = 0;
pitchVal = map(pitchInt, -25, 25, 0, 179);
if (rollInt > -90 & rollInt < 90)
{ rollVal = map(rollInt, -10, 10, 0, 179);}
else {rollVal = 90;}
pitchservo.write(pitchVal);
rollservo.write(rollVal);
if (stallS == "1" )
{tone(12,140);}
else{noTone(12);}
if (Serial.available()) {
CodeIn = getChar();
if (CodeIn == '<') {LESSTHAN();}
if (CodeIn == '?') {QUESTION();}
}
}
char getChar()
{
while(Serial.available() == 0);
return((char)Serial.read());
}
void LESSTHAN(){
CodeIn = getChar();
switch(CodeIn) {
case 'F':
gForceS = "";
gForceS += getChar();
gForceS += getChar();
gForceS += getChar();
gForceInt = gForceS.toInt();
break;
case 'S':
stallS = "";
stallS = "";
stallS = "";
stallS += getChar();
Serial.print("String: " + stallS);
stallInt = stallS.toInt();
Serial.println(" Int: " + stallInt);
break;
}
}
void QUESTION(){
CodeIn = getChar();
switch(CodeIn) {
case 'Y':
gearSimple = "";
gearSimple += getChar();// get first charactor (Nose gear)
if (gearSimple == "2"){digitalWrite(2, HIGH);}else{digitalWrite(2, LOW);}
if (gearSimple == "1"){digitalWrite(5, HIGH);}else{digitalWrite(5, LOW);}
case 'y':
pitchS = "";
pitchS += getChar();
pitchS += getChar();
pitchS += getChar();
pitchS += getChar();
pitchS += getChar();
pitchS += getChar();
pitchInt = pitchS.toInt();
break;
case 'x':
rollS = "";
rollS += getChar();
rollS += getChar();
rollS += getChar();
rollS += getChar();
rollS += getChar();
rollS += getChar();
rollInt = rollS.toInt();
break;
}
}// end of question void
Step 5: Making the Connections
For the small scale model
On the Arduino
-Pin 4 to low side of push button
-for the y axis servo white wire, put in pin 11
-for the x axis servo white wire, put in pin 8
-hook the led into pin 2
-pin 12 is for the speaker.
See picture
For the full size model with actuators
The push button, led and speaker stay the same.
To hook up the actuators
-5v on the arduino goes to the 5v on the Sabertooth motor controller
-gnd on arduino goes to 0v on the motor controller
-pin 0 goes to s2 on motor controller
-pin 1 goes to s1 on motor controller
-positive pin on 12v battery goes to b+ on saber tooth
-negative pin on 12v goes to b- on sabertooth
-m1a on Sabertooth goes to positive on actuator
-m1b goes to negative on actuator
-m2a on Sabertooth goes to positive on actuator2
-m2b goes to negative on actuator2
Step 6: Build a Full Size Model
You have the main part of the programming, and how to set everything up. The last step is to just mount everything on a custom built frame and away you fly!