This topic has 5 replies, 2 voices, and was last updated 8 years, 6 months ago by SuperDroid.
- AuthorPosts
- May 3, 2016 at 1:57 pm #3391beechParticipant
Hi,
I have your xbee analog joystick hooked up to a sabertooth 25 and it works perfect. However, i’m now trying to simplify by eliminating the wireless xbee and run a joystick straight from 1 arduino to a sabertooth MC. I was smart enough to order another joystick and MC from you, but that is where my brilliance ends. My arduino knowledge is so limited that I can’t seem to figure out how to eliminate the xbee code and combine XBee_joystick.ino and XBee_reciever.ino to run from a single uno. Any guidance would be appreciated.
May 3, 2016 at 2:40 pm #3392SuperDroidKeymasterHi,
To make this work, you need to:
1. Read the joystick values by calling analogRead(axis1pin) and analogRead(axis2pin). These reads will give you values from 0-1023.2. Scale both of your analogRead values from 0-1023 down to the range -127 to 127. In XBee_receiver.ino, these values are scaled down to 0-255 then sent to the receiver. XBee_receiver then subtracts 127 to get the correct range. Let’s call these values drive_value and turn_value.
3. Use the Sabertooth library’s ST_control.drive(drive_value) and ST_control.turn(turn_value) to control your motors. You can see this happening near the end of loop() in XBee_receiver.ino. It sounds like you have the Sabertooth library installed correctly, so in the Arduino IDE you should be able to go through File->Examples->Sabertooth to find some example sketches that make use of the Sabertooth library if you want. Also, make sure you call ST_control.autobaud() in setup() to initialize the Sabertooth to the correct baud rate.
May 17, 2016 at 2:41 pm #3431beechParticipantThank you for your reply, very helpful.
Back to the Xbee Joystick, can I change the sensitivity of turn? Drive is fine, but turn which is on “analogRead(A0)” is overly aggressive for my project. Again, this is my first time with arduino so maybe i’m just missing obvious settings in the joystick’s .ino file
Thanks again,
May 17, 2016 at 3:07 pm #3432SuperDroidKeymasterYou could reduce turn_value by some factor before sending the speed command to the Sabertooth. For instance, this would reduce your turn rate to 2/3 range:
turn_value = 0.67 * turn_value;
ST_control.turn(turn_value);May 25, 2016 at 9:53 am #3443beechParticipantthank you, that seems to work but wanted to make sure i’m not interfering with your inputBuffer and reduction from 255.
if (inputBuffer[0] == 'S' && inputBuffer[1] == 'D' && inputBuffer[2] == 'R' && inputBuffer[5]==(inputBuffer[3]+inputBuffer[4])>>1) { drive=-(inputBuffer[3]-127); //Normalize values once the header and checksum have passed turn=inputBuffer[4]-127; // Drive and turn commands //wire connect = turn black to m2a / drive red to m1a ST_control.drive(drive); // 5/22 test @ 67% turn=0.15 * turn; ST_control.turn(turn); }
May 25, 2016 at 10:12 am #3446SuperDroidKeymasterThis is correct since you’re scaling the turn value after the packet has been checked and normalized.
- AuthorPosts
You must be logged in to reply to this topic.