Netduino home hardware projects downloads community

Jump to content

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


Member Since 22 Oct 2011
Offline Last Active Mar 26 2012 02:18 PM

Posts I've Made

In Topic: The problem of setting PWM OUT to PWM IN

25 March 2012 - 07:42 PM

Nope, in the current implementation PWM runs at fixed frequency (10 kHz), it is the duty cycle what is changed - so you'd have to measure pulse length between opposite edges (rising - falling).

Thanks, CW2, I've now achieved that with Port.InterruptMode.InterruptEdgeBoth (and modified my post accordingly) and the test output now stacks up (which I have also edited to show the proper output) ... but having said that, I'm still to properly get my head around the implications of duty cycle! But it is nevertheless very good to see that PWM OUT is approximately equal to the same signal taken back in as input and then measured via interrupts!

Additional Edit: Thanks to your prompting, I've found an excellent PWM tutorial, and an excellent Servo tutorial by the same author, and once again modified my post accordingly, as well as adding those two links to it. Thanks again!

In Topic: PWM Input from the ground up

25 March 2012 - 07:34 PM

Hi Anthony,

this is not as difficult as it seems since we have edge driven interrupts on the pins of our Netduinos.

Basically if you have a methods that is called on both the leading (rising edge) and the falling edge of the pin then you can calculate the time between the two. This will give you your pulse width. Since you are not interested in the duty cycle then you won’t be wanting to measure time between leading edges.

I can give you a snippet of code to do this in VB if you want it.

Let me know.

Cheers Pete.

Hi Pete, somehow my reply has got lost, this is take-2!

I've sorted it out, thanks, your idea of measuring half cycles helped alot!

Here's my code,

Kind regards,


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.