Show / Hide Table of Contents
View Source

Class Pwm

PWM is the Pulse Width Modulation interface to libmraa. It allows the generation of a signal on a pin. Some boards may have higher or lower levels of resolution so make sure you check the board & pin you are using before hand.

Inheritance
System.Object
Pwm
Namespace:MraaSharp
Assembly:MraaSharp.dll
Syntax
public class Pwm : IDisposable

Constructors

View Source

Pwm(Int32)

Initialise pwm_context, uses board mapping

Declaration
public Pwm(int pin)
Parameters
Type Name Description
System.Int32 pin

The PWM PIN

View Source

Pwm(Int32, Int32)

Initialise pwm_context, raw mode

Declaration
public Pwm(int chipid, int pin)
Parameters
Type Name Description
System.Int32 chipid

The chip inwhich the PWM is under in SYSFS

System.Int32 pin

The PWM PIN

Properties

View Source

Enable

Set the enable status of the PWM pin. None zero will assume on with output being driven. and 0 will disable the output

Declaration
public bool Enable
{
    set;
}
Property Value
Type Description
System.Boolean
View Source

MaxPeriod

Get the maximum pwm period in us

Declaration
public int MaxPeriod
{
    get;
}
Property Value
Type Description
System.Int32
View Source

MinPeriod

Get the minimum pwm period in us

Declaration
public int MinPeriod
{
    get;
}
Property Value
Type Description
System.Int32
View Source

Owner

Change ownership of context

Declaration
public bool Owner
{
    set;
}
Property Value
Type Description
System.Boolean

Methods

View Source

ConfigMilliseconds(Int32, Single)

Set Both Period and DutyCycle on a PWM context

Declaration
public void ConfigMilliseconds(int period, float duty)
Parameters
Type Name Description
System.Int32 period

represented in ms.

System.Single duty

dutycycle of the pwm signal.

View Source

ConfigPercent(Int32, Single)

Set Both Period and DutyCycle on a PWM context. Duty represented as percentage.

Declaration
public void ConfigPercent(int period, float duty)
Parameters
Type Name Description
System.Int32 period

represented in ms.

System.Single duty

duty percantage. i.e. 50% = 0.5f

View Source

Dispose()

Declaration
public void Dispose()
View Source

SetPeriod(Single)

Set the PWM period as seconds represented in a float

Declaration
public void SetPeriod(float seconds)
Parameters
Type Name Description
System.Single seconds

Period represented as a float in seconds

View Source

SetPeriodMicroseconds(Int32)

Set period, microseconds.

Declaration
public void SetPeriodMicroseconds(int us)
Parameters
Type Name Description
System.Int32 us

Microseconds as period

View Source

SetPeriodMilliseconds(Int32)

Set period, milliseconds.

Declaration
public void SetPeriodMilliseconds(int ms)
Parameters
Type Name Description
System.Int32 ms

Milliseconds for period

View Source

SetPulseWidthMicroseconds(Int32)

Set pulsewidth, microseconds

Declaration
public void SetPulseWidthMicroseconds(int us)
Parameters
Type Name Description
System.Int32 us

Microseconds for pulsewidth

View Source

SetPulseWidthMicroseconds(Single)

Set pulsewidth, As represnted by seconds in a (float)

Declaration
public void SetPulseWidthMicroseconds(float seconds)
Parameters
Type Name Description
System.Single seconds

The duration of a pulse

View Source

SetPulseWidthMilliseconds(Int32)

Set pulsewidth, milliseconds

Declaration
public void SetPulseWidthMilliseconds(int ms)
Parameters
Type Name Description
System.Int32 ms

Milliseconds for pulsewidth

View Source

Write(Single)

Set the ouput duty-cycle percentage, as a float

Declaration
public void Write(float percentage)
Parameters
Type Name Description
System.Single percentage

A floating-point value representing percentage of output. The value should lie between 0.0f (representing on 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f

Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX