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

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 Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    I got some memory issues that makes it very hard for me to remember and read code. i basically cant hold 2 things in my head at once

    Does anyone have a finished script i could borrow for Wiper motos and Arduino H bridge. An explenation of pot setup is also great

    im using this https://www.ebay.co.uk/itm/50A-Dual...e=STRK:MEBIDX:IT&_trksid=p2057872.m2749.l2649
  2. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,575Coins
    Ratings:
    +1,831 / 32 / -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 Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    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 Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    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 Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Turned out to be a bad bridge and a dead one.