efficient counting
realolman
Posts: 65
What would be the most efficient method of counting the actual hi / lo transitions on a pin?
The COUNT command seems more useful for determining a frequency. The PULSIN doesn't quite seem to do it either.
I know I could count them, but it is important to me to use the fastest,· most efficient· method.
I am interested in knowing the actual number of transitions, in the least amount of time spent·executing the count, and having the accumulated count available for the largest amount of time.
thanks
The COUNT command seems more useful for determining a frequency. The PULSIN doesn't quite seem to do it either.
I know I could count them, but it is important to me to use the fastest,· most efficient· method.
I am interested in knowing the actual number of transitions, in the least amount of time spent·executing the count, and having the accumulated count available for the largest amount of time.
thanks
Comments
You will need some kind of external components if you want to count signal transitions while the Stamp is doing other things. A lot depends on how quickly these are coming in. If they're slow (in relation to the Stamp's speed ... a few thousand instructions a second), you could just use an external flipflop (made from a quad NOR or quad NAND gate). The Stamp would periodically look at the output of the flipflop. If set, a transition occurred and the Stamp can reset the flipflop. A simple series capacitor can convert a transition into a pulse so you'll get two output pulses per input pulse (two transitions).
If the transitions are coming in quickly, you may need to just count them with external circuitry and read the count with the Stamp.