libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Attributes | List of all members
PWM32 Class Reference

Run up to 32 channels of low speed PWM (up to ~10kHz@80MHz clock). More...

#include <pwm32.h>

Public Member Functions

 PWM32 ()
 
void Start (void)
 Start a cog with the PWM runner. More...
 
void Stop (void)
 Stop the cog, if running. More...
 
void Duty (int pin, int duty_cycle, int period)
 Output a PWM wave with a calculated duty. More...
 
void Servo (int pin, int pulse_width)
 Output a servo compatible pulse with a period of 20ms. More...
 
void PWM (int pin, int on_time, int off_time)
 Output a series of square waves with a high time of on_time microseconds, and a period of (on_time + low_time) microseconds. More...
 

Static Public Attributes

static const int Resolution = 8200
 

Detailed Description

Run up to 32 channels of low speed PWM (up to ~10kHz@80MHz clock).

No external hardware beyond the PWM devices is needed. Works with H bridges, LEDs, servos, and anything else that takes a repeating PWM signal.

Copyright (c) 2013 Kenneth Bedolla (libpr.nosp@m.opel.nosp@m.ler@k.nosp@m.enne.nosp@m.thbed.nosp@m.olla.nosp@m..com)

Constructor & Destructor Documentation

PWM32::PWM32 ( )
inline

Member Function Documentation

void PWM32::Duty ( int  pin,
int  duty_cycle,
int  period 
)
inline

Output a PWM wave with a calculated duty.

Parameters
pinThe I/O pin to use (0..31)
duty_cycleThe duty cycle (0..100) to use. 0 is off, 100 is full on.
periodThe period (in uS) of the cycle.
void PWM32::PWM ( int  pin,
int  on_time,
int  off_time 
)
inline

Output a series of square waves with a high time of on_time microseconds, and a period of (on_time + low_time) microseconds.

Parameters
pinThe I/O pin to use (0..31)
on_timeThe duration of the high time, in uS.
off_timeThe duration of the low time, in uS.
void PWM32::Servo ( int  pin,
int  pulse_width 
)
inline

Output a servo compatible pulse with a period of 20ms.

Parameters
pinThe I/O pin to use (0..31)
pulse_widthThe width of the servo pulse in uS. Can be any value, but most servos require a range (1000..2000)
void PWM32::Start ( void  )
inline

Start a cog with the PWM runner.

Here is the call graph for this function:

void PWM32::Stop ( void  )
inline

Stop the cog, if running.

Member Data Documentation

const int PWM32::Resolution = 8200
static

The documentation for this class was generated from the following file: