- Notifications
You must be signed in to change notification settings - Fork 13.3k
Unacceptable defaults that destroy servos #7023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0827917
a2a1e0d
86caa07
cc26161
e7695a9
4c4906f
c551dc2
ac0f239
ef33c5f
66933c1
2f1e390
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -27,9 +27,9 @@ | |
// | ||
// Servo - Class for manipulating servo motors connected to Arduino pins. | ||
// | ||
// attach(pin ) - Attaches a servo motor to an i/o pin. | ||
// attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds | ||
// default min is 544, max is 2400 | ||
// attach(pin) - Attaches a servo motor to an i/o pin. | ||
// attach(pin, min, max) - Attaches to a pin setting min and max values in microseconds | ||
// default min is 1000, max is 2000 | ||
// | ||
// write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) | ||
// writeMicroseconds() - Sets the servo pulse width in microseconds | ||
| @@ -44,13 +44,17 @@ | |
| ||
#include <Arduino.h> | ||
| ||
// the following are in us (microseconds) | ||
// | ||
#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo | ||
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo | ||
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached | ||
#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds | ||
#define MAX_SERVOS 12 | ||
// The following values are in us (microseconds). | ||
// Since the defaults can be overwritten in the new attach() member function, | ||
// they were modified from the Arduino AVR defaults to be in the safe range | ||
// of publically available specifications. While this implies that many 180° | ||
// servos do not operate the full 0° to 180° sweep using these, it also prevents | ||
// unsuspecting damage. For Arduino AVR, the same change is being discussed. | ||
#define DEFAULT_MIN_PULSE_WIDTH 1000 // uncalibrated default, the shortest duty cycle sent to a servo | ||
#define DEFAULT_MAX_PULSE_WIDTH 2000 // uncalibrated default, the longest duty cycle sent to a servo | ||
#define DEFAULT_NEUTRAL_PULSE_WIDTH 1500 // default duty cycle when servo is attached | ||
#define REFRESH_INTERVAL 20000 // classic default period to refresh servos in microseconds | ||
#define MAX_SERVOS 9 // D0-D8 | ||
| ||
#if !defined(ESP8266) | ||
| ||
| @@ -63,8 +67,16 @@ class Servo | |
public: | ||
Servo(); | ||
~Servo(); | ||
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure | ||
uint8_t attach(int pin, uint16_t min, uint16_t max); // as above but also sets min and max values for writes. | ||
// attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure. | ||
// returns channel number or 0 if failure. | ||
uint8_t attach(int pin); | ||
// attach the given pin to the next free channel, sets pinMode, min, and max values for write(). | ||
// returns channel number or 0 if failure. | ||
uint8_t attach(int pin, uint16_t min, uint16_t max); | ||
// attach the given pin to the next free channel, sets pinMode, min, and max values for write(), | ||
// and sets the initial value, the same as write(). | ||
// returns channel number or 0 if failure. | ||
uint8_t attach(int pin, uint16_t min, uint16_t max, int value); | ||
| ||
void detach(); | ||
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds | ||
void writeMicroseconds(int value); // Write pulse width in microseconds | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tech-TX These are the hard-coded limits.