NIM-duino as ersatz counter-ratemeter (counts up to ~50000 counts per second)

Semi-permanent mounting and wiring configuration of the Arduino/Ruggeduino in a NIM casette.

The Bonse Hart USAXS instrument is coming along nicely, and the expectation is that we can start using X-rays pretty soon. One missing element in my detector electronics chain, however, is a counter and rate-meter. Normally, one would buy these as NIM modules, in which case they are very nice, reliable and expensive (for example the Canberra 512 one which will cost on the order of 5 kEuro, and a similarly priced ratemeter module would be required as well). Alas, such money is not available in my budget at this time, so an alternative solution had to be found.

Semi-permanent mounting and wiring configuration of the Arduino/Ruggeduino in a NIM casette.
Figure 1: Semi-permanent configuration of the Arduino/Ruggeduino in a NIM casette.

Those of you who are following my Twitter stream (user @drheaddamage) will have seen the occasional tweet on the solution: letting the counting and ratemeting be done by an Arduino (or rather, a Ruggeduino variant, which is an Arduino for stupid people like me who like to make many mistakes in electronics engineering). I am happy to say that the project is now pretty much complete, with only the actual integration in the detection chain left to do (edit: this has now been done, and it works if the 100kOhm resistor connected to the BNC is replaced by a 120 Ohm resistor. Otherwise it will not detect the short pulses emanating from the Single Channel Analyser (SCA) module.).

The concept is straightforward: Sense the rising edge of a pulse coming in on one pin and count it. Simultaneously, keep track of the time spent actually counting (i.e. not the time spent on other administrative tasks) and be ready to export this information through the serial port to the controlling computer.

Hand-drawn connection schematic for fitting the Ruggeduino/Arduino into a NIM module
Hand-drawn connection schematic for fitting the Ruggeduino/Arduino into a NIM module

As it turns out, this is easy to do with an Arduino Uno, as it has two pins that can do event-based operations. Simple wiring, with the occasional resistor thrown in to help keep things under control (though this is not strictly required in the Ruggeduino) and a lot of crossed fingers when it is actually put into action may just do the trick.

The attached picture (Figure 1) shows the Arduino in its semi-permanent state, mounted in a NIM module. This module used to be an Ortec high voltage power supply, but turned out to be broken. The potentiometer, LEDs, switches and NIM and BNC connector have been reused. Testing with a signal generator showed a counting capability up to about 100000 counts per second, which is also pretty much the limit of my scintillation counter. Serial overhead seems to be very small so intermediate readout of the counter is no problem. I, for one, am quite excited to see if this all will work!

If anyone is interested in the code, it can be downloaded here: Counter_and_ratemeter_v0p2. It is not neat code, but I tried to keep it organised and legible. The connection diagram is hand-drawn and shown in Figure 2.

I have to agree with Pete Jemian, who noted that “the prospect of low-cost control systems involving Linux, EPICS, and the Raspberry Pi with Arduino or BeagleBone I/O boards has begun a new generation in value automation systems”. Let’s see what other (ab-)uses we can find for these things in the X-ray sciences! As always, questions and comments are very welcome below.


  1. Amazing project! – I’m trying to replicate it, but looking at the code you’ve supplied, it looks like there are a few things not working – pins allocated wrongly and such. Same thing goes for the circuit diagram Have you perhaps uploaded a dev version of the program?

    Sorry to bring up a 7 year old post..

    Thouroughly enjoying your blog!


1 Trackback / Pingback

  1. Spending money on Bonse Hart Bling-Bling | Looking At Nothing - A SA(X)S Weblog

Leave a Reply

Your email address will not be published.



This site uses Akismet to reduce spam. Learn how your comment data is processed.