Shop OBEX P1 Docs P2 Docs Learn Events
PWM Function Question — Parallax Forums

PWM Function Question

chiqueschiques Posts: 21
edited 2009-11-06 09:14 in BASIC Stamp
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???
1280 x 960 - 452K
1280 x 960 - 445K

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-11-06 06:55
    chiques,

    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 for the job.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • chiqueschiques Posts: 21
    edited 2009-11-06 09:14
    Thank you Beau
Sign In or Register to comment.