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