ATTiny, Counting with interupts

Robin2:
I am still a bit unsure about your external stuff. I think your LM567 produces a LOW everytime it detects the tone it is programmed for. I also think you said that the interval between successive tones (and hence LOWs) will be at least 250msecs.

Correct the LM567 pulses low when it detects a tone but the 250ms is the length of a single beep, the gap between beeps can be hours or so fast that they sound like a continuous tone, as in my sample mp3 above.

As it seems the smallest individual pulse width is 250ms (note as I don't have an oscilloscope to measure so I simply recorded a beep in Audacity to measure it) then sampling at 100ms should be safe, but this could easily be shortened.

The timing for your sampling will be a little more accurate if you use

lastBeepTime += 100;

instead of

lastBeepTime = currentTime;

For an explanation rad this long Thread

It would be better to store the 100 in a const at the top of the code.

Thanks for the link. I'll read up on it.

What would happen if you allow your ISR to increment beepCount until it is 3?

When I was using the ISR to count a rapid stream of beeps, it appears as one long pulse so it only registered as one count. This is why I changed to the above code.

I don't fully understand what your project is trying to do. If it worked it would probably be the simplest solution.

In simple terms again, I just want to count the pulses during a set period or the time the pulse is low. So in theory 1 single 1 second pulse or 10 single pulses during the timing period would be treated the same in the above code.

Regards,

Les