Forgive my lack of understanding in this area and if my title is incorrect.
I am trying to control a Sabertooth motor driver board which I can connect my Raspberry Pi to in two ways. 1. USB to Micro USB on Motor Driver 2. GPIO - Logic Level Shifter - Motor Driver
My understanding is that I can control the motors by sending plain text serial commands so according to the Sabertooth manual to drive a motor forward at half speed I send the following command: M1 1023\r\n
So my test code would look like this:
#!/usr/bin/python3 import serial from time import sleep ser = serial.Serial('/dev/ttyAMA0', 9600) #enter correct port for serial def main(): # write data to serial port ser.write("M1 1023\r\n") sleep(1) ser.write("M1 0\r\n") sleep(1) ser.write("M2 1023\r\n") sleep(1) ser.write("M2 0\r\n") sleep(1) ser.write("M1 -1023\r\n") sleep(1) ser.write("M1 0\r\n") sleep(1) ser.write("M2 -1023\r\n") sleep(1) ser.write("M2 0\r\n") main()
A couple of questions:
I am struggling to understand the correct serial port syntax for the USB connection or the GPIO connection. My guess is that I need to plug the Sabertooth in via USB to find the correct USB name using 'ls usb' or 'dmesg'?
What would the GPIO device name be?
What would the correct baud rate be?
I will be using WebIOPi eventually but want to test using command line first. (can't quite get my head around how to use WebIOPi yet so will start a different thread on that) I have installed it and can switch an LED on connected to the GPIO using the GPIO GUI.
This is a Pi 2 (40 Pin)