Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    75+ Posting Member vikingsraven's Avatar
    Join Date
    Dec 2012
    Location
    UK
    Posts
    89
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    attitude gage test

    HI just made an attitude gage for fsx, needs some tweeking but it works fine.

    if the videos on its side come back to it later. it should be fixed by youtube by then.
    i was bored when i got home this afternoon, been doing drawings and arduino code at work all day , so decide to come home rest and do more drawings and arduino code.
    Basically its a Twiglets tube, and a christmas ball, its based on an old eyemech i used to use in the films.
    the whole thing will sit in a frame behind a plexiglass cover in the cockpit, needs some range setting for the servo as its a bit out.
    the out case is on one servo, the hor'eye'zon is on another servo placed along the centre line.
    this is it painted.
    if anyone interested ill post some pictures of the parts.
    mark

  2. Thanks Jim NZ thanked for this post
    Likes Sammy-E, Fess_ter, BuzziBi liked this post
  3. #2
    150+ Forum Groupie
    Join Date
    Nov 2013
    Location
    Evansville, Indiana
    Posts
    243
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: attitude gage test

    Yes!
    We are interested.
    More pictures, please.
    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

  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: attitude gage test

    I love it Mark ,,, I would say lots of Guys will be interested in how you done it so the extra pictures and a splash of the Arduino code would be marvelous.

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

  5. #4
    75+ Posting Member vikingsraven's Avatar
    Join Date
    Dec 2012
    Location
    UK
    Posts
    89
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: attitude gage test

    As i said its just a test piece , proof of concept, it shouldn't take that long to build.

    Materials:


    • Link2Fs
    • Arduino (any)
    • 2 Servos with horns
    • 1 christmas polycarb (or anything really) bauble size to suit. Only half needed.
    • 1 tube mine was a twiglets box ( yeah i know the marmite love'm or hate'm) you'll use the tube and the lid. clean it out first!
    • 1 length of coat hanger wire or similar.
    • 2 pairs of pliers ( for bending above)
    • 1 wire cutter ( heavy duty ideal or if your not to worried use the cutter on the pliers but it will probably damage it)
    • hot glue gun (a god send for prototypes!)
    • some hole making implement, drill
    • Stanley or other craft knife
    • pencil or pen
    • sheet of paper
    • thin wire one of those plastic bag wrap things
    • paint ( i used acrylic but its not sticking to well maybe prime it first!)




    first remove the lid and cut out the centre ring, sand and then paint.


    next remove the hangar from the plastic ball, we now need to make a couple of holes in this, if you use the male half of the ball it has an over hang past the centre line, if not cut some scrap plastic and glue it to the inside edge.
    to determine the centre line draw round the hemisphere then cut out the shape and fold in half.



    put the hemisphere back on the paper and mark the centres.

    now make some holes the same size as the wire you have.

    as you can see above the lip is drilled to take the wire.
    cut 2 lengths of the hanger wire and about 20mm long and then bend 5mm at 90 degrees to get an ' L' shape.

    now to fix to the servo.
    First of all connect your servo to your duino, ive used pins 10 & 11 but what ever pins you want.
    we are going to set the centre position of the servo.
    Ive used a round horn on the pitch servo, as its all i had for that one but you can use any ones you have.
    now use the following code to centre the servo.


    Code:
    #include 
    
    #define ServP 10      // i use defines for known numbers as its easier to change them on bigger code up at the top
    #define ServR 11      // it also uses less memory apparently like i need it for this huge program
    
    
    Servo pitch;
    Servo roll;
    
    
    void setup() {
      pitch.attach(ServP);
      roll.attach(ServR);
      
    }
    
    void loop() {
     pitch.write(90);
     roll.write(90);
     delay(1000);                     // done this just incase this could just go in the setup
    
    }
    i didnt use this as you can see and the whole thing is about 15 degrees offset(Oh well !).
    now with the servo centered mark the horn , this is where you are going to attach one of the L wires.
    place the L on the horn and make sure the long upright is vertical and in the centre of the fixing screw.
    as shown below:



    i then wrapped a small thin wire through the horn holes to hold it in place then hot glued it into position ( theres no real force on this servo!). we will trim the length later if we need to.
    remove the arduino for now and then push the wire through the hole in the side of the hemisphere ( from inside) and point the horn to the front of the hemi. and Hot glue it in place, making sure you try to keep it so the centre of the horn lines up with the opposite hole as well.


    Then hotglue the other L wire to the other side. the wires on mine are too long really.

    Anyway let that go off, now to the case.
    turn the twiglets tin ( product placement , recon i may get some freebies!) upside down and find the centre, do the same as the hemisphere draw round it cut it out and fold int four and you have your centre and the cardinal points.
    this is the easy bit now, litteraly just fixe the servo to the bottom of the tin, ive screwed mine in from inside. also cut a hole for the pitch servo.



    Ideally you'll want a grommet in there or a bit of insulating/ gaffa tape round the hole to stop it cutting the wires.

    next we need to cut down the length of the tube, set the back end of the pitch servo, so that is lined up with the bottom rim of the tube, then mark the height your holes need to be made at and about 8mm below the front edge of the hemisphere. cut the tube to the line, and make 2 holes opposite each other in the side on the first height you marked, ideally so they are horizontal when the roll servo is at centre.( use above code again).


    thats it now test fit, slide the fixed pin on the hemisphere into the left hole looking from the front then push the hemisphere in ad slightly squeeze the tube and line up the servo side pin into its hole.
    if you want to later hot glue the servo into position, you can either remove the front or cut a hole into the tube to access it.
    As you can see the paint is peeling already on this, and that is basically that, ill tidy the code up and post that next. any question just post below.
    Hope it makes sense.
    Mark






  6. Thanks Jim NZ thanked for this post
    Likes Jim NZ liked this post
  7. #5
    75+ Posting Member vikingsraven's Avatar
    Join Date
    Dec 2012
    Location
    UK
    Posts
    89
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: attitude gage test

    Basically the code is just an update of the multi keys with flaps servo supplied by jim. all it does is reads for R (roll ) and Q (pitch) and sends out to the servo.
    ive halfed the range on the pitch servo as well , this makes it look closer to the on screen display. Ive left all the keys stuff in the code to enable switches.

    Code:
    /* 
        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 sets the complete Arduino card for "keys" input except pin 13.
        Attach a switch to any pin (except 13) and program that pin in "Multi"
        Pin 13 is used for the servo to indicate pitch.
        For this servo code to work you must tick "
    Servo pitchServo;
    Servo rollServo;
    
    
    #define rollServ 11
    #define pitchServ 10
    
    
    int CodeIn;// used on all serial reads
    int KpinNo; 
    int Koutpin;
    String pitch;
    String roll;
    
    
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;
    
    
    void setup() 
    {
      Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
      
      for (int KoutPin = 2; KoutPin < 70; KoutPin++)// Get all the pins ready for "Keys"  
      {
        pinMode(KoutPin, INPUT);
        digitalWrite(KoutPin, HIGH);  
      }
     Serial.begin(115200); 
     pinMode(pitchServ, OUTPUT);// For the servo.
     pinMode(rollServ,OUTPUT);
     pitchServo.attach(pitchServ);
     rollServo.attach(rollServ);
      
    }
    
    
    void loop() {
      {KEYS();} //Check the "keys" 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)
      }
    
    
    }
    
    
    char getChar()// Get a character from the serial buffer
    {
      while(Serial.available() == 0);// wait for data
      return((char)Serial.read());// Thanks Doug
    }
    
    
    void EQUALS(){      // The first identifier was "="
     CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the second identifier
           //Do something
        break;
         
        case 'B':
           //Do something
        break;
         
        case 'C':
           //Do something
        break;
         }
    }
    
    
    void LESSTHAN(){    // The first identifier was "<"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the second identifier
           //Do something
        break;
         
        case 'B':
           //Do something
        break;
        case 'R'://Found the second identifier ("R" roll position)
        {roll = "";
        roll +=getChar();
        roll +=getChar();
        roll +=getChar();
        roll +=getChar();
        roll +=getChar();
        roll +=getChar();
        int rolli = roll.toInt();
        rolli = (rolli +90);
        rollServo.write(rolli);}
        break;
        
        case 'Q'://Found the second identifier ("Q" pitch position)
          {pitch = "";
          pitch += getChar();
          pitch += getChar();
          pitch += getChar();
          pitch += getChar();
          pitch += getChar();
          pitch += getChar();
          int pitchi = pitch.toInt(); 
          pitchi = (pitchi/2 +90 );// Centres servo.
          pitchServo.write(pitchi); // send it out
          
        }
      break;
      }     
    }
    
    
    void QUESTION(){    // The first identifier was "?"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the second identifier
           //Do something
        break;
         
        case 'B':
           //Do something
        break;
         
        case 'C':
           //Do something
        break;
         }
    }
    void SLASH(){    // The first identifier was "/" (Annunciator)
      //Do something
    }
    void KEYS() 
    {
      Kstringnewstate = "";
      for (int KpinNo = 2; KpinNo < 70; KpinNo++){
        KpinStateSTR = String(digitalRead(KpinNo)); 
        KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 2));
        if (KpinStateSTR != KoldpinStateSTR)
        {
          if (KpinNo != 13){
          Serial.print ("D"); 
          if (KpinNo < 10) Serial.print ("0");
          Serial.print (KpinNo);
          Serial.println (KpinStateSTR);
          }
        }
        Kstringnewstate += KpinStateSTR;
      }
      Kstringoldstate = Kstringnewstate;
    }
    Last edited by vikingsraven; 01-05-2014 at 10:01 AM. Reason: code missing

  8. Thanks Jim NZ thanked for this post
    Likes Jim NZ liked this post
  9. #6
    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: attitude gage test

    This is good stuff Mark and thanks heaps for posting it ,, it will be a big help for some-one thinking along the same lines.

    You have covered it well but I have a couple of questions just to have the whole project info in one thread ,,,,

    1/.. What "Cycle time" were you using in the video ???
    (The Cycle time in the "Communications Settings" Tab of the Multi)

    2/.. Were you using the 5 volts from the Arduino (from the USB cable) for the drive to the servos or did you have a separate 5v feed from somewhere else ????
    (I see you are using a servo shield but I couldn't see any separate 5v lead ,, just wanted to clarify)

    3/.. I don't have a servo shield but understand that the servos could actually have been hooked directly to the Arduino ???

    I can't think of anything else that some-one may ask on this project as you have covered it so well Mark ,,,, great stuff ,, it makes it easy for some-one to do the same or modify for another type of meter.

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

  10. #7
    75+ Posting Member vikingsraven's Avatar
    Join Date
    Dec 2012
    Location
    UK
    Posts
    89
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: attitude gage test

    jim good point

    1/.. What "Cycle time" were you using in the video ???
    (The Cycle time in the "Communications Settings" Tab of the Multi)
    on the video its 200ms , but its a lot smoother at 100.

    2/.. Were you using the 5 volts from the Arduino (from the USB cable) for the drive to the servos or did you have a separate 5v feed from somewhere else ????
    (I see you are using a servo shield but I couldn't see any separate 5v lead ,, just wanted to clarify)
    Yes, 2 servos are fine as long as they not under too much load, its better to run them off a separate supply ideally just remember to common the ground on the arduino and the servos. Actually the best idea is have a fairly hefty current wise supply and run the arduino and the servos from the same thing, Arduinos have a Vin pin and you can supply it with that.

    3/.. I don't have a servo shield but understand that the servos could actually have been hooked directly to the Arduino ???
    yes connect the yellow/ white or orange wire (depending on servo) to the arduino pin, no need for resistors, thats the pwm sign in pin for positioning.

    just noticed that some of the code is missing when i posted it, it seems to loose anything in the <> brackets probably as is bulletin board code and that uses that, i thought the code thing would prevent that! ive seen it on some of the other code posts on here as well.

    I spent years in the film industry and building aircraft door trainers so im used to building stuff from scratch, don't mind helping out if people need info!
    Like wise with the coding, ive run into issues on an Arduino forum where people think just because they know , everyone else should and they can be damn nasty at it. Share and share alike, if people want to learn help them.

    going to have a go at a magnetic compass using a stepper motor next, ill post it when im done!

  11. #8
    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: attitude gage test

    Yea ,, posting code in here is a real pain as (as you say) it chops some things off ,,, mainly some "includes" but also if even the comments text has a certain combination it will chop that off too.

    For any "newbie" ,, what I done was ,,,,\
    Delete all the comments at the top ,, right down to (and including) the line ,,,
    "For this servo code to work you must tick "

    Next I add the "include servo",,,
    Click ,, Sketch / Import library / Servo
    And it compiles fine.

    Thanks again Mark and we look forward to your next project.

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

  12. #9
    75+ Posting Member



    Join Date
    Sep 2013
    Location
    California, USA
    Posts
    109
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: attitude gage test

    Hi Mark, This is simply excellent work. Whatever gave you the idea to use a Christmas ball in early January ? I'm going to use this as a design concept for my own instrument panel, maybe using some other materials I have on hand, but following your design. The servos you are using seem a bit large for the application, is that because it's what you had on hand or is there a need that I'm not seeing?

  13. #10
    New Member
    Join Date
    Dec 2013
    Location
    LA
    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: attitude gage test

    Built a Prototype of this over the weekend. After figuring out the missing parts of the code it all worked
    great. Thank you for posting this, one more piece of my 172 project figured out.

Page 1 of 2 12 LastLast