Pages: [1]   Go Down
Author Topic: PWM Servo library following the writeAnalog API model  (Read 928 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.

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

* PwmServo.h (1.17 KB - downloaded 10 times.)
* PwmServo.cpp (8.29 KB - downloaded 21 times.)
* keywords.txt (0.61 KB - downloaded 7 times.)
* pwmServoTest.ino (1.07 KB - downloaded 5 times.)
Logged

Pages: [1]   Go Up
Jump to: