Shop OBEX P1 Docs P2 Docs Learn Events
Frequency counter using COUNT or PULSIN? — Parallax Forums

Frequency counter using COUNT or PULSIN?

Steve in NMSteve in NM Posts: 54
edited 2008-11-22 17:06 in BASIC Stamp
Parallax provides examples using both, yet I get different results with the same hardware. Is that because one executes faster than the other?


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-22 17:06
    The two statements do very different things.

    COUNT is specifically intended to count the number of pulses that occur in a specified period of time. The actual pulse width isn't important and the time period for measurement is fairly accurate. This is likely to give you the best frequency information for short periods of time (up to a minute for a BS2).

    PULSIN is intended to measure the width of a pulse and to measure that fairly accurately. It doesn't tell you anything about the frequency of the pulses. That has to be done by the program that uses the PULSIN. Since there's no real time clock in the Stamps, there's no way to accurately measure the total elapsed time to use to divide by the number of pulses to get the frequency. You can approximate that time by using the execution time of the loops in the program, but that requires careful calibration.
Sign In or Register to comment.