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 SMC3 Arduino 3DOF Motor Driver and Windows Utilities

Discussion in 'SimTools compatible interfaces' started by RufusDufus, Dec 1, 2013.

  1. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    hello :) Thankyou all so I believe the vendor sold some BTS7970B drivers because he offers the 7960 too. At the moment the costs are not the only argument I want them to try out, I like the Arduino due to its different and many options. Nevertheless I believe sooner or later the jrks will land into my rig.
    • Like Like x 1
  2. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    Hey, yes I tried yaw and sway for traction loss... wasn't really what I'm after but as you say gives some feedback. No where near as good as the traction loss value1 has developed in Dirt3.

    It's a good prompt though to ask @value1 if he could add traction loss to iRacing when he can next spare some of his valuable time. :grin
    • Like Like x 2
    • Agree Agree x 2
  3. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    Good to hear you haven't been put off. As long as you're happy experimenting, we can continue to work on a solution.

    I have just realised the monster moto boards also use the same drivers as the JRK12v12's. I wonder if you need to increase the Kd term a bit to help stop them shutting down.

    Also I am assuming the motors aren't driving into the "limit zone" set in the SMC3. If it does the SMC3 software will shut down the motors to avoid damage to the rig.
    • Like Like x 1
  4. 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,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Correct they have the same driver as the Jrks hence I do recommend them for sim use, have tested it with prilads code and yes Kd is important to using the driver properly or it will overshoot and you will be forced to run a lower Kp than it can handle. Heat sinks and fan plus is the input amps strong enough these unit can draw 30amps each so the card can physically draw 60amps if both motors change direction fast. Why in a simular setup I use the combined DC battery and psu to provide the need apps, but this normally doesn't stop the driver, they have built in overheat protection and reverse voltage protection, and overvoltage protection.

    You have probably been asked this already, are the grounds isolated from motor. As this can trip out the card too. Ie if grounds are not and motor reverses it sends 12v through the body of the motor and if pot is connected like direct or lever it will send the 12v's through the ground of the pot to the Ard which has its ground connected to the driver. Resulting in Ard locking up or burning out or the card shutting itself down.

    The only other real issue it can have is back current, when the motor freewheels it produces voltage and drives that back to the card, the drivers then send that back to the psu connections, and if psu is not protected internally will cause it to fail or shutdown, inturn if this power can not escape the chip dissipated this with heat, this too can cause the driver to overheat quickly and shutdown too.

    Sorry not a real answer, don't feel its the code or the ard.
    Don't give up on the Ard its potential is good just not simple.
    • Like Like x 1
    • Useful Useful x 1
  5. james wheeler

    james wheeler Active Member

    Joined:
    Mar 17, 2014
    Messages:
    185
    Balance:
    216Coins
    Ratings:
    +48 / 1 / -0
    My Motion Simulator:
    2DOF, Arduino
    2 questions
    1 I am just starting to learn about ard. So How exactly do I edit the code at the top to pick mode 1? Do i add something in some where or take something out?

    2 I am using a pololu vnh5012 which has A0 &A1 as current sence will this cause a conflict? Is it easy to change the code to put the pots into A5 & A4?
    • Like Like x 1
  6. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    You edit the code in the Arduino IDE... When you open the sketch it should be displayed in the IDE's text editor.

    Simply look for the line at the top that says #define MODE1 and make sure it is MODE1 and not MODE2 (edit it as necessary then save and upload to the arduino).

    Yes it is possible to change the code to use alternate pins... what you need to keep in mind if doing this is you are essentially creating your own customised version that you will have to manually maintain from then on. ie if any new releases are made or bugfixes added, you will have to manually go through the code to find differences and add them to your version - or add your modifications to the new version of code. (I have actually used A5 for another function in a new version I am testing at the moment, so that of course would create more work for you if you choose to use it when released.) Also, it may make it difficult for us to help fault find issues if you have any when the code has been changed.

    So as long as you don't mind doing that there is no problem.

    The lines that need changing are:
    const int FeedbackPin1 = A0; // Motor 1 feedback pin
    const int FeedbackPin2 = A1; // Motor 2 feedback pin
    const int FeedbackPin3 = A2; // Motor 3 feedback pin

    Set as required.
    • Like Like x 1
    • Informative Informative x 1
  7. james wheeler

    james wheeler Active Member

    Joined:
    Mar 17, 2014
    Messages:
    185
    Balance:
    216Coins
    Ratings:
    +48 / 1 / -0
    My Motion Simulator:
    2DOF, Arduino
    thank you that was very helpfull and discriptive. i will look in to mabey changing the board config instead of the code so i can stay part of the updates
    • Like Like x 1
    • Agree Agree x 1
  8. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    You don't actually need to connect the vnh5012 current sense outputs to the Arduino, they are not used. Just leave them unconnected and connect your pots direct to the Arduino A0,A1 pins.
    • Like Like x 1
    • Agree Agree x 1
  9. james wheeler

    james wheeler Active Member

    Joined:
    Mar 17, 2014
    Messages:
    185
    Balance:
    216Coins
    Ratings:
    +48 / 1 / -0
    My Motion Simulator:
    2DOF, Arduino
    sry i miss typed. I am using vnh5019. but what you are saying is that even though the vnh5019 has A0 and A1 default set to current sence I can still connect the pots to them and they would still fuction correctly?
    • Like Like x 1
  10. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,975Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @james wheeler :
    No.
    The fact is that the current sense pins can be used to monitor the motor's current consumption. As we don't use these feature in our simulators, these is no need to wire them...
    ;-)
    • Like Like x 1
    Last edited: Apr 24, 2014
  11. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Which value do you recommend? Or up to which value I can go w/o damaging the bridge? Yesterday I tried out a value of 50 and I mean (feel, believe... ;) ) the stops are less then before...
    • Like Like x 1
  12. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    As RacingMat says, our current versions of Arduino code don't use the current sense outputs from the H-Bridge.

    So as long as you don't connect any wires between these H-Bridge pins and the Arduino, you are free to use the Arduino A0 and A1 as feedback pot inputs. This is one of the reasons we have suggested not plugging the H-Bridge as a piggyback shield onto the Arduino - it makes it harder to isolate these pins for use by the feedback pots.
    • Like Like x 1
  13. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    Increasing Kd will have the effect of stopping/reducing the motor from overshooting its target. It does this by slowing the motor movement. I would expect you could continue to increase the value to anything within the range the Windows SMC3 Utils allows. You will get to a point though that it slows the motion too much, so the best thing is to just try different values.

    Also see if you can find out what the max PWM frequency your H-Bridge can handle and set that correctly (Fpwm). It shouldn't break anything but will perform better if within spec.
    • Like Like x 1
    • Informative Informative x 1
    • Useful Useful x 1
  14. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    I think I got it!!! It is the Ki term. What I can say the winches needs very much load after a stop to the next move. This type of winches do not need a Ki term they do not move if there is no power. So the very first load (current) could be too high for the bridge. If I raise the Ki value up to 10, the Kp term can be reduced, because the winches are now more direct and have a better reaction. Using a Kp of 180 the winches blow me and my seat ;), finally a value of 130 is perfect (while PWMmax is 190). No stops for now I hope it will not burn my bridge at least...
    • Winner Winner x 1
    Last edited: Apr 24, 2014
  15. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    @Pit, great to hear... I spent months before I was happy with the motor tuning. That was one of the reasons I wrote the software to try and see what was going on.

    Have fun! :cheers
    • Like Like x 4
  16. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    @RufusDufus thank you very much for your efforts :) Your software is great and easy to use. Only one option I missed while experimenting the different values: a hard reset button :p
    • Like Like x 2
  17. dahfl

    dahfl New Member

    Joined:
    Feb 21, 2014
    Messages:
    29
    Occupation:
    Administrator
    Location:
    Mülheim Ruhr
    Balance:
    485Coins
    Ratings:
    +37 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    Hi,
    is that right for 3DOF ?

    SMC3_3DOF.jpg
    regards Andreas ?
    • Like Like x 2
    • Informative Informative x 2
    Last edited: May 3, 2014
  18. terry wells

    terry wells Active Member

    Joined:
    Jan 19, 2014
    Messages:
    250
    Occupation:
    retired military
    Location:
    minnesota USA
    Balance:
    716Coins
    Ratings:
    +59 / 1 / -0
    My Motion Simulator:
    3DOF, Arduino
    hey Andreas, Thanks for your wiring diagram. This is what I want to do.
    Terry W.
    • Like Like x 1
  19. dahfl

    dahfl New Member

    Joined:
    Feb 21, 2014
    Messages:
    29
    Occupation:
    Administrator
    Location:
    Mülheim Ruhr
    Balance:
    485Coins
    Ratings:
    +37 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    fine, then i can test it now.
    • Like Like x 1
  20. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    Hi dahfl, Unless you have some non-standard POTs your wiring to those is incorrect.

    The center pin is typically the adjustable wiper output and should have your coloured wire connected to it. The two outside pins have the +5V and GND connected.
    • Like Like x 1