12-bit Servo PWM resolution on Arduino Zero

Hi Everyone
i need to get 12-bit Servo PWM resolution on Arduino Zero , But how !
Best,,

Final-05.ino (3.12 KB)

I just discovered that I forgot to publish the Servo library for the Zero. I'm doing it right now.

Maybe the problems you're facing are due to this?

Otherwise may you explain better what are you trying to do?

what about the "normal" analogWrite().

Can you increase the resolution on the PWM-Pins on the Zero with the function analogWriteResolution()
and if yes how many bits ? (up to 32bit ?)

Can you use same analogWrite() command for the 1 channel DAC on the Zero,
and is the resolution set to 10bit by default in this case ?
or can you use analogWriteResolution() as well for the DAC ?

@robotage
I've updated the Servo library.
Please use the library manager to install version 1.1.0 that works on the Zero board too.

Dirk67:
Can you increase the resolution on the PWM-Pins on the Zero with the function analogWriteResolution()
and if yes how many bits ? (up to 32bit ?)

Yes, analogWriteResolution() works. You can change the resolution to anything between 1-bit and 32-bit, though the real resolution of the device may be more or less than requested and padding or truncation may occur respectively.

Dirk67:
Can you use same analogWrite() command for the 1 channel DAC on the Zero,
and is the resolution set to 10bit by default in this case ?
or can you use analogWriteResolution() as well for the DAC ?

default is 10 bit, and you can use analogWrite() and analogWriteResolution() as well.

(In case of PWMs the real resolution on the Zero board is fixed to 8bit, in case of DAC the real resolution available is 10bit)

Thanks again,

In case of PWMs the real resolution on the Zero board is fixed to 8bit,

that surprises me,
cause the SAMD21 Series is known for

Up to five 16-bit Timer/Counters (TC), configurable as either:
[...]
Three 24-bit Timer/Counters for Control (TCC), with extended functions:
[...]

or is it just limited for compatibility issues ?
(or cause of dual-slope operation ?)

Dirk67:
Thanks again,
that surprises me,
cause the SAMD21 Series is known for
or is it just limited for compatibility issues ?
(or cause of dual-slope operation ?)

Thank you for the accurate analysis/review of all the features :slight_smile:

IMHO it's just an arbitrary choice of the original developer, I guess that it could be easily updated to use more bits of resolution. Something to check at some point, do you care to open an issue?

cmaglie:
Something to check at some point, do you care to open an issue?

no,
I think it's not so important, at this time...
to evaluate one can use "arm-gcc syntax" instead (even within the Arduino-IDE), I think ?
(in such cases I just play around in atmel-studio and see what's possible...)

it's just quite interesting which of the (large number of) features of the chip is usable at the arduino IDE and which not ... :slight_smile:

you wrote:

...In case of PWMs the real resolution on the Zero board is fixed to 8bit,...

but on the zero "getting started" page http://www.arduino.cc/en/Guide/ArduinoZero
there is written

...It can support up to 12-bit ADC and PWM resolutions...

?

@cmaglie / @Dirk67
Thank you for reply

am using arduino zero with 12-bit digital servo.
am trying to get 12-bit servo resolution 4096 steps with 330Hz update rate
i was trying analogWriteResolution(12) but i think will not work , because i am using servo.writeMicroseconds.
i think analogWriteResolution(12) work only with analogWrite not with servo.writeMicroseconds.
what do you think
please take a look on the attache file
how can i get 330Hz do i need to play with servo.h :slight_smile:
Best,,

arduino zero have 10-bit DAC is that's mean it will support only 10-bit PWM !
what do you think
Best,,

I think it's true..."arduino zero have 10-bit DAC is that's mean it will support only 10-bit PWM !" but it's also true on the zero "getting started" page http://www.arduino.cc/en/Guide/ArduinoZero is written that "it can support up to 12-bit ADC and PWM resolutions..." So there something false. I'll open an issue