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

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,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,464
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,620Coins
    Ratings:
    +10,741 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  3. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,916Coins
    Ratings:
    +1,285 / 10 / -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 ?
  4. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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
  5. OZHEAT

    OZHEAT Active Member

    Joined:
    Oct 26, 2015
    Messages:
    208
    Location:
    Australia
    Balance:
    2,458Coins
    Ratings:
    +105 / 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?
  6. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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.
  7. bruce stephen

    bruce stephen Hammer doesnt fix it, must be electrical

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

    bruce stephen Hammer doesnt fix it, must be electrical

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

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,410Coins
    Ratings:
    +3,088 / 31 / -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
  10. hooshang

    hooshang Active Member

    Joined:
    Jul 6, 2011
    Messages:
    272
    Balance:
    289Coins
    Ratings:
    +157 / 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
  11. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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
  12. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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.
  13. hooshang

    hooshang Active Member

    Joined:
    Jul 6, 2011
    Messages:
    272
    Balance:
    289Coins
    Ratings:
    +157 / 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
  14. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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
  15. Bo Howell

    Bo Howell Member Gold Contributor

    Joined:
    Mar 4, 2020
    Messages:
    33
    Occupation:
    Product Specialist
    Location:
    New Sharon, Iowa
    Balance:
    119Coins
    Ratings:
    +24 / 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
  16. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,886
    Location:
    London
    Balance:
    11,543Coins
    Ratings:
    +453 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    it looks like TimesUp is declared twice

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

    Bo Howell Member Gold Contributor

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

    MarcoMade Active Member

    Joined:
    Jan 3, 2018
    Messages:
    150
    Occupation:
    Tecnico pc hardware/software MadeFix
    Location:
    italy
    Balance:
    157Coins
    Ratings:
    +62 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    nice found !! I try it as soon as possible !!
  19. Bo Howell

    Bo Howell Member Gold Contributor

    Joined:
    Mar 4, 2020
    Messages:
    33
    Occupation:
    Product Specialist
    Location:
    New Sharon, Iowa
    Balance:
    119Coins
    Ratings:
    +24 / 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.
  20. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -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.