Results 1 to 5 of 5
  1. #1
    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

    SHOW US YOUR ARDUINO PDE

    I've re-started this as the first ended up with 14 posts but no PDE's I've also added a couple of things, included Arduino in the name etc.

    Well here we go ,, a place to show your talents. We want to see your PDE's

    It's amazing what one learns from seeing some-one else's code ,, there are heaps of ways to code the same simple thing and
    sometimes one "just cant get it" when it's coded one way but it's painly obvious when coded in another way.

    Forums are a 2 way street and there have been virtually no PDE's posted to help the newbies thru the learning process.
    We all started with "not knowing a damn thing" about what we now do for fun ,,, Lets share.

    Just a posting of the PDE is fine ,,, it doesn't have to be flash or whizzy ,,, no-one's going to judge ,,, Helping each other is the name of the game here.
    How you done anything is going to be informative to some-one who hasn't been there before.
    If you don't want to interact ,, just put "No questions thanks" you've still done a lot of people a big favor.

    A lot of people don't like Forums (I for one) so to make them breath a bit easier ,,,,
    There is to be NO judgmental posts,, NO "Mine's bigger than yours" ,, NO criticism (If it don't work for you ,, then go and try something else.) Any post's that even hint along these lines will be deleted.

    OK guys ,, let the show begin.

    Just add the PDE to this post ,, then they are all together ,, or if it's a complete project then open a new thread.
    Not necessary but it would help to include,,,
    The Arduino software version that it compiles in.
    What it actually does.
    What hardware is connected to it and where.
    (ie switches on pins 6,7,11 etc)



    How to easily post a PDE ,,,,
    Open the Arduino IDE and load your PDE.
    In the IDE ,, click "EDIT" then click "COPY FOR FORUM"
    The PDE is now ready for pasting into the forum ,,, so ,,,
    Open the forum thread and hit "REPLY"
    Type in what you want and when ready to paste the PDE. right click and PASTE.
    It may all look a bit weird but it carried over all the formatting info as well.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  2. #2
    25+ Posting Member
    Join Date
    May 2012
    Location
    Great white north
    Posts
    32
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SHOW US YOUR ARDUINO PDE

    /*
      This Code is a skeleton extraction program for Link2fs. Your code can be added to the loop function after the extration call
      Feel free to modify this code and use it as you please. I accept no liability for use of this software
      By Steve Attfield
      Special thanks to Jim NZ
      
     */






    int BUFFERMAX = 9;
    //Extraction variables. use these.
    int gearNpos, gearRpos, gearLpos, airspeed, altitude, temp, com1mhz, com1khz, com1sbmhz, com1sbkhz, com2mhz, com2khz, com2sbmhz, com2sbkhz, gndClearance, flaps, trim, engineRPM, heading, fuel, vspeed, turnCoord, gs, transponder;
    int crs, nav1mhz, nav1khz, nav1sbmhz, nav1sbkhz, nav2mhz, nav2khz, nav2sbmhz, nav2sbkhz, apAltitude, apVspeed, apHeading, apSpeed;
    boolean stall, onGround, batt, apActive, apAltHold, apHeadHold, apApp, apBackCrsHold, apNavHold, apWing, apFlDir;
    //System variables. don't use these
    int sign, i;
    int j1;
    char readBuff;
    char Sbuffer[3];


    void setup()
    {
      Serial.begin(115200);
      Serial.flush();
    }


    void loop() {
      Sbuffer[0] = '\0'; // ensure that the read buffer is empty prior to commencing each read cycle
      // read the oldest byte in the serial buffer:
       if (Serial.available() > 0)
       {
          extraction();
          //your code goes here
       } //end if serial.avail
       
     } //end of fn loop
     
     
    void extractVar(int* variable, int len)
    {
        delay(11);
        i=0;
        while(i < len)
        {
          Sbuffer[i] = Serial.read();
          i++;
        }
        temp = atoi(Sbuffer);
        if(temp != *variable)
        {
          *variable = temp;
        }
    }

    void extractVar(boolean* variable)
    {
          Sbuffer[0] = Serial.read();
          temp = atoi(Sbuffer);
          if((boolean)temp != *variable)
          *variable = (boolean) temp;
    }

    void extraction()
    {
      j1 = Serial.read();
      switch(j1)
      {
        case 'W':
            extractVar(&airspeed, 3);
            break;
        
        case 'C':
            extractVar(&altitude, 5);
            break;
        
        case 'd':
         // Found the reading "Com 1 frequency"
            extractVar(&com1mhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&com1khz, 3);
            break;
        
        case 'e':
         // Found the reading "Com 1 standby frequency"
            extractVar(&com1sbmhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&com1sbkhz, 3);
            break;
        
        case 'f':
         // Found the reading "Com 2 frequency"
            extractVar(&com2mhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&com2khz, 3);
            break;
        
        case 'g':
         // Found the reading "Com 2 standby frequency"
            extractVar(&com2sbmhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&com2sbkhz, 3);
            break;
        
        case 'h':
         // Found the reading "Nav 1 frequency"
            extractVar(&nav1mhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&nav1khz, 3);
            break;
        
        case 'i':
         // Found the reading "Nav 1 standby frequency"
            extractVar(&nav1sbmhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&nav1sbkhz, 3);
            break;
        
        case 'j':
        // Found the reading "Nav 2 frequency"
            extractVar(&nav2mhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&nav2khz, 3);
            break;
        
        case 'k':
         // Found the reading "Nav 2 standby frequency"
            extractVar(&nav2sbmhz, 3);
            Serial.read(); //throw away the decimal we don't need it
            extractVar(&nav2sbkhz, 3);
            break;
        
       
         case 'I':
            extractVar(&gearNpos, 3);
            break;
          
         case 'J':
            extractVar(&gearLpos, 3);
            break;
          
         case 'K':
             extractVar(&gearRpos, 3);
             break;
         
        case 'D':
            extractVar(&gndClearance, 5);
            break;
        
        case 'L':
            extractVar(&stall);
            break;
        
        case 'M':
            extractVar(&flaps, 3);
            break;
        
        case 'N':
         //Found data "trim"
          Sbuffer[0]=Serial.read();
          temp = atoi(Sbuffer);
          sign = temp;
          extractVar(&trim, 3);
          if(sign == '-')
          {
            trim = 0-trim;
          }
          break;
        
        case 'O':
          extractVar(&engineRPM, 5);
          break;
        
        case 'Q':
        //found data "Heading"
          extractVar(&heading, 3);
          //we are going to trash the decimal because we don't really need it
          Serial.read();
          Serial.read();
          break;
        
        case 'R':
          extractVar(&fuel, 3);
          break;
        
        case 'T':
         //Found data "Vertical speed"
          Sbuffer[0]=Serial.read();
          temp = atoi(Sbuffer);
          sign = temp;
          extractVar(&vspeed, 5);
          if(sign == '-')
          {
            vspeed = 0-vspeed;
          }
          break;
        
        case 'U':
          //found data "Turn coordinator ball"
          Sbuffer[0]=Serial.read();
          temp = atoi(Sbuffer);
          sign = temp;
          extractVar(&turnCoord, 5);
          if(sign == '-')
          {
            turnCoord = 0-turnCoord;
          }
          break;
        
        case 'V':
          extractVar(&gs, 3);
          break;
        
        case 'm':
          extractVar(&transponder, 4);
          break;

        case 'P':
          extractVar(&onGround);
          break;
        
        case 'X':
          extractVar(&batt);
          break;
        
        case 'a':
          extractVar(&crs, 3);
          break;
        
        case 'b':
          extractVar(&apActive);
          break;
        
        
        case 'p':
          extractVar(&apAltitude, 5);
          break;
        
        case 'q':
          Sbuffer[0]=Serial.read();
          temp = atoi(Sbuffer);
          sign = temp;
          extractVar(&apVspeed, 5);
          if(sign == '-')
          {
            apVspeed = 0 - apVspeed;
          }
          break;

       case 'r':
         extractVar(&apHeading, 3);
         break;
       
       case 's':
         extractVar(&apAltHold);
         break;
       
       case 't':
         extractVar(&apHeadHold);
         break;
       
       case 'u':
         extractVar(&apSpeed, 3);
         break;
       
       case 'v':
         extractVar(&apApp);
         break;

       case 'w':
         extractVar(&apBackCrsHold);
         break;
       
       case 'x':
         extractVar(&apNavHold);
         break;

       case 'y':
         extractVar(&apWing);
         break;
       
       case 'z':
         extractVar(&apFlDir);
         break;
      }
    //end fn extraction
    this should give you a nice little skeleton extraction routine. I can make available a program I wrote using this skeleton to do something useful if people find this confusing to work with.

  3. Thanks Jim NZ thanked for this post
  4. #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: SHOW US YOUR ARDUINO PDE

    Thanks Steve ,, Your code ,,, I like it ,, in fact I like it a lot !!!
    That's a good skeleton and most of the work is already done for some-one to just plonk in their small bit of individual code to do what ever they want to.

    So ,, Yes please ,, can you put up another PDE (leave the skeleton there) and add in a couple of things so the Guys can see how little there is to do to make it work as they want. Maybe just gear and flaps indication to LED's or whatever. ???

    To a newbie ,, there seems an awful lot of code there and they wouldn't understand the magnitude of what you have just shared. Thanks.

    I've been under extreme pressure to complete a program for work and only finished yesterday so I'm in catch-up mode with all this. Aaaahhh so much to do ,, so little time

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

  5. #4
    500+ This must be a daytime job



    Join Date
    Oct 2009
    Location
    Juneau, AK
    Posts
    619
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SHOW US YOUR ARDUINO PDE

    Quote Originally Posted by Jim NZ View Post
    ...To a newbie ,, there seems an awful lot of code there and they wouldn't understand the magnitude of what you have just shared. Thanks.
    As a bonafide newbie, I concur with Jim! I not only don't know the magnitude, but cant tell what it even does....

    Reid
    http://juneaucessnasim.blogspot.com
    N58243 (virtual)- Low and Slow...

  6. #5
    150+ Forum Groupie WJH308's Avatar
    Join Date
    Aug 2008
    Location
    San Francisco, CA
    Posts
    159
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SHOW US YOUR ARDUINO PDE

    I like the code as well! After my final is over with, I'll actually be able to play with all of this again!