May 9, 2011

Arduino-based event counter

I teach Modern Physics here at CSUC, and we occasionally use isotopes with half-lives of a year or less (such as Zinc-65 and Cadmium-109) for energy-calibration sources for a gamma-spectroscopy lab. I thought it might be fun to try measuring the activity of one of these sources over time and thus get a looooong-scale half-life data-set for students to play around with. Or maybe watch background nuclear count rates as a function of time for a couple months and see if we can locate the sun and/or galactic center from the cosmic ray count rate as a function of time and/or season.

I didn't want to dedicate an entire computer and LabVIEW seat to the project, and besides I haven't yet seen a six-month period here during which our power didn't go off at least once. I figured it'd be nice to have a cheap self-contained module that did nothing else but count and log the counts. Here's what I came up with:

The control unit is an Arduino Pro Mini, 328/3.3V/8MHz. It talks to a DS3231 real-time clock to get time-stamp information, and counts nuclear events (or any other digital signals) using an interrupt. Every hour (or so) it saves the event count to the SD card, with time-stamp information at the beginning and end of the interval, and starts another interval. The board has a large capacitor and a zener diode so that if the power fails the Arduino immediately saves the current count (with time-stamp) and writes a warning in the file to let the user know what happened. When power resumes, so does the counting — on the next line in the file with a new time-stamp, of course. When you're ready to stop collecting data, flip the switch and pull the SD card: everything is saved in ASCII format on the file "DATA.TXT"

It can comfortably count events at up to 10ks/s. Possibly more, but I've not tested it past that rate as that's two orders of magnitude faster than what I need. There is also a count/don't-count switch, a battery backup on the RTC chip, an ALD1701 op-amp follower making sure that the input pulses are 3.3V-safe by the time they reach the Arduino, and of course an LCD that provides helpful information such as the time/date, count, and occasionally an error message.

A complete parts-list, EagleCAD schematic and board layout, and Arduino programs are available here, should you want to make your own. I use the DS3231 library I wrote earlier, so you'll need to either grab that or modify my code to use your own clock routines if you'd prefer. The board layout I put together has larger-than-necessary pads —particularly on the vias— to facilitate 2-sided board production if you're using the toner-transfer method.

In order to set the clock, you'll need to run the SetClock.pde program on the Arduino once. (It's provided in the above link.) This program uses the serial port connection to the Arduino to set the DS3231 clock: send the string "yymmddDhhmmssx" just once, and after that the clock will be fine until the CR1220 battery runs out in 10 years or so. (i.e. "1105092190115x" for 2011 May 9 Monday 7:01:15pm.) After the clock is set the first time, load and run the scaler.pde program for actual data collection.

Good luck with it, and feel free to contact me with any questions if you try making your own.