Page 1 of 4 1234 LastLast
Results 1 to 10 of 99

Hybrid View

  1. #1
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Arduino COM / NAV LED display - FSX

    Well...I have a success story. A small one, but a success story none-the-less.

    I have completed the COM1 freq display (beta) by using (4) seven segment LED blocks and Charlie-plexing the anodes; therefore, I am only using only 11 outputs to drive the entire COM1 display (...add another output to drive the leading MHZ "1" and trailing KHZ "0" and decimal pt). I am also using (4) inputs to increase/decrease the MHZ/KHZ freq according to the B737 display. I estimate I will be able to use COM1&2 and NAV1&2 on a single 2560 bd using a 5ms loop for an undetectable flicker rate and little bleed to the unlit segments - leaving room to use the analog inputs if I need.

    My problem will arise when I incorporate the rotary encoders; Since the loop will already be at 5ms, I believe I will need to use my second 2560 to handle the encoders and xmit data to the other 2560 "LED COM/NAV" display bd to prevent loop lag generated by the encoder read/translation.

    I admit that I am a novice. If I am on the wrong track, please do hesitate to offer alternatives.

  2. Thanks chitphoncha thanked for this post
    Likes Nelson Icibaci Filho liked this post
  3. #2
    500+ This must be a daytime job Jim NZ's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    764
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Hi James,,, Well done with the progress,,, neat stuff what you have acheived in such a short time and you will be looking forward to getting it to a usable state. Charlie-plexing ,,, very cunning approach.

    Now the rotary encoder thingy ,,, As you know I like pulse switchs but at the end of the day everyone gets rotary encoders. I have (and still am) digging into this dreaded corner and there are 2 ways to interface rotary encoders into Arduinos.
    1... Direct pin reading and sort it out internally or externally from there.(With or without an internal library)
    2.. Use interupts and sort it out internally or externally.

    Of the methods I have played with using the cheap mechanical rotary encoders, I found the following ,,,
    Direct input was the most consistant performer using the BOUNCE libray, but it still had direction/pulse errors and wasnt that fast ,, although you could "build in" acceleration.

    The interupt method was definately quicker but because of that, it really showed up dirty contacts with the wiping of the contacts in the switch, hence more direction/pulse errors. You can externally "debounce" the encoders contacts with capacitor/resistor arrangement but that puts you back to the speed of the direct read method,, more or less.

    Optical encoders would really perform with the interupt method. (I think ,, but I dont have any)

    Now,, That 5ms loop,, I wouldnt worry about it ,,, a "debounce" can be that long at anyrate so give it a go on the same card and see what happens.

    If you have good quality encoders you could use iether method,,, but if you have the cheapies,,, use the direct read method with the "bounce" library.

    I've been playing around with another method of handling rotary encoders and I'm Sooooo close to cracking it,, its frustrating. !!! A clean read with acceleration ,,, Soooo close. !!

    I seem to be writing a book here,,, but I've passed on what I know.... Hopefully some-one else with more knowledge might pop in and help you James.

    Again,, well done to get to where you are at ,,,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  4. Thanks JMeller, Joe Cygan thanked for this post
  5. #3
    300+ Forum Addict
    Join Date
    Apr 2008
    Location
    Graham, WA
    Posts
    323
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Instead of eating one more output for the leading 1 and trailing 0, why not just tie them to Vcc and recover the input?

    You might be better served in transmitting the freq up/dn commands to the host and let the COM1 Arduino pick up the change form the host instead of from another Arduino. (this is how I would do it, ymmv)

    Switch contacts have been known to bounce for as long as 25ms. I didn't know about the BOUNCE library - I'll have to dig into that!

    g.

  6. #4
    25+ Posting Member
    Join Date
    Apr 2012
    Location
    New Zealand
    Posts
    35
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Man this code is perfect for my home cockpit setup all except i stupidly bought common cath instead of anode LEDs and have no idea how to adjust the code accordingly, any hints mates?..

  7. #5
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Thanks Jim for the kind words and insight.

    Because I have a "new" set of eyes and have not developed (as of yet) a "set in stone" programming technique, I am going to toss this out there:
    The code I have written has only one delay (5ms) and that is to prevent the loop from running TOO fast. It prevents the current from leaking over to the unlit LED segments. To debounce the inputs, code was written to recognize that when any input goes high, a variable is incremented +1 at the end of the loop. This variable continues to increment so long as the input is HIGH. When the variable == 20, the display changes accordingly. When the variable == 40, the variable is reset to 0 and cycle repeats. If at anytime the input goes LOW, the variable resets to 0 - waiting for any input to go HIGH to begin it's cycle again. This allows the loop to run as fast as it can while allowing the switch to settle into place - - and also increment the display in a readable/predictable manner if I continue to hold in the button. I don't know if this perspective from a novice is useful, but I thought I would throw it out there anyway. Of course, mods to the code will needed with rotary encoders since A or B can hold their state at the next detent.

    As for the rotary encoders, I plan to purchase a moderately priced "grey code" encoder to reduce the aggravation of bouncing. Any recommendations are appreciated. I am also interested in the following post from Oleg (you probably have read this already) : http://www.circuitsathome.com/mcu/re...der-on-arduino
    However, I will need to get myself up to speed on truly understanding his code.

    I am anxiously awaiting the day when you share you success with encoders!

    Marching forward,
    James

  8. #6
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Thanks Jim for the kind words and insight.
    Gene, Vcc for the leading and trailing numbers - great catch; I'll do that.

    Because I have a "new" set of eyes and have not developed (as of yet) a "set in stone" programming technique, I am going to toss this out there:
    The code I have written has only one delay (5ms) and that is to prevent the loop from running TOO fast. It prevents the current from leaking over to the unlit LED segments. To debounce the inputs, code was written to recognize that when any input goes high, a variable is incremented +1 at the end of the loop. This variable continues to increment so long as the input is HIGH. When the variable == 20, the display changes accordingly. When the variable == 40, the variable is reset to 0 and cycle repeats. If at anytime the input goes LOW, the variable resets to 0 - waiting for any input to go HIGH to begin it's cycle again. This allows the loop to run as fast as it can while allowing the switch to settle into place - - and also increment the display in a readable/predictable manner if I continue to hold in the button. I don't know if this perspective from a novice is useful, but I thought I would throw it out there anyway. Of course, mods to the code will needed with rotary encoders since A or B can hold their state at the next detent.

    As for the rotary encoders, I plan to purchase a moderately priced "grey code" encoder to reduce the aggravation of bouncing. Any recommendations are appreciated. I am also interested in the following post from Oleg (you probably have read this already) : http://www.circuitsathome.com/mcu/re...der-on-arduino
    However, I will need to get myself up to speed on truly understanding his code.

    I am anxiously awaiting the day when you share you success with encoders!

    Marching forward,
    James

  9. #7
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Another success story!!!! Rather than use a rotary ENCODER, I had a 12pos 2pole rotary SWITCH in my parts bin (available from your over-priced Radio-Shack). Although it takes one more input than a rotary ENCODER, it works very well. After verifing the basic code operation, I inserted the code into my COM / NAV LED display code - with a few modifications (reducing the loop cycle to 4ms and to read on the 2ms.) It works PERFECTLY! As a test, I turned the rotary 3X faster than I would in flight - no misses!

    Jim,
    Will you help you help to point me in the direction of how to create/modify the software to interface with FSX, i.e. LinkFS ???

    If interested, I will post the code which can also be viewed by the Serial Monitor.

    Pumped!
    -James

  10. #8
    500+ This must be a daytime job Jim NZ's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    764
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Congradulations James ,, thrilled for you, and yes, the rotary switch is a good solid way to go.
    The "in and out" of FSX,, I can knock you up a "one of" to suit what you are doing, no worries.
    I've done heaps for other guys over the years (mainly motion platform stuff) although none of them were using Arduino's.
    I want to get this bug out of my "keys" program first though.
    In the meantime,, have a think of what info you want "out" and info back "in" to FSX ,,,, and its format.
    Just think of a basic "get it going" interface at this stage as I have plans to do a full blown in/out program to suit what we do. (A user can choose what he wants out and what he wants in)

    Of course we want code snippetts and pictures and anything you can produce that shares knowledge and helps other guys,, silly question ,,

    Well done James ,,,,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  11. #9
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    The basic wiring on the 12pos rotary switch - (Black) loop the 1st, 4th, 7th, and 10th pin to "input 53"; (Yellow) Loop the 2nd, 5th, 8th, and 11th pin to "input 51"; (Red) loop the 3rd, 6th, 9th, and 12th pins to "input 49". Place the common poles to +Vcc (w/ resistor).

    The basic code is as follows ( a smarter man can clean it up ):

    int pin53 = 53;
    int pin51 = 51;
    int pin49 = 49;

    int Black;
    int Yellow;
    int Red;

    int BlackMEM;
    int YellowMEM;
    int RedMEM;
    int BlackLOW;
    int YellowLOW;
    int RedLOW;

    int LOOPcycle;
    int Completed;


    void setup()
    {
    pinMode(pin53, INPUT);
    pinMode(pin51, INPUT);
    pinMode(pin49, INPUT);

    Serial.begin(9600);
    LOOPcycle = 0;
    Completed = 0;
    BlackMEM;
    YellowMEM = 0;
    RedMEM = 0;
    BlackLOW = 0;
    YellowLOW = 0;
    RedLOW = 0;
    }

    void loop()
    {
    Black = digitalRead(pin53);
    Yellow = digitalRead(pin51);
    Red = digitalRead(pin49);

    /* ++++++++++++++++++++++++++ Memory Storage ++++++++++++++++++++++++++ */
    if (Black == HIGH && LOOPcycle == 20)
    {
    BlackMEM = 1;
    // Serial.println("Black is HIGH");

    }

    if (Black != HIGH && BlackMEM == 1 && LOOPcycle == 20)
    {
    BlackLOW = 1;
    Completed = 0;
    }

    if (Yellow == HIGH && LOOPcycle == 20)
    {
    YellowMEM = 1;
    // Serial.println("Yellow is HIGH");
    }
    if (Yellow == !HIGH && YellowMEM == 1 && LOOPcycle == 20)
    {
    YellowLOW = 1;
    Completed = 0;
    }

    if (Red == HIGH && LOOPcycle == 20)
    {
    RedMEM = 1;
    // Serial.println("Red is HIGH");
    }
    if (Red == !HIGH && RedMEM == 1 && LOOPcycle == 20)
    {
    RedLOW = 1;
    Completed = 0;
    }

    /* ++++++++++++++++++++++++++ Determine Change ++++++++++++++++++++++++++ */

    if (Black == HIGH && RedLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("+1");
    RedMEM = 0;
    RedLOW = 0;
    Completed = 1;
    }
    if (Black == HIGH && YellowLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("-1");
    YellowMEM = 0;
    YellowLOW = 0;
    Completed = 1;
    }

    if (Yellow == HIGH && BlackLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("+1");
    BlackMEM = 0;
    BlackLOW = 0;
    Completed = 1;
    }
    if (Yellow == HIGH && RedLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("-1");
    RedMEM = 0;
    RedLOW = 0;
    Completed = 1;
    }

    if (Red == HIGH && YellowLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("+1");
    YellowMEM = 0;
    YellowLOW = 0;
    Completed = 1;
    }
    if (Red == HIGH && BlackLOW == 1 && LOOPcycle == 30)
    {
    Serial.println ("-1");
    BlackMEM = 0;
    BlackLOW = 0;
    Completed = 1;
    }

    LOOPcycle = LOOPcycle + 1;

    if (LOOPcycle == 40)
    {
    LOOPcycle = 0;
    }

    // if (Completed == 1)
    // LOOPcycle = 0;
    // Serial.println (LOOPcycle);
    delay(0);

    }



    -James

  12. Thanks mndless, Jim NZ thanked for this post
  13. #10
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino COM / NAV LED display - FSX

    Well, here is the code and a quick overview of the wiring modeled towards new comers, like myself. I did not realize, until now, that I could upload more than a jpeg. I still don't know how to post an image and the link. Oh well, I'll get the hang of this forum stuff yet!

    Anyhow, thanks again Jim for the links and support.
    Charlie-Plex_Final.jpgRotaryCOM1.zip

    Returning back into the hangar,
    James

  14. Thanks Sammy-E, Jim NZ thanked for this post
Page 1 of 4 1234 LastLast