Go Down

Topic: Multiple PWM Outputs with Unique Frequencies (Read 24160 times) previous topic - next topic


Hi there @kwasek83,

I am afraid that I need more information to be of any help.

At first sight, I suspect that is the -std=gnu++11 flag. In any case, to be sure, attach the output of the whole compilation process to know what is happening.



             Thanks for the library I do get some nice clean signals driving some transducers at 40khz.

I wanted to ask if you might have an example or an idea of how to accurately control the phase of PWM using your library.  Ideally Id like to get 12 channels or the maximum outputs I can with the DUE.

The basic_test code provided resulted in a out of phase signal of around 6us.  Id like to be able to sync the phases or adjust the phase.

Tested on it on an tektronix scope


Hi there @carbon_adam,

For changing the period (the frequency) of a PWM signal with pwm_lib you can use the method set_period_and_duty(), it modifies the period (and the duty). Have a look to example changing_period_test.ino. Update the last version of the library, because this feature has had a big change this last week to solve an important bug.

As to how many PWM signals you can manage with pwm_lib, you can manage 8 independent PWM signals using pwm_lib (the ones available in the ATSAM3X8E). Take into account that you can have for each channel, two signals, a PWM signal and its negated version. You might also generate PWM signals using any of the nine timer/counters available in the TC module of ATSAM3X8E. Have a look to the data-sheet to know how.

In addition, according to ATSAM3X8E's data-sheet you will see than you might synchronize the PWM channels to be in phase, I don't know if this is what you need. Unfortunately this feature is not available in pwm_lib, I have not had the necessity to have PWM synchronized channels.

I hope it helps.


Hello Guys, I am new to Arduino DUE. I need PWM frequency of 100 kHz. Please suggest me the ways how can i get it?


Hello, I need only one PWM port but with 100 kHz. How to get it on Arduino Due?

Go Up