PWM Class Reference

#include <lpc_pwm.hpp>

Public Types

enum  pwmType {
  pwm1 =0, pwm2 =1, pwm3 =2, pwm4 =3,
  pwm5 =4, pwm6 =5
}
 

Public Member Functions

 PWM (pwmType pwm, unsigned int frequencyHz=50)
 
 ~PWM ()
 Destructor that will destroy PWM configuration. More...
 
bool set (float percent)
 

Detailed Description

LPC PWM class. Example:

pwm2.set(10);
pwm2.set(5.0);

Member Enumeration Documentation

Enumerator
pwm1 

P2.0.

pwm2 

P2.1.

pwm3 

P2.2.

pwm4 

P2.3.

pwm5 

P2.4.

pwm6 

P2.5.

Constructor & Destructor Documentation

PWM::PWM ( pwmType  pwm,
unsigned int  frequencyHz = 50 
)

Initialize a PWM

Parameters
frequencyHzThe frequency of the PWM
Note
Frequency is only initialized the first time this class is constructed. Once it is initialized, it cannot be set or changed when more objects are constructed.
PWM::~PWM ( )

Destructor that will destroy PWM configuration.

Member Function Documentation

bool PWM::set ( float  percent)

Sets the PWM based on the percentage. If 50Hz Servo PWM was setup, then you can use the following :

  • Left : set(5.0); // 5.0 % of 20ms = 1.0ms
  • Neutral : set(7.5); // 7.5 % of 20ms = 1.5ms
  • Right : set(10.0); // 10 % of 20ms = 2.0ms

You can use micro-steps to position the servo motor by using set(5.1), set(5.2) ... set(7.4) etc.


The documentation for this class was generated from the following files:
  • /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/lpc_pwm.hpp
  • /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/src/lpc_pwm.cpp