orangenarwhals topnav

Friday, June 24, 2011

how to set up arduino + pololu mini maestro (for an 18 servo hexapod)

EDIT 4 Dec 2012:
As of august 2012-ish (I haven't tried to run hexapod since then, because I ate my pololu controller sometime while dragging my hexapod all around the country this summer >__< Ugh I fail at taking care of expensive electronic things), there are some syntax changes if you're using the latest version of arduino because newsoftserial is now built into arduino, not a separate library.

this post because pololu has awesome documentation but dear lord is it long and difficult to wade through when I'm fairly new to this stuff. Also, I finally figured out the sad-servo problem that was plaguing me for a week.

Fig. 1

My current setup: eighteen servos on maestro pins 1-18 (pin 0 left empty), VSRV=VIN jumper has been removed. 8.4V battery pack fed through 5V linear regulator on carrier board. The servo wire with with masking tape comes from PIN2 of the carrier board/arduino setup and is supplying the pololu controller with GND, VIN, and the serial signal. Red and black wires going from breadboard on carrier board to VSRV on maestro.

we should take a servo female-female wire, put one end on servo male header pins for pin 2 of Arduino.

RX/TX and Microntroller power: Put other end white wire (or yellow or whatever wire is SIG) on RX on maestro, and red (VIN) and black (GND). Should look like pic above, the wire-with-masking-tape, with black facing "out" toward the USB port.

Servo power: see pic above, the two non-servo cables (the red wire and black wire going to the breadboard) are screwed into the blue terminal block on the maestro. The breadboard has 5V and GND from the 8.4V battery going through the linear regulator on the carrier board. I'm actually stealing 5V from a servo pin. See the black wire soldered to Dig9Output, 5V in the upper left of this pic (which is actually carrying 5V, not GND) (via a female header pin so I wasn't soldering straight to the carrier board pins) (ignore the gazillion extraneous wires)

the single pin (pololu RX) inside the masking-tape-servo-cable is a sad pin. The cable also falls off often.

I used the jumper originally because I was thinking I would need two batteries (one for VSRV one for VIN) or something otherwise. But hey look, it's setup to be neater without the jumper, I'm still only dealing with one battery, and my hexapoddoesn't work with the jumper on. u___u

1) newsoftserial should be downloaded from the internet and the folder inside the zip put in (path to where you unzipped arduino)/arduino/libraries/ (e.g. for ubuntu 10.10 via the repository, /usr/share/arduino/libraries)

And the code from http://www.pololu.com/docs/0J40/5.e or from above means:
a. BYTE is a parameter that pecifies the base (format) to us http://www.arduino.cc/en/Serial/Print
b. target is a non-negative integer less than 8192 (it can be written in binary notation with 14 or fewer digits)e.g. 6000, or in binary: 01011101110000
c. 0x7F is 01111111 in binary, which infinity zeros to the left, so "&"ing (bitwise AND) it masks out all the digits in target (when target is written in binary) except the last 7 digits (only 1 AND 1 == 1. all other combinations == 0)

01011101110000
& 00000001111111
= 00000001110000

d. right shift operator, shifts last seven digits (numbers 7 through 13) in target off into empty space and so now the "new" last seven digits were originally bits #0 to 6 (see color-coded pololu doc). Mask with 0x7F again, just to be sure.