1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

2DOF Arduino miniature motion platform w 2-servos

Discussion in 'DIY Motion Simulator Projects' started by jamesdio, Oct 13, 2011.

  1. DERIY

    DERIY Member

    Joined:
    Apr 24, 2010
    Messages:
    64
    Location:
    RUSSIA
    Balance:
    - 52Coins
    Ratings:
    +7 / 1 / -0
    Hi!
    I found a solution to the problem with the servo shakes.
    Pause should be increased to 40 ms.
    [​IMG]
    • Disagree Disagree x 1
  2. JBoogie

    JBoogie Member

    Joined:
    Jan 14, 2014
    Messages:
    82
    Occupation:
    Pre-sales Engineer
    Location:
    Northern VA
    Balance:
    1,524Coins
    Ratings:
    +37 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, SimforceGT
  3. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    @JBoogie , if you are happy with DERIYs solution, then you had better go to the forum of which the software that is posted in the picture belongs.
    Dont ask for help for x-sim software here.
    • Agree Agree x 2
  4. fireflyone

    fireflyone firefly's simulatior test build

    Joined:
    Dec 30, 2013
    Messages:
    11
    Location:
    uk
    Balance:
    381Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    hi i have had a play with the code little not much as i am still learing set the output to hex and output bits to 10 bit instead of 8 kinda works better when i was seting up i had to move the sliders to - 70 to get the servo to work but if you change the above will work ok so dont shout i am still learning
  5. fireflyone

    fireflyone firefly's simulatior test build

    Joined:
    Dec 30, 2013
    Messages:
    11
    Location:
    uk
    Balance:
    381Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    /* i have added anothe servo fireflyone goint to add some more in min here is the updated code hope theis helps
    * 2DOF Motion Platform with 2 Servos
    * -------------------------------------
    * Thanks to herctrap and his source
    * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1280139142
    *
    * and also thanks to juiou and his source
    * http://www.x-simulator.de/forum/arduino-and-x-sim-t2773-30.html
    *
    * I just combined their sources.
    *
    */

    #include <Servo.h>

    Servo myservo1;
    Servo myservo2;
    Servo myservo3;
    //Servo myservo1;
    //Servo myservo1;
    //Servo myservo1;
    int Degree;
    int Gforce = 0;
    int Gforce1 = 0;
    int Gforce10 = 0;
    int Gforce100 = 0;
    char kind_of_data;
    void setup() {

    //set servo pins
    myservo1.attach(2);
    myservo2.attach(3);
    myservo3.attach(4); //pwm servo

    //align servos center postision
    myservo1.write(90);
    myservo2.write(90);
    myservo3.write(90);
    //open serial connection
    Serial.begin(115200);
    }
    void loop() {
    // wait for serial input (min 3 bytes in buffer)
    while(Serial.available() > 0) {

    kind_of_data = Serial.read(); //string from USO --> L~a01~ R~a02~ 8bit resolution\decimal output
    if(kind_of_data == 'L') {
    Read_Pos(kind_of_data);
    }
    if(kind_of_data == 'R') {
    Read_Pos(kind_of_data);
    }
    if(kind_of_data == 'F') {
    Read_Pos(kind_of_data);
    }
    }
    }
    void Read_Pos(char which_servo){
    delay(2);
    int Gforce100 = Serial.read()- '0';
    delay(2);
    int Gforce10 = Serial.read()- '0';
    delay(2);
    int Gforce1 = Serial.read()- '0';

    //Verifica se e centena dezena ou decimal... =]
    if (Gforce1 < 0) { Gforce = Gforce10 + 10*Gforce100; }
    if (Gforce1 < 0 && Gforce10 < 0) { Gforce = Gforce100; }
    if (Gforce100 < 0) { Gforce = 127; }
    if (Gforce1 >=0 && Gforce10 >= 0 && Gforce100 >= 0) { Gforce = 100 * Gforce100 + 10 * Gforce10 + Gforce1; }
    if (which_servo == 'L') {
    Degree = map(Gforce, 0, 255, 180, 0);
    }
    if (which_servo == 'R') {
    Degree = map(Gforce, 0, 255, 0, 180);
    }
    if (which_servo == 'F') {
    Degree = map(Gforce, 0, 255, 0, 180);
    }
    if (which_servo == 'L') {
    myservo1.write(Degree);
    }
    if (which_servo == 'R' ){
    myservo2.write(Degree);
    }
    if (which_servo == 'F' ){
    myservo2.write(Degree);
    }
    }

    //just edit the axis and keep adding L<Axis1>R<Axis2>F<Axis3> as i am making 3 dof sim i do still need help thanks all out thare from fireflyone@me.com
  6. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    because of the code this contains delays which is not a good way to control ultra quick servos. Please take a look at this code I develop with the help of @aarondc. Its way faster and can be made into 6dof code very easily as @Historiker has shown with his 6dof model.

    Attached Files:

  7. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    i am not shouting............yet
  8. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    How did it go @fireflyone , Im willing to mode my code for you to 3dof if needed mate. Let me know.
  9. fireflyone

    fireflyone firefly's simulatior test build

    Joined:
    Dec 30, 2013
    Messages:
    11
    Location:
    uk
    Balance:
    381Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF

    please this would be great help i am using 2 monstermoto sheilds and ither adruino uno or mega that would be the eassy way for you i plan to get some more pics on later to do some testing so i will soo how it goes my email is fireflyone@me.com sorry for the typing its coold fingers geting slow thank you
  10. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Ah sorry I dont use ard to control H bridges found the motion to be poor compared to Jrks I use so I dont bother but as a dashboard or used to run a RC model of a sim , they perform very well.
  11. 362442340

    362442340 New Member

    Joined:
    Mar 23, 2014
    Messages:
    15
    Balance:
    328Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    Arduino
    i can't control the servo by use this code for 4dof
  12. 362442340

    362442340 New Member

    Joined:
    Mar 23, 2014
    Messages:
    15
    Balance:
    328Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    Arduino
    can you tell me the simtool setting///thankyou'。
  13. Capitan

    Capitan New Member

    Joined:
    Feb 18, 2013
    Messages:
    16
    Balance:
    202Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hello a question you code works well used? I'm just back from doing one servor to test the system to see how it works for then launch into the simulator on a large scale.