Settable (dynamically) counter IC

Not quite sure if this is the correct forum....

I am looking for a counter IC that I can send a command to like '100', it will count to that number, and will set a pin to high (or low, whatever). I want to use something off board to do the counting, because I don't know how fast the data will be coming in, and I don't want to have my main board (Arduino) stuck counting cycles. It only needs to respond to the interrupt when the count is hit.

I could just use some 74xx or 40xx series ICs, but I don't know of one that will let me set it dynamically. Let's say I want to count to 100, then the next set of cycles to 50, etc. The standard ICs have to be wired, and the proper reset level set.

Any suggestions?

I am looking for a counter IC that I can send a command to like '100', it will count to that number, and will set a pin to high (or low, whatever).

The IC will count what? Something has to tell the IC that it's time to chalk up another tally.

I want to use something off board to do the counting, because I don't know how fast the data will be coming in, and I don't want to have my main board (Arduino) stuck counting cycles.

Where is the data coming from? What else is the Arduino doing? Can the incoming data trigger an interrupt?

Sorry, I was a bit vague. The IC will count logic level pulses. Since I am still trying to figure out if there is something out there, I don’t care if it is on rising, falling or both edges of the signal.

The Arduino will be doing other higher level stuff, such as math, ADC, etc. Once the counter hits the set point and triggers the interrupt, I want the Arduino to take an analog reading on another pin.

It would look like this:

x number of pulses → counter IC → interrupt → Arduino.
Where X could be changed on the fly by the Arduino.

Have you determined that the Arduino is not capable of responding to the rising/falling interrupt and counting occurrences?

Where are the "logic level pulses" coming from?

At least one of the AVR timers is capable of being clocked from an external pin, so it can be configured to do exactly what you want (generate an interrupts on the 100th clock; up to 255, maybe up to 65535) (Looks like there are two such clock inputs, T0 and T1, on Arduino pins 4 and 5. T0 can clock either timer0 or timer2, and T1 can clock timer1, if my quick look at the data sheet is right.)

You can use a 74HC393 (8 bit counter) feeding into one side of a 74HC85 (magnitude comparator), then feed the other side from a shift register 74HC594. Into the 594 feed your number with the shift out tutorial. When the two numbers are equal the = output goes high. The 393 counter can be reset with an arduino output.

Where are the “logic level pulses” coming from?

They probably come from some logic level stuff? :smiley:

More importantly, how fast will these signals be? Is there any chance the Arduino might miss this “count reached” signal? (I’m not sure how the hardware interrupt is made).

And not the lest, what westfw says! The AVR got it built-in too, so you might not need any extra counter IC’s at all. But it will cost you some 2 PWM outputs for each timer you use. I’m unsure if you can use timer0, as that’s also used for millis() and some other rather important stuff Arduino-wise.

I also wrote a somewhat lengthy mumbling answer combining presettable counters and whatnot, but then I remembered there are those things called “divide-by-N” counters. A quick googling gave me the 4059, or 74HCT4059, which might fit the bill. It can divide the input frequency from 3 to 15999.

Grumpy Mike, your circuit might be the ticket! raron, same thing. I think in order to make the 74hct4059 work, it will need some supporting chips, just so I don't need a tremendous number of pins in order for it to work.

I didn't want to use the Arduino directly. I am doing a handful of analog readings (which as I've read take significant amount of time), I am currently driving 2 servos (PWM output), and I still have more features I am trying to add. I don't know how often the pulses will be coming in, because it will depend on what the sensor is detecting. I just thought that if I could have something external count the pulses, I could have the Arduino doing something more important.

You all may be right, I may be trying to do something that the Arduino can already do, but I just thought that if I could do it off board, I could save the processing cycles for something more important.

kiltjim: I have never used it, but judging from the datasheet it would seem so. 16 JAM inputs, 1 latch enable and 3 mode inputs (and it didn't seem too straight forward in figuring out the dividend either). I'd suggest two or three shift registers (latchable), like the 74HC595.

Grumpy_Mike: Just for the record, my reference to any "lengthy mumbling answer" was not intended for you, but something I didn't include after all. I didn't see your answer until after! (I write slowly) :D

For needs like you describe, there is always the option of using a small microcontroller and implement the functionality you need. The ATTiny series is available in small packages (8-pin DIP and upwards). They have built in timers/counters, interrupt support and can talk to your Arduino through I2C, SPI or serial.