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. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    I did figure out why there was so much force involved; I had the game manager settings at 100% rather than 20% :D
  2. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    Mat, I have a question for you on your code.

    Background to my question:

    I connected my winch motors to the Arduino/Pololu755 rig. I am using standard 270degree pots which means that the winch lever will only rotate 5-10 degrees because of the gearing involved. The motor itself moves the full range but the gearing reduces this by the time the movement reaches the lever arm.

    Question: Is there a way to increase the range sent to the motors in your arduino sketch? Something that would allow a 1/4 turn of the pot to equal a full rotation of the motor? Or some such?

    Thanks

    David
  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
    hello eaorobbie !

    Yes, good idea ! ;D
    There could be 3 paramaters to play on :
    - the pwmMax (max speed limitation)
    - the acceleration (in the PID part of the code)
    - the range of movment (max angulation)

    For each paramter, a pot could be wired to the Arduino in order to have live modification.

    I can update the code this way :
    - first, being able to modify easily the parameters in the code (like PwmMax) but it requires to re-upload the program after every change
    - second, enable pots reading

    Mat
  4. 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
    hello David,

    yes, I can do this :yes:

    I'll insert a multiplier parameter (kind of gear ratio between motor and pot).
    Give me some hours and check tonight !

    I'll have to write the process for your tuning and translate this explanation :
    20130430113511-RacingMat-schy-ma-consigne-jeu-xsim-arduino-moteur-cockpit-v3.jpg

    Mat
    • Like Like x 2
  5. aarondc

    aarondc Member

    Joined:
    Jun 12, 2013
    Messages:
    133
    Location:
    Melbourne, Australia
    Balance:
    187Coins
    Ratings:
    +7 / 0 / -0
    Je ne parlez pas Francais, mais votre mind c'est beaucoup bel.

    White board FTW. Very well explained.
  6. 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
    @aarondc : thanks :cheers: your french is terrific ! champagne!

    @historiker : i've updated the code in first post.

    The process is the following : please, don't be too impatient ;D

    1- upload the new code

    2- calibrating the pot boundaries in the Arduino
    const int potMiniRorL=300;
    const int potMaxiRorL=700;

    these values are convenient as they will always constrain the values whatever comes from the simulator software,
    so the arduino will never send over-range value to the motors :) and your hardware will be protected !

    Now without any game running ! send orders from Arduino serial monitor :

    type the following strings in Hexa and press Enter:
    R7FL7F
    -> it should move the playseat in horizontal position

    increase the angulation
    R64L64
    go farther cautiously
    R3FL3F
    if the playseat moves too little, then the potMini and PotMaxi are too close to middle position
    and maybe go to max now : max backward tilt -> R01L01

    - if it's too litlle check how much you can go further and decrease potMiniRorL, reupload and resend R01L01
    and so on, until you found the pot minimal position

    - do the same for potMaxiRorL, send RFFLFF and increase potMaxiRorL, reupload and resend RFFLFF

    (write somewhere else these values that are associated to your particular playseat hardware).

    3- find your pot amplifying ratio
    - increase now the gearMotorRorLPotRatio (line 17)
    - by default, it's equal to 1
    - if you increase to 1,5 : the range will be increased by 50 %

    no worries, if the amplifying ratio is too high :
    - the playseat will not bump over the limits
    - but the mouvments will be fast or jittering

    Good tries !
    Mat
  7. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    Mat, I will give these a try! You, along with many others here, are a forum Superhero!

    David
  8. trust928

    trust928 Member

    Joined:
    Sep 19, 2013
    Messages:
    152
    Location:
    brazil
    Balance:
    435Coins
    Ratings:
    +7 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    i will try this code tomorrow I'm just confuse with some things
    ..like were goes the pots wires and the h-bridge wires in arduino..the correct ports..the images doesn't show very clear
    i read all the code but I'm not actually sure.. can some one help
  9. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    The potentiometer wiper wires to to the Arduino ports A4 and A5 (if you are only using two motors).

    The positive and negative potentiometer wires go to their respective ports on the Arduino.

    Dir (motor 1) is Pin 2 on the Arduino, Dir (motor 2) is Pin 3 on the Arduino.
    PWM (motor 1) is Pin 6 on the Arduino, PWM (motor 2) is Pin 9 on the Arduino.
  10. trust928

    trust928 Member

    Joined:
    Sep 19, 2013
    Messages:
    152
    Location:
    brazil
    Balance:
    435Coins
    Ratings:
    +7 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    thanks I've made an small draw to facility so it goes like this

    Attached Files:

  11. trust928

    trust928 Member

    Joined:
    Sep 19, 2013
    Messages:
    152
    Location:
    brazil
    Balance:
    435Coins
    Ratings:
    +7 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    now another question... it needs xsim software to work? i think so but just asking..
    and thats all just need to upload the code?..
  12. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    (Pssttt.....no X-Sim here....only SimTools) :)
  13. 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
    Hi Trust928!

    Nice to see your interest!

    Here is a wiring diagram http://gamoovernet.pixhotel.fr/pics_gamoovernet690px/20120703223559-lipide512-wiringdiagram.gif

    You can make your motors moving without any simulator software and without game:
    this is the first step I advise you to follow for your safety and hardware!
    start Arduino Serial Monitor and write manually orders to make the motors move...

    The Simulator software you need is Simtools developped by yobuddy and plugins developped by Value1
    As Simtools is not released yet, you have to ask for beta testing to RaceRay. Then you'll be granted to Simtools download page.
  14. trust928

    trust928 Member

    Joined:
    Sep 19, 2013
    Messages:
    152
    Location:
    brazil
    Balance:
    435Coins
    Ratings:
    +7 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    thanks racing mat I've asked them for the softwares and plugins now must wait them reply..
  15. korrea

    korrea New Member

    Joined:
    Dec 12, 2011
    Messages:
    22
    Balance:
    - 8Coins
    Ratings:
    +3 / 0 / -0
    Wooww! Your project is cool ;). I'll ask you about support your project in my software ;)

    Congratulations!
  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
    @korrea: Thanks for your compliments! :)
    You're welcome
  17. 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
    Some news: I've retested the chinese HBridge for a longer run...
    H..y shit! After few minutes (without load) one Hbridge started to smoke :eek: and kill my Arduino
    just like Historiker... and the Ard cannot be updated anymore : avrdude error 500

    This chineese Hbridges are too cheap! and finally cost more...

    PREFER POLOLU!

    PS : I can't update the first post: there are more than 13000 words...
    • Like Like x 1
  18. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,158 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    HA! I am not crazy or irresponsible!!! Er.....ok perhaps I am (according to my wife) but not in this case, lol :D

    I am actually sorry to hear that it is the H-bridge. I had hoped that they were actually good and I could use another one in my future builds.
  19. RaceRay

    RaceRay Administrator Staff Member SimAxe Beta Tester

    Joined:
    Nov 8, 2006
    Messages:
    4,656
    Occupation:
    Self-employed | Web and application development
    Location:
    Hamburg, Germany
    Balance:
    23,837Coins
    Ratings:
    +1,965 / 13 / -0
    My Motion Simulator:
    2DOF, DC motor, SimAxe, SimforceGT
    I changed it to 15.000 words. Who is buying cheap is buying twice...soory to hear:think
  20. prilad

    prilad Well-Known Member SimAxe Beta Tester SimTools Developer

    Joined:
    Apr 29, 2012
    Messages:
    380
    Location:
    Dubna, Russia
    Balance:
    9,614Coins
    Ratings:
    +512 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 4DOF
    I all time say, that I strongly recommend to use galvanic isolation...
    • Like Like x 1