Results 1 to 3 of 3
  1. #1
    New Member
    Join Date
    Feb 2015
    Location
    United States
    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

    Unhappy Problems with LCD based radiostack project

    Hi everyone, and a special thank you to Jim for writing Link2FS!

    I am a newbie to arduino (previously I made a LCD based computer system temp display and a few of the demo projects)
    and when I heard about Link2FS, decided to jump right in. My long term plan is to build several GA aircraft cockpit units.

    Right now, I am prototyping a 1602 HD44780 based COM1/NAV1 radio stack.

    Its based on a modified version of the Multi_LCD_simple_demo code that came with Link2FS. I have it 80% working. I am using the Arduino 1.0.6 IDE with the serial length hack applied (had lots of issues before I did this).

    The Problem: The LCD display doesn't display the NAV1 standby signal. All the other radio frequencies display accurately and formatted properly. All the buttons besides "B5" on pin D12, send the proper Link2FS key commands. That button sends nothing when viewed in both the Link2FS serial monitor, nor in the Arduino IDE's built in serial monitor. I have tried using another physical button as well as using the breadboard jumper to ground D12 (my understanding is all the switches are wired to pull voltage on the pin low when pressed). I have 2x and 3x checked that all correct boxes are checked in Link2FS to send the NAV1 S/b frequency, and currently Link2FS is sending "=A122.700=B135.775=E113.70=F117.20" to my arduino. The =F117.20 is my current NAV1 s/b frequency. So everything seems to be working on that end correctly.


    Here is how I have it breadboarded: http://imgur.com/2QlkQlp

    Here is the arduino code (it still references the Multi_LCD code and an arduino mega in the comments, but I have edited the important parts and hopefully accurately adjusted the pins to work for my UNO):

    Code:
    #include 
    
    
    
    
    /* 
        This code is in the public domain
        For use with "Link2fs_Multi"
        Jimspage.co.nz
        My thanks to the Guys that gave me snippets of code. 
        This is designed to be used with the Mega although it can be converted to use on the Uno.
        
        This is just a "demo" of switching the sim's lights on and off and showing the
        COM1, COM1 s/b, NAV1 and NAV1 s/b on a common 16x2 LCD.
        
    
    
        The LCD is connected to pins 2,3,4,5,6 and 7
        
        The light switchs all use simconnect.(not "keys") but the remaining
        pin's above pin 35 can be used for switchs using "Keys" in my program.
        Some planes are not set up for individual switchings so just fiddle and 
        watch the extraction '
    int CodeIn;// used on all serial reads
    int KpinNo; 
    int Koutpin;
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;
    String com, comold, comsb, comsbold, nav, navold, navsb, navsbold;
    void setup() 
    {
      Kstringoldstate = "11111";
      for (int KoutPin = 8; KoutPin < 13; KoutPin++)// Get these pins ready as inputs  
      {
        pinMode(KoutPin, INPUT);
        digitalWrite(KoutPin, HIGH);  
      }
      lcd.begin(16, 2);
      lcd.clear();
      lcd.print("Test");
     Serial.begin(115200);   
    }
    
    
    void loop() {
      {INPUTS();} //Check the "Inputs" section
      if (Serial.available()) {
        CodeIn = getChar();
        if (CodeIn == '=') {EQUALS();} // The first identifier is "="
        if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
        if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
        if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
      }//end of serial read bit
    }//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
    }
    
    
    void EQUALS(){
      CodeIn = getChar(); // Get the second identifier
      switch(CodeIn) {// Now lets find what to do with it
       case 'A': // found Com1 setting
          delay (11);
          com = "";
          com += getChar();
          com += getChar();
          com += getChar();
          com += getChar();
          com += getChar();
          com += getChar();
          if (com != comold){
            lcd.setCursor(0, 0);
            delay (11);//My LCD seems to need his
            lcd.print("C " + com);
            comold = comsb;
          }        
        break;
       case 'B': // found COM1 sb setting
          delay (11);
          comsb = "";
          comsb += getChar();
          comsb += getChar();
          comsb += getChar();
          comsb += getChar();
          comsb += getChar();
          comsb += getChar();
          if (comsb != comsbold){
            lcd.setCursor(0, 1);
            delay (11);
            lcd.print("^ " + comsb);
            comsbold = comsb;
           }
          break;
         case 'E': // found NAV1 setting
          delay (11);
          nav = "";
          nav += getChar();
          nav += getChar();
          nav += getChar();
          nav += getChar();
          nav += getChar();
          nav += getChar();
          if (nav != navold){
            lcd.setCursor(9, 0);
            delay (11);
            lcd.print("N" + nav);
            nav = navold;
         }       
         break;
       case 'F': // found NAV1sb setting
          delay (11);
          navsb = "";
          navsb += getChar();
          navsb += getChar();
          navsb += getChar();
          navsb += getChar();
          navsb += getChar();
          navsb += getChar();
          if (navsb != navsbold){
            lcd.setCursor(9, 1);
            delay (11);
            lcd.print("^" + nav);
            navsb = navsbold;
         }       
       break;
        }//end of case switch
      }// end of void equals
    
    
    void LESSTHAN(){    // The first identifier was "<"
    //do something
    }// end of <
     
    void QUESTION(){    // The first identifier was "?"
    //do something
    }// end of question
    
    
    void SLASH(){    // The first identifier was "/" (Annunciator)
      //Do something
    }
    
    
    void INPUTS() 
    {
      Kstringnewstate = "";
      for (int KpinNo = 8; KpinNo < 12; KpinNo++){// Pins 8 thru to 12 are all inputs
        KpinStateSTR = String(digitalRead(KpinNo)); 
        KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 8));//the 8 needs to be the same as the 8 in the "for" loop line.
        if (KpinStateSTR != KoldpinStateSTR)
        {
          if (KpinNo == 8){if (KpinStateSTR == "1" ){Serial.println ("A02");}}//COM1 +1 Mhz (course+)
          if (KpinNo == 9){if (KpinStateSTR == "1" ){Serial.println ("A01");}}//COM1 -1 Mhz (course-)
          if (KpinNo == 10){if (KpinStateSTR == "1" ){Serial.println ("A04");}}//COM1 +25 khz (fine+)
          if (KpinNo == 11){if (KpinStateSTR == "1" ){Serial.println ("A03");}}//COM1 -25 khz (fine-)
          if (KpinNo == 12){if (KpinStateSTR == "1" ){Serial.println ("A06");}}//Swap COM1 & COM1 s/b
          //if (KpinNo == 27){if (KpinStateSTR == "1" ){Serial.println ("C460");}else {Serial.println ("C461");}}//Panel lights
          //if (KpinNo == 28){if (KpinStateSTR == "1" ){Serial.println ("C470");}else {Serial.println ("C471");}}//Recognitian lights
          //if (KpinNo == 29){if (KpinStateSTR == "1" ){Serial.println ("C480");}else {Serial.println ("C481");}}//Wing lights
          //if (KpinNo == 30){if (KpinStateSTR == "1" ){Serial.println ("C490");}else {Serial.println ("C491");}}//Logo lights
          //if (KpinNo == 31){if (KpinStateSTR == "1" ){Serial.println ("C500");}else {Serial.println ("C501");}}//Cabin lights
          //if (KpinNo == 32 & KpinStateSTR == "1" ){Serial.println ("B11");}//Autopilot altitude set
          //if (KpinNo == 33 & KpinStateSTR == "1" ){Serial.println ("B12");}//Autopilot altitude set
          //if (KpinNo == 34 & KpinStateSTR == "1" ){Serial.println ("B13");}//Autopilot vert speed set
          //if (KpinNo == 35 & KpinStateSTR == "1" ){Serial.println ("B14");}//Autopilot vert speed set
          // add more direct inputs here but raise the pinNo (35) in the above live and the line below.
          //now the "keys" bit. Note the pinNo 35 in the line above and the line below.
          if (KpinNo > 35){
          Serial.print ("D"); 
          if (KpinNo < 10) Serial.print ("0");
          Serial.print (KpinNo);
          Serial.println (KpinStateSTR);
          }//end of "keys" bit
        }//end of yes it's different
        Kstringnewstate += KpinStateSTR;
      }//end of "for" loop
      Kstringoldstate = Kstringnewstate;
    }//end of OUTPUTS void

  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: Problems with LCD based radiostack project

    Hi Arion ,, normally I don't delve into INO support as I'm no good at C stuff and the other Guys are better than me ,, however on releasing your post the problem jumped out at me.

    The line
    lcd.print("^" + nav);

    should be,,,
    lcd.print("^" + navsb);

    I think it should work then.

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

  3. #3
    New Member
    Join Date
    Feb 2015
    Location
    United States
    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: Problems with LCD based radiostack project

    Thanks Jim. I actually solved the LCD NAV1 SB and S/B button issues after posting this. I caught that same mistake you pointed out, and then I noticed the button wasn't working because this 12 should be a 13.
    for (int KpinNo = 8; KpinNo < 12; KpinNo++)


Tags for this Thread