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

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,147
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    148,578Coins
    Ratings:
    +10,903 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    It would help if you posted pictures of all of your settings.
  2. mariano68

    mariano68 Active Member

    Joined:
    Nov 15, 2014
    Messages:
    576
    Occupation:
    builder contractor
    Location:
    Argentina
    Balance:
    3,339Coins
    Ratings:
    +395 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino, 4DOF
    A l298N is a 2amp bridge, I doubt you can control even 1 wiper with that.
  3. GRONEXP

    GRONEXP New Member Gold Contributor

    Joined:
    Mar 10, 2017
    Messages:
    6
    Location:
    chile
    Balance:
    105Coins
    Ratings:
    +1 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, SCN5, SCN6, SimAxe, Arduino, Motion platform
    correct the bridge h l298n is only for testing and sim start.
    attached configuration images made without having simtools action

    20171002_164601.jpg 20171002_164611.jpg 20171002_164741.jpg 20171002_164803.jpg
  4. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    • Agree Agree x 1
    • Winner Winner x 1
  5. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Hi guys.

    I have just got my new controller box up to the point where I can try setting up SMC3 and I am having trouble getting the Sabertooth's to respond.

    I uploaded the SMC3 SPS script to the Arduinos fine and it communicates with the Arduinos. The pots are working fine because if I move them by hand I can see them move on screen but I can't get the motors to move at all.

    When I apply power to the Sabertooth I just get the status light coming on. nothing else. I am using a brand new Sabertooth 2x60 and a Syren 50 and I am having the same problem on both of them. I have tried doing the jumpers to autobaud but still nothing

    I have checked the input voltage to the Sabertooth is fine at 12V but there is 0V on all of the motor outputs when I try to move the motors.

    I followed the steps in the first post and here are my initial setting, I'm sure I am just doing something dumb.

    upload_2017-10-31_22-16-2.png

    Here is a link to my build thread if you want to see how I have wired everything.

    https://www.xsimulator.net/communit...t-mover-gs-4-simvibe.5596/page-25#post-143435

    Attached Files:

  6. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    @Avenga76 SMC3-SPS does not support SyRen controllers. It has been optimized for use at 115200 baud for Sabertooth controllers and the maximum the SyRen supports is 38400. That said if you change the instances of 115200 in the sketch to 38400 it should then work with a SyRen although you may need to increase the Fpid setting.

    If you have your Sabertooth serial input wired correctly, set the dipswitches correctly, and had it powered before you powered the arduino then it should be autobauding. Did you reset the arduino each time you made a jumper change to autobaud? If so and its still not working then there's a chance your Sabertooth is set on 2400 baud and I didn't include a jumper for that. Find this code in the sketch and change 19200 to 2400 then upload it to the arduino.

    if (digitalRead(9) == LOW){
    mySerial.begin(19200);

    Then set jumper 9, power the sabertooth, and reset the arduino.
    • Informative Informative x 2
  7. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Cool, Thanks for that info. I didn't have the sabertooth powered on when I started the Arduino so I will give that a try, and I will tweak the sketch for the syren
  8. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Just tried it again. The sabertooth is working fine. Just need to start them in the other order.
  9. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    I trying to tweak the sketch for the syren but I'm not having much luck.

    In the sketch it looks like this is where the serial baud rates are set up, which one do I change?

    void setup()
    // set the data rate for the SoftwareSerial port
    #ifdef SECOND_SERIAL
    mySerial.begin(115200);
    #endif
    #ifdef MODE3
    {
    pinMode(8, INPUT_PULLUP);
    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);
    pinMode(11, INPUT_PULLUP);
    pinMode(12, INPUT_PULLUP);
    if (digitalRead(8) == HIGH){
    Serial.begin(500000);
    }
    else
    {
    Serial.begin(115200);
    }
    if (digitalRead(9) == LOW){
    mySerial.begin(19200);
    ST[0].setBaudRate(115200);
    ST[1].setBaudRate(115200);
    mySerial.end();
    }
    else if (digitalRead(10) == LOW){
    mySerial.begin(38400);
    ST[0].setBaudRate(115200);
    ST[1].setBaudRate(115200);
    mySerial.end();
    }
    else
    {
    mySerial.begin(9600);
    ST[0].setBaudRate(115200);
    ST[1].setBaudRate(115200);
    mySerial.end();
    }
    mySerial.begin(115200);

    If I change the last instance of 115200 then I get this error in SMC

    smc 1.JPG
  10. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Hmm. I think the Syren is going to be harder to get going with packet serial.

    It's not like the Sabertooth where you can set the baud rate once and it will keep that setting. With the Syren you need to send the baud speed as the first character sent after they Syren boots, and you need to set it each time you start the syren. You could probably get the sketch to send that character first but I am not a programmer so I wouldn't know how to make the arduino do that. Any ideas? I might have to run it in simple serial instead.

    https://www.dimensionengineering.com/datasheets/SyRen50.pdf

  11. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Okay, with a combination of luck, magic and bad programming I managed to get it going with the Syren.

    I remarked out all the auto baud stuff, and then added a " mySerial.begin(38400);" to set it to 38,400 then I used "mySerial.write(170);" to send a 10101010 packet to the SyRen. It used this packet to detect the baud rate that it will run at. This does mean that I need to start or reset the Arduino or after I boot up the SyRen because it will just sit there until it receives the 10101010 packet.

    I still get that warning in the screen shot above but it seems to sort itself out.

    Here is the part of the sketch I modified.

    // set the data rate for the SoftwareSerial port
    #ifdef SECOND_SERIAL
    mySerial.begin(115200);
    #endif

    #ifdef MODE3
    {
    pinMode(8, INPUT_PULLUP);
    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);
    pinMode(11, INPUT_PULLUP);
    pinMode(12, INPUT_PULLUP);
    if (digitalRead(8) == HIGH){
    Serial.begin(500000);
    }
    else
    {
    Serial.begin(115200);
    }
    // if (digitalRead(9) == LOW){
    // mySerial.begin(19200);
    // ST[0].setBaudRate(115200);
    // ST[1].setBaudRate(115200);
    // mySerial.end();
    // }
    // else if (digitalRead(10) == LOW){
    // mySerial.begin(38400);
    // ST[0].setBaudRate(115200);
    // ST[1].setBaudRate(115200);
    // mySerial.end();
    // }
    // else
    // {
    // mySerial.begin(9600);
    // ST[0].setBaudRate(115200);
    // ST[1].setBaudRate(115200);
    // mySerial.end();
    // }
    mySerial.begin(38400);

    if (digitalRead(11) == HIGH){
    ST[0].setTimeout(100);
    }
    if (digitalRead(12) == HIGH){
    ST[1].setTimeout(100);
    }
    mySerial.write(START_BYTE);
    mySerial.write(170);
    mySerial.write(END_BYTE);
    #endif

    Another quick question.

    The POT I use is a 1 turn pot and my range of motion is only about quarter of a turn. This means I can adjust the motor and clip limits enough. If I put them all the way up to 255 then they are still ages away from where the limits of my motion is. Is there a way to change this or do I need to swap the pots for half turn ones?

    smc 2.JPG
  12. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    • Informative Informative x 1
    • Useful Useful x 1
  13. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    I have some good news for you @Avenga76 . The information in the SyRen 50 manual about baud rate selection is simply wrong. While that is how you set the baud rate on v1 controllers the SyRen 50 is a v2 controller as is the Sabertooth 2x60.

    And also while there is no mention in any documentation about the SyRen doing 115200 baud I got to thinking that as a v2 controller too it should be able to do the same as the 2x60. So I used Describe software and looked at the packet serial baud settings available for the SyRen 50 and sure enough 115200 is available even though 38400 is as fast as documentation states.

    Therefore running SMC3-SPS without modification on the SyRen 50 should work the same as it does on the 2x60 after all. If you can verify this I will add the SyRen 50 to the supported controllers list.

    About your pots, while scaling them will bring them up to the range you want their resolution will remain the same. Therefore if you find that the motors don't respond as well as you think they should you may need to trying increasing resolution by using other pots.
    • Like Like x 1
    • Informative Informative x 1
  14. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Cool. I will give it a try with the standard sketch tonight and let you know how I get on.
  15. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    No luck running the normal sketch.

    The only way I can get it working is using the modified sketch and then send the 10101010 packet then run it at 38400
  16. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    Are you sure you must send the bauding character? In other words, have you ever tried running at 38400 only without sending the packet first? I suspect that your SyRen has 38400 stored in its eeprom and that's why its working with an arduino at 38400.

    In any case, one thing or the other is incorrect in Dimension Engineering's information on their site because both the SyRen 50 manual and this can't be true.

    // Set Baud Rate Sample for Packet Serial
    // Copyright (c) 2012 Dimension Engineering LLC
    // See license.txt for license details.

    // WARNING: This sample makes changes that will persist between restarts.
    // NOTE: The setBaudRate function will only have an effect on V2 controllers (2x12, 2x25 V2, 2x60, SyRen 50).
    // Earlier controllers automatically detect the baud rate you choose in Serial.begin
    // when you call the autobaud function. Autobaud was replaced in V2 controllers for reliability
    // in the event that the Sabertooth lost power.
  17. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    Btw, if it still works then run SMC3-SPS with pin 10 grounded to step it up to 115200.
  18. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    It seems to be persistent because I can power down to the SyRen and then it will keep the 38400 when I power it back on.

    When I first got it going I had to use the bauding character to intially set the baud rate because the motors wouldn't move at all before I added that, but it looks like after I set it once then it has stayed persistent in the eeprom somehow.

    I'll try grounding pin 10 tonight.
  19. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    No luck with grounding pin 10.

    It still stays at 38400.

    Although now that it is set to 38400 then I can just run the standard sketch and just change the mySerial.begin(115200); to mySerial.begin(38400);

    I still do get this error, but if I click ignore then switch from motor 1 to motor 2 then back again then it starts working okay, so I can live with that.

    smc 4.JPG
  20. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Okay, so something went really wrong on my first test drive.

    Everything was running well in the SMC but then I tried it in iRacing and it way overshot the limits.

    I have my max limits set at this angle.

    [​IMG]

    But something went wrong and it overshot all the way around and wedged itself into the wheel for my rear traction loss.

    [​IMG]

    [​IMG]

    The motor was still running hard when it hit the wheel because the stall current blew my main fuse.

    [​IMG]

    It didn't feel like an out of control oscillation, it just felt like it spun around in one movement and then blew the fuse. Not sure why the limits didn't kill the power to the motors.