PDA

View Full Version : Problem with verifying and compiling PDE in Arduino 1.0



HCarter
01-23-2012, 04:55 PM
Hi Jim

I'm new to Fliight Simulation. I'm an Avionics/Electronics teacher at George T. Baker Aviation School in Miami Fl. Here is our link http://www.bakeraviation.edu/. On several occasion we have been offered a full scale simulator as a donation to the school from Pan-Am, Air Bus and Beoing. Due to our limited space on the present school site and the area needed, we have had to turn them down. Just a month ago we were offerd an MD80 simulator, an ideal match being that we have an MD80 aircraft donated to the school by American Airlines. We have since decide to build our own PC based version. A co-worker of mine and I have applied and have recieved grant dollors towards this endeavor. We have looked at X-Plane and MS Sim X. We've decided to go with FSX.

Through research we ran accross your page and also found that there is a large community of Simmers. I have sense looked at your FSX interface software Linksfs_inout which I must say is really nice It will help us in meeting our low budget requirment for building a motion FSX simulator. I purchase Arduino Rev3 and download Arduino 1.0. I ran Blink as a test and it checked and uploaded fine. When I ran check on your PDE_inout_V1 I got some char size error. I'm not at my home computer where I can give you the exact error. But I want to know if you have verified that your PED works with Arduino 1.0 ? Your help in this matter is truly appreciated.

Sorry for such a long thread :)

Jim NZ
01-24-2012, 05:21 AM
What a neat project ,,, Things like that most of us only can dream of !!
And welcome to Mycockpit.org.

You are right with the non-compile of my PDE's using Arduino's IDE version 1.

If you want to "try" my demo PDE's you will have to download Arduino IDE version 0022 or being R3 cards you may have to use version 0023.
(I used version 0022 as I have the older cards.)
Both of them are available from the arduino site just under the download link for the latest version 1.

My PDE's wont compile in version 1 of their IDE due to them dramatically changing the way strings are handled. (amongst other improvements)

I am aware of this "problem" and plan to release PDE's to suit and also produce more "meaningful" demos PDE's.
For instance include "demo's" of a working radio head to include rotary encoders and show how to integrate rotary encoders into a project.

Any suggestion anyone ??? Idea's ,,, Volunteers ????
Maybe we can start a "Demo" library here that is in Flight Sim flavor. ???

Till then we are stuck with using the Arduino IDE version 0022 or 0023.

I wont get time for a week or so to do anything. :( :(

Get into it guys ,,, Jim

Tinnie
05-21-2012, 05:40 PM
I must congratulate Jim on his web site and sharing his extensive knowledge with those of us who do not have his

talents.

I bought an Arduino Uno a couple of weeks ago and tried to compile Starter1. As you know this doesn't compile with

the latest Arduino IDE version, so I had a go at updating the code for the changed string handling. I am long past my best

at 65 years old and have only a passing acquaintance with C++ but I struggled on and produced an update to Jim's

code. I had to add/change only 4 lines and this works on my system.

Here is a copy of the revised code, which will be saved as a '.ino' file.

/*

This example code is in the public domain.
*/

int xx; // sets up a variable for the receive cycle.

String gearnose, gearnoseold; // Sets up 2 string variables ,,, one for the new reading ,, one for the old.
// The reason why there is a new and old reading is to stop the code repeating the

commands.(It only act's on change)
// The reason they are strings and not bytes (or other) is, it's easier for a novice

to mentally visualize the
// difference in adding (1+2+3=6) versus concatentations (1+2+3=123).

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT); // Intitalises the pin 13 as an output pin.
Serial.begin(115200); // sets up the baud rate for the serial coms.
}

void loop() {
if (Serial.available() > 0) { //if there is a charator in the serial receive buffer then ,,,,
xx = Serial.read(); // read it.
if (xx == 'I'){ // Found the reading "Gear nose"
delay (11); // It seems to need a delay here

// LINES CHANGED FROM HERE *************

gearnose = ""; //clear string
gearnose += (char)Serial.read(); //Read the first charactor sent
gearnose += (char)Serial.read(); //Read the second charactor sent and add it to the first
gearnose += (char)Serial.read(); //Read the third charactor sent and add it to the other two.)
//Serial.println(gearnose); //--- this was used during testing to send value to serial monitor
// LINES CHANGED TO HERE *************

if (gearnose != gearnoseold){ // checks to see if its different to the "old" reading from the

last loop

if (gearnose == "000") {digitalWrite(13, LOW);} //if its "000" then turn OFF the LED

if (gearnose > "000" && gearnose < "100"){ // if its greater than "000" and less than "100" then

,,,
digitalWrite(13, HIGH); // set the LED on
delay(50); // wait for 50 milliseconds
digitalWrite(13, LOW); // set the LED off
delay(50); // wait for 50 milliseconds
}

if (gearnose == "100") {digitalWrite(13, HIGH);} //if its "100" percent down then turn ON the

LED

gearnoseold = gearnose; // Makes the old reading the same as the new reading.(So on the next

reading it can check to see if it's different)

} // end of the "yes it's different to the old reading" sequence
} //end of "found the gearnose" (I) read
} // end of "Yes" there is a serial read.
} // end of main loop (It goes back to the start of the main loop)


I hope this works for you.

Thanks Tinnie

WJH308
05-21-2012, 06:39 PM
Ah, I was right next door, I went to Miami Dade College to become an Air Traffic Controller, only to drop out and go to Flight School instead! Later CFI'ed in Tamiami at ADF airways before going over to Naples Air Center. One of my favorite memories of being over there was going to Alteon and getting to fly a full motion Level D 757 simulator. It was that experience that caused me to drop out of being an ATC'er and going directly to flight school.

Jim NZ
05-22-2012, 05:42 PM
Thanks for that Tinnie ,,, I haven't tried it yet but when I get back into "PDE mode" I will have a play with it. I think from memory the "Keys" bit is not liked by the new version as well so it's going to need some work and then I'll release updates.

Thanks again Tinnie ,,, Jim

WJH308
06-04-2012, 05:53 PM
I am currently working on a project using Arduino 0023 and rotary encoders. Later this week after I get my encoders and verify my code works, I will post the PDE on the forum. FYI, my project is using TM1640 displays from dealextreme, they are 16 7segment displays using serial input on a single pcb. Using two of them.
Thanks to Jim's hard work, all of this is going much easier than I ever imagined.

AK Mongo
06-04-2012, 06:36 PM
An encoder example would be great. Especially if it contains any "acceleration". Some other encoder interfaces do not handle performing large quick changes well while still having fine tuning.

This would be great for tuning things like nav radios requiring large compass card adjustments.

My .02..

Reid

WJH308
06-04-2012, 06:51 PM
I don't believe this to be a problem. My code does not do any acceleration because FSX itself does acceleration. What my code does is determine that if the encoder is turning left or right, and as long as it continues to move either increments or decrements the values. I do not count steps or clicks, just movement. To properly use an encoder and to count steps perfectly you need to use external interrupts, one for each pin. I can't do that, even with a mega, since my project uses 5 or 6 of them. I think a lot of people get hanged up on rotary encoders because they think they need to use them at full resolution?
I turn the encoder, it sends keys to flightsim, flightsim in turn updates my display. Don't need to count clicks. Anyhow my theories will be proven or disproven, I will post the code, and a project so everyone can build there own.
One thing I need to do to improve upon Jim's program is to incorporate the PMDG 737NGX sdk so I have access to all of the additional functions. Unless of course Jim is already working on that? wink wink.

AK Mongo
06-04-2012, 08:26 PM
I have used a BUO836X and FSUIPC to make the encoders work. Without a program to make it work, it is VERY slow turning. 1 detent on the encoder = 1 degree of change. If you speed it up to more degrees per detent you lose the fine tuning ability.

If you want to look at a code example, you can check out this LUA developed by Tom_G and Pete Dowson at the FSUIPC forums.

http://forum.simflight.com/topic/68260-rotary-encoder-input-speed/page__hl__%2Brotary+%2Bencoder+%2Bspeed

FSX through simconnect could be different, don't know enough about that. The LUA through the Bodnar card requires a great deal of fussing with as the timings that are set are dependent on frame rates from FSX. I thought the processing power of Arduino might make it closer to a driver level activity and relieve the CPU from extra duties....

WJH308
06-04-2012, 09:24 PM
I have used a BUO836X and FSUIPC to make the encoders work. Without a program to make it work, it is VERY slow turning. 1 detent on the encoder = 1 degree of change. If you speed it up to more degrees per detent you lose the fine tuning ability.

If you want to look at a code example, you can check out this LUA developed by Tom_G and Pete Dowson at the FSUIPC forums.

http://forum.simflight.com/topic/68260-rotary-encoder-input-speed/page__hl__%2Brotary+%2Bencoder+%2Bspeed

FSX through simconnect could be different, don't know enough about that. The LUA through the Bodnar card requires a great deal of fussing with as the timings that are set are dependent on frame rates from FSX. I thought the processing power of Arduino might make it closer to a driver level activity and relieve the CPU from extra duties....

Having not the chance to test out my code, I can't really say for sure. I am using a 3rd party encoder library from the same person that makes the teensy usb, PJRC.
His libraries have functions to count the number of clicks, etc. Using 2 interrupts per encoder, 1 interrupt, or no interrupts.
I simply test to see if the new value from the old value is greater, therefore I will increment 1 notch, if it is less than the old value, I decrease the same. If you are still turning the knob by the time the loop comes back to it, it will increase or decrease again. I am not counting the number of clicks, don't want to. You may turn it one click and nothing happens, I doubt that will be the case 99.99% of the time. I am very eager to share my code and my project, because I know this is something many, many people will love to have. I just want to make sure it works first before I post it.

WJH308
06-08-2012, 06:42 PM
Guys if you check out my post in this thread, http://www.mycockpit.org/forums/showthread.php/24715-My-PDE-Autopilot-controls-using-Rotary-Encoders-and-TM1640-displays

I made the appropriate changes to Jims program, and also the modifications to Keith's absolute best quadrature encoder library to all work in Arduino 1.0+