Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Smile Integers confusion

    And now, the old story, all over again
    This is new for me, and I understand nothing, nada, zero. Look at the picture.
    " Error: Multi_XPNDR_Mega: 348: error: crosses initialization of 'int fuelflowInt' "
    What does this mean?
    The error comes when I try to add another Edgewice Meter, to display the oil temp. on enging 1

    int.jpg


    Attached Images Attached Images
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  2. #2
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Integers confusion

    OK. So I found out how to work that out. When I used curly braces around every "case", it works.
    Code:
    { case 'V': //Found For Reading Fuelflow Engine One.       fuelflow1 = "";      
           fuelflow1 += getChar();      
           fuelflow1 += getChar();      
           fuelflow1 += getChar(); 
           fuelflow1 += getChar();
          //now send some "key" codes
          int fuelflow1Int = fuelflow1.toInt(); // convert it to an integer (Thanks Phill)
          fuelflow1Int = map(fuelflow1Int, 0, 120, 0 ,255);//map the integer
          analogWrite(10,fuelflow1Int);
          
    
          break; }
    But then I run into another wall!
    On my Arduino Mega, I have now connected My transponder, 3 Rotary Encoders, and
    8 Edgewice Meter's for instrumentation.
    First of all, I can get all pin's to work separatly, but when I put things together, pin 13 and 45 stops to work
    It does not look like there are some limitations in numbers of Edgewice Meter's can be used, the result is the same if I disconnect some of them.
    So is there anyone who can explain this to me?
    Below is the complete code.
    Code:
    
    
    int CodeIn;// used on all serial reads
    
    
    const int  buttonOFF = 37;   // the pin that the Rotary Switch OFF is attached to.
    const int  buttonSBY = 38;   // the pin that the Rotary Switch SBY is attached to.
    const int  buttonTST = 39;   // the pin that the Rotary Switch TST is attached to.
    const int  buttonON = 40;    // the pin that the Rotary Switch ON is attached to.
    const int  buttonALT = 41;   // the pin that the Rotary Switch ALT is attached to.
    const int  buttonZero = 28;  // the pin that the #Zero Button is attached to.
    const int  buttonOne = 29;   // the pin that the #One Button is attached to.
    const int  buttonTwo = 30;   // the pin that the #Two Button is attached to.
    const int  buttonThree = 31; // the pin that the #Three Button is attached to.
    const int  buttonFour = 32;  // the pin that the #Four Button is attached to.
    const int  buttonFive = 33;  // the pin that the #Five Button is attached to.
    const int  buttonSix = 34;   // the pin that the #Six Button is attached to.
    const int  buttonSeven = 35; // the pin that the #Seven Button is attached to.
    const int  buttonVFR = 36;   // the pin that the VFR Button is attached to.
    // Variables will change:
    int buttonState1 = 0;        // current state of the OFF Rotary Switch.
    int buttonState2 = 0;        // current state of the SBY Rotary Switch.
    int buttonState3 = 0;        // current state of the TST Rotary Switch.
    int buttonState4 = 0;        // current state of the ON Rotary Switch.
    int buttonState5 = 0;        // current state of the ALT Rotary Switch.
    int buttonState6 = 0;        // current state of the #Zero Button.
    int buttonState7 = 0;        // current state of the #One Button.
    int buttonState8 = 0;        // current state of the #Two Button.
    int buttonState9 = 0;        // current state of the #Three Button.
    int buttonState10 = 0;        // current state of the #Four Button.
    int buttonState11 = 0;        // current state of the #Five Button.
    int buttonState12 = 0;        // current state of the #Six Button.
    int buttonState13 = 0;        // current state of the #Seven Button.
    int buttonState14 = 0;        // current state of the VFR Button.
    
    
    #include 
    LiquidCrystal lcd1(22, 23, 24, 25, 26, 27);
    
    
    #include "math.h"
    #include "Quadrature.h"
    Quadrature quad1(6, 7);
    Quadrature quad2(4, 5);
    Quadrature quad3(2, 3);
    
    
    int R;// a variable
    int Rold;// the old reading
    int Rdif;// the difference since last loop
    int R2;// a second test variable
    int R3;// a second test variable
    int Rold2;// a second loop old reading
    int Rdif2; // the second test difference
    int Rold3;// a second loop old reading
    int Rdif3; // the second test difference
    
    
    // ++++  JM ADDED 
    String SWstate, SWstate2, Xpndr, Xpndrold, ALTLevel, ALTLevelold;  // used as Switch placement LCD text
    int newRead [14];  // declare newRead as an array w/ 5 slots for the Rotary Switch
    int oldRead [14];  // declare oldRead as an array w/ 5 slots for the Rotary Switch
    boolean start;
    long LoopCycle = 55000;
    long debounce;
    // +++++++++++
    
    
    String eng1rpm, eng2rpm, fuelflow1, fuelflow2, oiltmp1, oiltmp2, Exhtmp1, Exhtmp2;
    
    
    void setup() 
    {
          pinMode(8, OUTPUT); // Engine 1 RPM (Edgwice Meter)
          digitalWrite(8, LOW); 
          pinMode(9, OUTPUT); // Engine 2 RPM (Edgwice Meter)
          digitalWrite(9, LOW); 
          pinMode(10, OUTPUT); // Engine 1 Fuelflow (Edgwice Meter)
          digitalWrite(10, LOW); 
          pinMode(11, OUTPUT); // Engine 2 Fuelflow (Edgwice Meter)
          digitalWrite(11, LOW); 
          pinMode(12, OUTPUT); // Engine 1 Oiltemp (Edgwice Meter)
          digitalWrite(12, LOW);      
          pinMode(13, OUTPUT); // Engine 2 Oiltemp (Edgwice Meter)
          digitalWrite(13, LOW);     
          pinMode(44, OUTPUT); // Engine 1 ???? (Edgwice Meter)
          digitalWrite(44, LOW); 
          pinMode(45, OUTPUT); // Engine 2 ???? (Edgwice Meter)
          digitalWrite(45, LOW);       
          
       // initialize the button pin as a input:
       pinMode(buttonOFF, INPUT);
       pinMode(buttonSBY, INPUT);
       pinMode(buttonTST, INPUT);
       pinMode(buttonON, INPUT);
       pinMode(buttonALT, INPUT); 
       pinMode(buttonZero, INPUT);
       pinMode(buttonOne, INPUT);
       pinMode(buttonTwo, INPUT);
       pinMode(buttonThree, INPUT);
       pinMode(buttonFour, INPUT);
       pinMode(buttonFive, INPUT);
       pinMode(buttonSix, INPUT);
       pinMode(buttonSeven, INPUT);
       pinMode(buttonVFR, INPUT);  
       
    //########## Initialize serial communication:
     Serial.begin(115200); 
    //########## set up the 1.LCD's number of columns and rows:
      lcd1.begin(16,2); 
    }
    
    
    void loop() {
      
      {XPNDR();}// Check the XPNDR
      {ENCODER();} //Check the Rotary Encoders
      
      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)
      }
    }
    
    
    char getChar()// Get a character from the serial buffer
    {
      while(Serial.available() == 0);// wait for data
      delay (2);
      return((char)Serial.read());// Thanks Doug
    }
    void XPNDR(){
    
    
    //### Rotary Switch Read 
    buttonState1 = digitalRead(buttonOFF);
    buttonState2 = digitalRead(buttonSBY);
    buttonState3 = digitalRead(buttonTST);
    buttonState4 = digitalRead(buttonON);
    buttonState5 = digitalRead(buttonALT);
    //### Zero to 7 + VFR Button Read
    buttonState6 = digitalRead(buttonZero); 
    buttonState7 = digitalRead(buttonOne); 
    buttonState8 = digitalRead(buttonTwo); 
    buttonState9 = digitalRead(buttonThree); 
    buttonState10 = digitalRead(buttonFour); 
    buttonState11 = digitalRead(buttonFive); 
    buttonState12 = digitalRead(buttonSix); 
    buttonState13 = digitalRead(buttonSeven); 
    buttonState14 = digitalRead(buttonVFR);
    
    
    
    
    // check to see if user takes too long 
    if (LoopCycle == 75000){start = false; SWstate = ""; Serial.println("TIME-OUT - ");LoopCycle = 75001;}
    
    
    
    
    if(debounce == 1000){ //debounce rotary/push switch
    newRead [0] = buttonState6; // Store in newRead Button "Zero" in slot0
    newRead [1] = buttonState7; // Store in newRead Button "One" in slot1
    newRead [2] = buttonState8; // Store in newRead Button "Two" in slot2
    newRead [3] = buttonState9; // Store in newRead Button "Three" in slot3
    newRead [4] = buttonState10; // Store in newRead Button "Four" in slot4
    newRead [5] = buttonState11; // Store in newRead Button "Five" in slot5
    newRead [6] = buttonState12; // Store in newRead Button "Six" in slot6
    newRead [7] = buttonState13; // Store in newRead Button "Seven" in slot7
    newRead [8] = buttonState14; // Store in newRead Button "VFR" in slot8
    newRead [9] = buttonState1;  // Store in newRead "OFF" Rotary Switch in newRead slot9
    newRead [10] = buttonState2; // Store in newRead "SBY" Rotary Switch in newRead slot10
    newRead [11] = buttonState3; // Store in newRead "TST" Rotary Switch in newRead slot11
    newRead [12] = buttonState4; // Store in newRead "ON" Rotary Switch in newRead slot12
    newRead [13] = buttonState5; // Store in newRead "ALT" Rotary Switch in newRead slot13
    
    
    
    
    // Compare array slots to determine if LCD clear is needed
    for (int arrayNUM = 0; arrayNUM <= 13; arrayNUM++) {   // 0 based - 9 slots
      if (newRead [arrayNUM] != oldRead [arrayNUM] ) //compare slot #s and clear LCD if needed
        { start = true;  LoopCycle = 0; debounce = 0;}//lcd1.clear(); break;}
    } // END for-next
    
    
    } // END debounce of switch
    
    
    if (start == true){
      
    //### Zero Button
      if (newRead [0] != oldRead [0] && buttonState6 == HIGH ) 
      {SWstate += "0"; LCDprint();}
    //### One Button
      if (newRead [1] != oldRead [1] && buttonState7 == HIGH  ) 
      {SWstate += "1"; LCDprint();}
    //### Two Button
      if (newRead [2] != oldRead [2] && buttonState8 == HIGH ) 
      {SWstate += "2"; LCDprint();}
    //### Three Button
      if (newRead [3] != oldRead [3] && buttonState9 == HIGH ) 
      {SWstate += "3"; LCDprint();}
    //### Four Button  
      if (newRead [4] != oldRead [4] && buttonState10 == HIGH ) 
      {SWstate += "4"; LCDprint();}
    //### Five Button  
      if (newRead [5] != oldRead [5] && buttonState11 == HIGH ) 
      {SWstate += "5"; LCDprint();}
    //### Six Button  
      if (newRead [6] != oldRead [6] && buttonState12 == HIGH ) 
      {SWstate += "6"; LCDprint();}
    //### Seven Button  
      if (newRead [7] != oldRead [7] && buttonState13 == HIGH ) 
      {SWstate += "7"; LCDprint();}
    //### VFR Button  
      if (newRead [8] != oldRead [8] && buttonState14 == HIGH ) 
      {SWstate += "1200"; LCDprint();}
      
      // Rotary OFF
        if (newRead [9] != oldRead [9] && buttonState1 == HIGH ) 
        {lcd1.clear();
        lcd1.setCursor(0,0);
        lcd1.print("   XPNDR OFF");
        lcd1.setCursor(0,1);
        lcd1.print("   XPNDR OFF");
      }
    
    
    
    
      // Rotary SBY
      if (newRead [10] != oldRead [10] && buttonState2 == HIGH ) 
        {lcd1.clear();
        lcd1.setCursor(0,0);
        lcd1.print("  STANDBY  FOR");
        lcd1.setCursor(0,1);
        lcd1.print("  SQUAWK  CODE");
      }
        
      // Rotary TST
     if (newRead [11] != oldRead [11] && buttonState3 == HIGH ) 
        {lcd1.clear();
        lcd1.setCursor(0,0);
        lcd1.print("R-SBY-TEST-ON--R");
        lcd1.setCursor(0,1);
        lcd1.print("R-SBY-TEST-ON--R");
      }
        
      // Rotary ON
     if (newRead [12] != oldRead [12] && buttonState4 == HIGH ) 
        {lcd1.clear();
        lcd1.setCursor(0,0);
        lcd1.print("    ON   R");
        lcd1.setCursor(0,1);
        lcd1.print("   ");
        lcd1.setCursor(12,1);
        lcd1.print(Xpndr);
      }
        
      // Rotary ALT  
     if (newRead [13] != oldRead [13] && buttonState5 == HIGH ) 
        {lcd1.clear();
        lcd1.setCursor(0,0);
        lcd1.print("ALT        XPNDR");
        lcd1.setCursor(0,1);
        lcd1.print(ALTLevel);
        lcd1.setCursor(12,1);
        lcd1.print(Xpndr);
      }
    
    
    // Check to see if SWstate contains 4 characters
      if (SWstate.length() == 4){start = false; LinkFS_send();}
    
    
    // Increase Time-out timer   
    LoopCycle = LoopCycle + 1;  
    
    
    } // END if (start == true)
    
    
    debounce = debounce + 1; if (debounce == 2000){debounce =0;}
    oldRead [0] = newRead [0];  // Store in oldRead slot0
    oldRead [1] = newRead [1];  // Store in oldRead slot1
    oldRead [2] = newRead [2];  // Store in oldRead slot2
    oldRead [3] = newRead [3];  // Store in oldRead slot3
    oldRead [4] = newRead [4];  // Store in oldRead slot4
    oldRead [5] = newRead [5];  // Store in oldRead slot5
    oldRead [6] = newRead [6];  // Store in oldRead slot6
    oldRead [7] = newRead [7];  // Store in oldRead slot7
    oldRead [8] = newRead [8];  // Store in oldRead slot8
    oldRead [9] = newRead [9];  //Rotary Switch oldRead slot9
    oldRead [10] = newRead [10];//Rotary Switch oldRead slot10
    oldRead [11] = newRead [11];//Rotary Switch oldRead slot11
    oldRead [12] = newRead [12];//Rotary Switch oldRead slot12
    oldRead [13] = newRead [13];//Rotary Switch oldRead slot13
    
    
    } // End void loop
    
    
    void LCDprint(){
       lcd1.setCursor(12,1);
       lcd1.print(SWstate);
       Serial.println ("ENTRY - " + SWstate);
    }  // End LCDprint
    
    
    void LinkFS_send(){
      SWstate = "A42" + SWstate;
      Serial.println (SWstate);
      SWstate = "";
    }  // END LinkFS_send
    
    
    
    
    void EQUALS(){      // The first identifier was "="
     CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'J'://Found the second identifier "TRANSPONDER CODE"
                  Xpndr= "";
                  Xpndr += char(Serial.read());
                  Xpndr += char(Serial.read());
                  Xpndr += char(Serial.read());  
                  Xpndr += char(Serial.read());        
                  Xpndr += ("   ");  //pads it up to 8 caracters
                  if (Xpndr != Xpndrold){  // checks to see if its different to the "old" reading
                       lcd1.setCursor(12, 1); //sets the cursor position for the first letter
                       lcd1.print(Xpndr); //Prints the data to the LCD
                       Xpndrold = Xpndr; // Writes the current reading to the "old" string.
                       }
    
    
         
    
    
        
             
         }
    }
    void LESSTHAN(){    // The first identifier was "<"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
      
    case 'D'://Found the second identifier "ALTITUDE"
                  ALTLevel = "";
                  ALTLevel += char(Serial.read());
                  ALTLevel += char(Serial.read());
                  ALTLevel += char(Serial.read());
                  ALTLevel += ("   "); //pads it up to 8 caracters
                  if (ALTLevel != ALTLevelold){
                       lcd1.setCursor(0, 1);
                       lcd1.print(ALTLevel);
                       ALTLevelold = ALTLevel;
                   }                     
        break;
         
    {case 'T': //Found For Reading Engine One RPM.
           eng1rpm = "";      
           eng1rpm += getChar();      
           eng1rpm += getChar();      
           eng1rpm += getChar(); 
           eng1rpm += getChar();
          //now send some "key" codes
          int eng1rpmInt = eng1rpm.toInt(); // convert it to an integer (Thanks Phill)
          eng1rpmInt = map(eng1rpmInt, 500, 3000, 0 ,255);//map the integer
          analogWrite(8,eng1rpmInt);
        break; }
    
    
    {case 'U': //Found For Reading Engine Two RPM.
           eng2rpm = "";      
           eng2rpm += getChar();      
           eng2rpm += getChar();      
           eng2rpm += getChar(); 
           eng2rpm += getChar();
          //now send some "key" codes
          int eng2rpmInt = eng2rpm.toInt(); // convert it to an integer (Thanks Phill)
          eng2rpmInt = map(eng2rpmInt, 500, 3000, 0 ,255);//map the integer
          analogWrite(9,eng2rpmInt);
        break; }
           // int prop1rpmInt = prop1rpm.toInt(); // convert it to an integer (Thanks Phill)
           // prop1rpmInt = map(prop1rpmInt, 0, 540, 0 ,90);//map the integer
           // analogWrite(8,prop1rpmInt); 
    }
    }
    
    
    void QUESTION(){    // The first identifier was "?"
           CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
      
    { case 'V': //Found For Reading Fuelflow Engine One.
           fuelflow1 = "";      
           fuelflow1 += getChar();      
           fuelflow1 += getChar();      
           fuelflow1 += getChar(); 
           fuelflow1 += getChar();
          //now send some "key" codes
          int fuelflow1Int = fuelflow1.toInt(); // convert it to an integer (Thanks Phill)
          fuelflow1Int = map(fuelflow1Int, 0, 120, 0 ,255);//map the integer
          analogWrite(10,fuelflow1Int);
          
          break; }
        
    { case 'W': //Found For Reading Fuelflow Engine Two.
           fuelflow2 = "";      
           fuelflow2 += getChar();      
           fuelflow2 += getChar();      
           fuelflow2 += getChar(); 
           fuelflow2 += getChar();
          //now send some "key" codes
          int fuelflow2Int = fuelflow2.toInt(); // convert it to an integer (Thanks Phill)
          fuelflow2Int = map(fuelflow2Int, 0, 120, 0 ,255);//map the integer
          analogWrite(11,fuelflow2Int);
          
          break; }
          
    { case 'O': //Found For Reading Oil Temp Engine One.
           oiltmp1 = "";      
           oiltmp1 += getChar();      
           oiltmp1 += getChar();      
           oiltmp1 += getChar(); 
           oiltmp1 += getChar();
          //now send some "key" codes
          int oiltmp1Int = oiltmp1.toInt(); // convert it to an integer (Thanks Phill)
          oiltmp1Int = map(oiltmp1Int, 0, 120, 0 ,255);//map the integer
          analogWrite(12,oiltmp1Int);
          
          break;}
          
    { case 'P': //Found For Reading Oil Temp Engine Two.
           oiltmp1 = "";      
           oiltmp1 += getChar();      
           oiltmp1 += getChar();      
           oiltmp1 += getChar(); 
           oiltmp1 += getChar();
          //now send some "key" codes
          int oiltmp1Int = oiltmp1.toInt(); // convert it to an integer (Thanks Phill)
          oiltmp1Int = map(oiltmp1Int, 0, 120, 0 ,255);//map the integer
          analogWrite(13,oiltmp1Int);
          
          break;}
     
     { case 'M': //Found For Reading Exhaust Tmp. Engine One.
           Exhtmp1 = "";      
           Exhtmp1 += getChar();      
           Exhtmp1 += getChar();      
           Exhtmp1 += getChar(); 
           Exhtmp1 += getChar();
          //now send some "key" codes
          int Exhtmp1Int = Exhtmp1.toInt(); // convert it to an integer (Thanks Phill)
          Exhtmp1Int = map(Exhtmp1Int, 0, 120, 0 ,255);//map the integer
          analogWrite(44,Exhtmp1Int);
          
          break;}
          
    { case 'N': //Found For Reading Exhaust Tmp. Engine Two.
           Exhtmp2 = "";      
           Exhtmp2 += getChar();      
           Exhtmp2 += getChar();      
           Exhtmp2 += getChar(); 
           Exhtmp2 += getChar();
          //now send some "key" codes
          int Exhtmp2Int = Exhtmp2.toInt(); // convert it to an integer (Thanks Phill)
          Exhtmp2Int = map(Exhtmp2Int, 0, 120, 0 ,255);//map the integer
          analogWrite(45,Exhtmp2Int);
          
          break;}              
         }
    }
    void SLASH(){    // The first identifier was "/" (Annunciator)
      //Do something
    }
    
    
    void ENCODER(){
    R =(quad1.position()/2); //The /2 is to suit the encoder(See my website)
      if (R != Rold) { // checks to see if it different
        (Rdif = (R-Rold));// finds out the difference
       if (Rdif == 1) Serial.println ("A01");//Com1 Mhz down
       if (Rdif == -1) Serial.println ("A02"); //Com1 Mhz up
       Rold = R; // overwrites the old reading with the new one.
      } 
      R2 =(quad2.position());
      if (R2 != Rold2) {
        (Rdif2 = (R2-Rold2));
        if (Rdif2 == 1) Serial.println ("A03"); // Com1 Khz down
        if (Rdif2 == -1) Serial.println ("A04");//Com1 Khz up
        Rold2 = R2;
      }
      R3 =(quad3.position());
      if (R3 != Rold3) {
        (Rdif3 = (R3-Rold3));
        if (Rdif3 == 1) Serial.println ("C26"); // QNH down.
        if (Rdif3 == -1) Serial.println ("C25"); // QNH up.
        Rold3 = R3;
      }
    }
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  3. #3
    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: Integers confusion

    Curly brackets ,, It's very easy to check curly brackets as you code ,, just click on one and it automatically highlights the other one that the program see's as it's 'mate' ,, It's something I always do when I finish a section of code ,,, saves a lot of grief later on.

    PWM outputs are only available on certain pins ,, on the Mega it's pins 2 thru to 13. (Its' marked on the card)
    You will have to move some of your meters onto the above pins ,,, also your case 'P' variables are exactly the same as case 'O' so change the oiltmp1 to oiltmp2 where needed.

    You will have to move the rotary encoder pins to make room for the PWM's which means (if you haven't done it already) changing a figure in the 'quadrature.h' file, which is a file that comes with the quadrature library. Just use notepad but make sure it's saved with the same file name.

    From my web page ,,,
    In the download the demo is set up for using with a Uno card (max pin = 13) 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 (13)'. Change the 13 to what ever pin no. is going to be your highest.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  4. #4
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Integers confusion

    Hei Jim.
    I have now changed quadrature.h, moved the Encoders and connected the Edgewice meter's to pin 2 to pin 9, and moved the rotary encoders to other pin's.
    Still something
    is not working properly.
    The meter's still stops working as before. The meter's nr. 6 and nr. 8 on pin 7 and pin 9, disconnects randomly.
    The meter's nr. 6 and nr. 8 on pin 7 and pin 9, has the same problem as when I had them connected, meter's nr. 6 and nr. 8, connected to pin 13 and pin 45!
    I have to uncheck and recheck to get them to work. Then they seams to work as long FSX runs, but if I exit a flight and restart a new, then the same problem.
    So I found out that I would try to do some tests with the code. Trying with a Arduino Uno, and now I understand nothing!
    I can not get the values ​​I want from Link2fs Multi. Have I overlooked an important readme.file
    Look at the pictures.
    You will see what I have checked for, and what I receive.
    Have I got a bug in Link2fs Multi? Should I try to redownload.
    30-09-2013 20-11-11.png 30-09-2013 20-10-50.png 30-09-2013 20-11-28.png
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  5. #5
    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: Integers confusion

    Well your ticking extractions for "Card 1" but you are connected to "Card 2" so no wonder things aren't going right.

    You are sending =X (DME1 speed), =Y (DME2 speed), ?Y (Gear position simple), and ?Z (Rudder trim) to the connected card.
    None of them are mentioned in your posted code.

    It gets very confusing in your head when using multiple cards so what I do is ONLY use "Card 1" while I'm writing INO's ,, it's just so easy to forget what to tick where etc. Once the card is going properly then swing it over to Card 2 or 3 and tick the appropriate boxes etc. in it's own panel.

    I did however notice that the code for Rudder Trim was missing some data so I've fixed that and updated the down-load file.
    (The rudder trim extraction for Card 1 worked fine)
    It's now version beta5g but that's the only change I made.

    When things don't work ,, the first thing to look at is "Is the data being sent to my card" ,,, that's easy to see with the serial monitor.
    That way you can spot if it's my program or your INO.

    As you add more and more extractions the serial traffic obviously increases, especially if its long numbers or lots of them ,,, sooner or later you may have to do the serial buffer mod as detailed in the "pinned" thread at my Mycockpit. (Just a reminder)

    You mention meters not working ,, in your INO ,, extractions ?M and ?N (exhaust temperature) in the line,,,
    Exhtmp1Int = map(Exhtmp1Int, 0, 120, 0 ,255);//map the integer
    as I said in a earlier thread ,,, the first figure (0) is the minimum expected figure from the multi and the next figure (120) is the maximum expected from the multi.
    If the received figures are outside that "band" (0 - 120) then the meter will stop working and it can indicate anything.
    120 for exhaust temperature ??? ,, the baron idling is way over that and when it's flat out it's over 600.
    So change the 120 to 700 and see how you go.(for exhaust temperature)

    I'm guessing you will have to alter some of the other extractions as well to make them indicate true.

    As you have 5 volt meters ,,, the next 2 figures (0,255) are fine unless you want to 'span' the indication.
    Last edited by Jim NZ; 10-01-2013 at 12:32 AM.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  6. #6
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Integers confusion

    Hey Jim.
    I have now tried the Edgwice Meter's code on my Uno card.
    I gave up running all eight Meter's on the Mega card.
    I could not get more than four to work. More than that, I got problems. Why I do not know!
    I did also do the the "serial buffer mod", but no difference.
    I also found out why I struggled with the values, ​​to make the engine rpm display correct.
    In one way or another, I've got a line to much in the RPM code!
    Code:
    {case 'T': //Found For Reading Engine One RPM.       eng1rpm = "";      
           eng1rpm += getChar();      
           eng1rpm += getChar();      
           eng1rpm += getChar(); 
           eng1rpm += getChar();
          //now send some "key" codes
          int eng1rpmInt = eng1rpm.toInt(); // convert it to an integer (Thanks Phill)
          eng1rpmInt = map(eng1rpmInt, 500, 3000, 0 ,255);//map the integer
          analogWrite(8,eng1rpmInt);     break; }
    Removing one of the " eng1rpm += getChar(); " made the difference

    Now I could change the " eng1rpmInt = map(eng1rpmInt, 500, 3000, 0 ,255);//map the integer "
    To " eng1rpmInt = map(eng1rpmInt, 0, 350, 0 ,255);//map the integer "

    So now the situation is that I run four Edgwice Meter's on the Mega and four Edgwice Meter's on the Uno
    As I've learned, it's not the means, but our goal that is important
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  7. #7
    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: Integers confusion

    Aaaahh the wonders of coding ,,,, sometimes things just never add up.

    There is no reason that you can't run the 8 meters off the one Mega tho ,,, and looking at that code snippet that shouldn't run at all. !!

    I tend to think that some curly brackets are in the wrong place and that's what is messing up the "whole picture".
    The other thing is the engine RPM is 5 digits and your only reading 4 ???

    Never mind ,, it works and that's what it's all about so you've done well with all your perseverance.

    Actually it's my "last post" here for quite a while ,,, off into the "bush" in the "outback" of Aussie where one's natural body reflex is a swinging of the hand to keep the flys away from the beer and nibbles.
    Virtually no internet.
    No concrete jungle.
    We just love it

    Bye for now ,, Jim
    Last edited by Jim NZ; 10-06-2013 at 04:37 PM.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  8. #8
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Integers confusion

    One of the few programs on TV that we love to watch, "Masterchef Australia", with all the nice scenery pictures from your part of te world, has provided me a dream to visit Australia.
    If I were a rich man
    In the meantime, I have to be happy with the opportunity to visit virtual places using FSX
    Happy walkabout!
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  9. #9
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Integers confusion

    Just for fun, if anyone is interested in how the project's with the Edgewice Meter's are going.

    First, the conversion of the 5 Volt Edgewice Meter's, to show something more useful for FSX than 5 Volt!
    20131007_140034.jpg
    Then I built them into a panel.
    20131007_141037.jpg
    Now, the next step is to connect the Mega and two Uno cards with "link2fs_multi_beta5g".
    20131007_210018.jpg
    Hopefully there will be some FSX flying in the nearest future
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  10. #10
    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: Integers confusion

    WOW Buzzi ,,, very nicely done.
    It's not often we get to see the end result but the wait has been well worth it.

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

Page 1 of 2 12 LastLast