Results 1 to 5 of 5
  1. #1
    New Member
    Join Date
    Jan 2013
    Location
    leam
    Posts
    2
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Encoder Multi Radio

    Hi Jim,

    My name is Daniel, I'm fron Spain,

    I am working with a Multi Radio program, I changed the encoder pins original (8, 9), I've tested (10, 11) and (12, 13)
    and the encodr works well. The original encoder push pin 10. I put in the pin 27 and everything Works fine.

    But if I put the encoder pins (28 - 53) does not work the encoder

    Example:

    Quadrature quad1 (52, 53)

    pinMode (52, INPUT);
    digialWrite (52, HIGH);
    pinMode (53, INPUT);
    digitalWrite (53, HIGH);

    Please as I can put the encoder pins (28 to 53) ??

    Thank you very much.

  2. #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: Encoder Multi Radio

    Yes they do work on any pin ,,

    Copied from my website ,,, (And it's also in the Doc's)

    In the download the demo is set up for using with a Uno card (max pin = 14) but to use it with a Mega card ,, all that needs doing is to open out the 'quadrature.h' file and edit the line '#define DIGITAL_PINS (14)'. Change the 14 to what ever pin no. is going to be your highest.

    I'm assuming that is the problem Daniel.

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

  3. #3
    New Member
    Join Date
    Jan 2013
    Location
    leam
    Posts
    2
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Encoder Multi Radio

    Hi Jim

    OK OK, OK, I modified the value and you put 53 and it Works fine.

    Many, thank you very much.

    If I have any question I ask.

    A greeting and thanks

  4. #4
    New Member
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Encoder Multi Radio

    Hi, Iīm back building after 3 years pause, because of a computercrash in january 2012, and due to heavy workload the last 3 years.

    I have the same problem as dachiva, but modify the Quadrature.h didnīt help.

    Itīs the Quadrature2.zip from Jimīs site.

    Ivé done a lot of rework, partly from the InOut_v3 program and an early version of Multi (2011), and redesign to use with link2fs Multi 5h, and that has gone very well. Iīm back in the same status as before the crash, and a little more.

    Iīm going to rebuild my radiostack from swithes to dual rotary encoders from Leo Bodnar. They work very well, but only from pin 2-12, not 22-53 (Mega 2560).

    I need 4 dual encoders for Com and Nav, and 4 separate encoders for DIR, HDG, ALT, V/S to begin with. I have all the encoders, they work, but not from pin 14 an up.

    Iīve compiled the sketch with 1.5.8, and today with 1.6.0, with no success. (I needed 1.5.8 to get the LCD TFT to work.)

    The code below is complete, but stripped to only one encoder for easyer reading.

    Bug or is my head fucked up?

    /*

    ======================================================

    Compiled with IDE 1.6.0

    Quadrature.h modified #define DIGITAL_PINS (53)

    The sketch works with pin 2-12, but NOT with pin 14-53

    ======================================================
    */

    #include "math.h"
    #include "Quadrature.h"
    Quadrature quad1(23, 25);//Com1 MHz

    int X;//the RE's present state (RE = rotary encoder)
    int Xold;// the old reading
    int Xdif;// the difference since last loop
    int doutPin;
    int CodeIn;
    long timePrevious;
    long timeNow;
    long timeInterval = 80;//you adjust this for "your" feel of fast (default 80)
    int fastTurn = 0;//variable for turn-speed state

    void setup()
    {
    Serial.begin(115200);
    for (int doutPin = 2; doutPin <= 53; doutPin++)// setup the input pins
    {
    pinMode(doutPin, INPUT_PULLUP);
    digitalWrite(doutPin, HIGH);
    }
    }//end of setup

    void loop() {
    timeNow = millis();//get the milli count. (for speed check)
    {ROTARYS();} // go and check the rotary encoder
    if (Serial.available()) { // now lets check the serial buffer for any input data
    CodeIn = getChar();
    //if (CodeIn == '=') {EQUALS();}// The first identifier is "="
    //if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
    //if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
    } // end of serial available
    }// end of void loop

    char getChar()// Get a character from the serial buffer
    {
    while(Serial.available() == 0);// wait for data
    return((char)Serial.read());// Thanks Doug
    }//end of getchar

    void ROTARYS(){
    // Now the bit for the rotary encoder input
    X =(quad1.position()/2);//Com1 MHz
    if (X != Xold) { // checks to see if it different
    if(timeNow - timePrevious < timeInterval) {fastTurn = 1;}else{ fastTurn = 0;} //is it being turned fast or not ?
    (Xdif = (X-Xold));// finds out the RE's difference (going backwards or forwards)

    if (Xdif == 1) {//knob is going forward
    if (fastTurn == 1){//yes it's being turned fast ,, else ,, it's being turned slow
    for (int accel = 1; accel <= 10; accel++){//loop to send "A02" 10 times ,, use more or less to suit.
    Serial.println ("A02");}// Com1 MHz increase fast
    }else{//it's turned slow
    Serial.println ("A02");}// Com1 MHz increase slow (sent once)
    }//end of forward

    if (Xdif == -1) {//knob is going backwards
    if (fastTurn == 1){ //yes it's being turned fast ,, else ,, it's being turned slow
    for (int accel = 1; accel <= 10; accel++){//loop to send "A01" 10 times
    Serial.println ("A01");}// Com1 MHz decrease fast
    }else{//it's turned slow
    Serial.println ("A01");}// Com1 MHz decrease slow (sent once)
    }//end of backwards

    if (quad1.position() > 1000){ // zero the rotary encoder count if too high or low
    quad1.position(0);
    }
    if (quad1.position() < -1000){
    quad1.position(0);
    }
    Xold = X; // overwrites the old reading with the new one.
    timePrevious = timeNow;//resets the previous time to timenow
    }//end of yes its different
    } // end of 'Rotarys'

  5. #5
    New Member
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Encoder Multi Radio

    Hi, guys

    10 min after my post, I found the reason why it didnīt work from pin 14 and above, and I have to admit, it was a human error.

    I found out that it was the wrong Quadrature.h I had modified. I modified the one in the Arduino Install Catalog, and not in the one in my Arduino USER Catalog.

    Because it was my first post since registration 3 years ago, and a moderator had to approve the post, and I couldīnt edit my post directly.

    My radiostack now work in full. Sorry for the post, but I really did try hard to find the fault before I had to post.