Header MyCockpit
Results 1 to 7 of 7
  1. #1
    10+ Posting Member
    Join Date
    May 2012
    Location
    Versailles, France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    Please HELP
    I do not understand how to encode in FS2link_inOut, so I can move a servo via an ARDUINO UNO. Could you give me an example with the vario or Turn-coordinator.
    Thanks in advance.

    ------------------------

    Je ne comprends pas comment coder dans FS2link_inOut, pour que je puisse faire bouger un servo via une ARDUINO UNO. Pourriez vous me donner un example avec le vario ou le Turn-coordinator.
    Merci d'avance

    FX ;op

  2. #2
    10+ Posting Member
    Join Date
    May 2012
    Location
    Versailles, France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    Bin alors, personne n'a d'idée ?

    then, no one has idea ?

  3. #3
    500+ This must be a daytime job



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

    Re: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    That is a great question. I am playing with my Uno card today to try and figure out the method to do that.

    I am not sure what the basic process would even need to be. I would think it goes something like this:

    Move servo to known zero point

    Read value of FSX variable
    Compare FSX variable with known zero
    Compute value to be sent to move servo to proper value
    Move servo
    Wait some period of time

    repeat from read value of FSX variable


    Does anyone see anything I am missing in my thought process?

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

  4. #4
    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: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    Extremely easy to tell an arduino to move a servo, and even map its rotation, from 0 to 180 degrees or what ever range you need to the input from the program. You need to look at the included tutorial sketches in the arduino ide for examples with servos.
    You do not need to move a servo to a known 0, as the servo is a servo, and the servo knows where it is. If it was not a servo then it would need to move from a known zero, like a stepper motor needs to do.
    Think of a servo as a dc motor with an absolute rotary encoder mounted to the output shaft, or in the case of an r/c hobby servo, a pot.
    Code:
    // Controlling a servo position using a potentiometer (variable resistor) 
    // by Michal Rinott  
    
    #include  
     
    Servo myservo;  // create servo object to control a servo 
     
    int potpin = 0;  // analog pin used to connect the potentiometer
    int val;    // variable to read the value from the analog pin 
     
    void setup() 
    { 
      myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
    } 
     
    void loop() 
    { 
      val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
      myservo.write(val);                  // sets the servo position according to the scaled value 
      delay(15);                           // waits for the servo to get there 
    }
    Instead of reading the value from the ADC(the pin connected to the pot in the above example) have val equal the numerical value from flight sim. To do this, you may need to read a string and parse it to get the required information.
    Now lets say this number is airspeed and ranges from 0 to 350, and the servo only moves 150 deg from zero to 350(pretty lame ASI if you ask me)
    you would next change the values in the map function to look like this:
    Code:
    val = map(val, 0, 350, 0, 150);
    Keep in mind servo's move a max of 180 degrees, and many will move quite a bit less. To get more rotation gear or use a timing belt on the output shaft. Larger pulley on the servo, smaller pulley on the needle.

  5. Thanks WhiteStar01, AK Mongo thanked for this post
  6. #5
    500+ This must be a daytime job



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

    Re: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    Thanks for the suggestion and information WJH308!
    http://juneaucessnasim.blogspot.com
    N58243 (virtual)- Low and Slow...

  7. #6
    500+ This must be a daytime job



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

    Re: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    So in the above pde I would want to replace the lines
    "int potpin = 0; // analog pin used to connect the potentiometer
    int val; // variable to read the value from the analog pin "

    with something that reads a value from fs? Am I on the wrong track?

    If the above is true, then would I get the fs info from fs2 link?

    For instance if I am wanting a value for a vsi, would I use a modified version of Jim's LCD code and read the output data burst of Txxxx(where xxxx is vertical speed per minute)?

    Feeling lost-ish.....
    http://juneaucessnasim.blogspot.com
    N58243 (virtual)- Low and Slow...

  8. #7
    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: Gauges FSX whith servo or stepper motor & ARDUINO and FS2Link

    Ah you see, now this is the tricky part. I know embedded programming a heck of a lot better than I do windows programming. I've only briefly played with Jim's program and had the LCD do its trick but I am left feeling that I want more, and I want the program to talk back to Flight sim to verify the aircraft settings so I am not making any assumptions and winding up with gear indicators stating my gear are down when in fact they are up. I am currently getting myself up to speed with C# and using Jim's source code for reference and that of the SDK.
    To answer your question, if Jims program does in fact tell you the VSI data then yes, you can use that. Lets say the VSI data ranges from -4000 to +4000. Adjust the map function to show this:
    Code:
    val = map(val, -4000, 4000, 0, 179);
    Hopefully when your on the ground, the VSI will read 0, if not, maybe set a parameter that states servo position ~89 or 90ish while airplane is on ground.
    I am not giving you full details about reading the strings simply because I don't know enough to help you on that at this time.

    My own hopes and goals are to create an entirely new simconnect SDK tutorial using C#, Arduino's, AND the PMDG SDK all tied into one, making it all open source, open hardware for all to share and see. None of this junk about withholding source code to certain functions or programs, that just stinks!
    Sorry that I cannot be of more help right now. I'll be sure to let you know when I figure this out myself. After this week, my finals are over and will have more time!