Toolbox.NETMF.Hardware.IPWMPort

This is actually an interface, created so multiple PWM classes can be used. By default, all samples will use the Netduino PWM class, with the classname "Netduino.PWM".
By default, all samples will use the .NETMF built-in network stack, with the classname "Netduino.PWM".

Currently supported PWM controllers

- IntegratedPWM .NETMF 4.2 PWM Class
- Netduino.PWM Netduino PWM Class
- Fez.PWM Fez PWM Class

Required methods

  • Dispose() Disposes the PWM object
  • SetDutyCycle(dutyCycle, frequency) Sets the duty cycle
  • SetPulse(period_ns, duration_ns) Sets the signal pulse
  • StartPulse() Actually starts the signal
  • StopPulse() Stops the signal

Sample code in C#

IPWMPort Led1 = new Netduino.PWM(Pins.GPIO_PIN_D5);
Led1.StartPulse();

while (true)
{
    for (uint Brightness = 0; Brightness < 100; ++Brightness)
    {
        Led1.SetDutyCycle(Brightness);
        Thread.Sleep(100);
    }
    for (uint Brightness = 100; Brightness > 0; --Brightness)
    {
        Led1.SetDutyCycle(Brightness);
        Thread.Sleep(100);
    }
}

Sample code in VB

Dim Led1 As IPWMPort = New Netduino.PWM(Pins.GPIO_PIN_D5)
Led1.StartPulse()

Do
    For Brightness As Integer = 0 To 99
        Led1.SetDutyCycle(CUInt(Brightness))
        Thread.Sleep(100)
    Next
    For Brightness As Integer = 100 To 1 Step -1
        Led1.SetDutyCycle(CUInt(Brightness))
        Thread.Sleep(100)
    Next
Loop

Last edited Jul 2, 2012 at 11:04 AM by Garrcomm, version 7