arduino-libraries / Servo

Servo Library for Arduino
http://arduino.cc/
GNU Lesser General Public License v2.1
257 stars 263 forks source link

ATmega328PB #78

Open KHeintz opened 3 years ago

KHeintz commented 3 years ago

For the AVR I added the ATmega328PB. It has 3 16bit timers. Could address 22 servos. But I limited it to 20 servos, because I only need 20 servos . At TimerServos.h add I the 328PB

#elif defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega2561__)
#define _useTimer3
#define _useTimer1
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t;

In servo.h define I the Atmega328PB with 10 servos on one timer.

#if defined(__AVR_ATmega328PB__)
#define SERVOS_PER_TIMER       10     // the maximum number 10 of servos controlled by one timer at the ATmega328PB
#else
#define SERVOS_PER_TIMER       12    // the maximum number 12 of servos controlled by one timer
#endif

More than 11 servos on a timer makes no sense and everyone should ask themselves how many servos can be accommodated on a timer maximum because of the frame rate. 11 servos means already in the worst case 22ms or more frame rate or 45 Hz or less repetition rate.