PDA

View Full Version : Anyone got Sabertooth packetized mode to work?



shobley
01-11-2009, 03:28 PM
Has anyone here managed to get packetized serial to work with an Arduino (or any other mc)?

I just tried, and although the bauding character goes through OK, I can't get the Sabertooth to respond to commands. Simple serial seems to work Ok.

If anyone here has ever managed to get this to work, I'd love to take a look at some scope traces of successful packets...

I can't seem to get this to work from a PC either...

Strange.

Nammo
01-11-2009, 06:14 PM
Yes, I've used Sabertooth packetized mode before on an Atmel SAM7 and I just followed the directions exactly as written in the documentation and got working motors. This was on the Sabertooth 2x5. Unfortunately I've dismantled that project, but here's what the code looked like:

uart0Send(128);
uart0Send(1);
uart0Send(lspeed);
uart0Send((128 + 1 + lspeed) & 0x7f);
uart0Send(128);
uart0Send(5);
uart0Send(rspeed);
uart0Send((128 + 5 + rspeed) & 0x7f);

I called this code whenever either the left or right motor speed needed to be updated.

- Nathan

shobley
01-11-2009, 10:41 PM
Hmmm...

That looks a lot like what I'm doing. I read somewhere that the initialization stage can upset the Sabertooth. Maybe I have a faulty controller.

shobley
01-12-2009, 08:24 AM
I managed to get the Sabertooth running with the Roborealm software. Looking at the scope traces the output does not look the same as when I use the Arduino. The bauding character '0xAA' is very clean with roborealm, but with the Arduino in both software and hardware serial modes, it looks quite wrong.

Does anyone know if there is a primer on TTL level serial transmission somewhere? I need to delve into this a bit deeper...

shobley
01-12-2009, 06:47 PM
Here's an update -

This is the output from the FTDI chip when the Roborealm app sends the bauding character:

www.stephenhobley.com/arduino/st_128_bauding_bits.gif (http://www.stephenhobley.com/arduino/st_128_bauding_bits.gif)

With a start bit, and stop bit and 8 data bits this looks like how you would expect 0xAA (10101010) to look with the LSB coming through first.

Now this is the Arduino, same baud rate, and just calling Serial.print(0xAA) :

http://www.stephenhobley.com/arduino/arduino_bauding.gif

What a mess!

Does anyone have *any* idea why all this comes out when just printing a single char? The serial interface to the Arduino must work, as the PC can talk to it, but this makes no sense to me...

Steve

Adrenalynn
01-12-2009, 07:19 PM
It's sending two bytes instead of the one.

Errr - [edit]:

Try Serial.print(170,BYTE); [Just checked my LCD Serial code]

Adrenalynn
01-12-2009, 07:21 PM
I edited, want to bump this back to new.

jes1510
01-12-2009, 07:35 PM
It's sending two bytes instead of the one.

Errr - [edit]:

Try Serial.print(170,BYTE); [Just checked my LCD Serial code]

Yep that looks exactly like what is happening. This may be helpful:
http://www.arduino.cc/en/Serial/Print

Keep in mind that the Arduino wants to print ASCII unless you explicitly tell it otherwise. Also beware of the BIN switch. It doesn't actually print the binary bytes of a number. It prints the ASCII representation of the bytes.

Adrenalynn
01-12-2009, 08:07 PM
Yup! I screwed-up the first time and wrote "print(170, HEX)" without thinking/checking. Something tickled my memory that I fell down there myself with the LCD driver I wrote, and I went and checked (and edited my post). Specifying "BYTE" gets it to send the byte instead of the ascii representation.

shobley
01-25-2009, 08:28 PM
Yep, that was it! Thanks for all the help!

Here's a quick movie of the progress made...

YouTube - Making a robotic Dalek