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. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    748Coins
    Ratings:
    +186 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    what are 'default' correct values for a monster moto and zty-90 motors?
    I now have the Ki set to 400 but it seems it can't hold the position? Would it help if I put this Ki to a higher level?!
    • Like Like x 1
  2. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    Usually the Ki variable has a set maximum limit in code so that may need to be increased. Changing the Ki constant alone probably wont help because the error should still accumulate until its large enough to move the motors (unless it hits its max limit first). A smaller setting would just take longer for it to accumulate. I don’t have a clue myself as to what typical pid values are for a monster moto though.
    • Like Like x 1
  3. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    The above assumes that you have enough power output from your motors to do the job of course!
    • Like Like x 1
  4. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    From my testing I have concluded the I term has relatively little benefit in motion sims because of the constant and rapid changes. The I term is really geared toward getting the "steady state" error to be zero. In our motion sims they are rarely in steady state (there is usually always some movement even if very small). So as long as the P term is large enough I term can usually be kept low. Having too high an I term will create instability in PID loops and result in oscillation.

    The P term has most influence in motion sims with the D term used to help reduce overshoot. Too high a D term can cause "slowness" in response though.

    PID tuning is actually a very complex exercise to do correctly in a precision feedback process loop. Luckily our sims don't need to be super precise.

    My suggestion is to get the motion working as best you can with the P term and leave I and D terms at zero. When you are happy with that then start introducing some D and I to fine tune and get the results you want.

    Note: if the Green and Blue lines in Windows SMC3 Utils are tracking each other well then you don't really need to do any further tuning because the motor position is tracking the target position.
    • Like Like x 1
  5. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    748Coins
    Ratings:
    +186 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    I will try some values tomorrow.. As long as I leave the rods of all seems to be tracking ok.. but with out a person on the balance point the rig is too heavy to hold on one side?! It sounds weird but one motor can hold all but the other is 'lacking' power and moves down under load, this while the other motor can hold the complete rig on it's own.. . So I have to figure out what the problem is between these 2 ..
    • Like Like x 1
  6. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    I agree completely with RufusDufus's assessment! :thumbs

    The stated problem I was answering however was that the motor would not hold its position; thus, a steady state error. P and D only will not correct that. Increasing P will get it slightly closer, but will also increase overall speed during normal use (if there is more to give). The counter effect to this is a decrease in the resolution of that axis since it will reach its maximum position faster. At near steady state D does little to nothing. I is the only perimeter that adds errors together as they accumulate and puts them back into the loop until they correct the steady sate error. But RufusDufus is saying that our rigs are moving so much most of the time that I doesn’t have time to accumulate before the position changes so it isn't needed most of the time. And if you increase I too much you will add instability into the system at some point.

    But if one motor runs a little slower than the other, a larger P on the slower motor will increase its speed (aka power) to help keep it synced with the other. I would recommend setting P to where you like it on the slower motor first. Then lower P below that on the faster motor until it slows down to the first one. Doing it in reverse of this will not give enough power to the slower motor when the faster one is at is fastest speeds. It must be limited to the fastest speed of the slower motor. Then you can work on D and I if necessary. Without I both your motors will always have a steady state error though. But if the error is equal in both motors, you’re rig will probably be level and it is doubtful that you will even notice a steady state error present.

    Edit: Sorry @RufusDufus that I referred to you as RacingMat at first. Brain Fart! Error corrected!
    • Like Like x 1
    Last edited: Apr 19, 2014
  7. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    That's funny... No problems this end :thumbs Maybe it is RacingMat that is more offended? :grin

    @Michael Hensen What is your current PWMmax and PWMmin settings. I think you had a PWMmax of 120 before which is quite low. The PWMmax sets the maximum duty cycle that the H-Bride drives. The maximum value is 255 so your Duty cycle is 120/255 = approx 47% duty cycle max drive. Increasing this of course means the H-Bridge may have to work harder and might shut itself down as you experienced earlier.

    You could also try increasing the PWMmin value which is the minimum duty cycle (calculated as above) that will be used which may provide some better holding force.
  8. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    @RufusDufus please could you confirm using the 50A h-bridge from here should conform with AMC3? The specs seem to be conform but I want to be sure. This bridge is cheap and worth a try.

    Or as an alternative why not using two moto monster? The current will be divided if each motor gets his own bridge...at dx.com a bridge is only 25$.

    Thank you :)
    • Like Like x 1
    Last edited: Apr 19, 2014
  9. dualin

    dualin Member

    Joined:
    Jul 11, 2012
    Messages:
    31
    Location:
    Cáceres - Spain
    Balance:
    - 41Coins
    Ratings:
    +4 / 2 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi, I'm felling very stupid, that line I've changed it a few days ago, but the motors didn't move and I thought that wasn't the line. Now I've seen that the PWM max was 0. I've changed to 255 and all works fine.

    Thanks and sorry

    Enviado desde mi iPad con Tapatalk HD
    • Like Like x 1
  10. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    Good to hear. :thumbs
    • Like Like x 1
  11. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    It's a bit hard to be sure as I couldn't see a schematic for it.

    My guess is you could get it working in drive/coast mode by doing the following:

    Set SMC3 to MODE1
    Connect the PWM out from the Arduino to the EN pin on the H-Bridge
    Connect ENA from Arduino to the RPWM pin on the H-Bridge
    Connect ENB from Arduino to the LPWM pin on the H-Bridge

    Sounds a bit backward but should work (but as I said can't guarantee without circuit) It won't provide any braking just drive and coast but I have used that before and it was OK but it you need strong stopping power or holding force may not be as good.
    • Like Like x 1
  12. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    @RufusDufus thank you very much. Coming back to my issue I would provide you with more information:

    SOmetimes the winches stops, but waking up after 2 or 3 seconds.
    Sometimes they wont waking up and will wake up only if I (re)start the SMC3 utility.
    The issue is more if the Kp is 200 and more (PWMmax between 150 and 200)

    As I can say the moto monster does not like very fast returns. If the turns and moves are very smooth the winches are not stopping. The moto monster is bought at dx.com and not Genuine.

    To exclude any overheating reasons I will control the heat sink, perhaps it is not really flat mounted.
    Overheating should not be a real problem because the heat sink is not really hot ("lukewarm").
    • Like Like x 1
  13. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    PS: if (finally) there is no solution using arduino and a strong h-bridge I will be forced to switch to the jrks :-/ It is not a question about the costs, IMO your solution is a very custom solution and has to be supported in future.

    PS:!! I measured the current (Kp 300 and PWMmax 180). I got up to 25 A ONE winches only! Of course this is too much...
    • Like Like x 1
    Last edited: Apr 20, 2014
  14. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    As described above your code can run using a BTS7960B h-Bridge 43A. I found a dealer which sells a bridge "Double BTS7960 large current (68 A)". This type of h-bridge has been tested here and I will give it a try.

    http://www.ebay.ch/itm/Double-BTS79...112?pt=LH_DefaultDomain_0&hash=item27cb805a48

    PS: attached the 43A datasheet...

    Attached Files:

    • Like Like x 1
    Last edited: Apr 22, 2014
  15. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    Hi @Pit, Those are the H-Bridges I use... They work great as long as you don't load them too much or they go into shutdown mode and you have to cycle the power. I am lucky my sim doesn't put much load on the motors so not really a problem for me.

    I suspect given what you are experiencing with the Moto Monsters, the IBT-2 H-Bridges will have similar problems.

    Unless you can change your sim design a bit to reduce the load on the motors I suspect the cheapest "long term" solution would be to get a H-Bridge that has been proven to deliver under heavy load such as the JRK. If you want to stick with the Arduino maybe look for a H-Bridge that uses the same driver chips as the JRK.
    • Like Like x 1
  16. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    • Like Like x 1
  17. 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
    Pit, those are the same drivers. They are misrepresented as 68Amp (the max on each h-bridge is 33a but only for a fraction of a second).
    • Like Like x 1
  18. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    As @Historiker points out the one in the link uses the BTS7960B drivers which are the 43A ones. Could be just the poor Chinese documentation.

    I actually have some 68A ones, they use the newer BTS7970B drivers. Note however the difference that I can see from the data sheet is that they have raised the current limit, I don't think the devices themselves can handle greater current, they just won't shutdown as quick with short (<10ms) current spikes. Under heavy load you are likely to see very similar performance.

    So if you want the 68A ones make sure they have the BTS7970B driver chips.

    I haven't done enough testing myself to know if they perform any better. I have the 68A one on my traction loss but it doesn't get much use because as far as I know Dirt 3 is the only plugin with traction loss and I don't play that game much.
    • Like Like x 1
    • Informative Informative x 1
  19. 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
    Hey Rufus, I have been using sway for traction loss in the other games. It does help with the immersion; for example get "bumped" by another car and you can feel the sideforce in the rear. Works pretty well.

    Have you tried Yaw as traction loss?

    Sorry to sidetrack your thread.
    • Like Like x 1
  20. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,638Coins
    Ratings:
    +1,009 / 8 / -1
    I've only had a real "quick" look so far so don't rush out without some of your own investigation but...

    These Pololu H-bridges appear to have the same drivers as the popular JRK12v12. They are a dual motor H-Bridge but don't have an integrated PID controller so would suit an Arduino setup - and they are made by Pololu.

    I guess everyone should remember the reason the JRK12v12 are the price they are is because all the development and testing has been done for you, just drop them in and they work. If you're like me and enjoy the experimenting and can afford the risk of damaging the odd H-Bridge then Arduinos are a great option, just remember if you have to replace your H-Bridge a couple of times you may end up paying the same as a JRK12v12 anyway.

    As I said for me it's more about the fun and enjoyment I get out of experimenting so I am happy to help where I can but can't guarantee results.
    • Like Like x 1
    • Informative Informative x 1