Go Down

Topic: PWM Servo library following the writeAnalog API model (Read 1 time) previous topic - next topic


My first post!

With my new 2560 I found it had many supported PWM timers.

I wanted to use these PWM timers to drive servos directly.  This will give the project less interupt overhead than the Servo library.

So I followed the API model (and code) for analogWrite() and came up my own library.  The library files and a simple test project are attached for others to enjoy.

The exposed Api is...
Code: [Select]
void pwmServoAttachPin(uint8_t pin, int pwmDutyCycle = pwmServoCenter);
void pwmServoDetachPin(uint8_t pin);
void pwmServoWrite(uint8_t pin, int pwmDutyCycle);

Note that I intentionally left out range checking for the pulses and left this to the application developer.  I am using servos and motor controllers that support a wider range than normal and this would have got in the way.

p.s.  I am long term hobby AVR programmer but have only owned my Arduino Mega 2560 for a few weeks.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131