Table of Contents

Class PwmChannel

Namespace
System.Device.Pwm
Assembly
System.Device.Pwm.dll

Represents a single PWM channel.

public sealed class PwmChannel : IDisposable
Inheritance
PwmChannel
Implements
Inherited Members
Extension Methods

Constructors

PwmChannel(int, int, int, double)

Creates a new instance of the PwmChannel running on the current platform.

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

Parameters

chip int

The PWM chip number, formally known as TIM channel.

channel int

The PWM channel number.

frequency int

The frequency in hertz.

dutyCyclePercentage double

The duty cycle percentage represented as a value between 0.0 and 1.0.

Remarks

To create a PwmChannel from a GPIO pin number, please use CreateFromPin(int, int, double).

Properties

DutyCycle

The duty cycle represented as a value between 0.0 and 1.0.

public double DutyCycle { get; set; }

Property Value

double

Exceptions

ArgumentOutOfRangeException

Value must be between 0.0 and 1.0.

Frequency

The frequency in hertz.

public int Frequency { get; set; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

Value must not be negative.

Methods

Create(int, int, int, double)

Creates a new instance of the PwmChannel running on the current platform.

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

Parameters

chip int

The PWM chip number, formally known as TIM channel.

channel int

The channel number.

frequency int

The frequency in hertz.

dutyCyclePercentage double

The duty cycle percentage represented as a value between 0.0 and 1.0.

Returns

PwmChannel

A PwmChannel.

CreateFromPin(int, int, double)

Creates a PwmChannel from a pin number.

public static PwmChannel CreateFromPin(int pin, int frequency = 400, double dutyCyclePercentage = 0.5)

Parameters

pin int

The pin number.

frequency int

The frequency in hertz.

dutyCyclePercentage double

The duty cycle percentage represented as a value between 0.0 and 1.0.

Returns

PwmChannel

A PWM channel

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Start()

Starts the PWM channel.

public void Start()

Stop()

Stops the PWM channel.

public void Stop()