[riot-devel] Does the servo driver work on atmegas?

Marian Buschsieweke marian.buschsieweke at ovgu.de
Tue Sep 1 20:39:41 CEST 2020


> I was wondering if it is even possible at all. The current version of 
> the PWM peripheral has its resolution limited to 256.

this is because currently only the 8 bit timers are used for PWM. There are
also 16 bit timers that can be used for PWM, but those are not yet implemented.
I heard that @benpicco's avr-rss2 boards have an on-board LED connected to the
16 bit PWM output - so he might jump on this and implement the missing 16 bit
support ;-)

Not that for ATmegas currently only PWM_LEFT is implemented, PWM_RIGHT and
PWM_CENTER won't work. So, double check that you are using PWM_LEFT.

Do you have an logic analyzer at hand to confirm the PWM output is correct?
Otherwise, the brightness of an LED connected to the PWM output should also be
good indicator. (Don't forget to take into account that most ATmegas operate at
5 V when choosing the resistor for the LED ;-)) Does the serve has any
requirements on the PWM frequency?

Kind regards,

On Tue, 1 Sep 2020 20:00:09 +0200
Wouter Symons <wosym at airsantelmo.com> wrote:

> Hello all,
> I spent quite some time yesterday trying to get a servo working on an 
> atmega1284p, unfortunately to no avail.
> I was wondering if it is even possible at all. The current version of 
> the PWM peripheral has its resolution limited to 256. I think this 
> limitation is probably the cause for it not working.
> I tried removing the asserts that enforce this limitation, and this 
> caused the servo to rotate into one direction, but then stop moving 
> again (I could not get it to rotate in the other direction).
> I tried the same servo on a nucleo-board and this worked just fine. 
> However... only with a resolution way higher than 256. (Because STM32 
> does not have this limitation)
> So I wonder... should atmega be blacklisted for this test, since it 
> cannot work? And would there maybe be a workaround to this problem? I'm 
> not that experienced on this matter, so I'm not really sure why the 
> limitation on this resolution was put in place, but is it possible to 
> make changes to the peripheral driver so we can increase it?
> It's also possible that I'm simply doing something very wrong, and that 
> it should work without any changes. (hence the reason I asked on this 
> mailing list instead of opening an issue straight away)
> Kind regards,
> Wouter
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: OpenPGP digital signature
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20200901/3033d65f/attachment.sig>

More information about the devel mailing list