Shop OBEX P1 Docs P2 Docs Learn Events
Counting pulses over time. — Parallax Forums

Counting pulses over time.

FranklinFranklin Posts: 4,747
edited 2009-12-06 18:41 in Propeller 1
I'm working on a weather reporting station using the prop at the remote as suggested by someone here on the forums and have a need to count switch closures for the rain gauge and the anemometer. I'm not sure what I should code for this. I need to have a cog monitor a pin and when the pin goes high (or low depending on the way I finally wire it) it sees that and I will increment a counter.

Also, does anyone have a recommensation for a 3v 12bit 2 or 4·(or 8) channel ADC?

Thanks all,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Comments

  • Sal AmmoniacSal Ammoniac Posts: 213
    edited 2009-12-06 18:37
    You could use the "POS Detector" mode of one of a cog's two counters to count switch closures on an I/O pin. This would free the cog to continue to do other things rather than sitting waiting for the pulses.

    For the ADC, I recommend the Microchip MCP3204 (or MCP3208).

    Post Edited (Sal Ammoniac) : 12/6/2009 6:53:35 PM GMT
  • JonnyMacJonnyMac Posts: 9,208
    edited 2009-12-06 18:41
    I, too, would use a counter but only with signal conditioning (simple one-shot circuit to clean-up the bounce). By using a counter with external filtering you don't need to a separate cog. Of course, if you want a software-only solution you could dedicate a cog to debouncing an input and incrementing a hub-based value.
Sign In or Register to comment.