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. 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. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    It can be frustrating attempting to learn so much quickly and then having problems with things not working but no need for violence. :D
    It sounds like one or both of your motors may be running opposite the pot feedback. This is a normal occurrence and can easily be fixed by reversing the +&- leads on the motor.
    And just in case you haven't you need to read thru this carefully (second post). As I said I don't use it so I'm not really confident in giving advise about how to use it. Many here have more experience than me so please jump in if you can help out:cool:.
    https://www.xsimulator.net/communit...3dof-motor-driver-and-windows-utilities.4957/

    Btw, Its also frustrating that we can no longer link to a specific post @RaceRay.
    • Agree Agree x 1
    Last edited: Oct 14, 2018
  2. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    OK. So I did a search on pot settings and got https://www.xsimulator.net/communit...tor-driver-and-windows-utilities.4957/page-27 so I reset the pots as per the instructions and Motor 1 when tried turning up the PWMax I got nothing
    So I then tried Motor 2 and it started to move and it went beyond the red limits so I backed it right down to zero and it kept on going even if I re selected Motor 1 , so I turned off the power and it stopped

    BTW my pots are 180 degree Hall Effect Pots powered from the Arduino 5V output
    This is doing my head in :mad::mad: :sos
    Does this make any sense to anyone
    The top screen capture is M1
    SMC3-Capture-8478.392532780004 (1).jpg

    This is M2 that started but did not stop when I turned back the PWMax to Zero
    SMC3-Capture-8478.392532780004.jpg
  3. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    My head is starting to feel a little bit like yours now but I'm not quite out of ideas to try yet. Don't forget you are attempting to use an unsupported controller though so some issues are to be expected. With that said the 2x25 appears to be compatible with the sketch with the exception of not doing 115200. That's important however because the sketch has been optimized to run at that rate so it doesn't have much overhead. I therefore suggest you increase fpid to around 7 to give you some and then try again.

    Its been a couple of years now since I studied the original smc3 sketch in order to add sabertooth packet serial support but I believe PWMmax and PWMmin still apply even though a sabertooth is not controlled with pwm. But setting Kp back to zero should definitely stop a motor if Ki and Kd are also zero.

    And I'm not positive of what I'm seeing in you last photos but it looks like M2 may be wired backwards? And I don't know why M1 isn't running now. One thing I would do though is to test that the serial timeout is working on your 2x25. Redo your M2 test and as the motor runs disconnect the S1 wire on the 2x25. If its working the motor will stop. If it doesn't though be ready to remove power. This will at least tell us that smc3 is still sending out new data packets and that the 2x25 is not just continuing to run on the last command it received.

    If you still continue to have issues you may want to go ahead and try the smc3 test version. If the baud rate your using is causing the problems it shouldn't be an issue with the test version.
    • Informative Informative x 1
  4. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    Sorry if I'm giving you the sh*** mate but I appreciate your perseverance.
    Surely I can't be the only one trying the 2X25 V2 Sabertooth.
    I have been playing with the pots and I have probably rotated both through 360 degree.
    When I test either motor and it fails, to reset the Motor ON/OFF back to OFF I have to rotate the pot past the limit and back to the center and if I keep going to the next limit the trace goes from a smooth
    slope to a square wave type trace for a certain amount and then it becomes a smooth slope trace again.
    I did try upping the FPID to 5 after reading some posts but that had no effect
    The other thing which I think is pot related is when I reset the Motors after they go over limit or whatever and return the green trace to the center It only moves to target line only and no further regardless of how much I up the PWMax.
    The confusion for me comes from the fact that the green trace is meant to head towards the target line if the motor is wired correctly, but how is that so as I thought it would have to start near the limit and travel towards the target line and presumably pass the target , head towards the limit then crack a left and head back up to the blue target line again like a sine wave does I think ?
    Does any of that make sense.:think
    Your comment about the motor than continues rotating even though it has gone past the limits and I have backed the PWMax to zero and click on the opposite motor and it still continues on it's merry way until I disconnect power to the Sabertooth which sort of sounds like you said about it going rogue on it's last received command.
    It's Monday 2.55 a.m. and I am tempted to make the 100 mile round trip to the nearest electronics place and grabbing some garden variety 10K Linear pots just so that I can eliminate one suspect, the Hall Effect Pots which would then point the blame at the sketch possibly.
    The hall pots have a very amount of small rotation before it goes of the scale when I had the removed and was playing around to see what was happening.

    Is this the sketch you are referring to https://www.xsimulator.net/community/threads/smc3-sabretooth-test-version.6236/ if it is RufusDufus live in the same city as me and maybe I could contact him for some tips
    Anyhow time for an early night if you call 3.05 am early, I'm old and this is wearing me down .
    Meold.png
  5. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    I doubt it's your pots because me and many other's use the same ones and there quite robust. You can test with a voltmeter though. Output should be .2 to 4.8 v on almost 1/2 of the pots rotation.
    I looked it up and the 2x25v2 manual says it has serial timeout. But yes since the motor isn't stopping at limits it seems it's not working so needs testing by removing s1 wire.
    Yes that's the test version sketch link that uses simple serial. If you try it you will have to change the dip switches on the 2x25 though so it work with simple vs packet. See the manual for the settings.
    • Dislike Dislike x 1
  6. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    Episode 333
    I tested the pots with the voltmeter and yeas getting the 4.8V and then set them by the SMC utility checked voltage and at about mid point 2.5V
    Tested again and M1 did not move nor did green tace.
    Tested M2 and same. re did this few times and the same, same.
    Thought I'd reverse wires on motors and redid test.
    M1 moved and went out of limits, so I quickly removed the S1 wire from the Arduino and the motor kept running, so I then disconnected the Arduino's USB and the motor still kept going
    WTF batman, so I turned off the power to the motor and that stopped it.
    So now I am totally confused as to what is happening .
    BTW the motors were only being powered by my power supply and not with the separate battery connected for the regenerative current if that makes any difference. :sos
    I should have done a screen capture but I did hit the save image button and this was the trace

    SMC3-Capture AWOL.jpg
    Last edited: Oct 15, 2018
  7. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    For the serial timeout to function the 2x25 must be powered before the arduino. If you remove power from 2x25 and restore it you must reset your arduino too for the timeout to work again.
    It appears feedback is working fine though and the problem is elsewhere.
    Post images of smc3 utility settings for m1 and m2 please and try s1 test again. If the motor runs on again then communications may be an issue.
  8. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    I am getting further into the sh**
    I tried everything and just keep going around in circles chasing my tail.
    So I thought when in doubt start from the beginning.
    So I did that to confirm that the baud rate was set to 38400 and then I thought bugger it I will set it to "Simplified Serial" for something different and give the Test sketch a run around the block.
    In the "Simplified Serial" there are only one option for exponential map I think but I left that unchecked so I uploaded that and downloaded it again to check and it opened in the General tab which I don't know is right or not or if it should have been the "Simplified Serial" tab ?
    So on I went and uploaded the SMC3 v0.8 Sabretooth TEST.zip sketch and tried SMC3Utils and set the settings as detailed
    Not much different happened, reset pots etc and from memory I turned off the power and reset the Arduino and ran SMC3Utils again and reset the pots, then when I turned the motor power back on
    M2 started all on it's own at a fair speed, so I grabbed a screenshot then turned off the power again.
    So my experiment was a failure, but the hell made the motor go off it's trolley :confused:

    So for your entertainment is the pic
    runaway.jpg

    And this is the sketch

    Attached Files:

    • TEST.txt
      File size:
      393.1 KB
      Views:
      276
  9. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    Maybe I wasn't clear. Did you read the 2x25 manual to learn about simple serial? You don't use or need describe with simple serial you just set the dip switches on the 2x25. Set 1-6 as follows; on, off, on, off, off, on to set simple serial mode @38400.
    Is that what you did?
    Btw, since simple serial doesn't use a checksum and needs just one byte for control of a motor it will move with any byte sent; good or bad data. So it's best to have motor levers disconnected until things are sorted.
    Most people that use supported controllers with smc3-sps though don't usually have many issues other than a motor wired backwards of feedback so I can only think it has something to do with using a 2x25 @38400 if you have it all wired properly.
    Last edited: Oct 15, 2018
  10. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    I set the dip switches to Mode 3 as per the manual, ON-1,3.5,6 OFF - 2, 4
    The manual for 2X25 V 2 says that it will only go to 38400
    All the tests that I have done have all been done with levers disconnected.
    Even when I think that I've got it but the motor needs polarity change and I do that and then reset the pots to get the On/Off back to off and recenter the pots, then it must only drive a few clicks
    before it reaches the target line and can't go past that line for whatever.

    All I can do now is try dropping the baud rate to 9600 by the dip switches.
    When I uploaded the sketch for Both the soft start and Test, either by design or my stupidity wanted a file Sabertooth .h in the same folder and that is why I included the sketch for you to see if you could spot any bad code.
  11. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    I don't know what information your reading because this is how the manual shows to set to simple serial mode @ 38400 and that's what the Test sketch uses.
    SS38400.jpeg
    Its the same as how I told you to set it earlier but I guess you don't want to believe me anymore.o_O

    Why would you want to do that?:confused:

    I don't understand. The Test sketch doesn't need Sabertooth.h and you already had smc3-sps working previously. :confused::confused::confused:
    Last edited: Oct 16, 2018
  12. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    I had the baud rate set via the dip switches to 38400 and because I was having problems it said to drop it back to 9600 in the manual
    Mode3.jpg

    Like I said it was probably my stupidity but when I installed the sketch I kept on getting a path error and when I sorted that out when I uploaded the sketch it had an error message which referred to the file sabertooth.h which is in the Sabertooth Simplified Folder.
    Again human error and it's my first experience with Arduino software
    My easiest option is to start from scratch and upload your soft start sketch, set the dip switches back to 38400 and try again.
    I'm a bit thick and sometimes I don't get it right first time such as this, and electronics are always my weak point.
    The forum is my only source of help so please bear with me a bit.
  13. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    Today I uploaded a clean version of the Test sketch and set the dips to 38400
    Still got the same results of Motors not stopping and I followed your instruction of powering the Saber first and rest the Arduino which I was unsure if you meant the rest button or just unplugging and putting the USB cable back again so I did both. When the Arduino is reconnected I hear a definite clunk from the motor and If the reset button is pushed the motor will start, hit rest again and the other motor starts so I don't know what I've done or if it's a problem with either the Arduino or Sabertooth but I have not had any error led's come on , just solid blue.
    The Sabertooth somehow keeps starting the last command I assume.

    Not getting anywhere with that I decided to reload the Soft Start sketch and set the dips to 38400 and boom straight up it did the same thing as above.
    I don't know whether I'm coming or going, do I have a hardware, wiring , or software problem or all of the above.
    I usually troubleshoot by going back to the start and just re-doing each step which I've done withe same end result.
    Does anyone know how to reset the Sabertooth if that is the problem ? I tried Googling it and got little if any tips.
    I did read of a lot of people having problems with the 2X25 and wonder if it's the black sheep of the family.
  14. Peacemaker105

    Peacemaker105 Active Member Gold Contributor

    Joined:
    Jul 18, 2017
    Messages:
    114
    Location:
    Perth, Aus
    Balance:
    1,140Coins
    Ratings:
    +202 / 1 / -0
    My Motion Simulator:
    6DOF
    Hey guys, so i'm trying to setup smc3 with my 2x32. I have changed baud rate to 115200, set timeout to 0.1s in Describe. flashed the uno with the sketch, all seemed to go well. Load up smc3 utilities and i can see my pot feedback ok, it moves when i move it... but when i try to click the motor "on" it just flicks back to "off" instantly.. any ideas what might be causing this? Ive tried starting them up in different sequences to no avail. I didn't alter the sketch in any way, just uploaded it to the Uno. Any help would be appreciated.
    Cheers.
  15. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    Read the last two pages of this thread and see if that helps fix your problem.
  16. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    I've been working on my rig tonight so I don't have time to respond until tomorrow.
  17. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    I have been trying to do more reading of the manual to see if I have stuffed up somewhere which might be causing my problem
    I remember You said If you wish to use serial timeouts on a 2x32 you must set them to 100ms
    Now I think that my runaway motors are related to timeouts ?
    But I could not find a setting in Describe in any of the tabs in the latest version of V3.7
    So how or who is controlling timeouts, is it some code in the Soft_Start sketch ?
    Can I use Describe as a 2x32 rather than a 2x25 V2 - Answer is No. It recognizes it as a 2X25 V.2
    Only the RC tab has a timeout function in 2X25 mode, so I have tried uploading that set as 0.10 which I hope is right and it uploaded OK, so no to see if it makes any difference.
    I'm a pessimist by nature so $20 says Nope. But I am crossing my fingers anyhow.

    This is my Describe pic.
    Describe2x25v2.jpg

    Screen capture of Describe with Sabertooth 2x32 selected from drop down menu which does have the timeout function SerialUSB2x32t.jpg
    Last edited: Oct 17, 2018
  18. Deane

    Deane Old Fart

    Joined:
    Aug 25, 2018
    Messages:
    212
    Occupation:
    Retired
    Location:
    Wirrina Cove, South Australia
    Balance:
    659Coins
    Ratings:
    +89 / 3 / -0
    My Motion Simulator:
    2DOF
    I now can't stop the motors from moving when I apply power to the Sabertooth even though I am doing what you said about pulling the S1 wire which does stop the motor.
    I then reset the Arduino by pulling the USB and pushing the rest button on the board.
    When apply power back to the Sabertooth and connect the Arduino the Motor will start moving, if I puss the Arduino reset button it changes to the other motor.
    I think you said that the Sabertooth was keeping the last command sent in memory, is that correct ?
    So I thought that the routine that you said would reset the Sabertooth's memory but that doesn't seem to be doing anything.
    For good measure I reloaded the SoftStart sketch and edited the baud rate to 38400
    So I hooked the Sabertooth up to my laptop and did a reset from the file menu, then I re-did and checked the settings which are Baud 38400, Packet Serial and timeout 0.1

    Dip switches have been set for 38400

    With that done I hoped it would at least be back to square one, but no sir, the Sabertooth I assume is running on the last command, how and why I just don't know.
    Or is the Arduino doing weird things ?

  19. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,119
    Location:
    Oklahoma City, USA
    Balance:
    15,579Coins
    Ratings:
    +1,797 / 31 / -1
    Thats what it's supposed to do. It is a motor control sketch after all. The motors start and attempt to move to center position. If the pots are attached to the motors and the feedback is setup correctly the motors will stop when the feedback says they're centered. That's all I have time to say atm.
    • Agree Agree x 1
    Last edited: Oct 17, 2018
  20. Peacemaker105

    Peacemaker105 Active Member Gold Contributor

    Joined:
    Jul 18, 2017
    Messages:
    114
    Location:
    Perth, Aus
    Balance:
    1,140Coins
    Ratings:
    +202 / 1 / -0
    My Motion Simulator:
    6DOF
    Ok so i changed out arduino boards and it all seems to be working nicely at 115200 etc! Woohoo! timeout works too. So far so good. I had heaps of noise from my pot, installed some shielded cable and perfecto, nice and smooth feedback.

    Quick question.. the max limit at its maximum doesn't close in enough for where my actuator operates at, so basically the software end stops wont come into effect before my physical end stops. any way to change this? Or do i have to change the gearing on my potentiometer. currently its a 10 turn pot and from min to max is about 5 turns.