Results 1 to 5 of 5
  1. #1
    New Member HyperWarp's Avatar
    Join Date
    Apr 2013
    Location
    los angeles
    Posts
    1
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Question arduino unable to get readings from "More Extractions" in Link2fs

    Hi all,
    I've been playing with Link2fs for a couple of days. Great work Jim!

    So here's a piece of code I have, it reads "Gear Position Nose" ("I" in the main page) and sends it to the servo to simulate the motion.
    Everything worked if I'm using outputs from main page.

    My goal was to get readings from "Throttle 1 Position", which is (">g") in More Extractions tab.

    The problem is, Arduino is not getting readings when I changed the "I" in the code to ">g"
    I've turned off the "correct the + and -" option in Link2fs settings, so throttle position the output should be the same as the gear (ranging from 0-100)

    Any help or suggestions are appreciated.


    Code:
    #include 
    
    
    Servo myservo;
    int xx; 
    String gearnose, gearnoseold; 
    
    void setup() {                
      Serial.begin(115200); // sets up the baud rate for the serial coms.  
      myservo.attach(9); 
    }
    
    void loop() {
      if (Serial.available() > 0) {
        xx = Serial.read();    
        if (xx == 'I'){     // Found the reading "Gear nose"
          delay (11);    // It seems to need a delay here
          gearnose = ""; // Empty gearnose 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.)
    
          if (gearnose != gearnoseold){      // checks to see if its different to the "old" reading from the last loop
            int val = gearnose.toInt(); 
            val = map(val, 0, 100, 10, 180);
            myservo.write(val);                  // sets the servo position according to the scaled value ;    
            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)
    
          } 
        }
      }
    }

  2. #2
    New Member
    Join Date
    Feb 2013
    Location
    Quebec, Canada
    Posts
    1
    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 unable to get readings from "More Extractions" in Link2fs

    Hello

    I'm not a programmer but i think the line "xx = Serial.Read();" only reads one character so the character you will see with your If statement will be > not >g. I think you would need to do a second "Serial.Read()" and then test for the g character.

    Hope this helps.

  3. #3
    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 unable to get readings from "More Extractions" in Link2fs

    Ah! I see the problem.

    When reading Link2FS data, take care to:
    1.) Locate the identifier. ( i.e. g , >g, etc. - which you've done)
    2.) Notice the quantity of characters transmitted. Refer to the green columns.

    So, gear nose - sends 3 characters.
    However, Throttle 1 Position - sends 4 characters.
    Therefore, your incorrect gearnose variable is "+nn" when it should be "+nnn"

    To correct, try this:
    Code:
    gearnose = ""; // Empty gearnose string
    char discard = char(Serial.read());  //  1st character ...  discards + or -  sign if not needed
    
    gearnose += char(Serial.read());   //  2nd character
    gearnose += char(Serial.read());  //   3rd character
    gearnose += char(Serial.read());  //   4th character
    edit: I re-read your initial post where turned off the +/- ; Oops, I jumped on the common mistake.

  4. #4
    New Member
    Join Date
    Oct 2013
    Location
    singapore
    Posts
    4
    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 unable to get readings from "More Extractions" in Link2fs

    hi I face the same problem too... currently I want to take the reading of the AOA but then when I input >d no data is extracted. here is my programme

    if (Serial.available() > 0) {
    j1 = Serial.read();
    if (j1 == '>d'){ // Found the reading "AOA"
    delay (11); // It seems to need a delay here
    AOA = "";
    AOA += char(Serial.read());
    AOA += char(Serial.read());

    AOA += (" "); //pads it up to 5 caracters
    AOA += (" "); //pads it up to 8 caracters
    if (AOA != AOAold){ // checks to see if its different to the "old" reading
    // delay (11);
    lcd.setCursor(0, 0); //sets the cursor position for the first letter
    delay (11);
    lcd.print(AOA); //Prints the data to the LCD
    AOAold = AOA; // Writes the current reading to the "old" string.
    }
    }

  5. #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 unable to get readings from "More Extractions" in Link2fs

    Hello.
    I cannot find anything wrong with the snippet. I would venture to say there is line clearing the LCD before you have time to read it.
    I would troubleshoot the code by replacing lcd.print(AOA); with lcd.print("TEST");
    Continue to step out of each qualifying statement with
    lcd.print("TEST"); until it is printed. If you step all the way up to setup() and it still doesn't print - you have an LCD problem. I haven't any idea how much troubleshooting you've done thus far, so I'm just tossing out basics.

    JM

    Edit: Found it. the problem is here -
    (j1 == '>d') this is two characters when j1 only read one character.

    It should look something like this:
    j1 = Serial.read();
    if (j1 == '>'){
    j1 = Serial.read();

    if (j1 == 'd'){
    delay (11); // It seems to need a delay here
    AOA = "";
    AOA += char(Serial.read());
    AOA += char(Serial.read());
    }
    }

Tags for this Thread