## Building a Random Number Generating Geiger Counter

After a customer suggested that we carry Geiger-Muller tubes for detecting ionizing radiation, I looked into the possibility of building a Geiger counter. Little did I know, this project would turn into so much more.

A Geiger tube is far from your basic digital sensor. Most Geiger tubes need 100s of volts to create enough of a potential to detect an ionizing event within the Geiger tube. Once a gamma ray, alpha, or beta particle hits one of the atoms of gas inside the tube, an electron is knocked off and the atom has been ionized. Since the gas is under a large potential (100s of volts), the electron cascades rather quickly through the rest of the atoms in the gas. Once this happens, an avalanche of electrons is created and a pulse of current is formed on the output of the Geiger tube along with each event. Designing the high voltage power source and a simple digital output would be fun in itself, but I thought that a random number generator would make more use out of the random events the Geiger counter would detect.

What is the point of making a random number?

Computer encrytption is based on random number generation. Simulating complex behaviors requires a uniform distribution of numbers. For instance, chaotic systems like a flag waving in the wind or instabilities in fluids use random numbers to help better measure dynamical properties.

Monte Carlo simulations use random numbers to approximate physical constants like Pi (which we will get to) or the acceleration of the universe. And even music and art have components of randomness that give each piece it's own uniqueness. This project is broken up into three sections: a high voltage power supply, digital output, and random number generator. The sections will incorporate high voltage analog electronics, digital electronics, statistics, and a radioactive test source.

### High Voltage Power Supply

There are many ways to turn a low voltage into a very high voltage. An oscillator attached to a simple voltage multiplier would do the trick, as this is a common approach. A quick search on the web...Wow! There are many really good resources online as to how to build high voltage sources for Geiger Tubes. Techlib has a great site and provided some great example circuit diagrams.

Safety Note: Before jumping head first into high voltage power supplies, check out this safety information.

The Geiger tube I am using is an end window alpha-beta-gamma detector from LND Inc. (COM-08875) and recommends 500V across the anode and cathode.

Here are the two main parts of the high voltage supply; the oscillator and the voltage multiplier. Here is my schematic:

And here is what it looks like assembled on my breadboard.

(Hmm, now which wires should I not touch?!) It is really cool that with just a handful of components, you can generate such a high voltage. Imagine if I just made some small changes and threw a few more caps and diodes onto the voltage multiplier, I could make myself a Tesla Coil! Kinda creepy.

After assembling the components together I double checked all of my connections and probed for shorts (this breadboard has survived me since junior year in college and I could swear some of the conductive lines are damaged.) Everything looks good.

We are dealing with a high voltage, but a rather small current (micro amps), which is one reason why the power loaded on the caps really isn't much to worry about. Remember, static electricity contains 1000s of volts, but a tiny amount of current!

When measuring this low of an output current, a regular multimeter might load the output enough to really drop the voltage, therefore I added a series 10MOhm resistor in line with my multimeter. Assuming my multimeter has a DC resistance of 10MOhm, I basically just constructed a voltage divider. Whatever I see on the multimeter, I can assume that I am reading close to double the unloaded voltage output of the supply. Here is what I got:

Pretty close to half of 500V! I can assume my supply is outputting around 500V give or take 50 or so volts, which is within spec of the Geiger tube.

Another Safety Note: After building the completed Geiger counter, I was getting zapped when I would turn the device off. The zap wasn't much really, I would rate it a little more powerful than a good static shock, although it was considerable enough that I felt a short surge of heat. What was happening was that the big 0.01uF caps were holding charge and floating waiting to stop my heart. To prevent this, when I switched off the Geiger counter, I connected the high voltage line to a 100kOhm bleed resistor to ground. This allowed the remaining current to dissipate through the resistor instead of me.

Now it is time for me to test the Geiger tube. I used the manufacturers suggested schematic, which was simply a series 1MOhm and 10 Mohm resistor divided by a 50pF cap for the output. I attached the output to the o-scope and saw these noisy blips every few seconds.

Looks kind of odd, but the infrequent behavior of these blips and the amount (about 20 counts per minute) seemed reasonable for background radiation levels.

Background radiation is due to radioactive sources that are all around us, close and far. It is found inside our bodies, in lima beans and beer (mmm radiation), in wood, in anything that is a living organism, in the earth's crust, in our atmosphere, all over outer space, and of course from human technology.

Here are some fun facts: 1 gram of lima beans have about 4.6 pCi of Potassium-40, which comes out to about 1 decay (1 particle) every 5-6 seconds of a beta particle. Beta particles are actually used to treat certain types of cancer and can, coincidentally create cancer or mutations in healthy tissue, but there is really no reason to be afraid of a bowl of lima beans. One main reason: probability. First, there is a chance the particle could interact with something before it hits you (not so much the case with gamma rays). The intensity decreases as one over the distance squared (1/r2) and the chances of one particle being emitted directly at you is very low; it could be emitted in the opposite direction of you. If the beta particle happens to hit you, there is even less of a chance that the particle will happen to hit the part of your DNA that will harm you. One of the reasons radioactive sources like x-rays could give you cancer is that there are so many particles hitting you, there is a greater chance of one striking your DNA. And finally our body already contains about 100,000pCi of Potassium-40!

To be sure I was actually seeing background radiation in the form of gamma, alpha, or beta particles. I would need to have a piece radioactive material. The most common alpha emitter is Americium, found in common ionizing smoke detectors. I decided to get one and crack it open to get the Americium pellet, since it was the fastest and cheapest way to get my hands on radioactive material. However, we have heard that this might be a bad idea and could infringe on some federal regulations, so we don't suggest doing this, there are other radioactive sources that can be purchased. In addition, if the dust or particles from Americium were ingested from handling you would have extra radiation implanted in your body. Not good. Anyway, here is what it looks like:

When I held this little thing in front of the Geiger Counter I saw this on the o-scope:

Then I noticed my hand glowing and feelings of nausea. Not really. Just making sure you were paying attention.

That readout convinced me the Geiger Counter was actually working to some extent! The next step was to turn the signals into a usable digital waveform.

### Digital Output

In order to resolve the small pulses of current from the Geiger tube, the first thing I tried was a simple resistor-transistor logic circuit.

If there is a small current entering the base of the transistor, the collector will be amplified, thus forward biasing the emitter base junction. Connecting the collector in series with a resistor and 5V power source and the emitter to ground, the output line will be at 5V until a pulse from the Geiger tube is present on the base of the transistor, then the line will be pulled to a noisy low state.

To clean the output in its low state, I basically formed a low pass filter with a capacitor in parallel to the collector resistor. After trying a couple of capacitor values, I got a nice quick charge curve on the rising edge of the pulse. This is what I saw. Much better!

Looks pretty good. Next step was to hook up an LED to the output as shown in the above schematic, (sorry no classic buzzer, buzzers annoy me and people around me). Sure enough, the LED stays off until a pulse comes along and pulls the LED to GND, thus lighting the LED.

Next, I hooked the output up to an IO pin on my ATMega168. The edges were clean enough to register an event on the input pin.

My next move was to design a compact unit that will take the pulses and output a random number over USB. Below is a picture of my prototype, here is the one we currently sell.

### Random Number Generator

Now that I have random bits that can be seen by my micro, I can now create an algorithm that will give me a random number.

According to Jon von Neumann, “Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” Since I am already starting out with a truly random source, I want to make very basic assumptions about how to create random numbers.

Let me comment on the difference between truly random sources and pseudorandom sources. Computers programs will generate pseudo random numbers using mathematical formulae (unless the random number generation is based on quantum mechanical effects, like shot noise).  They are, therefore very fast at doing so, but unfortunately more deterministic than a truly random source. A true random event is something like a coin flip, a lightening strike, noise in our atmosphere, or background radiation. True random number generation does generally have a downside. It can take a long time to get many random numbers, since events can be sparse.

A truely random event alone doesn't have any random information. What is random is the time between events. All I need to do is measure the time between event 1 and event 2, then measure the time between event 2 and event 3 and so on. If the time between events 1 and 2 is less than 2 and 3, output a 0. If the time between events 1 and 2 is greater than 2 and 3, output a 1.

T1 < T2 output 0
T2 > T3 output 1

I now have a random bit generator. The first event I disregard, since I don't want to start comparing times until at least two events happen. Then, after an arbitrary amount of events, I can look at the bits accumulated. With 8 bits, which takes less than 30 seconds to obtain, there are 256 possible numbers that could occur. If I let the bits accumulate over time, I can create huge random values.

How random are the numbers? There is a really nice pseudorandom number test program called ENT you can download. With this tester, I can measure the entropy in my bit stream, Chi squared distribution, Monte Carlo simulated value for pi, and the arithmetic mean (50/50 distribution).

Here is my C code for an ATMega168, it's not perfect and results in a slightly non-random output.

I probably could of used the hardware timer on the ATMega to improve the randomness, but there is another element that takes some of the randomness out of detecting truly random background radiation; the Geiger tube. The tube has a specification called the minimum dead time. When an event occurs in the Geiger tube, it takes a certain amount of time (~90 microseconds with this tube) for the particle to create the current pulse and for the gas to quench itself after the ionizing event. During this time, another event cannot be detected. Although, we might miss very few events compared to how many collected, this inherent artifact in the tube does have an affect on the randomness.

Send us your results, let us know if you create any code that improves the randomness.

Cheers!

-Aaron
aaron@sparkfun.com

• Get some “salt substitute” from the grocery store. It usually has a fair amount of KCl (potassium chloride) in it. That should give you decent counts in a short period. Also, check out United Nuclear. They have all manner of radioactive stuff, including uranium ore…

• I wouldn’t be all that worried about the Americium in a smoke detector. First, it’s an almost purely alpha source (Am-241 undergoes alpha decay into the relatively stable Np-237). A centimeter of air, a sheet of paper, or your layer of dead skin are adequate shielding for alpha radiation. About the only way it can hurt you is if you inhale or eat it. Second, a typical smoke detector only contains about 0.2 _micro_grams of Am-241. It’s not a pellet and there’s no dust or particles- it’s just a tiny smear that’s been fused onto a metal disc. Here’s a better picture I’ve taken.
Certainly ionizing radiation is something to respected, but I wouldn’t worry about smoke detectors. In fact, the Nuclear Regulatory Commission estimates the worst-case scenario of a firefighter responding to a burning warehouse full of smoke detectors would still receive far less radiation (~0.3 millirem) than normal daily exposure (~1 millirem). (citation)
Fun fact: Every banana you eat exposes you to about 0.01 millirem.

• Just don’t eat it or breathe it. Alpha emitters are generally a non-issue outside the body where shielding (air) and distance are available. Put alpha emitters in lung tissue or in bone near the marrow and alphas can do some serious long-term damage. Nothing to be paranoid about; just treat radioactive material with appropriate caution as you would with high voltage, live steam, or any other hazard. Know the risks and don’t be cavalier about them.

• Exactly. All that “stopped by a sheet of paper” business doesn’t mean squat if you inhale or ingest a tiny bit. Polonium-210, another “safe” alpha emittter, which is in a fancy-schmancy photgrapher’s lens brush I have used, was apparently used to murder Alexander Litvinenko (a political dissedent).
DO NOT pull your smoke detector apart, it is not prudent to breach the Americum capsule. This is from a guy who used to keep a small piece of Uraninite on his desk. (until it “walked away”).

• How can I re-upload another firmware ?

• A suggestion to remove the bias from the Geiger tube’s minimum dead time: You said for this tube that’s about 90 microseconds. Could you add a program or circuit that disregards any counts for, say, 200 microseconds after the last count? As long as whatever creates that ‘blind interval’ doesn’t introduce any bias, you should be able to eliminate the dead-time bias.

• I use the Fluke 117 multimeter for my household meter as well! I love them, great size and accurate!

• Hello. I have the following question about the high voltage power supply. What is setting the output voltage to 500V instead of other voltage, say 400V or 600V? I see no feedback in the circuit so I can’t tell how that voltage is configured.

Thank you very much. Andrés

• Hello. I have the following question about the high voltage power supply. What is setting the output voltage to 500V instead of other voltage, say 400V or 600V? I see no feedback in the circuit so I can’t tell how that voltage is configured.

Thank you very much. Andrés

• Absolutely nothing. Spark-fun removed the voltage regulator for no reason I can discern.

The circuit as drawn above actually produces about 1-1.5KV. The method he is using to measure the voltage is drawing the voltage down to ~500V.

• On the Digital Output section of your tutorial, doesn’t the addition of a 4.7uF cap at the output of Q4 really blocks the detection of additional pulses?

The scope waveform shows multiple pulses occurring on a 100 ms division. If you can only output one pulse every 5 or six tube pulses….

• Does anyone have an Eagle library for the LND 712? Would be much appreciated!

• speaking to Tesla coils
does anyone know how to generate that amount of voltage from conventional ac supply
voltage multipliers cant push voltage upto 10000v

• I don’t really follow your question, but other than building a Tesla coil, neon sign transformers are inexpensive and readily available - just be aware that a lot of the newer solid state models have too many safety features for mad scientist uses - you need the more expensive old fashioned ones. Of course, I suggest building the Tesla. I built one in 6th grade. It was about 3' tall, and kicked out an estimated 250,000 volts. Can you imagine dragging that into science class to show off in today’s world?
(In the interest of full disclosure, I had access to a motor rewinding shop after hours as a child - that did make the task a bit easier - sadly that youthful playground is no more.)
Anyway, the better job you do of asking the question, the better job we can do of answering it, so if my answer isn’t dispositive, try asking with a bit more detail about your needs.

• To test the randomness of the data gathered using this device and a sample of Uranium ore, I gathered 4 groups of 65536 bits each.
Here are the results:
Group1:
Bit 0 found 31922 times
Bit 1 found 33614 times
Mean: 0.512908935547
ChiSquare: 43.6838378906 with a DOF of 1 mean that it is not a valid random sample
Group2:
Bit 0 found 31885 times
Bit 1 found 33651 times
Mean: 0.513473510742
ChiSquare: 47.5884399414 with a DOF of 1 mean that it is not a valid random sample
Group3:
Bit 0 found 31960 times
Bit 1 found 33576 times
Mean: 0.512329101562
ChiSquare: 39.84765625 with a DOF of 1 mean that it is not a valid random sample
Group4:
Bit 0 found 31982 times
Bit 1 found 33554 times
Mean: 0.511993408203
ChiSquare: 37.7072753906 with a DOF of 1 mean that it is not a valid random sample
What software do I need to reprogram the on board Atmega168 to improve randomness? I would like to implement the algorithm that takes 4 events instead of 3 to generate a bit.

• The Hotbits web site, which describes a similar project,
warns against the statistical bias that results from using three events to produce two time intervals (http://fourmilab.ch/hotbits/how3.html).
Four events per bit are required to eliminate the statistical bias.

• There is an error on the schematic. In the detector area where you show a symbol for a resistor but the reference designator is CAP 50pF. Took me a minute to figure out how you were detecting the current spike till I noticed the ref des and value.

• “In practice, to avoid any residual bias resulting from non-random systematic errors in the apparatus or measuring process consistently favouring one state, the sense of the comparison between T1 and T2 is reversed for consecutive bits.” –John Walker
http://www.fourmilab.ch/hotbits/how3.html
ie, measure the time between 4 counts and compare the length of T1->T2 to T3->T4, if the latter is greater, output one, if the former is greater, output zero, if they are the same, no output.

In 2003, CU student Nate Seidle blew a power supply in his dorm room and, in lieu of a way to order easy replacements, decided to start his own company. Since then, SparkFun has been committed to sustainably helping our world achieve electronics literacy from our headquarters in Boulder, Colorado.

No matter your vision, SparkFun's products and resources are designed to make the world of electronics more accessible. In addition to over 2,000 open source components and widgets, SparkFun offers curriculum, training and online tutorials designed to help demystify the wonderful world of embedded electronics. We're here to help you start something.