Go Down

Topic: count pulses (Read 1 time) previous topic - next topic

brenande

Is there a chip of some sort that could count pulses sent to it and then the arduino could query this chip and get the current count of pulses?  I'm thinking of something like this to be used with a tipping style rain gauge.  Or, should I just use an interrupt pin?

Thanks.

Daniel

hey

yes there are lots of chips... but it's a very 80's to use an external counter chip. :) The Atmega can count them for you. The problem with external counters is that unless they are serially interfaced, they'll require something like 8 pins just to give you the binary equivalent of 256. How high do you have to count?

D

brenande

I would like to count tips of a rain gauge, so that could potentially be a few hundred in a day.  I don't really have a number as I haven't built it yet.  I am also planning on using the arduino to measure temperature and other weather related things, so I don't necessarily want the arduino only counting pulses.

How would you use the Atmega?  Would you use an interrupt pin or do you have another idea?

Thanks.

boardboy

This is just a far fetched idea and I wouldn't know how to put it together, but you could have the tipping rain gauge activate some sort of counter, independent of the arduino, then when you need the rain fall info have the arduino poll the counter.  This would assume that you only need the info once per day or some other predefined time period (this wouldn't help for IDF storm info).  
If your displaying and collecting info somewhere downstream of the arduino, like a computer, and just have the arduino sending the computer the info, then using interrupts might work as long as you're not interrupting some time dependent function, and time stamp the info from the rain gauge on the computer.

I'm pretty new at this stuff so you might want to just take my ideas as conceptual, I really have no idea how you would go about it (although the tipping rain gauge, if it's just a simple mechanical one, you could add a magnet to it and use a reed switch to do the activation of when the gauge tips).

Daniel

#4
Aug 22, 2007, 08:11 pm Last Edit: Aug 22, 2007, 08:21 pm by Daniel Reason: 1
Quote
I would like to count tips of a rain gauge, so that could potentially be a few hundred in a day.  I don't really have a number as I haven't built it yet.  I am also planning on using the arduino to measure temperature and other weather related things, so I don't necessarily want the arduino only counting pulses.

How would you use the Atmega?  Would you use an interrupt pin or do you have another idea?

Thanks.


hey

a few hundred counts a day corresponds to one every fifteen minutes. If you want to do it the hardware way, you just need an RS (sometimes called SR) or similar  flip-flop logic gate: 29 cents. Basiciall this is a single-state memory device.  Look in the 74HCT line for an appropriate one.

An RS flip-flop has two inputs: "set" ( connect to rain gauge) and "reset" (connect to Arduino.)   Tell the Arudino to read the "Q" output and then have the Arduino reset the flip-flop. You only need four pins between the Arudino and the flip flop: +5, GND, and two digital pins to read and reset the flip-flop.  

Basically the rain gauge sets the flip-flop state to tripped, and when the Arduino reads it, it resets the state to unflipped.

You can get these gates in tiny tiny sizes too. If you are unsure about how flip-flops work, track down a copy of "getting started in electronics" by Forest M Mims, as it has about a dozen examples of how to do this kind of thing. Radio Sha*k has it in the US.

D

TJ

Compared to the Arduino's speed, your rain bucket will tip at geologic rates.   :)

If I was going to build one of these systems, I'd place a small magnet at one side of the bucket, then place a magnetic reed switch in such a way that the rain bucket would close the reed when tipped one way, and open it when tipped the other.

In the Arduino code, you could detect the reed's change of state using either an interrupt or by polling.  Since things will be happening slowly, polling is probably the way to go.  It also facilitates debouncing.

When you first read and debounce the reed switch, store its state and initialize your counter.  In your polling routine, watch for the change of state.  Debounce it, then update your counter and change the state you're watching for in the polling routine.  (And your debounce routine can use ridiculously long timing.  Rather than milliseconds as you might use for a switch, you could debounce in tenths or even seconds to allow for some bucket oscillation at the near-balance point.)

You'll have lots of time left to read and process temperature, humidity, barometric pressure, etc.

Save the interrupt for your anemometer.   :)

Sounds like a good project.  I hope you'll have fun with it!

Tom
Embedded Arduino Digicam Remote & Intervalometer
http://www.mindspring.com/~tom2000/Projects/AI-1_Remote/AI-1_Remote.html

Go Up