1. 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!
  2. 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
  3. 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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.
  4. All new posts and threads should be written in English. Please do not create dual posts in other languages. If you are not a master of the English language you can use an external service to create a translation of your words, for instance, Google translate or DeepL.
    Due to low activity, we've also closed the french section.
    Dismiss Notice

SMC3 Arduino 3DOF Motor Driver with SoftStart

Discussion in 'SimTools compatible interfaces' started by BlazinH, Jan 4, 2017.

  1. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    Since I have seen many members ask for it, especially as of late, I have added a Soft Start Motor routine to RufusDufus's standard SMC3 sketch https://www.xsimulator.net/communit...3dof-motor-driver-and-windows-utilities.4957/.

    Its a simple routine that starts the motors out at 0 volts and then increases the voltage up to the set maximum (PWMmax) for each motor over time. Increasing SSloop will slow down the start and decreasing it will speed it up. SSloop can be found at the top of the sketch (I estimate SSloop = 30 to be about 2 seconds).
    //*****************************************************************************************
    //SET SOFTSTART SPEED
    const int SSloop = 30;
    //*****************************************************************************************

    NOTE: I don't use SMC3 for myself so I have not tested this since its not that easy for me to do so. So you will be beta testing this if you try it. :eek::D If it needs tweaking let me know and I'll see what I can do.

    Also, if you need a SMC3 sketch to drive a Sabertooth motor controller, you can download my SMC3-SPS sabertooth packet serial sketch here. I have added a Soft Start Motor routine to it also. https://www.xsimulator.net/communit...ket-serial-pid-motor-driver-w-softstart.9277/

    When I wrote smc3-sps I anticapated some people may have issues running Simtools at 500000 with the arduino. Therefore I included a jumper setting that allows for it to be changed between 500000 and 115200 without altering the sketch at all. Putting a jumper from gnd to pin 8 will switch the arduino from 500000 to 115200 and removing it will switch it back (requires an arduino reset or power cycle each time switched). If you want to get really fancy you can put a switch on the jumper so you can switch it without pulling the jumper wire.

    [​IMG]

    * Update 3/22/20: Fixed error in soft start code

    Attached Files:

    • Winner Winner x 8
    • Like Like x 6
    • Useful Useful x 1
    Last edited: Mar 22, 2020
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    14,695
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    108,645Coins
    Ratings:
    +8,882 / 43 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  4. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,195
    Location:
    Alexandria , Egypt
    Balance:
    7,635Coins
    Ratings:
    +1,270 / 9 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Yeh, that's a real start in this issue and I'm really happy with it ... :cheers
    But let me see if I'm missing something before testing ...
    The rig is in the parking positions => SimTools starts => the motors slowly moves to the center within 2 seconds ... that's really great ... we go play and the game ends .
    Then what ?
    How can I get a slow back ?
  5. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    To be honest the code I added was an easy fix to something that I don’t need for myself to make a soft startup possible for others to use if they want. So it doesn’t do it all. But it’s not something that can simply be reversed to reverse the process.
    Doing what you want would require adding a shutdown sequence to simtools which of course means you would need to add additional code to the sketch in order to process it in addition to the code to do the actual shutdown. Then you would need to add a startup sequence also and repeat the above process for it unless you would be satisfied with just turning the power off and on again every time you need to restart everything.
    • Like Like x 1
  6. OZHEAT

    OZHEAT Member

    Joined:
    Oct 26, 2015
    Messages:
    158
    Location:
    Australia
    Balance:
    1,902Coins
    Ratings:
    +83 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor
    @BlazinH
    Great work, good to see you step up to the plate.

    l was looking at the code and notice that there is a line in the command list.
    // [] Drive all motors to defined stop positions and hold there
    l can't find where that points to in the code, can you shed any light on this?

    l am no coding expert and was considering trying to adapt SMC3 in to a more real motor controller ie. monitor current &temp as well.
    That way you could connect pretty much any h-bridge to SMC3 and be able to limit like jrk and sabretooths can, thus help saving blowing bridges.
    l do have a few other ideas as well.
    Would you and/or @RufusDufus consider taking on the project?
  7. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    I really don't have time to take on more projects atm. And RufusDufus is more an expert on his sketch than I am. But I suggest instead of adapting the SMC3 sketch that you use a dedicated microcontroller instead. In this hobby the cost of one more Uno is peanuts. SMC3 is already working hard on PID control at 4000Hz so its pretty busy already. So instead of a SMC3 Sabertooth sketch driving a Sabertooth controller it could drive your smart h-bridge controller.
  8. bruce stephen

    bruce stephen Hammer doesnt fix it, must be electrical

    Joined:
    Jun 7, 2015
    Messages:
    1,293
    Occupation:
    general contractor
    Location:
    michigan
    Balance:
    9,014Coins
    Ratings:
    +1,225 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform, 6DOF
    hug:
    This is a nice addition ty.
  9. bruce stephen

    bruce stephen Hammer doesnt fix it, must be electrical

    Joined:
    Jun 7, 2015
    Messages:
    1,293
    Occupation:
    general contractor
    Location:
    michigan
    Balance:
    9,014Coins
    Ratings:
    +1,225 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform, 6DOF
    Last edited: Jan 8, 2017
  10. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,021
    Location:
    Switzerland
    Balance:
    29,702Coins
    Ratings:
    +3,032 / 30 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    I dunno why i missed this @BlazinH...?! Thank you a lot for this and as already mentioned many of us will be (more) happy than before - including me. When I'm back from holidays I will check this out immediately. Long time awaited and now available :) Thumbs up.
    • Useful Useful x 1
  11. hooshang

    hooshang Active Member Gold Contributor

    Joined:
    Jul 6, 2011
    Messages:
    250
    Balance:
    186Coins
    Ratings:
    +146 / 3 / -0
    My Motion Simulator:
    2DOF, DC motor, AC motor, Arduino, 6DOF
    thank you @BlazinH
    I just try your code (smc v1.7) instead the @RufusDufus SMC3 sketch,and let say I have
    2dof rig with heavy platform for my motors and gearboxes, so as the motors try to hold their position on the
    center point there is a little unwanted pendulum motion and as I just replace the code, when I turn off the simtools
    just after around 15 seconds, motors got calm and smooth at the center point!!!! what is the reason ?
    thank you guys
  12. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    Sounds like possibly a timing issue although no one else as stated such an issue. SMC3 is optimized for speed though and my soft start code adds few clock cycles to the overall loop speed of the sketch. Its maybe only 2 or 3 clock cycles at most but at 4000 loops a second it starts adding up. So find this line of code in the sketch and start increasing the process period by 50 uS at a time and test. Btw, try up to 1000 uS if needed.

    #define PROCESS_PERIOD_uS 250 // 244 -> 4096 per second approx

    :popcorn
    • Informative Informative x 1
    • Useful Useful x 1
    Last edited: Feb 25, 2017
  13. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    Btw, whats your Simtools output speed setting? If you're using 1ms you may need to try increasing that a little bit too to see if that helps.
  14. hooshang

    hooshang Active Member Gold Contributor

    Joined:
    Jul 6, 2011
    Messages:
    250
    Balance:
    186Coins
    Ratings:
    +146 / 3 / -0
    My Motion Simulator:
    2DOF, DC motor, AC motor, Arduino, 6DOF
    thank you so much @BlazinH
    first I think it has nothing to do with simtool couse I have always this problem even without starting simtools!
    and just when i shift to the SMC 1.7 softstart the platform got calm after around 15 second!! so let say iam not code expert
    ad I find the line you mention(#define PROCESS_PERIOD_uS 250 // 244 -> 4096 per second approx)but I donno which number should change?!?!?
    thank you again
  15. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    250 is the current setting so change that number. Btw, // means anything after that is just a remark.

    But maybe before doing that try setting SSloop = 1. Your motors should snap into place like the standard SMC3 sketch. If that fixes your issue you can then increase SSloop until the issue starts again and then back off that setting a little.
    • Like Like x 2
    • Informative Informative x 2
    • Useful Useful x 1
  16. Bo Howell

    Bo Howell New Member Gold Contributor

    Joined:
    Mar 4, 2020
    Messages:
    28
    Occupation:
    Product Specialist
    Location:
    New Sharon, Iowa
    Balance:
    167Coins
    Ratings:
    +22 / 0 / -0
    My Motion Simulator:
    6DOF
    Hello @BlazinH, I have tried uploading your SMC3 SoftStart changed sketch. I am getting the following error when it compiles and uploads. Any idea? I apologize I am not a programmer by any means. Thanks. 146DA313-F9A6-4775-97E7-6C3509106C4C.jpeg
  17. Gadget999

    Gadget999 Active Member

    Joined:
    Dec 27, 2015
    Messages:
    861
    Location:
    London
    Balance:
    6,327Coins
    Ratings:
    +190 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    it looks like TimesUp is declared twice

    remove that line and see if it compiles
  18. Bo Howell

    Bo Howell New Member Gold Contributor

    Joined:
    Mar 4, 2020
    Messages:
    28
    Occupation:
    Product Specialist
    Location:
    New Sharon, Iowa
    Balance:
    167Coins
    Ratings:
    +22 / 0 / -0
    My Motion Simulator:
    6DOF
    Thanks @Gadget999 I will try that today.
  19. MarcoMade

    MarcoMade Active Member

    Joined:
    Jan 3, 2018
    Messages:
    140
    Occupation:
    Tecnico pc hardware/software C/O PcCorner.it
    Location:
    italy
    Balance:
    65Coins
    Ratings:
    +52 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    nice found !! I try it as soon as possible !!
  20. Bo Howell

    Bo Howell New Member Gold Contributor

    Joined:
    Mar 4, 2020
    Messages:
    28
    Occupation:
    Product Specialist
    Location:
    New Sharon, Iowa
    Balance:
    167Coins
    Ratings:
    +22 / 0 / -0
    My Motion Simulator:
    6DOF
    I tried removing that line and it still wouldn’t compile. It says that TimesUp is missing now. Unless I deleted the wrong one? Thanks.
  21. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,112
    Location:
    Oklahoma City, USA
    Balance:
    15,498Coins
    Ratings:
    +1,789 / 31 / -1
    Does it say Uno in the lower right corner? If so download the sketch and try again. I just uploaded a new version that fixed a soft soft error but it still compiled fine for me before that.