Library for Pololu Maestro Servo Controller http://www.pololu.com/docs/0J40
Library for Pololu Maestro Servo Controller
Library docs: https://developer.mbed.org/users/kochansky/code/Maestro/docs/f374c7b60318/classMaestro.html
Example usage:
#include "mbed.h" #include "Maestro.h" Maestro maestro(PTC4,PTC3); int main() { maestro.setBaudRate(9600); // limit speed for each servo for (uint8_t i = 0; i < 17; i++) { maestro.setSpeed(i, 10); } while (true) { // set servo on channel 0 to 90 degrees maestro.setServoAngle(0, 90); wait(2); // set servo on channel 0 to 45 degrees maestro.setServoAngle(0, 45); wait(2); } }
Serial commands based on manual: http://www.pololu.com/docs/0J40/5.e
Device pinout:
Diff: Maestro.cpp
- Revision:
- 6:1d8357775b6d
- Parent:
- 5:0fd491357750
- Child:
- 7:18a57f597ec4
--- a/Maestro.cpp Mon Jan 06 11:14:19 2014 +0000 +++ b/Maestro.cpp Mon Jan 06 13:16:37 2014 +0000 @@ -33,7 +33,7 @@ setTarget(channel, angle * 40 + 6000); } -void Maestro::setMultipleTargets(uint8_t count, uint8_t firstChannel, uint16_t* targets) +void Maestro::setMultipleTargets(uint8_t firstChannel, uint8_t count, uint16_t* targets) { serial.putc(SET_MULTIPLE_TARGETS); serial.putc(count); @@ -46,15 +46,15 @@ } } -void Maestro::setServosAngles(uint8_t count, uint8_t firstChannel, int8_t* angles) +void Maestro::setServosAngles(uint8_t firstChannel, uint8_t count, int8_t* angles) { uint16_t targets[count]; for (uint8_t i = 0; i < count; i++) { - targets[i] = angles[i] * 40 + 6000; + targets[i] = 6000 + angles[i] * 40; } - setMultipleTargets(count, firstChannel, targets); + setMultipleTargets(firstChannel, count, targets); } void Maestro::setSpeed(uint8_t channel, uint16_t speed)