logging 3 (slow) counters + SDcard

I have 3 counters, they measure liquid flow. For each counter, a +5V signal should be triggered when a certain flow is met. Assuming that each physical count is 100ml, the counter shall show a signal at 100ml, 200mL, and so on. The goal is to use one Arduino to keep counts of all 3 counters.

Sub-goals:
(a) 3 counters * [ch61664] serial.print (PC); use PC to reset counter.
(b) 3 counters * [ch61664] LCD display; use PC to reset counter.
(c) 3 counters * [ch61664] LCD display + write to SDcard; on-board button to reset counts.

  • with debounce

(Constraints/Requirements:

  1. count frequency: 0.1min/count or lower.
    but 2 counters may send triggers at the same time – but probably not within 0.01sec;
  2. it is possible to have a low SDcard-writing frequency, say once in 6h. I'm expecting data interval = 10min, I will have 3 x 6 hr x 6set/hr = 108 data/write
  3. not sure if LCD-display will steal time from the counters)

I am quite new to Arduino programming. I'm not sure if I need interrupt or simple polling (noted a possible time-lag in writing to SDcard -- expects to be read by Excel in PC), and if I need to learn 'protothread'.
Tons of thanks for pointing to a similar successful project with “multiple infrequent counters” or better.

The Arduino operates at 16MHz. That's 16,000,000 instructions per second. With an average pulse rate of once every 6 seconds, the Arduino will spend most of it's time doing nothing.

However, it is still possible that the Arduino will be busy doing something when a pulse occurs, and will miss it. The likelihood of that happening depends on how long the pulse lasts, and you didn't mention that.

If it's a 4 microsecond pulse, it might be missed. If it's a 4 second pulse, it won't be missed.

the 'hardware' is still in the lab and I will test it pretty soon. I have a feeling that the Pulse will last ~0.1s. My concern is more on the time Arduino spends to attend to SDcard and LCDdisplay, am I over-worried?

Just in case SDcard/LCDdisplay is not going to be a serious concern, can I just do simple Polling without extensive use of Interrupt ?

Many thanks.

My concern is more on the time Arduino spends to attend to SDcard and LCDdisplay, am I over-worried?

There was a reply to a thread this morning from a person successfully writing 70 bytes to an SD card several times per second. LCDs are orders of magnitude faster, so, yes, you are probably worried about nothing.

The only way to really tell is to try it out on your hardware.

If it is essential to never miss a pulse, external interrupts are the only way to go. The UNO/Duemilanove only support 2 external interrupts (you need 3), but the Mega supports 6 external interrupts.

The UNO/Duemilanove only support 2 external interrupts (you need 3)

While there are only two pins that directly produce an interrupt you can also use the pin change interrupt function to get your third on a Duemilanove.

While there are only two pins that directly produce an interrupt you can also use the pin change interrupt function to get your third on a Duemilanove.

This would be a good spot to provide a hint as to how that is done. Got a link?

Well it's in the data sheet but I used that method on my project:-
http://www.thebox.myzen.co.uk/Hardware/Crazy_People.html
To read 6 signals from three RFID readers through interrupts.

Seriously. Many thanks.
I shall start with polling. (missing counts of 1-2% should be acceptable).
For 3-interrupts in Duemilanove, it looks like a huge challenge. I may try that later.