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

SimTools and Arduino Uno Micro servo

Discussion in 'DIY Motion Simulator Projects' started by Darkhanbaatar, Jan 23, 2014.

  1. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    hi I have many problems, i used SimTools and Arduino Uno, Micro servo SG 90 arduino code is: RC_Sim_Model.ino file it didnot wort there is no any motion. what i do?
  2. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,156 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    before sending that code to your Arduino you have to comment (\\) out this line:

    #define DEBUG 1 // comment out this line to remove debuggin Serial.print lines
  3. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    //********************************************************************************************
    // RC Model Servo
    // Written By EAOROBBIE (Robert Lindsay)
    // For free use for Sim Tool Motion Software
    //********************************************************************************************

    #include <Servo.h>

    Servo myservo1; // create servo object to control a servo
    Servo myservo2; // create servo object to control a servo
    char kind_of_data; // to capture which servo needs to be move
    int valLSP = 90; // set the intial Left Servo Position to centre
    int valRSP = 90; // set the intial Right Servo Position to centre

    void setup()
    {
    myservo1.attach(3); // attaches the servo on pin 5 to the servo object
    myservo2.attach(5); // attaches the servo on pin 4 to the servo object
    myservo1.write(valLSP); // sets the servo position according to the scaled value
    myservo2.write(valRSP); // set the servo position according to the scaled value

    Serial.begin(9600); // opens serial port at a baud rate of 9600
    }

    void loop()
    {
    //****************************** READ DATA FROM SERIAL ******************************
    while (Serial.available() > 0)
    {

    kind_of_data = Serial.read();
    if (kind_of_data == 'R' ) Read_RightServo();
    if (kind_of_data == 'L' ) Read_LeftServo();


    myservo1.write(valRSP); // sets the servo position according to the scaled value
    myservo2.write(valLSP); // sets the servo position according to the scaled value
    }
    }

    void Read_RightServo(){

    int RightServoPos = 0;
    delay(2);
    int RSP100 = Serial.read();
    delay(2);
    int RSP10 = Serial.read();
    delay(2);
    int RSP1= Serial.read();
    RSP100 = ((RSP100)-48)*100;
    RSP10 = ((RSP10)-48)*10;
    RSP1 = ((RSP1)-48)*1;
    if (RSP10 < 0 && RSP1 < 0){RSP100 = RSP100/100;RSP10 = 0;RSP1 = 0;}
    if (RSP1 < 0){RSP100 = RSP100/10;RSP10 = RSP10/10;RSP1 = 0;}
    //Serial.println(RSP100); // these are here for debugging purposes
    //Serial.println(RSP10); // these are here for debugging purposes
    //Serial.println(RSP1); // these are here for debugging purposes
    RightServoPos = RSP100+RSP10+RSP1;
    valRSP = map(RightServoPos, 0, 255, 0, 179); // scale it to use it with the servo (value between 0 and 180)
    //Serial.println(RightServoPos); // these are here for debugging purposes
    //Serial.println(valRSP); // these are here for debugging purposes
    }

    void Read_LeftServo(){

    int LeftServoPos = 0;
    delay(2);
    int LSP100 = Serial.read();
    delay(2);
    int LSP10 = Serial.read();
    delay(2);
    int LSP1= Serial.read();
    LSP100 = ((LSP100)-48)*100;
    LSP10 = ((LSP10)-48)*10;
    LSP1 = ((LSP1)-48)*1;
    if (LSP10 < 0 && LSP1 < 0){LSP100 = LSP100/100;LSP10 = 0;LSP1 = 0;}
    if (LSP1 < 0){LSP100 = LSP100/10;LSP10 = LSP10/10;LSP1 = 0;}
    //Serial.println(LSP100); // these are here for debugging purposes
    //Serial.println(LSP10); // these are here for debugging purposes
    //Serial.println(LSP1); // these are here for debugging purposes
    LeftServoPos = LSP100+LSP10+LSP1;
    valLSP = map(LeftServoPos, 0, 255, 179, 0); // scale it to use it with the servo (value between 0 and 180)
    //Serial.println(LeftServoPos); // these are here for debugging purposes
    //Serial.println(valLSP); // these are here for debugging purposes
    }

    that is my used arduino code, i used arduino uno and micro servo SG90
  4. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    PLS insert tutorial RC_Sim_Model
    • Agree Agree x 1
  5. 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,390Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Ok I agree look like thats my project for tonight.
  6. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    Hi i used SimTools and Arduino Uno, Micro servo SG 90 it is working fine just live for speed game and other games race 07, rFactor 1,2 dirt2,3 are working fine but arduino uno received signals (Led flashing) but output testing-virtual axis area have lesser sensation and micro servo don't move
    help me
  7. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    Hi my simTools working fine Dirt3, Race07, rFactor, i used Arduino Uno, Micro servo SG 90.
    thanks help me.i'll make big one wiper motor or window motor
    • Like Like x 2
  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,390Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    The code will only drive servos, need to update code to several here on site, @prilad and @RufusDufus both have codes with nice tut and apps to setup them up.
    The rc code is for models only.
  9. Darkhanbaatar

    Darkhanbaatar New Member

    Joined:
    Dec 15, 2013
    Messages:
    20
    Balance:
    - 6Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 4DOF
    ok thanks i know it
  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,390Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Gday @neotonight, please start your own build post so not to clutter @Darkhanbaatar topic.
    Then we can advise you which steps are next.
    Quick answers, 6 servos on one UNO, yes will work with a external power supply
    Yes 2 wipers per Ard UNO, some codes will run up to 3 , but to me Ard is not powerful enough to cope properly so I would recommend only using one ard for two motors.
    And last NO wont work.
  11. jsbuitrago

    jsbuitrago New Member

    Joined:
    Sep 5, 2018
    Messages:
    1
    Balance:
    42Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    6DOF
    hola estoy intentado realizar la conexion de simtools con arduino pero no he podido ver si se esta comunicando por la ventana serial le agradezco si me dan una ayua
  12. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,460
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,596Coins
    Ratings:
    +10,741 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Please be aware that you can dual language post but must provide an English translation, as per the Forum Rules, using Google Translate is fine: https://www.xsimulator.net/community/threads/forum-rules.9527/