Skip to main content

PwmChannel Class

NuGet: GHIElectronics.TinyCLR.Devices.Pwm
Assembly: System.Device.Pwm
Namespace: System.Device.Pwm

.NET-style PWM channel. Same surface as System.Device.Pwm.PwmChannel; internally routes through TinyCLR's PWM driver.

public class PwmChannel : IDisposable

Constructors​

PwmChannel(int chip, int channel)​

protected PwmChannel(int chip, int channel) : this(chip, channel, 400, 0.5)

Opens a channel on the given chip at 400 Hz and 50% duty cycle.

PwmChannel(int chip, int channel, int frequency, double dutyCyclePercentage)​

protected PwmChannel(int chip, int channel, int frequency, double dutyCyclePercentage)

Opens a channel on the given chip with the given frequency and duty cycle.

Properties​

Channel​

public int Channel { get; }

The channel number on the controller.

Controller​

public int Controller { get; }

The controller (chip) index.

Frequency​

public double Frequency { get; set; }

The output frequency in Hz. Setting it changes the whole controller's frequency.

DutyCycle​

public double DutyCycle { get; set; }

The duty cycle from 0.0 to 1.0.

Polarity​

public PwmPulsePolarity Polarity { get; set; }

The pulse polarity.

Methods​

Create(int chip, int channel)​

public static PwmChannel Create(int chip, int channel)

Opens a channel on the given chip at 400 Hz and 50% duty cycle.

Returns PwmChannel

Create(int chip, int channel, int frequency, double dutyCyclePercentage)​

public static PwmChannel Create(int chip, int channel, int frequency = 400, double dutyCyclePercentage = 0.5)

Opens a channel on the given chip with the given frequency and duty cycle.

Returns PwmChannel

Start()​

public void Start()

Starts the PWM output.

Stop()​

public void Stop()

Stops the PWM output.

Dispose()​

public void Dispose()

Stops the output and releases the channel.