Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

multiple sabertooth controlled by raspberry pi

Mon Aug 03, 2020 8:31 pm

hi everyone,

recently I've been working on a robot and I have had issues with using multiple sabertooth motor controllers with a raspberry pi 3b+. I have had success controlling just one sabertooth 2x60 but as soon as I tried controlling another sabertooth, the system crashed and now my original code won't work for any of my sabertooth motor controllers. bellow is my code. the only thing I changed to try and get the raspberry pi to work with another sabertooth controller is changing the GPIO outputs. thanks for the help guys!

Code: Select all

import RPi.GPIO as GPIO
import time


PIN_MOTOR1=12 #S1
PIN_MOTOR2=19 #S2

try:
    while True:
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(PIN_MOTOR1, GPIO.OUT)
        GPIO.setup(PIN_MOTOR2, GPIO.OUT)
        GPIO.output(12,GPIO.HIGH)
        GPIO.output(19,GPIO.LOW)
        motor1 = GPIO.PWM(PIN_MOTOR1,1000)
        motor2 = GPIO.PWM(PIN_MOTOR2,1000)
    #go forward
        motor1.start(100)
        motor2.start(100)
    #GPIO.output(PIN_MOTOR1,GPIO.HIGH)
        time.sleep(1000)


    #go back
        motor1.start(25)
        motor2.start(25)
    #GPIO.output(PIN_MOTOR1,GPIO.LOW)
        time.sleep(5)


    #stop
        motor1.stop()
        motor2.stop()
 
except KeyboardInterrupt :
    pass
except :
    GPIO.cleanup()
    raise
GPIO.cleanup()

User avatar
rpiMike
Posts: 1432
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: multiple sabertooth controlled by raspberry pi

Thu Aug 06, 2020 9:40 pm

Why are you using 2 sabertooth controllers?

How have you wired 2 controllers to the Pi?

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Sun Aug 09, 2020 9:08 pm

first off, they are all connected through a level converter, then the S! and S2 connections are connected to different GPIO pins. doe sthat answer your question. also sorry for answering so late

User avatar
rpiMike
Posts: 1432
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: multiple sabertooth controlled by raspberry pi

Sun Aug 09, 2020 9:34 pm

No, you didn’t answer why you need 2 controllers.

As far as I am aware the Pi3B+ only has one serial interface on the GPIO pins, so you can only connect one controller to GPIO.

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Sun Aug 09, 2020 11:19 pm

for my project, I need to control four motors for the drive, two motors for the arm, and one motor for a grip. I just thought I could control three sabertooth motor controllers from the raspi. is there a better way to do this?

User avatar
rpiMike
Posts: 1432
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 7:11 am

You could connect the 2nd controller with a serial to usb converter.

User avatar
joan
Posts: 14989
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 7:33 am

What control mode do you want to use? You can send servo pulses to S1 and S2 to separately control the two motors on one controller.

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 2:42 pm

but can I do that with one raspberry pi for three separate motor controllers?

User avatar
joan
Posts: 14989
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 2:55 pm

@Socialmedia

Yes, if you are talking about sending servo pulses to 3 controllers (i.e. six different servo pulses).

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 3:11 pm

okay, cool. so what mode would this be? sorry for the rudimentary questions I just started to learn programming.

User avatar
joan
Posts: 14989
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 3:21 pm

This isn't a software mode, it's an operation mode of the sabretooth 2x60 controller according to its pdf.

I am assuming you know the mode you are currently using.

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 3:24 pm

I am in serial mode rn

Socialmedia
Posts: 8
Joined: Mon Aug 03, 2020 6:58 pm

Re: multiple sabertooth controlled by raspberry pi

Mon Aug 10, 2020 3:27 pm

Ahhh. I see that now, thank you

Return to “Automation, sensing and robotics”