Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino Mini highest PWM frequency


  • Please log in to reply
5 replies to this topic

#1 Hugo145

Hugo145

    New Member

  • Members
  • Pip
  • 7 posts

Posted 27 November 2012 - 02:37 PM

Hello,
I've read quite a few threads here regarding internal timers, microsecond delays, native code etc. but still have some questions.
My problem is I want to provide ~16Mhz clock signal to some external device with Netduino Mini and be able to control it. Can you please help me with the following.
1. What is the highest frequency available on PWM outputs with the latest firmware?
2. Is it possible to "count" number of output PWM pulses (or, say, set PWM for exactly N pulses)
3. Is it possible to "count" number of input PWM pulses from external oscillator with interrupts (or other way)? What max frequency can be achieved?
4. If not - how would you accomplish this task?

Thank you very much for any suggestions.

 

Please see updated question below.


Edited by Hugo145, 24 January 2013 - 11:51 AM.


#2 Hugo145

Hugo145

    New Member

  • Members
  • Pip
  • 7 posts

Posted 24 January 2013 - 11:51 AM

What is the default Mini PWM frequency with 4.1 firmware? Is it possible to use new Microsoft.SPOT.Hardware.PWM classes with 4.2.0.1 firmware on Mini and adjust frequency in micro/nanosecond range? Thank you!



#3 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 24 January 2013 - 02:28 PM

Here's a couple of earlier posts on the subject that might help:

 

http://forums.netdui..."pwm frequency"

http://forums.netdui...wm-demystified/

 

As I gather from these posts, default PWM is 10kHz (10.000 cycles per second).

 

Oh, and Stefan also made a class for PWM that can be found in his toolkit which is based on nano seconds:

http://netmftoolbox....re.Netduino.PWM

 

Good luck!



#4 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 24 January 2013 - 03:11 PM

Hi Hugo145,

 

I posted some information about the Microsoft PWM class a few days ago and how to calculate the period for any given frequency and vice versa. Also the post shows you how to calculate the lowest possible frequency.

 

Reasonable frequencies for PWM

 

Essentially the maximum frequency that you can obtain is half of the PWM base clock, which is set to 1Mhz. Therefore you'll notice a maximum frequency of 500Khz at 50% duty cycle. 

 

The MS PWM class also provides you with two constructors:

 

public PWM(Cpu.PWMChannel channel, double frequency_Hz, double dutyCycle, bool invert);public PWM(Cpu.PWMChannel channel, uint period, uint duration, PWM.ScaleFactor scale, bool invert); 

You'll see the second constructor has as a parameter a PWM.ScaleFactor. This enum provides the following options for the scale:

 

public enum ScaleFactor{    Milliseconds = 1000,    Microseconds = 1000000,    Nanoseconds = 1000000000,} 

 

Hopefully this will provide you with the flexibility you are looking for. You can also check out the PWM class on the 4.2 NETMF API however I find that it's missing some information. I find it best to look at the class using the Object Browser in Visual Studio. 

 

Cheers,

Steve



#5 Hugo145

Hugo145

    New Member

  • Members
  • Pip
  • 7 posts

Posted 24 January 2013 - 03:15 PM

Thanks, hanzibal,

I've seen those topics, just wanted to hear a confirmation about 10kHz.

Regarding Stefan's class - it's just a wrapper around original PWM class where he divides passed values by 1000 and calls it nanoseconds. It will not work if native PWM will still be driven at 10kHz, so I want to know whether it is possible to use "new" Microsoft.SPOT.Hardware.PWM class (where I can set scale factor of nanoseconds) with Mini.

 

Thanks, Gutworks,

That's exactly the class I'm talking about. I want to make sure I can use it on Mini with latest 4.2.0.1 firmware, because currently I'm on 4.1 and I will have to flash it.

 

Regards.



#6 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 24 January 2013 - 10:14 PM

I see, I hadn't looked into Stefan's class myself but just assumed it could handle actual PWM periods in the nano second range.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.