Adjustable Frequency PWM 1Hz to 2MHz with LCD Menu Display

Hi,

I just finished my first library (well a modification of an existing one) and want to post the library and sample code. Is this the right place to put it?

The library is called “NanoPWMac”. It will output a bipolar signal using the two pins, i.e. when one is high, the other is low and vice-versa.
You can set it like this…

long frequency = 100000; // The frequency in Hz
long pulseWidth = 125; // The width of the output pulse in nanoseconds
NanoPWMac(frequency, pulseWidth); // Activates the output signal

The minimum step for the pulse width is 125ns. If you enter a number not divisible by 125ns, then the library will just round it down.

I’ve attached the library, and the code I used to make a nice adjustable PWM pulse generator with LCD menu. The device I wrote the code for is the RMCybernetics PDI-1
http://www.rmcybernetics.com/shop/cyber-circuits/signal-control/programmable-usb-device-pdi1

I will put future code updates here…
http://www.rmcybernetics.com/projects/code/index.htm

NanoPWMac.zip (3.59 KB)