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

simulador 2dof arduino inicio

Discussion in 'SimTools compatible interfaces' started by Claudemir, Nov 22, 2013.

  1. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Bom dia !
    Vejo que todos aqui são muito experiente na parte de automação , pesso ajuda por favor .com a ajuda de vocês creio que vou ter o meu próprio simulador .
    Para começar tenho duas ponte H IBT-2 , um arduino uno R3 dois motores 24v .
    A questão é como devo fazer a ligação destes componentes ?
    [​IMG]
  2. 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,400Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    A little more information on the H Bridge would be nice, I could find it with a search thou, looks like it needs two seperate pwn signals to control direction but with a doc on them we could confirm that. Not sure if a firmware for the Ard exist to run this style of H Bridge. Check @prilad code and @RacingMat but not sure if they can drive the H Bridge properly. I use Jrk12v12 no good for 24v sorry, you seem to have all the bits , yes.
  3. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    [quote = "eaorobbie, POS: 47.856,: Membro: 2210"] hum pouco Mais de Informação Sobre a ponte H séria BOM, eu poderia Encontra-lo com Uma Pesquisa tu, parece Que Precisa de Dois Sinais pwn separadas parágrafo Controlar a Direção, mas com hum doc Sobre enguias pudemos Confirmar ISSO. Nao tenho Certeza se hum firmware Pará o Ard existem parágrafo executar this Estilo de H Bridge. Verifique @ [USER = 6867] prilad [/ USER] Código e @ [USER = 8138] RacingMat [/ USER], mas nao tenho Certeza se ELES PODEM conduzir uma corretamente Ponte H. Eu USO Jrk12v12 Localidade: Não E BOM Pará 24v desculpe, parece Que VOCÊ TEM TODOS OS pedaços, sim. [/ Quote]

    Obrigado los respondedor Minha pergunta eaorobbie!
    eu tenho Duas ponte H IBT-2 43A.
    VOCÊ poderia Montar hum Esquema elétrico?
    Eu tenho Duas ponte H IBT-2, um arduino R3, Dois Motores
    Last edited: Nov 1, 2014
  4. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,648Coins
    Ratings:
    +1,009 / 9 / -1
    Hi Claudemir, I am using these H-Bridges at the moment (nice and cheap!). They are a little different in their interface to most used on this site though.

    They require direct drive of the highside/lowside switches for each motor terminal.

    The way I have currently connected them is as follows:

    R_EN connect to Uno R3 Motor PWM out
    L_EN connect to Uno R3 Motor PWM out (ie connect to same pin as above)
    RPWM connect to Uno R3 Motor DIR1 out
    LPWM connect to Uno R3 Motor DIR2 out
    VCC connect to Uno R3 +5V
    GND connect to Uno R3 GND
    R_IS not used
    L_IS not used

    (Sorry - I need to learn how to do a diagram with Fritzing or something)

    This is cheating a little as it is using the "driver enable" pins for the PWM. So rather than the PWM alternating the H-Bridge switching it is actually rapidly enabling/disabling the entire H-Bridge. While this works well (for me) and can be used with existing Arduino code it has the downside of overriding the temp sensing of the devices as the PWM is constantly resetting it - SO DON"T LET THEM RUN HOT if using this technique. I have been successfully using them like this for some months now but my sim doesn't load the motors much and they run pretty cool. I did burn one out when I setup my traction loss which loaded the motor more and ran the drivers much hotter - had to add some cooling for it.

    I have actually recently finished writing my own 3DOF PID Arduino code for these motors that drives them correctly. I haven't had a chance to rewire the interface and test the software though. Hopefully soon. You are welcome to have a copy once tested. It also has a companion PC program to setup and monitor the motor tracking but is not required. When tested I'll post it to the forums with instructions. It can be used for the more common H-Bridges as well.

    The correct way to drive the H-Bridges is with the RPWM and LPWM alone with the R_EN and L_EN just set High(+5v).

    Not sure how technical you are interested in getting... can supply more details if you like?
    • Like Like x 2
    Last edited: Nov 24, 2013
  5. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,648Coins
    Ratings:
    +1,009 / 9 / -1
    Attached is the H-Bridge schematic and driver datasheet

    Attached Files:

  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,400Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Ard firmware could be easily modified to handle this driver correctly, one on the originators of the codes was will to change theirs.
  7. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Estou Muito feliz Que estao me ajudando! : D

    Bom Aqui esta o Que eu tenho um par Começar Montar, entao Como eu sou Mecânico e de: Não entendo de Elétrica esto Fazendo Tudo O Que Voces estao me dizendo como here Peças Que eu JÁ tenho parágrafo Começar

    Attached Files:

    Last edited: Nov 1, 2014
  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,400Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    @RufusDufus If you can supply the pin out for the Ard connection to suit your code I can post a diagram for you guys and maybe you can include it in your post for it.

    @Claudemir If your not using RufusDufus code please tell us the code you will be using from there we can fill in the picture for you.
  9. 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,400Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Well Ard code is something you need to decide on, sorry I have only tested one here and that is @prilad 's with a different driver, just to prove communication with SimTools to the Ard for his code didnt drive the whole sim.

    See I use Jrk12v12 for www.pololu.com but not cheap to buy but simple to wire, wire power supply, motor,pot to the jrk and plug it in via usb and set the jrk's settings and use SimTools. I only use Ard UNO for Dashboard purposes. Jrk has its own micro-controller on board and H-Bridge all in one. 12v / 30amp peaks. (recorded 45amp on occasions)

    I would ask @RufusDufus nicely to be able to test his, as its designed for your type of H-Bridge and continue with the Ard , is one of the cheapest methods.
  10. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    estou terminando de fazer o desenho do cockpit e assim que tiver pronto eu posto aqui todas as fotos de como fazer um cockpit bom e barato para todos ! mais na parte de elétrica to levando uma surra !
  11. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,648Coins
    Ratings:
    +1,009 / 9 / -1
    I will see if I can find time to do some basic checks of the code and post it to the forums this weekend. ;)
    • Like Like x 1
  12. 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,400Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Thanks heaps mate, will post a diagram as soon as possible for people to follow and use, Gives the Ard Boys more options, Thanks.
  13. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Noite Boa? Fiz hum Vídeo de com Transformar Uma homocinética Pará Plataforma de Movimento do simulador.
    A homocinética VOCÊ PODE encontrar NAS oficinas MECANICAS de altomóveis, geralmente ELE trocão dos Carros quando estao estralando, MAIS Caso não fazer simulador ISSO
    Last edited: Nov 1, 2014
  14. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Desenho de Base da Capital de hum simulado

    Attached Files:

    Last edited: Nov 1, 2014
  15. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,648Coins
    Ratings:
    +1,009 / 9 / -1
    • Like Like x 2
  16. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
  17. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,648Coins
    Ratings:
    +1,009 / 9 / -1
    It can be used for 1, 2, or 3 motors. You will need a H-Bride for as many motors that you use.
  18. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    como eu não sei de eletrónica você poderia completar meu desenho de ligação ? eu tenho 2 H IBT-2 como no desenho descrito em cima ficarei muito agradecido !! desculpe por estar fazendo tantos pedidos !
    :blush
  19. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Code:
    /*
    Opensource code for xsimulator by Jean David SEDRUE
    Version betatest26 - 24042012
    test21 with Tacho
    test22 less tache to continue biMotor test
    */
    #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[i], OUTPUT);
    pinMode(inBpin[i], OUTPUT);
    pinMode(pwmpin[i], OUTPUT);
    }
    // Initialize braked for motor
    for (int i=0; i<2; i++)
    {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], 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[i]>47 && x[i]<58 ){//for xA to xF
    x[i]=x[i]-48;
    }
    if ( x[i]>64 && x[i]<71 ){//for x0 to x9
    x[i]=x[i]-55;
    }
    }
    result=(x[1]*16+x[2]);
    return result;
    } 
  20. Claudemir

    Claudemir Member Gold Contributor

    Joined:
    Oct 22, 2012
    Messages:
    168
    Balance:
    49Coins
    Ratings:
    +33 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    com este código consigo fazer o esquema elétrico ? e funciona para meu simulador ?