BBBCSIO

The PWMPortMM Class

 

The PWMPortMM Class

The PWMPortMM class reads from the one of the six PWM bus On Chip Peripheral (OCP) devices integrated into the Beaglebone Black CPU via the PWM memory Mapped access method. There is also a file system based PWM port available. For more information see the PWMPortFS help file.

 

Source Code

The source code for this class is available online for download and also in browseable form.

 

Example Code

Example code which demonstrates the use of this class can be found on the PWM Port Example page.

 

Syntax

public class PWMPortMM : PortMM

Provides Pulse Width Modulation (PWM) port functionality for a BeagleBone Black (Memory Mapped Version).

 

Public Constructors

public PWMPortMM(PWMPortEnum pwmPortIn) : base(GpioEnum.GPIO_NONE)

Constructor.

Parameters
pwmPortIn - The PWM port to access.

 

Public Methods

public override void ClosePort()

Closes the port.

 

public void Dispose()

Implements IDisposable. Should be called after the class is closed to release resources.

 

public override PortDirectionEnum PortDirection()

Gets the PortDirection

Returns
A PortDirectionEnum value. This value is always PortDirectionEnum.PORTDIR_OUTPUT.

 

Public Properties

public uint DutyNS { get; set; }

Gets/Sets the duty cycle of the PWM output square wave form in nanoseconds

The duty cycle is the part of the wave form devoted to a high state.

value
the duty cycle of the PWM output in nanoseconds. This should always be less than the PeriodNS.

 

public double DutyPercent { get; set; }

Gets/Sets the duty cycle of the PWM output square wave form as a percent

value
percentage of the input value. Must be between 0 and 100.

 

public uint FrequencyHz { get; set;}

Gets/Sets the frequency of the PWM output square wave form.

value
frequency in Hz.

 

public uint PeriodNS { get; set;}

Gets/Sets the period of the PWM output square wave form

value
the period (1/Freq) in nano seconds.

 

public PWMPortEnum PWMPort { get; }

Gets the PWM Port. There is no Set accessor this is set in the constructor

value
The working PWMPortEnum.

 

public bool RunState { get; set;}

Gets/Sets the run state of the PWM output square wave

value
true - begin running, false - stop running.