Library that allows for higher resolution and speed than standard mbed PWM library. Based on FastPWM without floating point calculation in most functions

Fork of FastPWM by Erik -

Library that allows faster and/or higher resolution PWM output.

This library is based original on FastPWM by Erik Olieman but without floating point (double) calculation in each call of pulsewidth_xx. This change was nessecary to get a performant motion controller.

Library can directly replace standard mbed PWM library. Only limitation is that the maximum PWM period is four times shorter The maximum achievable period is roughly 40 seconds, I dont think that should be a problem. Do take into account all PWM objects (based on defailt PWM lib) will run four times faster than default.

Contrary to the default mbed library, this library takes doubles instead of floats. The compiler will autocast if needed, but do take into account it is done for a reason, your accuracy will otherwise be limitted by the floating point precision.

Using this library for a RC servo the resolution of steps (min to max) is increased from 1000 to 96000.

This library can be also used as a analoge output (with external low-pass filter) with a frequency of e.g. 20kHz and a resolution 4800 steps (similar to a 12 bit DAC) instead of 50 steps (similar to a 5 bit DAC) on original PWM lib.

In your program you can define F_CLK if you use a different clock frequency than the default one.

Only works on LPC1768 for now. If you want support for the other one, send a PM and I will have a look, but I cannot even compile for it.

History

based on FastPWM, changed double calculation to int calculation for most functions default tip

2013-05-23, by jocis [Thu, 23 May 2013 10:39:29 +0000] rev 4

based on FastPWM, changed double calculation to int calculation for most functions


Fixed clk_sel, latch registers and constant duty when changing period

2012-07-25, by Sissors [Wed, 25 Jul 2012 07:14:39 +0000] rev 3

Fixed clk_sel, latch registers and constant duty when changing period


ms and us functions were multiplying by 1k(k) instead of dividing

2012-07-12, by Sissors [Thu, 12 Jul 2012 19:26:43 +0000] rev 2

ms and us functions were multiplying by 1k(k) instead of dividing


ASCII art turtle added

2012-07-12, by Sissors [Thu, 12 Jul 2012 11:23:31 +0000] rev 1

ASCII art turtle added


v1.0, seems completely functional

2012-07-12, by Sissors [Thu, 12 Jul 2012 11:20:09 +0000] rev 0

v1.0, seems completely functional