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 SPS - Sabertooth Packet Serial PID motor driver sketch w/SoftStart

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

  1. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    OMG, you just ended 4 days of wasted time, I was litrally turning around myself at somepoint trying to find why I'm unable to to get my sim to work, I was thinking that SMC3 utility is just a tool to drive to motor manually and visualize the values, so at the end of my useage I would drop the PWMmax down to 0 trying to kill the power slowly, but in reality this was re-written to the arduino and eventually will never move.

    Thank you very much for the quick answer, it really really helped, you made my rig move for the first time. hug:
    • Friendly Friendly x 1
  2. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    I'm glad I asked my silly question last time as this solved the problem and got me progressing big step forward, so I want to ask another basic question hoping to get things sorted out in a more clean way, here is the procedure for tuning as I understand it now, please correct me if I'm wrong:
    1- Open SMC3-win-util
    2- Adjust values for (Motor 1) till satisfied with performance while using various output modes to check the response
    3- Switch the output mode to Monitor
    4- Turn off the motor using the ON/OFF button (I'm not sure if this is needed)
    5- Repeat steps 2 to 4 for Motor 2 (or just copy the settings from M1 using >M2 button)

    I noticed that after this is done, when the motor is not driven by the game it will tend to hold the position set by the target value (blue marker) in SMC3-win-util, so for this particular point I have the following concern: say that my target is set to be in the mid-range and I power off the rig when I'm not using it, and under self weight the actuator when not powered will drop all the way to bottom limit, now when I power up the rig it immediately and aggressively jumps to the mid-range point again, I find this very risky and will eventually break and damage things if not hurting someone too. Any idea what to do here?

    Thanks again.
  3. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    If you downloaded smc3-sps on or prior to Oct 10, 2019 download the latest sketch, the old one had a soft start programming error :oops:. Then follow these instructions to adjust the speed to your needs.

    *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)

    It works only once when you power on or reset your arduino so make sure the sabertooth has power first.
    • Informative Informative x 1
  4. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    I actually downloaded it at the end of September, I'll update to the new one.

    What about the 5 steps I listed above, do you agree?
  5. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    Hi,
    my pot reading is not centered relative to the physical movement range, I tried to compensate for that by changing the center offset and the max and min limits in the smc sketch, but seems that smc-win-utility is messing things up and it also enforces symetric min and max limits.
    Any ideas what to do?
  6. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    I'm the wrong person to answer those questions. I actually don't use the sketch or utilities myself. I wrote my own motion software before I found this website and was already using sabertooth controllers before anyone else here. But I wanted to contribute to the community so others could use them too using its safe packet serial mode so I just added support for them to the original SMC3 sketch.

    It appears that you are trying to use audio taper pots; you need linear taper pots. Or better yet a lot of use inexpensive hall pots named Magnepot. They come in 360, 180, 90 degree and some others.
    Last edited: Oct 17, 2019
  7. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    Thank you for the reply and the great work you did, I agree with you about the fact that Sabertooth is not that popular among users here (I guess the price plays a major roll here) but my opinion is they are great in terms of performance and quality.


    I'll try to explain the full story, I am actually using a standard (10Kohm X 10 turns) potentiometers, the mechanical setup I have (i.e. belt and pulley gear ratio) yields 7.5 pot revolutions per full stroke of the linear actuator (end-to-end), these pots are my second batch, the first one was a set of cheap stuff which literally broke in half under slight belt tension even before using them and they had bad signal quality too, I moved to a higher quality ones (which are my current pots) and they are way more sturdy and have better quality, and to avoid loading the shaft of the pot with belt force I switched the mechanism to be gears with no belt, the results are very good in terms of signal quality and responsiveness. When I installed them I didn’t stress myself about getting their range perfectly centered since I knew the Arduino sketch allows for range center offset, and min/max limits and clipping, see the screenshots below for sections from the sketch:

    Pot range setup.PNG
    My hope was to be able to use the parameters highlighted in yellow to precisely put the range where it is supposed to be and get the correct position reading.

    So first thing I do is running an Arduino sketch that resets EEPROM and zeros all the bits to get rid of any values in there (these are values from previous tuning session), then I upload the new sketch with new tuned values as shown above, then I try to test the system and get some movement but the motors stay dead, I can only get them to become alive if I open SMC3-Win-Utility and put the tuning values in there then close the SMC3 utility software then start the rig. The problem with this procedure is it uses the pot range information from the SMC3 utility not from the sketch, I can tell because I can never get more than 70% of the stroke and can never move the actuators towards the lower 30% , basically the actuators can move from 30% open to 100% open back and forth, it appears that the SMC3 utility overwrites the sketch, the down side is SMC3 utility does not differentiate min from max limits like in the sketch and it uses one limit and clipping value for both ends of the pot range, I can live with that if it allows me to move the centre from the default 1024/2=512 (in SMC3 utility this will be 512/4=128) but SMC3 win utility does not have a center offset parameter so it is always assuming 128 (I guess based on what the behavior I’m getting).

    After all, I think right now I have the following options:

    1- Go and center the pots physically, but that will be approximate and will never be precise nor consistent among all 6 pots

    2- Dig into the Arduino sketch and see why I can’t get it to power up the motors without going through SMC3-win utility first, SMC3 utility must be changing something that missed to set in the sketch, I believe it is one of the power tuning parameters that I might be using incorrectly (please see screenshot for used parameters summary and tell me if you see anything wrong)

    PID values.PNG
    Last edited: Oct 17, 2019
  8. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    Oh I just noticed one more thing in the sketch, the first three parameters in the image in my previous post are never called by the code at any step, which means they are defined but never get used, if this is right then that explains why I'm unable to move the center of the range to where I need it to be.

    center offset.PNG

    This now limits my options more and more.
    At some point I was actually considering switching to encoders instead of pots, they are cheaper and more precise, I actually bought them and will be looking in modifying the sketch to adapt encoders instead of pots, I just don't see this happening in the near future due to practical reasons, at the moment I will stick to what have to get the project moving forward.
  9. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    The perimeters are variables not constants and get overwritten by the EEPROM value's when you run the sketch.

    Some of the variables may be leftovers from when it's author was developing the sketch and trying different things.
    • Informative Informative x 1
  10. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    And you need dedicated hardware to read encoders then you send the values over.
    • Like Like x 1
    • Informative Informative x 1
  11. TSHracing

    TSHracing New Member

    Joined:
    Dec 14, 2017
    Messages:
    26
    Location:
    Canada
    Balance:
    329Coins
    Ratings:
    +5 / 0 / -0
    You are right, so this would be somewhat a long shot but if I have nothing else to do I might look into it.
    In the mean time I found more stuff in the sketch and SMC3 win utility that raised more serious questions than before, so who do you suggest to help me with this, is @RufusDufus the original writer of these two?
  12. Patte83

    Patte83 Member

    Joined:
    Nov 20, 2018
    Messages:
    55
    Balance:
    24Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    3DOF
    Need help. My simulator works great in SMC3 and moving smooth. Sometimes it the motors lag. In game it works fine then after a while when playing hard it starts to shake bad with out no control.
    Then i have to turn the Simtools off and put SMC3 on to stop it and reset it.

    Anyone who knows what it might be please help.
  13. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    I'd try running at 115200 from Simtools instead of 500000 first to see if that solves anything.
  14. Patte83

    Patte83 Member

    Joined:
    Nov 20, 2018
    Messages:
    55
    Balance:
    24Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    3DOF
    Hmm its dead now no movment at all not even power to motors...
  15. MarkusB

    MarkusB Well-Known Member Gold Contributor

    Joined:
    Jun 30, 2015
    Messages:
    552
    Location:
    Germany
    Balance:
    4,213Coins
    Ratings:
    +596 / 2 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, Motion platform
    This sounds like your motors ran out of their allowed movement range, which is a safety feature of SMC3.

    To get them running again, start SMC3 Utils, disconnect the pot from your motor, manually turn the pot until the pot curve is centered again, and then connect the pot again.
    After this you should be able to turn the motor on again.
    • Informative Informative x 1
  16. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    If you didn't ground pin 8 on your arduino do that, reset, and try again.
  17. Patte83

    Patte83 Member

    Joined:
    Nov 20, 2018
    Messages:
    55
    Balance:
    24Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    3DOF
    I got them working again :) But still the same with the game. Playing assetto corsa competizione and everything works fine for 2 laps. Then one of the motors Shakes violent,
    only way is to stop Sim tools and start SMC3 to reset it.

    Wonder what it can be maybe someone else had this issue.
  18. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    Since this thread is for sabertooth controllers and I assume that's what you have it may be a power supply issue.
  19. Patte83

    Patte83 Member

    Joined:
    Nov 20, 2018
    Messages:
    55
    Balance:
    24Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    3DOF
    Strange it works in SMC3 with out a problem really don't know why it starts to shake bad in Simtools.
  20. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,032
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,890Coins
    Ratings:
    +10,880 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK