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 Download Package Now!
  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.

Tutorial SMC3-SPS Sabertooth Packet Serial PID motor driver w/SoftStart

Discussion in 'SimTools compatible interfaces' started by BlazinH, Nov 10, 2016.

  1. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,620
    Location:
    Oklahoma City, USA
    Balance:
    11,755Coins
    Ratings:
    +1,418 / 29 / -1
    SMC3-SPS is a modified version of RufusDufus’s fantastic SMC3 sketch.
    SPS = Sabertooth Packet Serial version.


    Features:

    *Support for one Sabertooth 2x32 or one Sabertooth 2x60. (controls 2 motors only but you can use additional Arduinos to add more motors if needed).

    *Support for Mega and Uno Arduinos (uses the same sketch for both)

    *Plug and Play Sabertooth 2x60 – on a new 2x60 just set dipswitches and wire up as shown in the wiring diagram. (note: A new 2x32 also requires use of DEscribe software to set the correct baud rate)

    *Packet Serial Mode – uses a checksum so a Sabertooth won’t act if there are transmission errors.

    *Serial Timeout feature – a Sabertooth will shut down motors if a new position command is not received within 100ms of the last one.

    *Double Motor Resolution - twice the resolution of Simple Serial mode.

    *Soft Start Motor startup (at top of sketch look for //SET SOFTSTART SPEED const int SSloop = 8;. Increase SSloop for a slower start and decrease for a faster start)

    *Self-configuring baud rate on 2x60’s – will automatically change the baud rate of a new 2x60 from its 9600 default setting to 115200 baud. This makes the use of Describe software from Dimension Engineering as well as the need to purchase a TTL line level converter for the 2x60 Sabertooth unnecessary.
    A baud rate change to 115200 on a Sabertooth 2x60 that has been previously set to 19200 or 38400 baud can be accomplished automatically also by adding a jumper wire from ground to the appropriate pin on the Arduino (see wiring diagram)

    *Full PID motor control via the original SMC3 sketch by RufusDufus.

    ===Many thanks to @Pit for his assistance and serving as a test dummy for the cause:)===


    wiring.jpg

    Initial Setup

    Make sure Simtools is NOT running.

    1. If you have a new 2x32 or a 2x32 that is not already set to 115200 baud, use DEscribe software to set its baud rate to 115200. (note: setting the baud on a new 2x60 with DEscribe is not necessary) https://www.dimensionengineering.com/info/describe
    2. If you wish to use serial timeouts on a 2x32 you must set them to 100ms using DEscribe also.
    3. Wire up your Arduino to your Sabertooth as shown above in the wiring diagram
    4. Connect your Arduino to your computer via USB.
    5. If not already done download and install the Arduino programming software
    6. Download and run SabertoothArduinoLibrary.exe attached below
    7. If not already done apply power to your Sabertooths motor inputs.
    8. Now use the Arduino programming software to install the SMC3-SPS sketch attached below on your Arduino. Make sure you choose Uno or Mega and to set the comport number.
    9. Next download and run the Windows SMC3 Utility software attached below and make sure it communicates with your Arduino. Open the accompanying SMC3Utils.ini with notepad to change the comport if needed (see image below)
    10. Set Fpid to / 1. (If you experience motor twitching or other issues then try increasing it)
    11. Set Step to 100 and then set Kp, Ki, Kd, PWMmin, PWMmax, PWMrev to 0 (This will make sure the motors don’t move)
    12. Set Clip to 255 (you need to do this first) and Limit to 255 (This will give you plenty of margin if something goes wrong while setting up)
    13. Now click the -> M2 button to apply the same settings to motor 2 also
    14. Change Kp for motor 1 from 0 to about 400
    15. Set step back to 1
    16. Click the ON/OFF button for motor 1 to ON
    17. Now slowly, increase PWMmax… at some point the motor should start to move. When it does check the “Green” feedback line is moving toward the “Blue” target position.
      • If it is then that motor and feedback is wired correctly - proceed to test other motors.
      • If it is moving away turn off motor power immediately (or quickly reduce PWMmax again). In this case you need to either reverse the wires to the motor being tested –OR– reverse the +5V and GND wires to your feedback pot for the motor being tested (do not do both). Restart the test from the beginning.
      • If you are using a 2x60 and the motor doesn’t move, and assuming its wiring is correct, then its possible that your Sabertooths baud rate did not match what was expected when the sketch was run so it may not have autobauded. See the wiring diagram about setting jumpers to try a different baud rates.
    18. Set Step back to 100 and repeat steps #13, #14, #15, and #16 above for motor 2
    19. Motor driver setup is now complete but the PID controller will still need to be turned to work properly with your particular setup. This will be done later though and is not included in the scope of this tutorial
    20. Now start Simtools Game Engine (see image below)
    21. Open Interface Settings
    22. Now set up Interface1 as shown in the image below but substitute your arduino’s ComPort number if it is not on Com1.
    23. Click the SAVE button
    24. Simtools Game Engine Interface is now correctly configured to send data to the SMC3-SPS motor driver sketch
    25. That’s all. You can now start testing your setup with Simtools.

    For further information regarding PID tuning and Windows SMC3 Utilities go here.
    SMC3 Arduino 3DOF Motor Driver and Windows Utilities



    SMC_ut.jpg

    simtinf.jpg
    Simtools2 requires you add an a or b to the end of each axis. Example [A<Axis1a>]


    Below is useful information regarding the Sabertooths power and wiring requirements


    2x32pow.jpg


    2x60pow.jpg
    wireg.jpg

    UPDATE Beta5 to Beta 6 on Nov 12, 2016 - commented out motor3 to optimize serial execution speed and because it likely won't be used anyway since only one motor channel on a second sabertooth can be used.

    UPDATE Beta to RC on Jan 4, 2017 - Further optimized timing. Fpid can now be set as low as 1. Added soft start motor startup.

    Attached Files:

    • Winner Winner x 12
    • Like Like x 6
    • Informative Informative x 4
    • Useful Useful x 1
    Last edited: Nov 16, 2018 at 19:40
  2. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,620
    Location:
    Oklahoma City, USA
    Balance:
    11,755Coins
    Ratings:
    +1,418 / 29 / -1
    Reserved
  3. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Awesome @BlazinH you must of read my mind as I am about to upgrade to these :D

    Thanks
    • Like Like x 1
  4. wannabeaflyer2

    wannabeaflyer2 Well-Known Member

    Joined:
    Jun 12, 2015
    Messages:
    405
    Location:
    london uk
    Balance:
    5,574Coins
    Ratings:
    +591 / 4 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform, 6DOF
    Mr will you stop shifting the goal post LOL :) seriously once again thanks for the effort put into this , very informative and well laid out nicely done and will be a great help to a lot of us guys here .. massive respect @BlazinH :)
    • Like Like x 1
    • Funny Funny x 1
  5. wannabeaflyer2

    wannabeaflyer2 Well-Known Member

    Joined:
    Jun 12, 2015
    Messages:
    405
    Location:
    london uk
    Balance:
    5,574Coins
    Ratings:
    +591 / 4 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform, 6DOF
    @SilentChill ya beat me by 2 seconds LOL great stuff all round ....things were good before on this forum these guys are stepping up big time , Am i loving it or what :)
    • Funny Funny x 1
  6. noorbeast

    noorbeast VR - The Next Generation Staff Member Moderator SimTools 2.0 Beta Tester

    Joined:
    Jul 13, 2014
    Messages:
    11,642
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    90,628Coins
    Ratings:
    +7,632 / 37 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Brilliant tutorial and a great option for using Sabertooths, which given the frustrations with MMs are likely to be used more often in demanding sims :thumbs
    • Agree Agree x 2
  7. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,620
    Location:
    Oklahoma City, USA
    Balance:
    11,755Coins
    Ratings:
    +1,418 / 29 / -1
    No mate, I can't read minds (thank god). But I can read posts (sometimes). :D Actually Pit and I have been working on this for a few months now when we had the time. As of a few days ago all that was left was to create a thread for the sketch. Since I saw you would be receiving 2x32's soon, I decided to spend the time to get this posted now for you and others.

    I'm still calling it a beta though because only Pit and I have tested it so far. And I only have 2x60's so I tested on it and Pit tested on his 2x32. I think issues are sorted now but with only two testers I can't say for sure that they all are. So all feedback is welcomed.hug:
    • Like Like x 3
    • Winner Winner x 1
  8. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Can't thank you and @Pit enough I really appreciate the time you guys must of put into it. I'm just waiting for the damn drivers to arrive now. Hopefully I will get them before the weekend but at the moment they are still in France :(
    • Agree Agree x 1
    • Friendly Friendly x 1
  9. SeatTime

    SeatTime Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Dec 27, 2013
    Messages:
    2,001
    Location:
    Newcastle Australia
    Balance:
    25,131Coins
    Ratings:
    +2,335 / 20 / -0
    My Motion Simulator:
    DC motor, Motion platform, 6DOF
    Excellent work @BlazinH and @Pit :thumbs , with the unreliable nature of MMs , these will be the goto controller/driver combination for any larger sized sim.
    • Agree Agree x 1
    • Friendly Friendly x 1
  10. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  11. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Ok got it working :D

    Ok got a problem lolol When I go into to simtools to test DOF I'm getting weird glitching on each motor every few seconds its like twitching a bit ?? Its perfectly stable in SMC3 no movement at all until I ask it to .

    Anyone any ideas ??

    @Pit @wannabeaflyer2 @BlazinH @Grigory ??? please help :)
  12. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,620
    Location:
    Oklahoma City, USA
    Balance:
    11,755Coins
    Ratings:
    +1,418 / 29 / -1
    Are you using a mega or uno? Pit reported similar behavior when using his mega but he said changing 10ms to 1ms in Simtools interface fixed it. If that doesn't do it you can also try grounding pin 8 and reducing the baud from 500000 to 115000.
    • Informative Informative x 2
    • Agree Agree x 1
  13. BlazinH

    BlazinH Well-Known Member SimTools 2.0 Beta Tester

    Joined:
    Oct 19, 2013
    Messages:
    1,620
    Location:
    Oklahoma City, USA
    Balance:
    11,755Coins
    Ratings:
    +1,418 / 29 / -1
    Btw, I know you figured it out already but for information Fpwm is irreverent since we are not directly controlling the h-bridge on the sabertooth.
    • Agree Agree x 1
  14. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Thanks matey I will try in the morning, I am using UNO clones. I thought pin8 was just for 2x60's will try that too :)
  15. mariano68

    mariano68 Active Member

    Joined:
    Nov 15, 2014
    Messages:
    584
    Occupation:
    builder contractor
    Location:
    Argentina
    Balance:
    3,628Coins
    Ratings:
    +380 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino, 4DOF
    Better motors, better software (Simtools 2.0), better designs, all ask for a better driver and better software driver, perfect timing! You guys are great!
    I'm ordering a pair of sabertooth 2x32 for my new sim!
    • Like Like x 1
    • Winner Winner x 1
  16. Pit

    Pit - - - - - - - - - - - - - - - - Staff Member Moderator Gold Contributor SimTools 2.0 Beta Tester

    Joined:
    Oct 2, 2013
    Messages:
    2,965
    Location:
    Switzerland
    Balance:
    28,459Coins
    Ratings:
    +2,921 / 28 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    SimTools = 500000
    Sabertooth = 115200
    Uno or Mega = 115200
    SimTools Paket Rate Uno = 10ms
    SimTools Paket Rate Mega = 1ms
    • Informative Informative x 2
  17. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    12,436Coins
    Ratings:
    +833 / 7 / -1
    Nice work!
    • Friendly Friendly x 1
  18. SilentChill

    SilentChill Problem Maker SimTools 2.0 Beta Tester

    Joined:
    Jul 19, 2014
    Messages:
    2,117
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    16,850Coins
    Ratings:
    +2,841 / 29 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Ok I've tried changing the PacketRate and it makes the twitches more frequent at 1ms and if I put it higher than 10ms they do go away but the motion is jerky as hell. In fact the movement from simtools is terrible its jerking everywhere.

    I use SCM3 to move the actuators and they are as smooth as you like, I have no idea lol
  19. Pit

    Pit - - - - - - - - - - - - - - - - Staff Member Moderator Gold Contributor SimTools 2.0 Beta Tester

    Joined:
    Oct 2, 2013
    Messages:
    2,965
    Location:
    Switzerland
    Balance:
    28,459Coins
    Ratings:
    +2,921 / 28 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    1ms is only MEGA compatible. Can you upload all your settings for once?
  20. Pit

    Pit - - - - - - - - - - - - - - - - Staff Member Moderator Gold Contributor SimTools 2.0 Beta Tester

    Joined:
    Oct 2, 2013
    Messages:
    2,965
    Location:
    Switzerland
    Balance:
    28,459Coins
    Ratings:
    +2,921 / 28 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF