View Full Version : PWM Function Question

11-06-2009, 05:40 AM
Hello Everyone,

I'm using the PWM and RCTIME functions to generate an adjustable pulse. I was reading the reference manual and noticed the PWM has the following comment.

… It outputs a rapid sequence of on/off pulses, as short as 1.6 μs in duration, whose overall proportion
over the course of a full PWM cycle of approximately a millisecond is equal to the duty cycle. This has the advantage of very quickly zeroing in on the desired output voltage, but it does not produce the neat, orderly pulses that you might expect.

I quickly figured this out by running the example specified in the book (see figure below).

When I adjusted my Duty variable to about 85, I can see a fairly clean pulse (see 85.jpg).

When I adjusted my Duty variable to about 191, it generated an awful looking pulse (see 191.jpg).

The code I'm using is in attachment rctime_366.bs2

Is there any way to clean this up???

Beau Schwabe
11-06-2009, 01:55 PM

The Pseudo random PWM signal from the Stamp is showing exactly what it was designed to do. PWM of the Stamp is optimized for converting a digital signal into an analog signal through a simple RC integration. If your looking for a 'fixed' base period of the PWM sutable for driving a motor speed controller you might consider a PWMPAL (http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/PWM/List/0/SortField/4/ProductID/67/Default.aspx) for the job.

Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

11-06-2009, 04:14 PM
Thank you Beau