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

Tutorial Arduino code for 4DOF and 1 DIRpin Hbridge board

Discussion in 'DIY Motion Simulator Projects' started by RacingMat, Aug 7, 2013.

  1. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,775 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    @RacingMat's code is available for download here: http://www.xsimulator.net/community/marketplace/arduino-code-4dof-and-1-pin-direction-hbridge.68/
    • Like Like x 2
  2. AlexinChina

    AlexinChina Member

    Joined:
    Sep 2, 2015
    Messages:
    71
    Location:
    China
    Balance:
    371Coins
    Ratings:
    +8 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
  3. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Yes, this code is working for 4DOF :)
    Just check your HBridge has only 1 pin direction
    • Like Like x 1
    • Informative Informative x 1
  4. luky_90

    luky_90 Member

    Joined:
    Mar 3, 2016
    Messages:
    106
    Location:
    Italy
    Balance:
    276Coins
    Ratings:
    +16 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I'm continuing with work and I wanted to understand one thing , I am using the code 4dof racing mat with 2 monster motor, reading the features of the card read :
    ● Voltage Max : 16V
    ● Maximum current rating : 30A
    ● Practical Continuous Current : 14 A
    ● Current available to Arduino analog pin sensing
    ● on-resistance MOSFET : 19 M: ( per leg )
    ● Maximum PWM frequency: 20 kHz
    ● Thermal Shutdown
    ● Undervoltage and Overvoltage shutdown
    If I have a 12v engine that develops continuous current 14A , the motorcycle monster card can attack only one right engine ?
  5. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
  6. zylle

    zylle New Member

    Joined:
    Oct 15, 2016
    Messages:
    21
    Location:
    Denmark
    Balance:
    124Coins
    Ratings:
    +11 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I can second your experience with that cheap h-bridge, it lasted me 5 minutes of low-amp- playing around before it sparked and began to smoke! :D

    2x pololu h bridges are now ordered and on their way :)
    IMG_20161025_200247.jpg IMG_20161025_200258.jpg

    Your code works flawlessy with 2 motors btw, its awesome, thanks a lot!
    • Informative Informative x 2
  7. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Bad news... Hopefully your arduino has not been destroyed like mine did when these Hbridge blew up.

    Thanks for your feedback :)
    • Like Like x 1
  8. hartsa90

    hartsa90 Member

    Joined:
    Sep 12, 2016
    Messages:
    30
    Location:
    Finland
    Balance:
    110Coins
    Ratings:
    +13 / 0 / -0
    Hi Mat,

    Could you tell me the Arduino Uno pin outs for DIR3, PWM3 and pot3.
    I am using three Pololu 24v 21 drivers. https://www.pololu.com/product/2995
    It could be already stated on your posts... Just can't find it sorry.
  9. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    your driver is One pin direction and One pin PWM
    so it's compatible with the code

    Code:
    #define potL A5
    #define potR A4
    #define potY A3
    //#define potW A2  // no PID needed for Wind -> no Pot on a wind motor
    
    int DIRpin[4] = {
      2, 3, 4, 5};  // if HIGH/LOW then motor runs Forward/Reverse (depending on wiring)
    int PWMpin[4] = {
      6, 9, 10, 11}; // PWM vary between 1 (slow speed) and 255 (fast speed)
    DIR3 -> 4
    PWM3 -> 10
    and pot3 -> A2
    • Informative Informative x 1
  10. hartsa90

    hartsa90 Member

    Joined:
    Sep 12, 2016
    Messages:
    30
    Location:
    Finland
    Balance:
    110Coins
    Ratings:
    +13 / 0 / -0
    Thanks Mat!
  11. Mamati

    Mamati Member

    Joined:
    Jan 12, 2011
    Messages:
    52
    Location:
    Istanbul/Turkey
    Balance:
    158Coins
    Ratings:
    +6 / 1 / -0
    Hello Mat,
    Thank you for this great work. Yesterday I tried your code with the configuration and set-up below. I want to ask you what must be the wires for 4th motor? I tried on A2 to Dir 5 and Pwm 11 but it didn't work. What could be the wrong thing?

    Arduino Uno => Pololu #758 (18V25)
    Pin A5 => DIR pin 2 , PWM pin 6 Ok, It works
    Pin A4 => DIR pin 3 , PWM pin 9 Ok, It works
    Pin A3 => DIR pin 4 , PWM pin 10 Ok, It works
    Pin A2 => DIR pin 5 , PWM pin 11 Unfortunately It didn't works

    You mentioned that to use 4 motors Simtools set-up:
    R7FL7FY7FW7F
    R<Axis1>L<Axis2>Y<Axis3>W<Axis4>
    R7FL7FY7FW7F

    Thanks
    Burak
  12. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    What is your fourth motor?
    If you need to read its potentiometer, uncomment the line (= remove // at the beginning)

    #define potY A3
    //#define potW A2
  13. Mamati

    Mamati Member

    Joined:
    Jan 12, 2011
    Messages:
    52
    Location:
    Istanbul/Turkey
    Balance:
    158Coins
    Ratings:
    +6 / 1 / -0
    Thank you for fast reply, I will try it on Monday.
    I am using 1 Arduino, 4 Pololu 758, 4 motor, 4 pot.
  14. panfilo

    panfilo New Member

    Joined:
    Nov 20, 2016
    Messages:
    1
    Location:
    Australia
    Balance:
    - 9Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino, Motion platform
    I think this is awesome I have ordered some motomonster cards for $25.15eaAUD and will give your code a try keep up the great work.
    • Like Like x 1
  15. Mamati

    Mamati Member

    Joined:
    Jan 12, 2011
    Messages:
    52
    Location:
    Istanbul/Turkey
    Balance:
    158Coins
    Ratings:
    +6 / 1 / -0
    Hi,
    my wind simulator fan didn't work, no output but the other Dofs are working.
    What could be the problem? please help.

    My interface settings are:
    R7FL7FY7FW0
    R<Axis1>L<Axis2>Y<Axis3>W<Axis4>
    R7FL7FY7FW0

    On Arduino Uno
    5-11 and GND are wired to Pololu DIR-PWM-GND

    On Simtools Axis assignment, the 4th Dof is set to %100 Surge

    Thanks
  16. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Can you please post some setup screenshots and photo of your boards?
  17. liuyidao

    liuyidao New Member

    Joined:
    Mar 23, 2017
    Messages:
    5
    Location:
    china hubei wuhan
    Balance:
    171Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    Thank you, very helpful
    But I might want to consider using 2 cheap motors to try
  18. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,775 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    @Everh please stop spamming posts, @Pit can you please clean this thread up when you have time.
  19. lemaitre

    lemaitre Member

    Joined:
    Jan 10, 2015
    Messages:
    62
    Balance:
    - 112Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, Motion platform
    merci racingmat pour ton travail et ton partage
    j »i un simu 2dof avec ton code que je viens de refaire complètement en 3dof
    mécaniquement, je n'ai aucun problème, mais programmation je suis pas top du tout
    j »i un arduino et 2 monstershield et le progamme qui est dans ta signature est pour une direction alors que les monster on besoin de 2
    comment modifier ton premier programme 2dof en 3dof?
  20. lemaitre

    lemaitre Member

    Joined:
    Jan 10, 2015
    Messages:
    62
    Balance:
    - 112Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, Motion platform
    j ai fait une erreur , ça ne marche pas car les monter shield sont prévu pour 16 volt max et pas 24 volt, donc mon problème est résolut , faut des sabertooth 2x32