I have recently purchased an a4wd3 rover kit with the RC and was wondering if you could point me to any example code that I could use to help me get started. In the future I will be connecting a Pi to the Sabretooth motor controller, so any related examples on that would also be appreciated.
Would you mind to give us the model of Lynxmotion A4WD3 Rover you purchased ?
(we were not able to verify this with your community email address, no order in the system)
Our RC version do not require any code to run.
The receiver is connected directly to the Sabertooth motor controller.
We do have some example code available for kits which include an Arduino controller: Lynxmotion/Rovers/A4WD3
I have purchased the RC version using my registered work email address. The order was placed on 9th May.
After testing the RC version I would like to run the code from a Pi and was therefore wondering if there was any examples on how to connect the sabretooth to the Pi and send signals to the motors.
I require your help regarding a problem I’m encountering and you seem like an expert in your field so I thought I would take a shot in asking for your assistance.
Description:
My supervisor purchased an A4WD3 Rugged Wheeled Autonomous Rover from RoboShop to be used for my masters thesis project, and I am having some trouble wiring the motor encoders to the botboarduino. I am trying to build this autonomous rover to be able to control it using code, and to serve as a mobile base for my tethered drone.
I have tried looking at the wiki instructions, done some research and even inquired through chatGPT to pinpoint if other people have assembled the rover successfully using the components provided to us when purchased but I found nothing. I connected the motors positive and negatives to the sabertooth 2x12 provided, and connected the encoders to the I/O buses with the black on the edge, red in the middle and blue on the inside of the board (on row 10), with the other encoder green encoder output on the next lines inside pin (on row 11). I have no experience using the arduino environment but i have been researching and tried out this sample code provided to me through chatGPT to try to get rotation on just one of the motors, just to test it out, but once I uploaded it onto botboarduino, i got no movement. The sabertooth motor controller is connected to the botboarduino through its Positive and Negative output, and Signal output S1, to I/O bus line 13. Sabertooth switches are as follows:
1: off
2: on
3: on
4: off
5: on
6: off
Could you kindly help me understand what i might be doing wrong and how to fix it, along with a potential code to assist me in understanding how to control the motors using Sabertooth and the botboarduino board? Hardware concerned:
Sabertooth 2x12 motor controller
Botboarduino : 3.00" x 2.30" with 0.125" holes set in 0.15" from each edge
4 Motors: Gear Motor (36GP 540-51-EN)
Software concerned:
Arduino Environment
Troubleshooting steps already taken:
Additional information:
Code used:
#include <Sabertooth.h>
// Define the motor controller’s address
#define SABERTOOTH_ADDRESS 128
// Define the motor channel
#define MOTOR_CHANNEL 1
// Define the encoder pins
#define ENCODER_A 10
#define ENCODER_B 11
// Define the motor speed
#define MOTOR_SPEED 100
// Define forward and backward
#define FORWARD 1
#define BACKWARD -1
// Create an instance of the Sabertooth class
Sabertooth ST(SABERTOOTH_ADDRESS);
void setup() {
// Set the encoder pins as inputs
pinMode(ENCODER_A, INPUT);
pinMode(ENCODER_B, INPUT);
// Set the motor speed to zero
ST.motor(MOTOR_CHANNEL, 0);
}
void loop() {
// Read the encoder values
int encoderA = digitalRead(ENCODER_A);
int encoderB = digitalRead(ENCODER_B);
// Determine the direction of rotation based on the encoder values
int direction = (encoderA == HIGH && encoderB == LOW) || (encoderA == LOW && encoderB == HIGH) ? FORWARD : BACKWARD;
// Set the motor speed and direction
ST.motor(MOTOR_CHANNEL, MOTOR_SPEED * direction);
}
Thank you so much in advance for your help!
Your assistance would be greatly appreciated in any way. I also attached some photos of the current set up I have for wiring. I have only one motor encoder connected just to test it out
The first thing to do would be to look at our official example code instead of using ChatGPT.
Also, the BotBoarduino alone does not allow you to use 4 encoders as there are not enough I/O that can handle that type of signals.
We do not make use the Encoders at all in our sample code. The encoders are supplied if someone would like to use them.