IC Counter with TWI or SPI?

Creating a low power device which runs on a battery. It only needs to count up. Resettable would be nice but not required. Something in the range of 10-12 bits should be fine. Though for margin, closer to 11 or 12 bit would be preferred. There are a couple external devices which periodically and asynchronously trigger INTs (~100Hz range). The problem, in order to save power I need the uC to sleep a fair bit. Obviously if its counting INTs its not sleeping. I know there are IC counters and I've hears some offer SPI/TWI interfaces. Would it be possible to have a counter count the INT from the two external devices and simply periodically wake, pole, and reset the counts via TWI or SPI? This way the uC only needs to wake at perhaps 1-10Hz. The exactly uC poll rate has not been determined yet.

Obviously the first question is, is it likely to be worth the effort and save power? Does such an IC exist? How much does it approximately cost? Does this sound like a reasonable approach? Obviously if there are better approaches, lay it on me.

Note: I may not be referring to the proper type of IC. I'm not talking about a visual counter LCD. I'm talking about something which counts pulses. So please correct me if I'm referring to the wrong type of component.

Edit: Note made.

There are plenty of N-bit counters around, look at chips like the 74HC4040. What's happening with the count value? Do you need an Arduino at all?


Rob

Graynomad: There are plenty of N-bit counters around, look at chips like the 74HC4040. What's happening with the count value? Do you need an Arduino at all?


Rob

That's a good question and I should have provided that. Yes, the arduino is required. This is a sensor node which also has an RF component as which also control yet some other devices.

Interestingly enough, those were the first components I looked at. Doesn't that just make the current count value available via parallel data lines? Is there some type of encoder which won't require N-bit digital ports? Or perhaps I misunderstand how those work. Sorry, never seen or used one before.

Yes those chips just have 12 outputs. If you had two for counting that's 24 outputs, feed them into 3 PISO shift registers (like 74xx165/166) and you can read the lot with 3 pins.

I can't think of any counter chips with serial interfaces, you could of course use a small processor like the ATtiny85 as a counter and get the data via SPI.

is it likely to be worth the effort and save power?

Only you can answer that, it depends on the application.

in order to save power I need the uC to sleep a fair bit.

That would obviously use the least hardware, ie none.

You need to decide just how power miserly this has to be. If it needs to run for 10 years on a coin cell you can't use an Arduino anyway because there are too many things besides the processor that chew power.


Rob

The SN74LV8154N has two 16-bit counters (you can stack them if wanted) and a single 8-bit output port (requiring only one shift register to read as serial). Through-hole or SMT are both available.

Nice chip, that looks perfect.


Rob

Graynomad: is it likely to be worth the effort and save power?

Ya, I understand that was an open ended question. My angle was to not carry forward an assumption on my part which is that these types of ICs have significantly low power demands such that their continuous operation with the uC sleeping, is likely to result in a net win versus the uC staying awake and much less frequently sleeping.

It wasn't that I expected you to intuit the entire end product, but rather comparatively speaking, my assumption is that these ICs will draw a tiny amount of power relative to that of the uC being awake. Obviously I'll review the data sheet.

MarkT: The SN74LV8154N has two 16-bit counters (you can stack them if wanted) and a single 8-bit output port (requiring only one shift register to read as serial). Through-hole or SMT are both available.

Awesome. Thanks guys.

I assume the shift registers above are still a good match here? They may not be needed now that I'm not looking at some 20-22 pins. Just the same, having the option on the table is always nice.

I also assume there is another latch or two which controls which 8-value is available on the 8-latches? I guess that's why a shift register would require three pins on the arduino? One for serial data and two to control which 8-bit value to read?

I assume the shift registers above are still a good match here?

Yes

They may not be needed now that I'm not looking at some 20-22 pins.

You still need one, unless you use eight digital inputs.

I also assume there is another latch or two which controls which 8-value is available on the 8-latches?

The GAL, GAU etc pins select which byte is muxed out of the chip.

I guess that's why a shift register would require three pins on the arduino? One for serial data and two to control which 8-bit value to read?

No, shift regs usually have a latch, clock and data in, data out pins. With three pins on the Arduino you can read 1000s of inputs just by daisy-chaining the shift registers.

If you use that chip without a shift reg you will need 12 pins I think. With an input SR you need 3 pins for it and 4 to control the counter mux. If you really need to save pins you could add a second SR (SIPO like the 74xx595) to control the mux. That would be 4-5 pins all up I think.

my assumption is that these ICs will draw a tiny amount of power relative to that of the uC being awake.

Probably true, that counter uses 20uA by the looks of it.

But the ATmega328 only uses about 0.1uA in power-down mode. You'll have to do the maths, estimate how long it takes to handle a counter in an ISR (tip, not very long, just a few uS plus wakeup over head) and calc the average power consumption.

Using the processor with sleep modes is still probably the best option, but not with all the Arduino stuff on the PCB, you'd have to do your own stand alone board.

Also, if you use external chips what's going to power the Arduino on/off?

Will this be a product or a one off?


Rob