PWM frequency N2 or N3


Currently I own a N1 plus and a N2 plus, they’re pretty cool.
I’m also considering a N3 with wifi (because wifi).

I’m thinking about driving LED strips with them and a MOSFET.
For the sake of making them “flicker free” I’d need a high frequency PWM, maybe a couple of KHz or something.
I know the arduino is capable of around 8KHz, which is quite nice.

I couldn’t find the actual range that netduino supports other than the microsoft documentation using doubles:
I can certainly make big numbers there :smiley:
The other part of the documentation is talking about microseconds: which would result in about 4KHz if you want 256bit accuracy I guess.
Would this actually be feasible and is the output “clean” at these frequencies?

How is the PWM generated actually? I quick look in the spec-sheet of the chip shows 2 12bit DAC’s with triangle and noise wave generation. Or is the Netduino firmware using timers?

Thanks :slight_smile:

edit: oh yeah, pretty cool the Netduino project received some new life from wilderness labs! Especially the last few years I haven’t felt very confident about the development of the product, but now I feel some new energy to make things again :smiley:

I bought a mini scope (DS203) to test the PWM myself on my N2+.
I used the following code to get a nice moving pwm signal:

PWM pwm6 = new PWM(PWMChannels.PWM_PIN_D6, 100, 10, PWM.ScaleFactor.Microseconds, false);

        if (pwm6.Duration > pwm6.Period * 0.9)

    while (true)


        if (pwm6.Duration < pwm6.Period * 0.1)

It seems to work quite well, the scope confirms the 0.100mS I set in my code:

When I switch to nano seconds scaling with a period of 10000 the duty cycle just jumps up with 1uS every 10% increase in duration. So I guess there’s some false precision going on here.
When setting the period to 1000uS the signal is no longer PWM but just high or low. I guess the limit from MSDN (microsecond) holds up here resulting in a maximum PWM frequency of 1MHz. Kinda useless to mention nano seconds in the scaling factor imho.

Conclusion for me is that I can have an accurate 10bit PWM at about 1KHz :grinning:

I think the problem may come from the values being used.

PWM pwm6 = new PWM(PWMChannels.PWM_PIN_D6, 2000, 1000, PWM.ScaleFactor.Nanoseconds, false);

This will generate a 500 KHz signal with a 50% duty cycle. This is equivalent to:

PWM pwm6 = new PWM(PWMChannels.PWM_PIN_D6, 2, 1, PWM.ScaleFactor.Microseconds, false);


Hi Mark,

Sure, that’s the same thing. I was trying to find out if you could actually use timings below microseconds.
But you can’t increase the resolution higher than integer microseconds, so why bother using nanoseconds?
Microsoft just advertises false hope for non-existing resolution by providing that scale factor basically.