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 project started

Discussion in 'DIY Motion Simulator Projects' started by Elias, Dec 7, 2017.

  1. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi everyone,
    i have started my 2DOF project based on the one found at this link
    http://www.xsimulator.net/2dof-motion-simulator-truck-wiper-motor-playseat/
    I would thank the author for the amazing job he made it too easy for a rookie in electronics like me.
    I am using:
    1. Arduino Improved MEGA2560 R3 Development Board Module for Arduino - Blue (Cheap Chinese version)
    http://www.dx.com/p/368279
    2. Moto Monster shield
    http://www.dx.com/p/161274
    3. HP DPS600PB
    4. Some Jumper wires.
    5. 2x 10K potentiometers
    6. Still waiting for my DC wiper motors.

    To start and in order to understand how wiring should be done without burning anything i have started working with 7.2v batteries and 2 tiny DC motors.



    After several trials VOILA the motors are moving and controlled manually with the potentiometers.

    Now i will be waiting for the motors to arrive to move to another step.

    Attached Files:

    • Like Like x 2
  2. MarcNSF

    MarcNSF Marc

    Joined:
    May 24, 2017
    Messages:
    66
    Location:
    Lebanon
    Balance:
    - 98Coins
    Ratings:
    +42 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
  3. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thanks Marc
  4. Max Stanford

    Max Stanford New Member

    Joined:
    Oct 24, 2017
    Messages:
    8
    Occupation:
    Student
    Location:
    Malaysia
    Balance:
    101Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hey there, ive done my 2dof seat! can you update your frame equipment and design?
  5. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Dear Max,
    i haven't reached that phase yet, i m still waiting for my motors that i expect to receive today to start my design.
    i ll let you know when i develop something
    • Friendly Friendly x 1
  6. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Guys,
    i have tried the moto monster shield and everything works fine knowing that i am still simulating using tiny motors.
    i bought 2 single H-bridges IMS-2A that are supposed to handle 30A each with the purpose of using more powerful motors.
    http://www.ekt2.com/products/productdetails/412_ARDUINO_DC_MOTOR_DRIVER_30A
    i have noticed that i had to disconnect the R1 because The V + pin is by default a direct connection with the B + pin (refer to attachment).


    wires connection as follow:

    Arduino H bridge 1
    pin 2 IN1 (supposedly ENA) motor1
    pin 9 IN2 (supposedly PWM) motor1
    pin 3 EN (supposedly ENB) motor1
    Grnd Grnd
    5v V+

    H bridge 2
    pin 4 IN1 (supposedly ENA) motor2
    pin 10 IN2 (supposedly PWM) motor2
    pin 5 EN (supposedly ENB) motor2
    Grnd Grnd
    5v V+

    A1 Pot 1
    A2 Pot2

    I used SMC3 v1.0 with mode 2

    Nothing moved, on the other hand i have noticed that even without external power supply connected i am getting 5.08V coming from the Arduino on the B+ and Grnd of the H bridge.

    I would appreciate if anyone can help.

    Attached Files:

  7. Max Stanford

    Max Stanford New Member

    Joined:
    Oct 24, 2017
    Messages:
    8
    Occupation:
    Student
    Location:
    Malaysia
    Balance:
    101Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Goodluck on building your 2dof bro.
  8. MarcNSF

    MarcNSF Marc

    Joined:
    May 24, 2017
    Messages:
    66
    Location:
    Lebanon
    Balance:
    - 98Coins
    Ratings:
    +42 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
  9. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Dear Max,
    i know i m late but this is what i have reached

    Attached Files:

    • Like Like x 2
  10. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Help
    I have reached the phase where i m sending orders via arduino serial monitor
    Everything works great.
    I have downloaded SimTools and followed the directions but nothing is moving i m stuck can anyone help
    Last edited: May 2, 2018
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,461
    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
    What code are you using with the Arduino, SMC3 or something else?

    Please post pictures of all of your settings.
  12. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I am using this one
    /*
    Arduino code for dynamic playseat 2DOF
    Created 24 May 2011 by Jim Lindblom SparkFun Electronics https://www.sparkfun.com/products/10182 "Example Code"
    Created 24 Apr 2012 by Jean David SEDRUE Version betatest26 - 24042012 http://www.gamoover.net/Forums/index.php?topic=25907
    Updated 20 May 2013 by RacingMat in english http://www.xsimulator.net/2dof-wiper-motor-playseat/ in french : http://www.gamoover.net/Forums/index.php?topic=27617
    Updated 30 April 2014 by RacingMat (bug for value below 16 corrected)
    */
    #define BRAKEVCC 0
    #define RV 2 //beware it's depending on your hardware wiring
    #define FW 1 //beware it's depending on your hardware wiring
    #define STOP 0
    #define BRAKEGND 3
    ////////////////////////////////////////////////////////////////////////////////
    #define pwmMax 255 // or less, if you want to lower the maximum motor's speed
    // defining the range of potentiometer's rotation
    const int potMini=208;
    const int potMaxi=815;
    ////////////////////////////////////////////////////////////////////////////////
    #define motLeft 0
    #define motRight 1
    #define potL A0
    #define potR A1
    ////////////////////////////////////////////////////////////////////////////////
    // DECLARATIONS
    ////////////////////////////////////////////////////////////////////////////////
    /* VNH2SP30 pin definitions*/
    int inApin[2] = {
    7, 4}; // INA: Clockwise input
    int inBpin[2] = {
    8, 9}; // INB: Counter-clockwise input
    int pwmpin[2] = {
    5, 6}; // PWM input
    int cspin[2] = {
    2, 3}; // CS: Current sense ANALOG input
    int enpin[2] = {
    0, 1}; // EN: Status of switches output (Analog pin)
    int statpin = 13; //not explained by Sparkfun
    /* init position value*/
    int DataValueL=512; //middle position 0-1024
    int DataValueR=512; //middle position 0-1024
    ////////////////////////////////////////////////////////////////////////////////
    // INITIALIZATION
    ////////////////////////////////////////////////////////////////////////////////
    void setup()
    {
    // serial initialization
    Serial.begin(115200);
    // initialization of Arduino's pins
    pinMode(statpin, OUTPUT); //not explained by Sparkfun
    digitalWrite(statpin, LOW);
    for (int i=0; i<2; i++)
    {
    pinMode(inApin, OUTPUT);
    pinMode(inBpin, OUTPUT);
    pinMode(pwmpin, OUTPUT);
    }
    // Initialize braked for motor
    for (int i=0; i<2; i++)
    {
    digitalWrite(inApin, LOW);
    digitalWrite(inBpin, LOW);
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////// Main Loop ////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////
    void loop()
    {
    int sensorL,sensorR;
    readSerialData(); // DataValueR & L contain the last order received (if there is no newer received, the last is kept)
    // the previous order will still be used by the PID regulation MotorMotion Function
    sensorR = analogRead(potR); // range 0-1024
    sensorL = analogRead(potL); // range 0-1024
    motorMotion(motRight,sensorR,DataValueR);
    motorMotion(motLeft,sensorL,DataValueL);
    }
    ////////////////////////////////////////////////////////////////////////////////
    // Procedure: wait for complete trame
    ////////////////////////////////////////////////////////////////////////////////
    void readSerialData()
    {
    byte Data[3]={
    '0','0','0' };
    // keep this function short, because the loop has to be short to keep the control over the motors
    if (Serial.available()>2){
    //parse the buffer : test if the byte is the first of the order "R"
    Data[0]=Serial.read();
    if (Data[0]=='L'){
    Data[1]=Serial.read();
    Data[2]=Serial.read();
    // call the function that converts the hexa in decimal and that maps the range
    DataValueR=NormalizeData(Data);
    }
    if (Data[0]=='R'){
    Data[1]=Serial.read();
    Data[2]=Serial.read();
    // call the function that converts the hexa in decimal and maps the range
    DataValueL=NormalizeData(Data);
    }
    }
    if (Serial.available()>16) Serial.flush();
    }
    ////////////////////////////////////////////////////////
    void motorMotion(int numMot,int actualPos,int targetPos)
    ////////////////////////////////////////////////////////
    {
    int Tol=20; // no order to move will be sent to the motor if the target is close to the actual position
    // this prevents short jittering moves
    //could be a parameter read from a pot on an analogic pin
    // the highest value, the calmest the simulator would be (less moves)
    int gap;
    int pwm;
    int brakingDistance=30;
    // security concern : targetPos has to be within the mechanically authorized range
    targetPos=constrain(targetPos,potMini+brakingDistance,potMaxi-brakingDistance);
    gap=abs(targetPos-actualPos);
    if (gap<= Tol) {
    motorOff(numMot); //too near to move
    }
    else {
    // PID : calculates speed according to distance
    pwm=195;
    if (gap>50) pwm=215;
    if (gap>75) pwm=235;
    if (gap>100) pwm=255;
    pwm=map(pwm, 0, 255, 0, pwmMax); //adjust the value according to pwmMax for mechanical debugging purpose !
    // if motor is outside from the range, send motor back to the limit !
    // go forward (up)
    if ((actualPos<potMini) || (actualPos<targetPos)) motorGo(numMot, FW, pwm);
    // go reverse (down)
    if ((actualPos>potMaxi) || (actualPos>targetPos)) motorGo(numMot, RV, pwm);
    }
    }


    ////////////////////////////////////////////////////////////////////////////////
    void motorOff(int motor){ //Brake Ground : free wheel actually
    ////////////////////////////////////////////////////////////////////////////////
    digitalWrite(inApin[motor], LOW);
    digitalWrite(inBpin[motor], LOW);
    analogWrite(pwmpin[motor], 0);
    }
    ////////////////////////////////////////////////////////////////////////////////
    void motorOffBraked(int motor){ // "brake VCC" : short-circuit inducing electromagnetic brake
    ////////////////////////////////////////////////////////////////////////////////
    digitalWrite(inApin[motor], HIGH);
    digitalWrite(inBpin[motor], HIGH);
    analogWrite(pwmpin[motor], 0);
    }
    ////////////////////////////////////////////////////////////////////////////////
    void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
    ////////////////////////////////////////////////////////////////////////////////
    {
    if (motor <= 1)
    {
    if (direct <=4)
    {
    // Set inA[motor]
    if (direct <=1)
    digitalWrite(inApin[motor], HIGH);
    else
    digitalWrite(inApin[motor], LOW);
    // Set inB[motor]
    if ((direct==0)||(direct==2))
    digitalWrite(inBpin[motor], HIGH);
    else
    digitalWrite(inBpin[motor], LOW);
    analogWrite(pwmpin[motor], pwm);
    }
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    void motorDrive(uint8_t motor, uint8_t direct, uint8_t pwm)
    ////////////////////////////////////////////////////////////////////////////////
    {
    // more readable function than Jim's (for educational purpose)
    // but 50 octets heavier -> unused
    if (motor <= 1 && direct <=4)
    {
    switch (direct) {
    case 0: //electromagnetic brake : brake VCC
    digitalWrite(inApin[motor], HIGH);
    digitalWrite(inBpin[motor], HIGH);
    break;
    case 3: //Brake Ground (free wheel)
    digitalWrite(inApin[motor], LOW);
    digitalWrite(inBpin[motor], LOW);
    break;
    case 1: // forward : beware it's depending on your hardware wiring
    digitalWrite(inApin[motor], HIGH);
    digitalWrite(inBpin[motor], LOW);
    break;
    case 2: // Reverse : beware it's depending on your hardware wiring
    digitalWrite(inApin[motor], LOW);
    digitalWrite(inBpin[motor], HIGH);
    break;
    }
    analogWrite(pwmpin[motor], pwm);
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    // testPot
    ////////////////////////////////////////////////////////////////////////////////
    void testPot(){
    Serial.print(analogRead(potR));
    Serial.print(";");
    Serial.println(analogRead(potL));
    delay(250);
    }
    ////////////////////////////////////////////////////////////////////////////////
    void testpulse(){
    int pw=120;
    while (true){
    motorGo(motLeft, FW, pw);
    delay(250);
    motorOff(motLeft);
    delay(250);
    motorGo(motLeft, RV, pw);
    delay(250);
    motorOff(motLeft);
    delay(500);
    motorGo(motRight, FW, pw);
    delay(250);
    motorOff(motRight);
    delay(250);
    motorGo(motRight, RV, pw);
    delay(250);
    motorOff(motRight);
    Serial.println("testpulse pwm:80");
    delay(500);
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    // Function: convert Hex to Dec
    ////////////////////////////////////////////////////////////////////////////////
    int NormalizeData(byte x[3])
    ////////////////////////////////////////////////////////////////////////////////
    {
    int result;
    if ((x[2]==13) || (x[2]=='R') || (x[2]=='L')) //only a LSB and Carrier Return or 'L' or 'R' in case of value below 16 (ie one CHAR and not 2)
    {
    x[2]=x[1]; //move MSB to LSB
    x[1]='0'; //clear MSB
    }
    for (int i=1; i<3; i++)
    {
    if (x>47 && x<58 ){//for xA to xF
    x=x-48;
    }
    if ( x>64 && x<71 ){//for x0 to x9
    x=x-55;
    }
    }
    // map the range from Xsim (0 <-> 255) to the mechanically authorized range (potMini <-> potMaxi)
    result=map((x[1]*16+x[2]),0,255,potMini,potMaxi);
    return result;
    }
  13. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino

    Attached Files:

  14. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,461
    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
    The difference from SimTools 1.3 to SimTools 2 in setup is that in the Interface Settings instead of axis defined like this <Axis1> it now has designate grouping for a or b in SimTools 2 for each axis assignment, like this L<Axis1a>R<Axis2a>
  15. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thanks a lot
    it's working now, i tried the output test and it moved but wehn i ran LFS the simulator didn't behave as expected. when i tried again i got tis message
    upload_2018-5-5_9-9-0.png

    what could be wrong?
  16. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,461
    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
    Did you run a couple of laps in LFS before patching it, as that generates some necessary files. If not then un-patch LFS, run a couple of laps, then re-patch LFS.

    If you still get the error message after that the hot the Details button on the error message and post a picture of it.
  17. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thanks i ll do that
    Last edited by a moderator: May 5, 2018
  18. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I did it’s working now but can u please tell me how to reverse the axis when i brake it goes back and when i push the throttle it mives to the front.
    Thks
  19. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,461
    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
  20. Elias

    Elias New Member

    Joined:
    Oct 18, 2017
    Messages:
    20
    Occupation:
    Architect
    Location:
    Lebanon
    Balance:
    163Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    A big thanks now i got it it works perfectly thanks to everyone this community is the best
    Chears
    • Winner Winner x 2
    • Like Like x 1