The poor mans sim pit

Graphics Cards, Sound Cards, Joysticks, Computers, etc. Ask or advise here!

Re: The poor mans sim pit

Postby OldAirmail » Thu Nov 03, 2016 9:27 pm

Thanks, Zeus. This is EXACTLY the kind of post that I was hoping to see four years ago when I started The poor mans sim pit.

Everybody has their own idea of what they want. Usually time and money get in the way, and like you I have a space problem to contend with.

Basically, I wanted to find alternatives to the "real" simpits, like this one - Terry's 737NG Cockpit Project

Image Image

Image

I'm not knocking the guy, I simply can't do what he's doing. And, I think that there are many more like me that have to make the most of what we have.


So, I've come up with practical ways to go past just a joystick and keyboard. (The joystick I don't mind. But I absolutly HATE having to use a keyboard to "fly")

For instance, I've shown how to take a cheap numeric keypad and use it to control the on-screen GPS.

Image Image


Then, although I really, really like the small Saitek gauges, I could only justify buying one. So for significantly less I bought two 9" USB monitors for instruments.

Image

Doing that gives me the advantage of using "glass instruments" in the same space, as in this Cessna.

Image


Speaking of GPS, an early example of how to use cheap USB monitors with the Saitek Radio Panel was this one -
[youtube]http://www.youtube.com/watch?v=JVFRKou7R_U[/youtube]


Over the years I've offered alternatives. Some more expensive than others, yes. But all cheaper than a full sim cockpit. :D

And now I've discovered Arduino controller boards - What it takes to make an Arduino Flight Sim Controller.

For less than $10 and a pocket full of buttons you can make your own flight sim panels that will do the same as the Saitek and Pro Flight panels for hundreds less. All you need is a little time, a little learning, and a little ingenuity.



You've got a great "sim pit". It actually looks better than mine. :D

If you could, can you show a picture of the whole "small bedside table" setup? I have a friend who's thinking of putting the same kind of thing in front of his 50" TV. :D
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby zeus981 » Fri Nov 04, 2016 2:12 am

As requested here is a few photos of my Flight Sim 2 prop bedside table set-up.
Image
Above shows the metal C frame of the table..( chosen because its shape gives good clear leg room) and a side plywood vertical support to give a bit of bracing to it and provides a place to attach USB hubs.
Image
The above shows the other side. The original wood top I discarded and replaced with a larger bit I had from an old coffee table. It was exactly the same width as the width of yoke, a FIP and saitek panel.
Image
The above shows the frame I made for the touch screen monitor mounted on top of the yoke. Basically build something strong enough to not wobble or drop the monitor. I probably over engineered this. Mounting points will depend on brand purchased. $20 worth of cheap tools (hack saw, pop riveter, small file and screwdriver) and $20 worth of flat aluminium strips / L angle strips is all thats required from local hardware store.. There are screw holes on top of the yoke ( made for other saitek panels) that provides the means to fit this frame.
Image
Above shows the left side of the yoke fixed to wooden table top with flat aluminium strip and one of the brackets holding the saitek switch panel under the yoke... screwed into the underside of the table top. Getting the 2 small bolt holes perfecly aligned for the switch panel is crucial. I missed by about 1mm but it holds firmly in place with just the lower bolts anyway. NB Its essential that the yoke strap be formed to fit precisely around the contours of the yoke otherwise it will wobble. A tight fit will mean only one strap is needed. I took the yoke apart to check that the two screws I put into each side of the yoke were not going to hit anything on the inside.
Image
The above shows that not everything is precise and neatly manufactured. The throttle quads slide onto the table top and are clamped into place with the help of some timber pieces. Note that the diagonal brace on this side is fixed on top of a small piece of wood (20mm height) so as to give clearance for the throttle quad to be clamped directly to the table top.
Image
I added the above in case any observant persons wondered what the small pieces of L shaped aluminium strips were above the GoFlight module and switch panel. They hide some LED strip lights (button battery powered but for extra $$ could be powered from USB) so I can see what Im doing when I turn off the room light for night-time flying. I also have a piece of purplish celophane paper stretched over the small monitor to reduce night-time glare.
Image
Above - the full picture (taken before plywood vertical bracing was put on)
Finally, it took me quite a while before I got around to putting all the cables into flex tubes and keep it tidy.. ..trust me, do that straight away. .. and one day I will stop using the back of the set-up as a scrap heap of bits and pieces and will make it into a shelf or compartment for storage of manuals / software add-on discs etc.
zeus981
Ground hog
Ground hog
 
Posts: 26
Joined: Sat Sep 26, 2015 4:19 am
Location: Geelong, Vic., Aust.

Re: The poor mans sim pit

Postby OldAirmail » Fri Nov 04, 2016 5:57 pm

I blew the screen up 200%, and saw something. Do you have a label maker? Like a Brothers P touch? I've labeled all my USB cables too. :D

The table stand is square/rectangle tubing? That might be hard to find nowadays, but I'll show him the pictures. Thanks



It won't work for you, but you might like how I mounted my two 9" USB monitors. My computer desk is an old 1990s office printer table. It has to serve me for a work space, place to watch movies, and a flight sim pit.

The two monitors rest in a U channel wall shelf support. In a minute or two I can drop both monitors into the track, and takeoff. The wireless keyboard has just enough room to slide under the Saitek equipment and out of the way, giving me a small work/project area. :D

Image


Image


Image

No monitor stand needed. :D
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Sat Nov 05, 2016 8:17 pm

Back to building the Arduino based GPS



Back to basics - Read the beginning of the Arduino box, and the beginning of Arduino controller - Building a GPS if you missed those parts. If you haven't read them, what follows isn't going to make much sense.

One side note - the camera that I have isn't very good color wise, and the close-up pictures come out as if it had a fisheye lens. Trust me, things look better in real life.



So you have all the parts. Maybe you've spent $60 or $70 on the parts. You may have even spent less if you were careful. :confusion-shrug:

Whatever you have, you now need to start putting holes in something.

I started by laying the monitor ON TOP of the aluminum plate and marking it out. You could cut a window for the monitor to sit behind the plate, but why cause problems?

This also helped to determine how much room there was for the buttons, and where to put them.

Image



Next, I drilled a series of connecting holes for the monitor ribbon to pass through. After filing the rough edges smooth, I "painted" the edges with liquid electrical tape. I bought it cheaper at the local hardware store.

Image

Image

I also used the liquid electrical tape to paint the bare metal around the edges of the monitor. Big mistake, it looks ugly. Just use regular paint.



The project box that I'm using gives me the option of having it lay horizontal, or stand upright. I prefer the flat, horizontal, position.

At least with the monitor that I have, it looks better at that angle. And as there are no overhead lights, there is no reflection problems. This position also gives greater stability when pushing the buttons.

Two things about this picture. 1) the screen in real life looks MUCH better. 2) In Prepar3d, if you have the main, flight sim, screen in "full screen mode" (hold the ALT key down & hit the Return key), the aircrafts GPS will have no "Windows" border around it. The GPS in this picture doesn't fill the screen because the cable that I had been using suddenly went bad and I had to disconnect the main monitor to use it's cable. If I had had a good cable the GPS in this picture would have filled the screen top to bottom, and side to side.

Horizontal
Image

Dialing in KSEA from 3W5, Concrete, WA
Image


Standing upright
Image



There are many things that we can do with the help of a cheap Arduino board and a bit of work. Start thinking, and start building.



End notes
Labels - Later I'll printout an overlay with the button identifiers on paper. After printing the overlay, I'll laminate it. If you want to keep it simple, use a label maker.

This is an example of what I want to do.
Image

I'll probably steal the idea of buttons/switches/knobs on the top edge too. :D

Dual concentric knobs - I have a black set, and a gray set of knobs from Propwash Simulations. For the pictures I thought that I'd have one of each for contrast in the pictures. I like it. :D I'll keep it that way.

Attaching the monitor -This isn't gong to get tossed around much, so I attached the monitor with double sided tape. Simple. :D

Monitor resolution - 800 X 640 worked best for this monitor.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Sun Nov 06, 2016 10:55 am

VERY INTERESTING - VERY IMPORTANT.

I kept hearing the connect/disconnect sound that Windows makes every time that you plug/unplug a USB device.

Furthermore, checking the "Device and Printers" section in the control panel, I'd see that there was a USB device that was unrecognizable.

The Arduino Pro Micro (correctly identified as an Arduino Leonardo, which it imitates) was still shown in the "Device and Printers" section, and still worked without any problem.



Slow child in the neighborhood that I am, it took a while to recall that Windows 10 in particular, has a tendency of using the power saving settings to turn off some USB devices.

So, guess what? THAT is the problem.

Go here and uncheck the box where it says "Allow the computer to turn off this device to save power". DO IT FOR EVERY USB HUB/CONTROLLER LISTED!

Image

If you need a little help read this - Fix issue: USB Ports not Working in Windows 10

The only thing left to say is that I had to restart the computer to do a 100% fix.

What a difference! :D
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Tue Nov 08, 2016 10:24 pm

Just a short post before I go to bed.


Thought that I'd do a very quick run through of the GPS text.

This first one wasn't too far off. The lines will be removed. Maybe. Maybe not.

Text shifted a bit.

And then I'll have to decide what type of paper to print it on. Lots of choices out there, every thing from metallic to textured stock. Maybe even a solid color.

The screws will be covered, as here.


Anyway, here's the first mock-up, on plain white paper, of what I want to print.

Image
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby zeus981 » Sun Nov 13, 2016 4:55 pm

OldAirmail wrote:The two monitors rest in a U channel wall shelf support.
from 4 Nov
This is a novel way of supporting monitors in position but what stops them from falling forwards or backwards?

PS my label maker is a sticky tape dispenser. ...Label is a bit of paper sandwiched between two pieces of sticky tape.
zeus981
Ground hog
Ground hog
 
Posts: 26
Joined: Sat Sep 26, 2015 4:19 am
Location: Geelong, Vic., Aust.

Re: The poor mans sim pit

Postby OldAirmail » Sun Nov 13, 2016 7:22 pm

zeus981 wrote:
OldAirmail wrote:The two monitors rest in a U channel wall shelf support.
from 4 Nov
This is a novel way of supporting monitors in position but what stops them from falling forwards or backwards?

PS my label maker is a sticky tape dispenser. ...Label is a bit of paper sandwiched between two pieces of sticky tape.

Image

The table that I use was used in the late '80s/early '90s as a printer table. It big and VERY heavy. I bought it for around $10 after an auction was over. They must have had at least 15 shoved against a wall.

Later I built a wide monitor stand with just enough space next to the stand for my computer case. That's what the U channel is mounted to (It has brown imitation wood trim).

Later, when I started using FSX, I bought three 23" monitors, but the old monitor stand wasn't wide enough so I put an eighteen inch deep board on top of the old stand. That's the white(er) board above the fake wood trimmed stand.

The upper board is moved back about 1/2 inch. The monitors drops into the U channel slot and rests at a slight angle against the white board.

In the past four, or more, years I think that I've almost knocked one 9" monitor over one time. They're very stable. I used to take them down after using FSX to clear the shelf, but most of the time now I just leave them in place.

For what it's worth, the monitors came with small stands, but the stands took up too much room sitting on top of the makeshift table top.


"PS my label maker is a sticky tape dispenser. ...Label is a bit of paper..."

All things come to those who visit yard sales. :D
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Sun Nov 27, 2016 12:03 pm

First the good part


The FLT1 is even better looking in real life than it is on the DSD website.

It's bigger than I was expecting, even though they give the measurements on the website. That extra space is important because the room around the rotary encoder knobs give people like me, with large hands, plenty of room to turn the knobs.

Also, I guessed right in ordering the red buttons for the GPS that I made - they match very well. :D

(The label cover on the GPS is only a rough first draft for label placement, not the finished label cover.)
Image

Frankly, I love it.




Next. The, not so, good part

I've had this for the last ten hours. Just thinking about what to do. I really don't want to give it up.

Posting a quick review at this moment may be disrespectful to DSD, but I'm VERY disappointed.

Mostly what I'm thinking is that I could just rip out the controller board and put in an Arduino board. :think:


Here's the problem

The rotary encoders, at the top, work ok. Every now and then, they skip past a rotational click or two, but that wouldn't be unnoticeable to most people.

The lower red buttons are perfect. Every time that you push them, they immediately register with the computer. Couldn't be better.


The ON/OFF switches, on the other hand....

Flip the switch either ON or OFF, and it makes a VERY brief contact.

The way that the on/off switches work on the Saitek switch panel is like this - Move the switch up and it HOLDS a button press until you move the switch down.


Why is that important?

Lets use the landing lights as an example.

The switch in the Saitek Panel only makes an electrical contact when you move the switch up. You assign that action one event - Landing lights on.

When you move the Saitek switch down you break the contact. What you do then is to assign an action for when that switch loses contact - Landing lights off.

The lower red buttons actually work the way that the switches should - they hold a connection as long as you press them down. Remove your finger and the contact is broken.

The switches on the other hand, will sometimes register NO CONTACT AT ALL.

Two of the switches (counting left to right), numbers 5 and 7, feel soft when flipped upwards, and DO NOT register any connection at all. They're standard size switches, and I have several in my drawer. Replacing them wouldn't be a technical problem.
Image

The other switches, as I said, will usually, but very briefly, register the same button contact when flipped either up or down.

Remember, on normal switches, there should be a constant contact held until the contact is broken by moving the switch down, to the OFF position. Not a VERY brief contact in either direction.


To put it another way, think of the keyboard "G" key. The G key controls the landing gear.

It doesn't matter what state the landing gear is in, when you push the G key, the landing gear will "toggle" from one position, to the other position.

That's fine for a key on a keyboard, but not a switch that should be definitely ON or definitely OFF.



To me, it looks like the wires from the switches were attached to the red buttons, and what should be on the buttons, were attached to the switches.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Sun Nov 27, 2016 2:09 pm

Another update


Good news from DSD. A new FLT1 is on it's way. :dance:

I'm not kidding you when I say that I like this button box a lot. This can be a perfect flight sim controller for those who want to use as little space as possible.




I've reread the DSD website concerning the ON/OFF switches.

It clearly states that the switches give a brief contact (button press #) when switched on, and the same contact (button press #) when switched to the OFF position.


That works great for functions that have a "toggle" action, such as the Landing gear.

Although this says "Button", that's just the way that the switch is read - as a button. (1 in this case)
Image

The only problem with a brief momentary contact in a ON/OFF switch is that the switch has to be in the proper position before the sim is loaded. Understand that and you're on your way to using the switches.



The actual red buttons, however, do behave like the Saitek switches.

If held in they maintain connect, and you can then program an action for when they're released (switched to the OFF position).

Image


Aside from the way that I would prefer the switches to work, I believe this to be a VERY good bargain.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby OldAirmail » Sun Nov 27, 2016 10:46 pm

And yet another update

The DSD button box didn't have to go back to the owner. The repairs were very minor.

Naturally, there are mods that I'll want to do, but that can wait for later. There are still mods that I'm thinking about for the GPS.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby Sprocket » Wed Nov 30, 2016 8:47 am

..
Basics for 737-800 MCP.
Don't really know where to post this, but I don't think it is worth a new thread, or if it will even be worth anything to anybody. So OAM, if I may? :think:

Some time the beginning of this year, I cobbled together the hardware and sketch for the default 737-800 MCP. This past weekend I dusted it all off again, made some changes to the sketch (program)
and fired it all up again.
It is not as if I need, or even want, a 737 MCP...I do these things purely out of interest and amusement. But at this point I do not want to go any further with it.

I have put in loads of notations and explanations, so if you are interested, I suggest that you read the sketch basically line for line.
Finally, I make my own circuit boards at home, so you will notice from the photo that the Led Modules are NOT the standard 8xdigit modules available on line.
(Having each MCP function on its own led module, gives you the freedom to mount the modules each in the correct place on the panel).

Like I said, this is the basics of the MCP, dealing mainly with the readouts.

Photos:
Image
Image

Sketch:

//**********************************************************************************
/*
This is a basic "start" for the default Boeing 737-800 MCP For Arduino Mega. By Jan -- Sprocket

It is intended to be used with Jim's Link2FS : http://www.jimspage.co.nz/Link2fs_Multi.htm
I have borrowed heavely from Fess_ter at My Cockpit, as well as from Jim's examples - THANKS GUYS.

General: There are 5 MAX7219 Led modules designated Module 0 to Module 4.
From Left to Right, the digits order are: 7,6,5,4,3,2,1,0
The modules must have their own 5V supply, BUT be shure to COMMON the negatives

MODULE 0 = Course on 3 Digits
MODULE 1 = Speed on 4 Digits
MODULE 2 = Heading on 3 Digits
MODULE 3 = Altitude setting on 5 Digits
MODULE 4 = Vertical Speed setting on 5 Digits


There are 5 rotary encoders with push switch: QuadA for setting Course _ Here I used a half cycle encoder, 24 detents, from the scrap box. **SPECIAL NOTE HERE IN THE ENCODER ENGINE SECTION
QuadB for setting Speed _ For the next 4 I used full cycle/24 detents with "push to make" switch.
QuadC for setting Heading
QuadD for setting Altitude
QuadE for setting Vertical speed
*/
//*****************************************************************************************************************

#include "Quadrature.h" // This Library required for the working of the encoders.
#include "LedControl.h" // This Library required to drive the MAX7219 7 segment LED displays.

// "Led_Module" is the variable name of the daisy chained modules,
LedControl Led_Module = LedControl(22,24,23,8); // running off pins 22,24,23. Pin 22 is DataOut(Goes to 1st MAX "Din"), Pin 24 is clock, Pin 23 is
// Load or CS. The 8 is the count for how many modules you have in the chain. Max allowed = 8.
// To daisy chain the MAX7219 modules, parallel all Clk inputs and all CS (chip select)inputs, then
// Data Out from pin 22 goes to the 1st module "Data In". "Data Out" from the 1st and subsequent module then to next module "Data In"

Quadrature quad1(2, 3);
Quadrature quad2(4, 5);
Quadrature quad3(6, 7);
Quadrature quad4(8, 9);
Quadrature quad5(10,11);



int CodeIn; // used on all serial reads
int Count; // This variable used in loops in the EQUALS() function
int current_pin; //Used on button switches


String current_pin_state; // The state of an individual pin being processed
String current_pin_old_state; // The previous state of an individual pin being processed for comparison
String all_pins_state; // The state of all of the pins that we are using for Encoders, Buttons, and Switches
String all_pins_old_state; // The previous state of all of the pins that we are using for Encoders, Buttons, and Switches for comparison




//****************************************************************************
String Digit;
String QuadAup;
String QuadAdown;
String QuadBup;
String QuadBdown;
String QuadCup;
String QuadCdown;
String QuadDup;
String QuadDdown;
String QuadEup;
String QuadEdown;
String FDon;
String FDoff;
//****************************************************************************

int AP_alt_set[5];
int AP_vs_set[4]; // Hopefully all of these variable names are mostly obvious.
int AP_hdg_set[3]; // The [n] with a number in it tells the arduino to make an array of the size n
int AP_crs_set[3]; // They are used to store the extractions in array format.
int AP_speed_kt_set[3]; // The information is stored in arrays to be able to display it without delay
int AP_mach_set[3];
int AP_AutoThrottle_arm; // State of the Auto Throttle Arm
int AP_Flight_Director_Active; // State of the Flight Director

int KntsMach_select = 50;

long Xold1;// the first encoder "old" reading
long Xold2;// the second encoder "old" reading
long Xold3;// the third encoder "old" reading
long Xold4;// the fourth encoder "old" reading
long Xold5;// the fith encoder "old" reading

char AP_vs_minus; // This is used to designate whether the AutoPilot VS is climbing or descending,
//so for this we use the first digit of Module 1 which will show a "-" or not, depending.
void setup() {

all_pins_old_state = "111111111111111111111111111111111111111111111111111111111111111111111"; // Setting a starting point for comparison.

for (current_pin = 28; current_pin <= 53; current_pin++) // Get all the pins, from 28 to 53, ready as Inputs
{
pinMode(current_pin, INPUT_PULLUP); // By setting the pins as INPUT_PULLUP it makes them all "HIGH"

}
// Then, all of the rest, Pins 54 to 69, are set as Outputs for LED annunciators
pinMode(A0, OUTPUT); // Analog pin A0 is also pin 54
pinMode(A1, OUTPUT); // Analog pin A1 is also pin 55
pinMode(A2, OUTPUT); // Analog pin A2 is also pin 56
pinMode(A3, OUTPUT); // Analog pin A3 is also pin 57
pinMode(A4, OUTPUT); // Analog pin A4 is also pin 58
pinMode(A5, OUTPUT); // Analog pin A5 is also pin 59
pinMode(A6, OUTPUT); // Analog pin A6 is also pin 60
pinMode(A7, OUTPUT); // Analog pin A7 is also pin 61
pinMode(A8, OUTPUT); // Analog pin A8 is also pin 62
pinMode(A9, OUTPUT); // Analog pin A9 is also pin 63
pinMode(A10, OUTPUT); // Analog pin A10 is also pin 64
pinMode(A11, OUTPUT); // Analog pin A11 is also pin 65
pinMode(A12, OUTPUT); // Analog pin A12 is also pin 66
pinMode(A13, OUTPUT); // Analog pin A13 is also pin 67
pinMode(A14, OUTPUT); // Analog pin A14 is also pin 68
pinMode(A15, OUTPUT); // Analog pin A15 is also pin 69

// Wake-up
Led_Module.shutdown(0,false); // The MAX7219's are in power-saving mode on startup, we have to do a wakeup call
delay (100); // Put the delay in so they dont all start drawing current at the same time.
Led_Module.shutdown(1,false);
delay (100);
Led_Module.shutdown(2,false);
delay (100);
Led_Module.shutdown(3,false);
delay (100);
Led_Module.shutdown(4,false);

// Set the display brightness to a lower than medium values
Led_Module.setIntensity(0,8);
Led_Module.setIntensity(1,8);
Led_Module.setIntensity(2,8);
Led_Module.setIntensity(3,8);
Led_Module.setIntensity(4,8);


Serial.begin(115200);

} //end of setup

void loop(){

if (Serial.available())
{
CodeIn = getChar();
if (CodeIn == '=')
{
EQUALS();
}
}

//******************* Rotary Encoders engine ***********************

//****COURSE******
long X1 =(quad1.position()/2); // ** NOTE: divide by 2 here because here I have used a "half cycle" encoder.
if (X1 != Xold1){
if (X1 > Xold1) {Serial.println(QuadAup);} else {Serial.println(QuadAdown);}
Xold1 = X1;

}//end of quad1 read

//****SPEED*****
long X2 =(quad2.position()); // The rest are full cycle encoders
if (X2 != Xold2){
if (X2 > Xold2) {Serial.println(QuadBup);} else {Serial.println(QuadBdown);}
Xold2 = X2;
}//end of quad2 read

//****HEADING********
long X3 =(quad3.position());
if (X3 != Xold3){
if (X3 > Xold3) {Serial.println(QuadCup);} else {Serial.println(QuadCdown);}
Xold3 = X3;
}//end of quad3 read

//****ALTITUDE*****
long X4 =(quad4.position());
if (X4 != Xold4){
if (X4 > Xold4) {Serial.println(QuadDup);} else {Serial.println(QuadDdown);}
Xold4 = X4;
}//end of quad4 read

//****VS*******
long X5 =(quad5.position());
if (X5 != Xold5){
if (X5 > Xold5) {Serial.println(QuadEup);} else {Serial.println(QuadEdown);}
Xold5 = X5;
}//end of quad5 read

{ //**************** End of Encoders engine ***********************

// ***********************************************************
// ************* Manual Settings by encoder knobs ***************
{
QuadAup = "A55";
QuadAdown = "A56";

Led_Module.setDigit(0,7,AP_crs_set[0],false); //Course:
Led_Module.setDigit(0,6,AP_crs_set[1],false);
Led_Module.setDigit(0,5,AP_crs_set[2],false);
}

//{
if (digitalRead(50) == HIGH)
{
QuadBup = "B15";
QuadBdown = "B16";
Led_Module.setDigit(1,6,AP_speed_kt_set[0],false); //Speed in Knts on 3 readouts
Led_Module.setDigit(1,5,AP_speed_kt_set[1],false);
Led_Module.setDigit(1,4,AP_speed_kt_set[2],false);

}

else if (digitalRead(50) == LOW)
{
QuadBup = "B18";
QuadBdown = "B19";
Led_Module.setChar(1,7,' ',false);
Led_Module.setDigit(1,6,AP_mach_set[0],true); //Speed in Mach on 4 readouts
Led_Module.setDigit(1,5,AP_mach_set[1],false);
Led_Module.setDigit(1,4,AP_mach_set[2],false);
}
//}

{
QuadCup = "A57";
QuadCdown = "A58";

Led_Module.setDigit(2,7,AP_hdg_set[0],false); //Heading:
Led_Module.setDigit(2,6,AP_hdg_set[1],false);
Led_Module.setDigit(2,5,AP_hdg_set[2],false);

}

{
QuadDup = "B11";
QuadDdown = "B12";

Led_Module.setDigit(3,7,AP_alt_set[0],false); //Altitude: 5 readouts
Led_Module.setDigit(3,6,AP_alt_set[1],false);
Led_Module.setDigit(3,5,AP_alt_set[2],false);
Led_Module.setDigit(3,4,AP_alt_set[3],false);
Led_Module.setDigit(3,3,AP_alt_set[4],false);

}

{
QuadEup = "B13";
QuadEdown = "B14";

Led_Module.setChar(4,7,AP_vs_minus,false); // Here a "minus" token is use to indicate when the VS is minus.
Led_Module.setDigit(4,6,AP_vs_set[0],false); //Vertical speed: 5 readouts
Led_Module.setDigit(4,5,AP_vs_set[1],false);
Led_Module.setDigit(4,4,AP_vs_set[2],false);
Led_Module.setDigit(4,3,AP_vs_set[3],false);
}

}// Goes high up -do not remove..

}//End of void loop

//**********************************************************************************************************

//**********************************************************************************************************
void INPUTPINS() // All of the Encoders, Buttons and Switches are checked for changes
{
all_pins_state = ""; // Clear this before the "for" loop because we will recreate it at the bottom one pin at a time
for (int current_pin = 21; current_pin <=53; current_pin++) // going to cycle thru all input pins 21 - 53
{
current_pin_state = String(digitalRead(current_pin)); // get the state of the current pin and make it a string format
current_pin_old_state = String(all_pins_old_state.charAt(current_pin - 21)); // acquire the previous state of the current pin
// *** Explanation *** The previous state of the current pin is acquired by reading a single character in the string "all_pins_old_state"
// *** Explanation *** All of the pins, previous states are stored as individual characters in the string "all_pins_old_state" as a "0" or a "1".
// *** Explanation *** We treat the individual characters as being numbered 0,1,2,3,4,...
// *** Explanation *** If the current_pin is 25, "all_pins_old_state.charAt(current_pin - 21)" takes (25-21) which = 4.
// *** Explanation *** ".charAt" gets the character at position 4 in the string "all_pins_old_state"
// *** Explanation *** Now we have the current pin's previous state and we can compare it to the current pin's "current" state.
if (current_pin_state != current_pin_old_state) // compare the state of the current pin to its previous state
{


/* ************** INPUT Pin Uses ******************


22-23_24 Designated pins for the MAX 7219 Modules
2+3 Encoder for Altitude adjust -- (All encoder center pins are connected to ground)
4+5 Encoder for Heading adjust
6+7 Encoder for Vertical speed setting
8+9 Encoder for Course setting
10+11 Encoder for Speed setting

************ Possible INPUT pin uses **************
21 Free
28 Flt Director Switch
29 Free
30 Free
31 Free
32 CMD A Button
33 Free
34 Free
35 ALT HLD Button
36 Free
37 VOR LOC Button
38 APP Button
39 HDG SEL Button
40 VNAV Button
41
42 SPEED/Mach Button
43 A/T Arm Switch
44 Speed Hold Button - Send B26 for toggle, (or B24 for ON and B25 for OFF)
45 N1 Button
46 Push Button on HDG Encoder
47 AP Disengage Switch

48-49
50-51
52-53

************ Possible LED Annunciator Pins (ie, OUTPUTS) *************
2
A0 (54)
A1 (55)
A2 (56)
A3 (57) CMD A Light
A4 (58) V/S Light
A5 (59) ALT HOLD Light
A6 (60) APP Light
A7 (61) VOR LOC Light
A8 (62) LNAV Light
A9 (63) HDG SEL Light
A10 (64)
A11 (65) VNAV Light
A12 (66) SPEED Light
A13 (67) N1 Light
A14 (68)
A15 (69)
*******************************************
*/


// *******************************************************************************************
// N1 Button
if (current_pin == 45)
{
if (digitalRead(45) == HIGH) // N1 Button is depressed and we need to Send a command
{
Serial.println ("B31"); // Send the Toggle command
}
}
// *******************************************************************************************
// SPEED Button
if (current_pin == 44)
{
if (digitalRead(44) == LOW)
{
Serial.println ("B26"); // Toggle Airspeed hold
}
}
// *******************************************************************************************
//Auto Throttle Arm Switch
if (current_pin == 43)
{
if (digitalRead(43) == HIGH and AP_AutoThrottle_arm == 1 ) //Auto Throttle arm ON
{
Serial.println ("B34");
}
if (digitalRead(43) == LOW and AP_AutoThrottle_arm ==0 ) //Auto Throttle arm OFF
{
Serial.println ("B34");
}
}
// *******************************************************************************************
// ???? Button
if (current_pin == 42)
{
if (digitalRead(42) == LOW)
{
Serial.println ("");
}
}
// *******************************************************************************************
// ????? Button
if (current_pin == 21)
{
if (digitalRead(21) == LOW)
{
Serial.println ("");
}
}
// *******************************************************************************************
// VNAV Button
if (current_pin == 40)
{
if (digitalRead(40) == LOW)
{
Serial.println ("");
}
}
// *******************************************************************************************
// HDG Button
if (current_pin == 39)
{
if (digitalRead(39) == LOW)
{
Serial.println ("B04");
}
}
// *******************************************************************************************
// APP Button
if (current_pin == 38)
{
if (digitalRead(38) == LOW)
{
Serial.println ("B08");
}
}
// *******************************************************************************************
// VOR LOC Button
if (current_pin == 37)
{
if (digitalRead(37) == LOW)
{
Serial.println ("B07");
}
}
// *******************************************************************************************
// ????? Button
if (current_pin == 36)
{
if (digitalRead(36) == LOW)
{
Serial.println ("B10");
}
}
// *******************************************************************************************
// ALT HOLD Button
if (current_pin == 35)
{
if (digitalRead(35) == LOW)
{
Serial.println ("B05");
}
}
// *******************************************************************************************
} // End of IF Current Pin State Check
all_pins_state += current_pin_state; // Constructs what will become the all_pins_old_state after the "for" loop is done
} // End of 'for' loop
all_pins_old_state = all_pins_state; // all_pins_old_state is updated for the next trip thru the "for" loop
} // End of INPUTPINS() Function

//************************************************************************************************************
// Read from the FS and display the values on the modules
//************************************************************************************************************

char getChar()// Get a character from the serial buffer

{
while(Serial.available()== 0 ); // wait for data//
return((char)Serial.read());
}

void EQUALS(){ // The first identifier was "="
CodeIn = getChar(); // Get another character
switch(CodeIn)

{

case 'b': // AP altitude set
Count = 0;
while (Count < 5)
{
Digit = "";
Digit += getChar();

AP_alt_set[Count] = Digit.toInt();
Count++;
}

{
Led_Module.setDigit(3,7,AP_alt_set[0],false); //Altitude
Led_Module.setDigit(3,6,AP_alt_set[1],false);
Led_Module.setDigit(3,5,AP_alt_set[2],false);
Led_Module.setDigit(3,4,AP_alt_set[3],false);
Led_Module.setDigit(3,3,AP_alt_set[4],false);
}
break;

case 'c': // AP vertical speed set
Count = 0;
while (Count < 4)
{
Digit = "";
Digit += getChar();

if (Count == 0)
{
if (Digit == "-")
{
AP_vs_minus = '-';
}
else
{
AP_vs_minus = ' ';
}
Digit = "";
Digit += getChar();
}


AP_vs_set[Count] = Digit.toInt();
Count++;

{
Led_Module.setChar(4,7,AP_vs_minus,false);
Led_Module.setDigit(4,6,AP_vs_set[0],false); //Vertical speed
Led_Module.setDigit(4,5,AP_vs_set[1],false);
Led_Module.setDigit(4,4,AP_vs_set[2],false);
Led_Module.setDigit(4,3,AP_vs_set[3],false);

}
}

break;

case 'd': // AP heading set
Count = 0;
while (Count < 3)
{
Digit = "";
Digit += getChar();

AP_hdg_set[Count] = Digit.toInt();
Count++;
}

{
Led_Module.setDigit(2,2,AP_hdg_set[0],false); //Heading
Led_Module.setDigit(2,1,AP_hdg_set[1],false);
Led_Module.setDigit(2,0,AP_hdg_set[2],false);


}

break;

case 'e': // AP course set
Count = 0;
while (Count < 3)
{
Digit = "";
Digit += getChar();

AP_crs_set[Count] = Digit.toInt();
Count++;
}

{
Led_Module.setDigit(0,2,AP_crs_set[0],false); //Course
Led_Module.setDigit(0,1,AP_crs_set[1],false);
Led_Module.setDigit(0,0,AP_crs_set[2],false);

}

break;

case 'f': // AP speed knots set kts
Count = 0;
while (Count < 3)
{
Digit = "";
Digit += getChar();

AP_speed_kt_set[Count] = Digit.toInt();
Count++;
}

{
Led_Module.setDigit(1,6,AP_speed_kt_set[0],false); //Speed in Knts
Led_Module.setDigit(1,5,AP_speed_kt_set[1],false);
Led_Module.setDigit(1,4,AP_speed_kt_set[2],false);

}

break;

case 'g': // AP mach set
Count = 0;
while (Count < 3)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}

AP_mach_set[Count] = Digit.toInt();
Count++;
}

{
Led_Module.setChar(1,7,' ',false);
Led_Module.setDigit(1,6,AP_mach_set[0],true); //Speed in Mach
Led_Module.setDigit(1,5,AP_mach_set[1],false);
Led_Module.setDigit(1,4,AP_mach_set[2],false);

}
break;

// ************************************************
// Following are the annuciators - LED Indicators

case 'a': // AP active
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(57, HIGH);
}
else
{
digitalWrite(57, LOW);
}
break;
case 't': // AP AutoThrottle armed on/off
Digit = "";
Digit += getChar();
AP_AutoThrottle_arm = Digit.toInt();
if (AP_AutoThrottle_arm == 1 )
{
digitalWrite(69, HIGH);
}
else
{
digitalWrite(69, LOW);
}
break;
case 'q': // Flight Director Active
Digit = "";
Digit += getChar();
AP_Flight_Director_Active = Digit.toInt();
if (AP_Flight_Director_Active == 1 )
{
digitalWrite(A1, HIGH);
}
else
{
digitalWrite(A1, LOW);
}
break;
case 'k': // Altitude lock active
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(59, HIGH);
}
else
{
digitalWrite(59, LOW);
}
break;
case 'm': // APP
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(60, HIGH);
}
else
{
digitalWrite(60, LOW);
}
break;
case 'j': // Heading lock Active
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(63, HIGH);
}
else
{
digitalWrite(63, LOW);
}
break;
case 'p': // VLOC
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(61, HIGH);
}
else
{
digitalWrite(61, LOW);
}
break;
case 'v': // v/s
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(58, HIGH);
}
else
{
digitalWrite(58, LOW);
}
break;
case 'o': // LNAV
Digit = "";
Digit += getChar();
if (Digit == "1")
{
digitalWrite(62, HIGH);
}
else
{
digitalWrite(62, LOW);
}
break;


}

}
User avatar
Sprocket
1st Lieutenant
1st Lieutenant
 
Posts: 309
Joined: Wed Oct 30, 2013 12:10 pm

Re: The poor mans sim pit

Postby OldAirmail » Wed Nov 30, 2016 10:25 am

Thanks, Sprocket. That's fantastic.

Question - Is the Arduino Mega the one you had earlier mentioned as being "too slow"?

I'd imagine that for the aircraft that I often fly, "speed" wouldn't be critical. :lol:
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The poor mans sim pit

Postby Sprocket » Wed Nov 30, 2016 12:51 pm

OldAirmail wrote:Question - Is the Arduino Mega the one you had earlier mentioned as being "too slow"?


Hi OAM..No, the Arduino Mega itself is not the issue, but rather how the code has been written, or been put together.

The "void loop" is mostly where trouble occurs. For instance, in this very MCP sketch I originally had a different method of reading the encoders.

During the execution of the program, the loop runs over and over. In this sketch, it is instructed to, amongst other things, to also constantly look at
any button or input that may have changed state, and act accordingly. And that includes even just one tick on any one encoder.

My original encoder section was not suitable, and made the whole thing too slow to be of any good. From Jim's pages, I found an example of the current
encoder engine, which I then adapted for my use, and it is working fine now.
I also avoid any time delays anywhere in the loop.

Here's one for you. Contrary to what you may believe, I AM AN ABSOLUTE NOVICE WITH ARDUINO.. :think: :?

I do however have experience with National Instruments LabVIEW, http://www.youtube.com/user/Labview
and many years of building stuff with "Microchip" PICS.
Arduino is based on the Atmel AVR, and in the days before Arduino, you were either in one of the two camps...
You were either a PIC man, or an AVR man. With constant bantering both ways.

Most commercial products around the world uses the PIC, medical equipment, vacuum cleaners, fridges and anything that needs a controller.
The sale of PICS are measured in billions per annum.

But, great was my surprise to read that the mighty MICROCHIP company has now acquired and amalgamated the Atmel Company.
http://www.microchip.com/announcements/ ... ires-atmel

Anyways, this is getting longwinded..Point is, the code must be streamlined.

Jan
User avatar
Sprocket
1st Lieutenant
1st Lieutenant
 
Posts: 309
Joined: Wed Oct 30, 2013 12:10 pm

Re: The poor mans sim pit

Postby OldAirmail » Tue Dec 06, 2016 9:18 pm

Thanks, Jan.

I'll have to give it a try that code later.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

PreviousNext

Return to Hardware

Who is online

Users browsing this forum: No registered users and 108 guests