1. 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 Download Package Now!
  2. 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
  3. 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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

Arduino code for G seat H bridge?

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by Trigen, Jan 6, 2019.

  1. Trigen

    Trigen New Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    24
    Balance:
    205Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF
  2. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,731
    Location:
    Oklahoma City, USA
    Balance:
    12,629Coins
    Ratings:
    +1,505 / 30 / -1
    I don't know if there is one anywhere on this forum for that driver. This one doesn't work the way your motor driver states to use it but it still may work with it in mode 2 https://www.xsimulator.net/communit...3dof-motor-driver-and-windows-utilities.4957/.
    • Agree Agree x 1
    Last edited: Jan 12, 2019
  3. Trigen

    Trigen New Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    24
    Balance:
    205Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF
    Thanks this worked better. Mode 2. Im only able to get it to run one way though and im sure the connections are correct. If i use the tool and go a square it should alternate right? Also the same in Game engine Axis tester
  4. Trigen

    Trigen New Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    24
    Balance:
    205Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF
    This script works fine and it runs both ways

    Code:
    const int pwm = 2 ;  //initializing pin 2 as pwm // EN pin
    const int in_1 = 3 ; // RPWM
    const int in_2 = 5 ; // LPWM
    
    /*const int pwm = 2 ;  //initializing pin 2 as pwm
    const int in_1 = 3 ;
    const int in_2 = 5 ;
    */
    //For providing logic to L298 IC to choose the direction of the DC motor 
    
    void setup()
    {
    pinMode(pwm,OUTPUT) ;   //we have to set PWM pin as output
    pinMode(in_1,OUTPUT) ;  //Logic pins are also set as output
    pinMode(in_2,OUTPUT) ;
    }
    
    void loop()
    {
    //For Clock wise motion , in_1 = High , in_2 = Low
    
    digitalWrite(in_1,HIGH) ;
    digitalWrite(in_2, LOW) ;
    analogWrite(pwm,255) ;
    
    /*setting pwm of the motor to 255
    we can change the speed of rotaion
    by chaning pwm input but we are only
    using arduino so we are using higest
    value to driver the motor  */
    
    //Clockwise for 3 secs
    delay(3000) ;     
    
    //For brake
    digitalWrite(in_1,HIGH) ;
    digitalWrite(in_2,HIGH) ;
    delay(1000) ;
    
    //For Anti Clock-wise motion - IN_1 = LOW , IN_2 = HIGH
    digitalWrite(in_1,LOW) ;
    digitalWrite(in_2,HIGH) ;
    analogWrite(pwm,255) ;
    delay(3000) ;
    
    //For brake
    digitalWrite(in_1,HIGH) ;
    digitalWrite(in_2,HIGH) ;
    delay(1000) ;
    }
    
  5. Trigen

    Trigen New Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    24
    Balance:
    205Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF
    Turned out to be a bad bridge and a dead one.