Seperate IC to Count Pulse Input?

There's a good chip for this sort of thing in the 1-Wire range... well... there WAS one in the range. You can still buy modules from HobbyBoards.com, search for "counter", even though Dallas isn't making any more of the chips.

1-Wire to Arduino: Uses just one digital I/O line.

MarkT:
I didn't find such a chip when I last looked, so I've used a counter chip with parallel output and a shift-register to read its output... Is there a reason you can't just use pin2 or pin3 with an interrupt routine?

actually I'm doing this, the problem is to maintain my arduino on and it stays drawing power(the ethernet is consuming >200mA).

I made a research yesterday and comes to this solution you are saying:
1 x 74HC4020 (14-bit counter)
2 x 74HC165N (shift register)

I bought the ICs and are waiting for the tests. I'll put my arduino to sleep, it'll wake-up from a 555 monostable and then I'll have to get the counter, reset it, send using ethernet and sleeping again. My main concern is to get the counter and reset. Do you have any code getting to get the counter?

Graynomad:
Yep, an ATtiny85/84.

They will use more power than a counter chip, but this idea is good for a lot of "is there a chip than co do ..." cases where as a hobbyist you may have a go at creating it yourself.

No one mentioned the more obvious solution however, that all of the three AtMega timers can be configured to work as pulse counters.

BenF:
No one mentioned the more obvious solution however, that all of the three AtMega timers can be configured to work as pulse counters.

I know, but I can't maintain my arduino on. So I need a "offline" solution to count for me. Even if I put an attiny85 to do this and transfer using some USART or I2C between arduino/chip.

The DS2423 is a good way to go. But the chip is SMD I'll need a breakout board to it because $25.00 for the complete board on hobbyboards is VERY expensive.

When using sleep mode idle, counters will still operate and you can disable unused peripherals for further power reduction. Wakeup source could include timer overflow (from the timer that counts external pulses). When using an external counter IC, you will probably need to wake up more frequently (worst case wind condition) in order not to overflow the external counter. Using the internal counter (8-bit for timer2 or 16-bit for timer1) you would only wake up if and when needed. Power usage in sleep mode idle is about 2.5mA so this would be the target to beat when considering external counters (you could probably avoid the 555 timer as well using sleep mode idle).

Timer2 can be configured for asynchronous operation and this would allow operation during additional sleep modes, but unfortunately is not compatible with the Arduino design (AtMega must run on internal oscillator in this mode) with the asynchronous clock connected to PB6 (Atmega328 pin 9).

Might try a 74590 with a PCF8574. Count on the 74590 and read I2C from the PCF8574 chip. Thinking of doing this myself as I want all my weather sensors to be I2C. :slight_smile:

Hey, I've been looking for a similar solution a separate IC that can count pulses and also calculate frequency..since you're already counting pulses and using timers..

Anyway, was looking for a ready made solution and found one chip the LS7366r which communicates via SPI. They're not cheap or very easy to come by. I found a few breakout boards, but still pricey.

I opted to program an ATtiny85 and came up with a working solution that will send pulse information over I2c. The major problem is precision... If you want to use the 8bit timer/counter then you cannot use a crystal. Regardless, I tried both an interrupt based method and count interrupts with a short ISR(PCINT) and with the 8bit counter. Lastly, to get better timer precision, you can tune it, but it's not ideal for me. I might try an ATtiny84 which has more pins free for crystal and counter. If anyone would like to collaborate or help or just test it on their setup, PM me.

I might try the crystal and pcint on the 85 and report back...need to buy a crystal

Thanks

The PCF8593 is a clock/calendar but it can be configured as a 6-digit event counter.
http://www.nxp.com/documents/data_sheet/PCF8593.pdf

Pete

I looked at some of those real time clocks as well..but if you need multiple counters at the same time, you'd have an i2c address conflict. Also, I'm more interested in frequency measurement so I'd be nice if the IC was able to do most of the computing.

It would be great if a small single chip could take two or three inputs as counters or interrupts to count. And communicate via i2c or spi. Maybe attiny84? I might look into that

One of our members did a board with 4 (I think) tiny85s (or maybe 84s) whose job it was to do high-speed counting. There all talked to the master mega2560 with SPI.

I'll see if I can find the thread.

EDIT:
This is the thread, "The Brick" - All In One - Arduino Platform Compatible - Exhibition / Gallery - Arduino Forum, I didn't re read it to see if there are any details but I know that's what he did because I helped off line with it.


Rob

Graynomad:
EDIT:
This is the thread, "The Brick" - All In One - Arduino Platform Compatible - Exhibition / Gallery - Arduino Forum, I didn't re read it to see if there are any details but I know that's what he did because I helped off line with it.


Rob

Thanks Rob! It's quite an old thread, but I've posted there to see if the code could be made available.

I wonder if there are some small FPGAs that could do this.. or maybe it's overkill. I haven't done anything with an FPGA before, so excuse my ignorance.

Yes you could use an FPGA or CPLD, one hell of a learning curve though just for this app, OTOH if you wanted to get into them this would be a good first project I think.


Rob

I was searching for a similar chip myself, for a very similar problem. Whilst I was reading the post I though about connecting the counter chips to something like a Microchip MCP23008 or MCP23S08, which are 8 bit IO Expanders with either an I2C or SPI interface. I have used them from a Netduino before and they are very easy to use. You can power them up and down from a single Arduino port and then 2 more for the I2C interface. There is also a 16bit version, but I haven't got that to work yet.

Any progress on this front? I've been reading this thread going "Oh yeah!" thinking you were all getting close to something I need; an I2C event counter (could also be a decade counter etc.)

I'm making a rain gauge for an Arduino platform weather station. Have most of the bits put together, but as I completed the anemometer with a Hall effect sensor, I thought this would be better with a decade counter attached that I could read. Not finding one, I completed the project using a polling approach to see how long a revolution took.

Now that the anemometer is done, I've turned my attention to the rain gauge and I think I really need something with a "memory" for this. I can't sit around and see how fast the water is falling, I need to record it as it falls, using a two bucket design, and then transfer the total and clear periodically. This approach seems so obvious, I can't figure out why no one has done it yet.

I'm looking at the I/O expander chips (MCP23017 and their ilk) and I could do this, but I still need a counter that will work nicely with them.

I kind of gave up on this for a while, but might pick back up on this project. It was working without a crystal but values were inaccurate.

I also tried to construct a setup using a PCF8593 but it seems very difficult to get it stable: I count too many pulses.

I'm now considering the DS1678, which records all the events, it's more versatile but also more complicated. It also needs a crystal for its time base (with the benefit that it gives an RTC at the same time).

Another option is to program an ATtiny25, but that's definitely more work (could be fun though).

I now see there's also the DS1682, that may be the easiest solution, though it only counts 16 bits.

from my little research into using the ATTiny85 as an option
The issue would be that you have to disable interrupts in order to perform I2C or SPI communication
Therefore during communications you'd be missing counts

The ATTiny84 has hardware SPI, so maybe the situation is different there?

Currently experimenting with using ESP's PCNT counters instead
My application is Quadrature counting, and using interrupts on Atmel or ESP both have issues when doing things like software I2C because that disables interrupts

Very old thread coming back to life time and again :slight_smile:

The AVR processors have counter inputs, then you can count in hardware at speeds up to fclk/2 (I've counted 6 MHz on a 16 MHz system). The T1 pin is Arduino pin 5; you have to set the Timer1 registers to make it use that pin as clock input and you can count pulses easily.

Some AVR processors offer hardware quadrature input. This AN describes specifically how you can read/decode quadrature enocders with specific AVR chips.

amazing!
i actually got this working today on an ESP32 using hardware counters

The ESP counter function lets you set a direction pin and a pulse pin + a decent amount of config options so it was possible to get HW quadrature input working reliably

Great to know this is possible in AVR land too!