An interface to read a PWM input signal, using InterruptIn

Dependents:   PwmIn_HelloWorld PwmIn_ModSerial CHR6dm_reading tugboat ... more

Embed: (wiki syntax)

« Back to documentation index

PwmIn Class Reference

PwmIn Class Reference

PwmIn class to read PWM inputs. More...

#include <PwmIn.h>

Public Member Functions

 PwmIn (PinName p)
 Create a PwmIn.
float period ()
 Read the current period.
float pulsewidth ()
 Read the current pulsewidth.
float dutycycle ()
 Read the current dutycycle.

Detailed Description

PwmIn class to read PWM inputs.

Uses InterruptIn to measure the changes on the input and record the time they occur

Note:
uses InterruptIn, so not available on p19/p20

Definition at line 35 of file PwmIn.h.


Constructor & Destructor Documentation

PwmIn ( PinName  p )

Create a PwmIn.

Parameters:
pThe pwm input pin (must support InterruptIn)

Definition at line 25 of file PwmIn.cpp.


Member Function Documentation

float dutycycle (  )

Read the current dutycycle.

Returns:
the dutycycle as a percentage, represented between 0.0-1.0

Definition at line 41 of file PwmIn.cpp.

float period (  )

Read the current period.

Returns:
the period in seconds

Definition at line 33 of file PwmIn.cpp.

float pulsewidth (  )

Read the current pulsewidth.

Returns:
the pulsewidth in seconds

Definition at line 37 of file PwmIn.cpp.