SparkFun Electronics will be closed on July 3rd, 2015 in observance of Independence Day. Any orders placed after 2:00pm MT on July 2nd will be shipped out after the weekend. Thanks!
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.
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.
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.
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.