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

    ROTARY ENCODERS and the like.

    Rotary encoders and the like are a fact of life when it comes to cockpit building. How else are we going to "tune the radio" or "set the autopilot" etc etc.
    I started writing a starter post for this but it got too long and messy so I made it a page on my website for easy reference (if that's the word).

    www.jimspage.co.nz/encoders2.htm

    I'm a wee bit behind the eight ball here ,, I'm flat out with updating my program (v2) and I need to buy some new rotary encoders. (I found out the one I was using for testing was faulty one way)

    Got any stories ?? idea's ??? code ??? fire away and we can all have a play. The idea is to sort out the best we can come up with whether its using rotary encoders , rotary switch with a cunning wiring ,, pulse switch etc etc. Anything will do as long as its going to "up or down" a value.
    It needs to work on an already "busy" card and also needs to be able to work as multiple encoder inputs to a single card.

    So guys,, into it and have fun. ,,, Jim
    (And then it all went quite )

    P.S. James could you post your switch system here too please so other people researching this can find it easily ?? ,, Taa.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  2. #2
    500+ This must be a daytime job



    Join Date
    Oct 2009
    Location
    Juneau, AK
    Posts
    619
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: ROTARY ENCODERS and the like.

    Jim,

    One thing that I would add if possible to your Rotary function....Ability to detect acceleration and/or continuous turning to increase input speed. This is a problem that is encountered with some input cards and rotaries. A practical example of what I am saying is shown by GA pits and VOR/ADF card setting.

    My Rotaries have 16 "clicks" per 360 deg revolution. If the software reads 1 click per degree, then it takes 9+revolutions to change the heading or OBS by 180 deg. GoFlight units have some sort of acceleration on their rotaries, so that 1 slow click is one degree(unit of khz, tenth of an inch of Hg, etc.) but if you turn it more quickly it allows you to make gross adjustments quickly. Apparently this can be done on OpenCockpits units as well. It would be a great benefit to new users of arduino, if this were included in the GUI somehow.

    Does what I am saying make any sense?

    Reid
    http://juneaucessnasim.blogspot.com
    N58243 (virtual)- Low and Slow...

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

    Re: ROTARY ENCODERS and the like.

    I read your updated page, Jim. There are some quite informative links. And to oblige your request, below is a sample PDE and wiring diagram. (I feel honored to do so )
    Charlie-PlexJPG.jpgRotaryCOM1.zip
    I found the above to be reliable - no matter how fast the rotation. Long term however, it will not suit my NAV/COM display since I want to use the dual encoder for MHZ & KHZ (any links or part numbers would be appreciated). To address AK Mongo - In theory, I believe it will suite the autopilot controls incorporating the acceleration rotation. For example, the PDE loop detect for "+1" is 2 cycles; if you add a few lines to each "high" pin at given intervals before the cycle returns to the value of "0" and restarts the cycle, you could set the output value to + 100' or 1000'. This is an untested theory and I may be way off base. I will be watching this thread closely for, what I expect to be, much better ideas.

    -James

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

    Re: ROTARY ENCODERS and the like.

    Hi Guys ,, Well I've got rotary encoder stuff pouring out my ears now,, just spent the whole day making a decision on what ones to buy and to follow thru on with suitable code. I'm going to get "2 bit gray code" ,, with about 16 indents per complete turn. I'm going to get both the "full cycle" and the "half cycle". I'm starting on the "full cycle" as they will be the easiest to get going with simple code. Once that's done it only requires an upgrade of the code to handle the "half cycle" ones. Well,,, that's my angle of attack. Really looking forward to this mission ,, you guys are away ahead of me though.

    While researching all this I fell apon a great explanatory page ,,,, Not using Arduino though but a real good breakdown of these silly encoder things ,,,
    http://overkillsystems.com/id12.html
    complete with adaptations of making dual controls.
    That site belongs to Terry Adams and he can certainly turn out neat stuff.
    Talking of dual controls ,,, they seem to be a real rare bread and the easiest to get your hands on one is via Leo Bodnar (down the bottom of the page) ,,, http://www.leobodnar.com/products/BU0836X (half cycle ones) Pretty expensive though.
    James ,, I couldn't find it today but somewhere in the past there was a webpage showing how to make a dual control using the exact same switches as you use. It showed them as "ganged" and also as offset similar to the ones in Terry's page.(above) Food for thought. ???

    Thanks for reposting your setup here James ,,, I just thought that if some-one was researching rotary encoders they would find it here amongst all the other stuff on encoders we are going to do,, great stuff and thanks.

    Reid ,, Acceleration ,, yes I thought of that too but it would be good to thrash out good code for reliable use before bringing in acceleration. There is more to it than that though ,,, acceleration can be added later but mainly ,,, going into FSX via my "keys" program acceleration happens at any rate. As you know, I like pulse switches and I hooked up a pulse switch to the Arduino and coded it to turn the OBS pointer in the gauge and it worked a treat !!! Turn the pulse switch a lot and it speeds up. Programatically,, if it works for pulse switches,, it will work for rotary encoders.
    That code is still actually in my downloaded PDE file (Shift v = ) if you want to play, even just using buttons.
    Just the same ,, if some-one else dives in and makes a direct route into FSX (rather than thru "keys") then you will need acceleration right from the start. I do intend to bring in some "direct in" options as time goes by but while the "keys" option is temporary filling everyone's need then I'm not rushing into it.

    Just the same ,,, this is'nt all about what I think ,,, it OUR forum and it here for US ALL to make use of it. Things will shoot away above what I'm doing and that's great. I will be a happy chappy once straight forward projects are here and available for the novice to "get their hands into it" and enjoy the thrill of what we all do just about every day ,,, soooo ,,,, get into it and do your own stuff too.

    Sorry guys ,, writing a book again ,,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

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

    Re: ROTARY ENCODERS and the like.

    Now here's an interesting read. They talk about being adjustable from half cycle to full cycle, accelleration,, the works.

    http://www.neufeld.newton.ks.us/elec...p=248#more-248
    The download page ,,,,
    http://www.neufeld.newton.ks.us/elec...s/?page_id=249

    You cant get a simpler PDE loop than this ,,, AND its reading 2 encoders !!!

    /******************************************************************************
    * quadrature_two_encoders
    * Keith Neufeld
    * July 4, 2008
    *
    * Read and decode two quadrature rotary encoders.
    *
    * Demo system has encoders connected to digital pins 8/10 and 9/11.
    *****************************************************/
    #include "math.h" // (added later)
    #include "Quadrature.h"

    Quadrature quad1(8, 10);
    Quadrature quad2(9, 11);


    void setup() {
    Serial.begin(9600);

    quad1.minimum(0);
    quad1.maximum(150);
    quad2.minimum(-5);
    quad2.maximum(5);
    }


    void loop() {
    Serial.print(quad1.position());
    Serial.print("\t");
    Serial.println(quad2.position());
    delay(100);
    }


    I'm really keen to give this one a play when my encoders arrive.

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

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

    Re: ROTARY ENCODERS and the like.

    Something I want to add to the "rotary testing bench." With these Arduino's, pin voltages will float without the help of pull up or pull down resistors.... the chips have these built in, but they aren't real strong.... so, I was thinking about playing with a schmitt trigger and pull ups...

    here is a picture of how this would work for a single switch....


    I'd give credit, but I don't remember where I got this image....

    These come in a variety of shapes and sizes, the 8 pin DIP version would support 6 switches or 3 rotaries....

    In short, you pull the line high (5V) when nothing is happening... though the logic inverter of the schmitt trigger, that gives the arduino a low. When you actuate the switch, turn the rotary, you go to ground, a low... again, through the schmitt trigger, that will give you a high...

    Whether this is the right approach or not, I do not know, but something like this would have to help the consitency of rotaries.... or one would think.... Going to order a couple and play with them....

  7. #7
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2011
    Location
    Denmark
    Posts
    5
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: ROTARY ENCODERS and the like.

    I have been using this code with 4 encoders for a while now and it works great. It is scanning the encoders with a frequency of 50Hz and the Arduino can handle a lot more then 4 if necessary.
    INFO: if you want to use this library with a Mega card, you need to open the 'quadrature.h' file (which is in the library folder) and change the following line
    '#define DIGITAL_PINS (14)' to something like '#define DIGITAL_PINS (60)' otherwise you can only use pins 0-14 with an encoder.

    The one thing I have noticed with the Link2fs_FSX_inOut_v1 program is that when you turn the encoder fast FSX receives all the keystrokes and updates the screen accordingly, but nothing is sent back to the Arduino until it stops transmitting. This means that the LCD display does not get updated when turning the encoder fast. Maybe FSX is not updating the Link2fs program when it is receiving a lot of input?
    Anyway, it is a great library that functions flawless, but it does not have any accelleration built in (as far as I have found out).

    My MCP is coming along great (adding a lot of pushbuttons) and I am designing the frontpanel for it. Will show pics when that is done.

    David

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

    Re: ROTARY ENCODERS and the like.

    Well,, after loosing a heap of good fiddling time on this today ,,, I worked out they had left a line off the demo code.(above)
    You need to include the "math.h" into the sketch !!!! and it has to be before the Quadrature include ,,, like this ,,,,

    #include "math.h"
    #include "Quadrature.h"

    Lifes too short for these wee frustration.

    Right,, now I have my sanity back ,,, David,, good to get an update from you and thanks for that info for the Mega card and the quadrature library.

    I have got 2 of those "long" LCD's coming as I think they are perfect for an autopilot module. They can get everything one needs all in the one screen.
    Now,, the accelleration etc ,, yes I havent "studied" the whole thread yet but they talked about accelleration and the different cycles and there was code so I'll get back to it as I get into this PDE more. Accelleration can be added to any code really ,, but in saying that there is always a "catch" or a "spin off" when it comes to what we do.

    Good to know that you have that code working ,,, did you have to add the math.h line too ????

    The data from/to FSXinOut ,,, There's something wrong there David ,,, I can turn my pulse switch as fast as I like and the data in the LCD on the Arduino is changing with it along with the radio frequency in FSX ,, it works as it should.
    Have a look see at ,,,,,
    1/. Where in the void loop you have the "send data" stuff. (be careful if you have a seperate loop for transmitting only)
    2/. The Quadrature thingy may be upsetting things ??? (I'll know in a couple of days when I play with it myself)
    3/. Baud rate. ( This wont be the case if you are using 115200.)
    If all the above are OK ,, then get back to us and fire something into the FSX_inOut thread and we will dig into it and find whats going on.

    Yes ,, It would be great if you post some pictures of your project David,,, a picture tells a million words and it encourages others to do the same. The pictures dont have to be of a completed project, just a "here is where I'm at" type thing, in fact sometimes they are the more informative ones to see.

    Tony ,,, yep ,,, go for it ,, I know what your saying and understand, so it will be interesting how it goes as against us "software only" geeks.
    May the better way win !!!! LOL

    Cheers Guys ,,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

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

    Re: ROTARY ENCODERS and the like.

    WOW !!!! All I can say about Keith Neufeld's encoders code is WOW.!!!!!
    After getting some new encoders I put this to the test using the code below, which is a way of quickly showing up any error readings, (copy and paste ??)

    /****************************************************
    * quadrature_two_encoders
    * Keith Neufeld
    * July 4, 2008
    * Modified by Jim NZ to show error reads !!!!!
    * Read and decode two, different cycle quadrature rotary encoders.
    * Demo system has encoders connected to digital pins 8/10 and 9/11.
    *****************************************************/
    #include "math.h"
    #include "Quadrature.h"
    Quadrature quad1(8, 10);
    Quadrature quad2(9, 11);
    int X; // a test variable
    int Xold; // the old reading
    int Xdif; // the difference since last loop
    int X2; // a second test variable
    int Xold2; // a second loop old reading
    int Xdif2; // the second test difference
    void setup() {
    Serial.begin(115200);
    quad1.minimum(-1500);
    quad1.maximum(1500);
    quad2.minimum(-1500);
    quad2.maximum(1500);
    }
    void loop() {
    X =(quad1.position())/2; // divide by 2 for full cycle encoders
    if (X != Xold) { // checks to see if it different
    (Xdif = (X-Xold)); // finds out the difference
    Serial.println (Xdif); // sends the difference to computer
    Xold = X; // overwrites the old reading with the new one.
    }
    X2 =(quad2.position()); //normal code for half cycle encoders
    if (X2 != Xold2) {
    (Xdif2 = (X2-Xold2));
    Serial.println (Xdif2);
    Xold2 = X2;
    }
    }

    I'm pleased to say this came thru with flying colors with very few error reads.
    The two encoders I used were,, one, half cycle 30 indents ,, and the other was a full cycle 12 indents.
    I then integrated "sort of" similar hacked code into my default PDE (as supplied with my FSinOut program) and other than an unrelated problem (see below) ,, it worked beautifully.

    I think (KNOW !!!) I'm going to stick with this library due to ,,
    Real easy to get going. (Not complicated)
    It handles half and full cycle encoders (Very simple change)
    It has very good (Although not perfect) rate on "no errors".
    It is FAST !!!!!
    It can be used for multiple encoders on the one card.
    The code to integrate it into projects is dead simple. !!!!!
    Contact bounce ,,, Never had any problems here at all,, although, both were new encoders.
    To be quite frank ,,, I'm not even going to dig out all my codes from my earlier plays with encoders.

    Acceleration ,,, Once I fixed a glitch in my FSXinOut (see below) I turned my attention to acceleration.
    I changed the code to input to the OBS pointer in the panel and all I can say is ,,, NICE !!! it was far smoother than earlier experiments although,, with the 30 indent encoder you had to be careful as the acceleration "kicked in" very quickly ,, This confirmed the earlier conclusion that indents should be in the 12 to 20 range. (Stay away from 30 indent ones)

    Well,, that's all the good news ,,, the bad news,,, David is correct that there is a delay in the data getting back to the board from FSX ,,, in fact FSXinOut isn't even processing it to send back quickly. I have made a post in the FSXinOut thread to keep that all together and its development to "flow".

    Cheers Guys ,,, Jim with many
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  10. #10
    25+ Posting Member
    Join Date
    Apr 2007
    Location
    SC
    Posts
    71
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: ROTARY ENCODERS and the like.

    Thanks for posting that Jim.... have it saved... not quite ready with my "rotary encoder testing bench" just yet....

    Glued up a few things today, working in that direction...



    It will make sence soon!!

Page 1 of 3 123 LastLast