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 Sabretooth TEST version

Discussion in 'SimTools compatible interfaces' started by RufusDufus, Jan 25, 2015.

  1. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,900Coins
    Ratings:
    +1,016 / 10 / -1
    Hi, I have seen a number of people comment they would like to use the sabretooth or other compatible high current motor drivers.

    Attached it a TEST version of SMC3 that "should" drive the Sabretooth in "Simplified Serial" mode for anyone who is game enough to give it a try.

    I don't have a sabretooth so its untested apart from checking the serial comms that would go to the sabretooth. So please don't go out and buy one specially for this in case it can't be made to work.

    Use the default Windows SMC3Utils software to configure the PID parameters etc...

    Set Fpid / 5 so that it does not overload the serial comms to the sabretooth
    Set PWMmin to 0
    Set PWMmax to 255
    Set the sabretooth to simplified serial mode using 38400 baud
    Pin 13 on the Arduino is the Tx serial line that connects to the sabretooth
    When SMC3 is in this new mode (MODE3) it can only drive two motors

    Test on the bench first to minimise risk of damage.

    Let me know if it works

    Attached Files:

    • Like Like x 4
    • Winner Winner x 2
    • Useful Useful x 1
  2. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    @RufusDufus great work, unfortunately I have no Sabertooth for testing. BTW a sabretooth would be something like this:
    250px-Sabretooth_X-Men162.jpg

    :):):):):)
    • Funny Funny x 3
    • Like Like x 1
  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
    @RufusDufus, I have an Uno but I have never used it. I don’t have time to attempt to do so in order to test this. However, I have examined your code and it appears it should work as written to control one sabertooth using simple serial. I assume though that you have tested your code without a sabertooth connected in order to confirm that the use of software serial doesn’t interfere with PID timing since software serial output is bit-banged (although it is only one byte being sent each time).

    I will make one recommendation for a code alteration however. It may be necessary to limit the maximum output on each motors channel in order to ovoid damage to gearing due to high current being available. I have chipped teeth off worm gears due to this. While an end-user could easily do this themselves by altering the constrain perimeters for each motors output and reprogramming their uno, it would be better to have 4 variables within your code that could be set instead; one set between 1 and 63 and another between 65 and 127 for each direction of motor 1, and one set between 128 and 191 and another between 193 and 255 for each direction of motor 2.

    p.s. To put a sabertooth in simple serial mode at 38400 baud set it's dip switches as follows: 1-on, 2-off, 3-on, 4-off, 5-off, 6-on.
    Last edited: Jan 25, 2015
  4. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,900Coins
    Ratings:
    +1,016 / 10 / -1
    Yes that is correct.. as long as set Fpid/5 all is good. (In fact SMC3 will run ok upto Fpid/3 at 38400 but I'm not sure if it will benefit the sabretooth any more.

    This already can be setup using the Windows SMC3 Utils.. It is the PWMmin and PWMmax values. The range is 0-255 for compatibility with the other SMC3 modes but this is scaled to 0 to 64 etc for MODE3 Sabretooth. :)

    Thanks, that is useful info :thumbs
  5. 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 agree. If my understanding is correct, Fpid/5 would be over 800 motor updates per second. While the sabertooth will accept up to 2000 per second and omit any over that, 800 per second is more than enough in my opinion.
    I see. I'm not proficient at arduino code so I didn't catch that initially.
  6. ericRacer

    ericRacer You get old because you stop playing ! Gold Contributor

    Joined:
    Jun 11, 2009
    Messages:
    251
    Occupation:
    Pilot
    Location:
    Canada, Quebec
    Balance:
    989Coins
    Ratings:
    +147 / 2 / -0
    My Motion Simulator:
    3DOF, Arduino, Motion platform
    Hi @RufusDufus ,
    very interesting this version to use my Sabertooth. My MM work well but I would rather use my Sabertooth. I will test this week for sure. Thank you for this beautiful work. I tried to modify SMC3 for it but without success, my programming knowledge (Arduino) are really too limited.
    Eric
    • Like Like x 1
    Last edited: Feb 2, 2015
  7. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,900Coins
    Ratings:
    +1,016 / 10 / -1
    Good to hear, I am interested how it goes.
    • Like Like x 1
  8. ericRacer

    ericRacer You get old because you stop playing ! Gold Contributor

    Joined:
    Jun 11, 2009
    Messages:
    251
    Occupation:
    Pilot
    Location:
    Canada, Quebec
    Balance:
    989Coins
    Ratings:
    +147 / 2 / -0
    My Motion Simulator:
    3DOF, Arduino, Motion platform
    Hi @RufusDufus
    I tried it yesterday and it works very well with SMC3utils. By cons with Simtools I had trouble. The engine had a somewhat erratic behavior and sometimes he railed without stopping even after spending the clipping area. Fortunately I found a part of the problem, I have to change the baud rate of 500K >> -> 115200 baud. I thought it might come in sync with "SoftwareSerial" I tried different configuration with FPID / 1-2-3-4-5 without improvement.
    For now it works very well for me at 115200 bds.:thumbs
    :cheers

    ps. i didn't try with pot scaling .and i tried with Arduino Nano v.3
    • Like Like x 2
    Last edited: Feb 4, 2015
  9. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Hi @RufusDufus the next days I will test your code. I am using a MEGA so if there is any unexpected behavior please warn ;) I use the Sabertooth 2X32 which supports 115200 bds.
    • Like Like 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
    I see you have now decided to give the Sabertooth version of SMC3 a try @Pit. I can’t say for sure myself if the mega will cause any problems with RufusDufus’s sketch considering it uses bit shifting, etc.

    However, there is no reason for you to use software serial to control your sabertooth as the sketch is written since the mega has 4 UART’s and not only 1. Therefore, I have modified the test version to use the mega’s Serial1 port instead. The modified sketch sets the mega’s Serial1 baud rate to 115200 and uses it to send commands to the sabertooth vs. a software serial port.

    The attachment below is not zipped but sent as a text so copy and paste the code into your
    Arduino programming software if you wish to try it. Good Luck!
    :popcorn

    Attached Files:

    • Useful Useful x 2
    Last edited: Oct 20, 2015
  11. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,900Coins
    Ratings:
    +1,016 / 10 / -1
    Hi @Pit, I haven't used this code with either the MEGA or a Sabretooth myself - that is why I posted it in a separate thread marked test. I don't see any reasons why it shouldn't work though.

    @BlazinH is correct about the MEGA serial ports, much better to use the hardware serial when available. (Are you using this code BlazinH?)

    I noticed your post in another thread about the sabretooth running away and crashing your sim into a wall. Unfortunately this is one of the risks of Sabretooth in serial control mode. You send a serial command to the driver to tell it how fast to go... if there is any noise or problems with comms then it isn't going to stop. I don't think Sabretooths and serial control are ideal for sims for this reason, but of course they have other advantages.

    I think you might be able to set the sabretooth up to stop if it doesn't recieve commands for a while but not sure if this will be quick enough to catch any problems? Best thing is to make sure you have good connections with minimal noise on the serial lines.

    I suggest you try and test using a setup that won't damage anything if it goes wrong.
  12. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Dear RufusDufus how can this be done? Any suggestions about that? Thank you.
    • Like Like x 1
  13. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,900Coins
    Ratings:
    +1,016 / 10 / -1
    @Pit, I just had a look at the manual and may have got that wrong? It seems to be an option for the packetised serial mode and doesn't say if it applies to simple serial - I am guessing it doesn't because its simple. Also it lloks like the minimum timeout is 100ms which may be too slow anyway.

    (Edit: the last sentence below says it is only for packet serial!)

    the command was:
  14. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    100ms should be enough, mostly the rig is operating around the middle position and accelerates after malfunction. I attached the settings of Desctibe which should allow to set the timeout function on the sabertooth using the serial mode:
    serialtimeout.jpg
    An arduino code should go as well:

    Code:
    // Set Serial Timeout Sample for Packet Serial
    // Copyright (c) 2012 Dimension Engineering LLC
    // See license.txt for license details.
    #include <Sabertooth.h>
    Sabertooth ST(128);
    void setup()
    {
      SabertoothTXPinSerial.begin(9600);
      ST.autobaud();
    
      // setTimeout rounds up to the nearest 100 milliseconds, so this 950 will actually be 1 second.
      // A value of 0 disables the serial timeout.
      ST.setTimeout(950);
    }
    void loop()
    {
      // Set motor 1 to reverse 20 (out of 127), and sleep for 5 seconds.
      // Notice how it cuts out after 1 second -- this is the serial timeout in action.
      // Since we configured it in setup() for 1 second, 1 second without any new
      // commands will cause the motors to stop.
      ST.motor(1, -20);
      delay(5000);
    
      // Why do this?
      // If the S1 wire gets cut for some reason, or if your program crashes,
      // the Sabertooth will stop receiving commands from the Arduino.
      // With a timeout, your robot will stop. So, it's a safety feature mostly.
    }
    
  15. 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 don't use your sketch @RufusDufus but I am using a mega now to control three sabertooths so I have used the code I added to your sketch before.

    Also you are spot on with your analysis above except I think a 100ms timeout should be fast enough in most cases.
  16. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Dear @BlazinH, do you use pin 13 as well for the Serial1 line?

    PS: Position of the DIP Switches? Same like @Wanegain?
  17. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    Hi @Pit. On my mega serial1 tx is marked as pin 18. The dip switch settings for a 2x32 are 1-off, 2-off, 3-on, 4-off, 5-off, 6-on but you must use Describe to set the sabertooth to 115200 baud first if its not already.

    Ps Remember to power cycle the sabertooth after a baud change.
    • Informative Informative x 1
    Last edited: Nov 21, 2015
  18. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    ok, thanks a lot. I will start today with testing.
  19. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    I've uploaded the code successfully, only I am wondering about the very high Kd and Ks values - it needs hours to set them to zero ;p

    Got it (pushing space to the limit). What Fpid value are you using?
  20. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,439Coins
    Ratings:
    +3,089 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Update: I have no PWM output on SMC3...