pololu maestro servo controller

11 Feb 2012

Has anyone had experience with controlling the Pololu Maestro Servo Controller ( http://www.pololu.com/catalog/product/1352 )??? A library would be handy.. (I'm not that great at creating them...plus there's a lot of conversions that trip me up....) I found this ( http://mbed.org/users/Torsten/programs/pololu_class/lhb1d6/docs/main_8cpp_source.html ) and it looks like the compact control code...or the older code....doesn't seem to work with this device.....

Any help or word in the right direction would be really appreciated!!! (this is my last step in getting this quad copter off the ground!)

16 Feb 2012

If not, can someone lend a hand on converting the decimal value for the servo position into the binary numbers required?

Quote:

The Maestro has several serial commands for setting the target of a channel, getting its current position, and setting its speed and acceleration limits.

Set Target (Pololu/Compact protocol)

Compact protocol: 0x84, channel number, target low bits, target high bits Pololu protocol: 0xAA, device number, 0x04, channel number, target low bits, target high bits

The lower 7 bits of the third data byte represent bits 0–6 of the target (the lower 7 bits), while the lower 7 bits of the fourth data byte represent bits 7–13 of the target. The target is a non-negative integer.

If the channel is configured as a servo, then the target represents the pulse width to transmit in units of quarter- microseconds. A target value of 0 tells the Maestro to stop sending pulses to the servo.

If the channel is configured as a digital output, values less than 6000 tell the Maestro to drive the line low, while values of 6000 or greater tell the Maestro to drive the line high.

For example, if channel 2 is configured as a servo and you want to set its target to 1500 µs (1500×4 = 6000 = 01011101110000 in binary), you could send the following byte sequence:

  • in binary: 10000100, 00000010, 01110000, 00101110
  • in hex: 0x84, 0x02, 0x70, 0x2E
  • in decimal: 132, 2, 112, 46

Here is some example C code that will generate the correct serial bytes, given an integer “channel” that holds the channel number, an integer “target” that holds the desired target (in units of quarter microseconds if this is a servo channel) and an array called serialBytes:

  • serialBytes[0] = 0x84; Command byte: Set Target.
  • serialBytes[1] = channel; First data byte holds channel number.
  • serialBytes[2] = target & 0x7F; Second byte holds the lower 7 bits of target.
  • serialBytes[3]= (target >> 7) & 0x7F; Third data byte holds the bits 7-13 of target.

Anyone have a suggestion on how to code that...? If I need 1500us, I can multiple that by 4 and get the 6000... but then how do I write the code to get the msb lsb in binary from that and push that out a serial port to the maestro device?

Any help is really appreciated.. I've been attacked by this thing twice now.. It's going for blood.... lol

17 Mar 2014

Check out my mbed library for Pololu Maestro Servo Controller: http://mbed.org/users/kochansky/code/Maestro/docs/c952ac46bd39/classMaestro.html ;)