Shop OBEX P1 Docs P2 Docs Learn Events
Measuring pulse width with PWMPAL — Parallax Forums

Measuring pulse width with PWMPAL

dcecardcecar Posts: 1
edited 2008-03-16 14:52 in BASIC Stamp
Hi All,

I would like to measure a width of an RC Servo receiver pulse with the basic stamp, but I dont want to use PULSEIN. The reason for this is I need to keep BS2 bussy with other things. Can this pulse measurement be done in the background? I do have a PWMPAL and I thought it would be easy to have this done with PWMPAL but i wasnt able to find an appnote that did this.

Many thanks

Dejan
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-16 14:52
    The pulse measurement can't be done in the background because there is no "background" for the Stamps. Sometimes you can overlap several simple things, like you can supply servo pulses to several servos while briefly checking some sensors. This is possible because servos only require a brief pulse (0.5-2.5ms) roughly every 20ms and the other work can happen in between the servo pulses. The PWMPAL and ServoPAL are external "co-processors" that even remove this task. Once they're set up, they will repeat the requested servo pulses every 20ms without further attention until the pulse width needs to change. They won't do pulse width measurement though.

    In your case, because the receiver pulse can occur at any time, the Stamp is tied waiting to measure it. Only the PULSIN statement can do the job because the Stamp is not fast enough to accurately measure the pulse width using its Basic. The only workable Stamp solution is to move the measurement task to a co-processor or to other external hardware. Other microcontrollers like the SX and the Propeller can do this kind of thing easily by using interrupts (the SX) or by having multiple processors (the Propeller).
Sign In or Register to comment.