Results 1 to 3 of 3
  1. #1
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    rotary switch,dip switch or encoder

    Hi the
    yet again I need help
    I have my panels and pcb designed in eagle, ready to be shipped out to be made, but the is one if

    On my EFIS panel I need 2 rotary switches but they need to work as they weld be encodes, because airbus add on recognise only increase or decrease

    Anyway I was looking for some solution
    Now there is that article that says how to convert rotary switch to encoder, I tried that out and it does not work as it should.

    Second option is to us rotary 8 position DIP switch http://www.ebay.co.uk/itm/Switch-Rot...item51adada174 but I don't know how to program it in arduino so it would work as encoder.

    Option 3 is to wire up 45 degree rotary switch (8 position rotary switch) to arduino and program is as encoder, but again I do not know how.

    So please help on this case I think option 3 or using rotary DIP switch make sense.



    That is my pnel by the way

    Attached Images Attached Images

  2. #2
    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: rotary switch,dip switch or encoder

    In a past project, I found a way to have 12 position rotary switch to emulate an encoder; I'm sure there are better ways, however this worked for me.
    Using post #17 as a pictorial reference, below is a snippet; Black, Yellow, Red, and all nnnMEM are declared as int. LOOPcycle was used to prevent accidental repeats; LOOPcycle increases by 1 and when LOOPcycle == 4 then LOOPcycle resets to zero.

    In a nutshell, when you turn the switch, the arduino needs to remember which wire/input was HIGH versus what is currently HIGH to determine whether to increase or decrease.

    Code:
    /*  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ROTARY READ  ++++++++++++++++++++++++++++++++++++++++++++++++  */  
     /* ++++++++++++++++++++++++++  Memory Storage  ++++++++++++++++++++++++++ */ 
      if (Black == HIGH  && LOOPcycle == 2)
      {
      BlackMEM = 1;
     // Serial.println("Black is HIGH");
    
    
      }
     
      if (Black != HIGH && BlackMEM == 1 && LOOPcycle == 2) {  BlackLOW = 1; }
    
    
      if (Yellow == HIGH  && LOOPcycle == 2)  { YellowMEM = 1;   // Serial.println("Yellow is HIGH"); }
      if (Yellow == !HIGH && YellowMEM == 1 && LOOPcycle == 2) {  YellowLOW = 1; }
    
    
      if (Red == HIGH  && LOOPcycle == 2)  { RedMEM = 1; // Serial.println("Red is HIGH"); }
      if (Red == !HIGH && RedMEM == 1 && LOOPcycle == 2)  {  RedLOW = 1; }
      
    /* ++++++++++++++++++++++++++  Determine Change  ++++++++++++++++++++++++++ */ 
    
    
      if (Black == HIGH  && RedLOW == 1 && LOOPcycle == 2)  { //Serial.println ("+1");  RedMEM = 0;  RedLOW = 0; }
      if (Black == HIGH  && YellowLOW == 1 && LOOPcycle == 2)  { // Serial.println ("-1"); YellowMEM = 0; YellowLOW = 0; }
      
      if (Yellow == HIGH  && BlackLOW == 1 && LOOPcycle == 2) { //Serial.println ("+1"); BlackMEM = 0; BlackLOW = 0; }
      if (Yellow == HIGH  && RedLOW == 1 && LOOPcycle == 2) {  //Serial.println ("-1");  RedMEM = 0;   RedLOW = 0;  }
    
    
      if (Red == HIGH  && YellowLOW == 1 && LOOPcycle == 2)  {// Serial.println ("+1"); YellowMEM = 0; YellowLOW = 0; }
      if (Red == HIGH  && BlackLOW == 1 && LOOPcycle == 2)  { // Serial.println ("-1");  BlackMEM = 0;  BlackLOW = 0; }
    /*  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ROTARY END  ++++++++++++++++++++++++++++++++++++++++++++++++  */
    Hope this helps,
    James

  3. #3
    150+ Forum Groupie


    BushPilotWannabe's Avatar
    Join Date
    Jan 2014
    Location
    Alberta, Canada
    Posts
    176
    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 switch,dip switch or encoder

    Have not seen these before. Thanks for posting.