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

Showroom 2 dof (Arduino - motormoster - wiper motor)

Discussion in 'DIY Motion Simulator Projects' started by IRaceSim, Jan 11, 2019.

Tags:
  1. IRaceSim

    IRaceSim Impalone

    Joined:
    Jan 5, 2018
    Messages:
    24
    Occupation:
    Geometra
    Location:
    Teramo
    Balance:
    63Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, SCN5, Arduino
    I present my "sim 2 dof". For my homemade simulator, I chose the iron rods of 35x35mm sp.2mm size for the base and 30x30mm and 20x20 sp.2mm for the upper float. The all welded.

    I will show you step by step my realization.

    P_20160322_194747_1_p.jpg P_20160322_194803_p.jpg P_20160322_194812_1_p.jpg P_20160322_194829_p.jpg


    [​IMG][​IMG]
    [​IMG]
    ______________________________________________________ Chassis
    ______________________________________________________

    The upper part of my frame

    20150429_181147.jpg 20150429_181140 - Copia.jpg
    [​IMG]

    The lower base with adjustable feet.

    20150429_181202.jpg 20150429_181206.jpg
    [​IMG]
    [​IMG]

    The cardan joint used in the assembly of the top and the bottom of the chassis.

    P_20160305_184600_1_p.jpg

    It is very important that the joint prevents rotation of the upper part.

    The result is this

    20150520_185713.jpg

    [​IMG]
    ______________________________________________________
    Electronic and motor
    ______________________________________________________

    The utilized solution to move the frame, are two wiper motors, exactly SMOLKA VALEO 404.458, powered and controlled by motomonster card and Arduino UNO, controlled by 10Kohm linear potentiometers.

    This is the assembly scheme.
    lipide512-wiringdiagram.gif

    I've got all the necessary material on various internet sites.

    Wiper motor - Smolka Valeo 404.458 12V Wiper Motor
    [​IMG]
    Linear pot 10k
    [​IMG]
    Arduino and motomoster shield
    [​IMG]
    Electric cables
    [​IMG]
    power supply 12V 50A
    [​IMG]

    The motomoster can be attached on top of the Arduino. I preferred to make them work parallel, so there is no danger of a short circuit and overheating.

    20141218_220746.jpg
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    Once the boards have been prepared, the motors are mounted on the chassis and the potentiometers are connected.
    For the assembly of the engines I have prepared some special brackets.

    20150429_183104.jpg
    20150429_184805.jpg
    20150518_225652.jpg 20150518_193218.jpg

    I inserted pieces for gaming devices

    20150506_215312.jpg
    20150506_215332.jpg

    Finished with the motor brackets and with the chassis, I proceed with the preparation of the 6mm mechanical shaft to connect the potentiometers. I disassembled the engine, created a mechanical thread which I need to screw the created mechanical shaft.

    20150518_214132.jpg 20150518_214231.jpg 20150518_214249.jpg 20150518_214323.jpg
    20150518_214349.jpg
    20150518_214504.jpg
    I created some potentiometer brackets. A flexible material is recommended

    20150518_214135.jpg

    This is the result

    20150518_193214.jpg

    As you can see, the potentiometer is connected to the transmission shaft by means of a 6mm electrical connector with clamping screws.

    Completed the mechanical and electrical assembly, I continued to load the arduino code on the board. In this operation it is very important not to power the motors, and do not tighten the connection screws between potentiometers and motors, it is sufficient to keep only the arduino board powered.

    I installed the computer program with the card via the USB cable and by selecting the card port (in my case) I entered this code.

    #define BRAKEVCC 0
    #define RV 2 //according to cable at 24/11/2011
    #define FW 1 //according to cable at 24/11/2011
    #define STOP 0
    #define BRAKEGND 3
    #define CS_THRESHOLD 253 //not use :(
    ////////////////////////////////////////////////////////////////////////////////
    #define pwmMin 128;
    #define pwmMax 250;
    #define motLeft 0
    #define motRigth 1
    #define speedPin 10
    #define potL A4
    #define potR A5

    ////////////////////////////////////////////////////////////////////////////////
    // 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;
    /* init position value*/
    int DataValueL=125; //middle position
    int DataValueR=125; //middle position

    ////////////////////////////////////////////////////////////////////////////////
    // INITIALIZATION
    ////////////////////////////////////////////////////////////////////////////////
    void setup()
    {
    /* serial initialization */
    Serial.begin(115200);
    /* motor initialization */
    pinMode(statpin, OUTPUT);
    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;

    serialData();
    sensorR = analogRead(A4)/4;
    sensorL = analogRead(A5)/4; // echelle 0-1000
    /* Serial.print(sensorL);
    Serial.print(" ; ");
    Serial.println(sensorR);
    motorGo(motRigth, FW, 255);
    delay(100);
    motorOff(motRigth);
    delay(1000);
    */
    motorMotion(motRigth,sensorR,DataValueR);
    motorMotion(motLeft,sensorL,DataValueL);

    }
    ////////////////////////////////////////////////////////////////////////////////
    // Procedure: wait for complete trame
    ////////////////////////////////////////////////////////////////////////////////
    void serialData()
    {
    byte Data[3]={
    '0','0','0' };
    // il faut limmitter le temps pour garder le contrôle des moteurs
    if (Serial.available()>2){ //wait a packets of 6
    //test if order R or L data type
    Data[0]=Serial.read();
    if (Data[0]=='R'){ // ordre connue ?, si non je verrais au prochain tour !
    Data[1]=Serial.read();
    Data[2]=Serial.read();
    DataValueR=NormalizeData(Data);
    }
    if (Data[0]=='L'){ // ordre connue ?, si non je verrais au prochain tour !
    Data[1]=Serial.read();
    Data[2]=Serial.read();
    DataValueL=NormalizeData(Data);

    }
    }
    if (Serial.available()>16) Serial.flush();
    }
    ////////////////////////////////////////////////////////
    void motorMotion(int numMot,int actualPos,int targetPos)
    ////////////////////////////////////////////////////////
    {
    // int potPinL=A4; //to include in header procedure
    // int potPinR=A5; //to include in header procedure

    int Tol=4;
    int difference;
    int pwm;
    int securityLow=20;
    int securityHigh=200;
    int brakeDistance=16;
    boolean move=true;

    // encadrements des valeurs
    if (targetPos<securityLow+brakeDistance) targetPos=(securityLow+brakeDistance); //software limits, but consideration speed brake.
    if (targetPos>securityHigh-brakeDistance) targetPos=(securityHigh-brakeDistance); //software limits, but consideration speed brake.
    // calculate speed about distance
    difference=abs(targetPos-actualPos);

    if (difference<=Tol) pwm=0; // to near to mov
    if (difference>Tol) pwm=168;
    if (difference>50) pwm=200;
    if (difference>75) pwm=225;
    if (difference>100) pwm=255;
    // pay attention for security for Right motor!!
    if (actualPos>securityHigh || actualPos<securityLow) move=false; //mechanicals limits
    //to near to move
    if (difference<= Tol) move=false; //to near to move
    // en avant (haut)
    if (actualPos<targetPos && move) {
    pwm=255; //need power to go up !
    motorGo(numMot, FW, pwm);
    }
    pwm=255; //test !
    // en arriere (bas)
    if (actualPos>targetPos && move) motorGo(numMot, RV, pwm);
    // ne pas bouger !
    if (move==false) motorOff(numMot);// STOP
    }
    ////////////////////////////////////////////////////////////////////////////////
    void motorOff(int motor){
    ////////////////////////////////////////////////////////////////////////////////
    digitalWrite(inApin[motor], LOW);
    digitalWrite(inBpin[motor], LOW);
    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);

    }
    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    // testPot
    ////////////////////////////////////////////////////////////////////////////////
    void testPot(){

    Serial.print(analogRead(A4));
    Serial.print(";");
    Serial.println(analogRead(A5));
    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(motRigth, FW, pw);
    delay(250);
    motorOff(motRigth);
    delay(250);
    motorGo(motRigth, RV, pw);
    delay(250);
    motorOff(motRigth);
    Serial.println("testpulse pwm:80");
    delay(500);

    }
    }
    ////////////////////////////////////////////////////////////////////////////////
    // Function: convert Hex to Dec
    ////////////////////////////////////////////////////////////////////////////////
    int NormalizeData(byte x[3])
    ////////////////////////////////////////////////////////////////////////////////
    {
    int result;

    if (x[2]==13) //only a LSB and Carrier Return
    {
    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;
    }
    }
    result=(x[1]*16+x[2]);
    return result;
    }

    when the code was loaded, I turned the engines on. I have the potentiometers on each side in my hand, and I tried to rotate the potentiometer. With the potentiometer positioned in the same way that will be mounted, I tried to rotate, the motor started in the opposite direction (otherwise you need to reverse the power supply wires of the motor) Once this verification was completed, I rotated the potentiometers in the central position and the motors stopped. I connected everything and with the assembly of the pieces to make the upper part move.
    20150520_185655.jpg
    This in the result.

    20150708_072836.jpg


    I connected the card to the PC, I powered the engines, opened the serial warning of the Arduino program and entering these codes the simulator responded as expected.

    In the "Serial Monitor" send the following strings in Hexa and Enter:
    R7FL7F
    -> it should move the playseat in horizontal position

    R64L64
    R3FL3F
    R01L01 (max !!)
    -> it should tilt the playseat backward and a bit further

    R9BL9B
    RC1LC1
    RFFLFF (Max !!)
    -> it should tilt the playseat forward and a bit further

    You can mix for rolling movment :
    R3FLC1
    R01LFF (Max !!)
    -> roll left

    RC1L3F
    RFFL01 (Max !!)
    -> roll right

    The simulator is ready for final test.

    1°test


    I will continue to connect with simtools later on.

    a special thanks to Racing Mat which was a reference.

    Attached Files:

    • Like Like x 1
    Last edited: Jan 11, 2019
  2. Pramuuditha Kumara

    Pramuuditha Kumara Member

    Joined:
    Jan 6, 2019
    Messages:
    51
    Balance:
    81Coins
    Ratings:
    +4 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hi nice work buddy,
    im planing almost same way.
    can please share sim tools setting to me ....
    thank you in advance...
  3. Timebandit

    Timebandit New Member SimAxe Beta Tester Gold Contributor

    Joined:
    May 20, 2015
    Messages:
    2
    Occupation:
    COO
    Location:
    Finland
    Balance:
    107Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    Well done @IRaceSim! I have plans for making (finally) 2DOF sim with almost exactly same setup. Can you share the dimensions of your motor brackets? Those look pretty strong ones.
  4. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,233
    Location:
    Marseille - FRANCE
    Balance:
    20,875Coins
    Ratings:
    +2,079 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I'm glad my tutorial was helpful :cheers
    good finish
    nice to see your sim in action!!! :thumbs

    please remove the code from your post and instead post a link: if I need to correct it or add something, it's a mess if many different versions are spreaded @IRaceSim
  5. Andrei14

    Andrei14 New Member

    Joined:
    Nov 7, 2018
    Messages:
    23
    Balance:
    183Coins
    Ratings:
    +4 / 0 / -0
    Very nice @IRaceSim, I'm also following the @RacingMat's tutorial. For the moment I figured out how to control the motors (working to refine my simtools settings).
    Can you please share your simtools settings?
  6. 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
    • Like Like x 1