Recording Geiger counter CPM
Andrew (ARLISS)
Posts: 213
I am currently building a data logger using a Parallax Quickstart board. It collects various sensor data and records it to a microSD card periodically.
I have recently acquired a Geiger counter from Sparkfun and would like to record the values as counts per minute. As it stands, the counter outputs a random ASCII byte (0 or 1) each time an event happens. How would I go about monitoring the number of random bytes each minute? This is the first sensor of this kind I have used with Propeller, and my experience in Spin is minimal, so I would appreciate a push in the right direction.
Many thanks,
Andrew
I have recently acquired a Geiger counter from Sparkfun and would like to record the values as counts per minute. As it stands, the counter outputs a random ASCII byte (0 or 1) each time an event happens. How would I go about monitoring the number of random bytes each minute? This is the first sensor of this kind I have used with Propeller, and my experience in Spin is minimal, so I would appreciate a push in the right direction.
Many thanks,
Andrew
Comments
Mark,
From what I've read in application note AN015, creating a Schmitt-trigger on the Quickstart board shouldn't be too difficult. However, it's still the code that I'm having trouble getting a start on. Any pointers?
Thanks again,
Andrew
If the pulse is reasonably clean you can use a counter to detect the high/low transition on the TTL pin. Be sure to include a 3.3K resistor on the pin if the input is 5V.
I tried it and this code came out:
I just use the Serial In pin (31) as pulse input, so I can simulate the Geiger pulses with hitting keys on the terminal. You need to connect the Geiger module TX pin over a resistor to a Propeller pin and set this pin in the CON section.
Andy
How has this been working for you? I tried to build that circuit twice (using my own custom PCB) and could never quite get it to work. I was never convinced that their power supply design produced the correct voltage. There's also some concern in the sparkfun comments about the maximum frequency their detector can detect. I was clumsy and eventually broke my LND tube and gave up on that particular design.
My latest project uses my own power supply and the detector circuit from this site: https://sites.google.com/site/diygeigercounter/ with a cheap russian SBM-20 geiger tube.
My current project is here (uses a propeller, nixie tubes, and a russian SBM-20):
http://www.youtube.com/watch?v=6qo9W1SOV3o&list=UU447n3ekXiEXOYTgOcENiEw
The second advantage is the russian tubes are very durable. I was pretty bummed when I broke that ~ $95 LND tube, and said to myself "this is why I can't own nice things" and proceeded to order the cheaper tubes.
http://pastebin.com/Y2cEsstc
Oddly, during another trial, negative CPM numbers showed up in the terminal, notably after I removed the Americium sample and only background radiation was present:http://pastebin.com/3bivpdU8
What are your thoughts on this? Is this behavior normal?
The Geiger counter outputs ASCII "1" or ASCII "0". You'll want to read the Geiger counter's output with a serial driver. You should also be able to send the output directly to a PC terminal window with a Prop Plug or equivalent. The Prop Plug might need a current limiting resistor when used with a 5V signal.
I haven't tested it with a separate serial line. For testing I used the following modifications.
Here's some example output.
The modified "test" version of the code has the second FDS start commented out.
I kept typing "1" into the serial terminal to test it.
The program in the previous post uses a circular buffer to compute the average count rate.
I realized after I posted the above the output is missing a few words.
"total of last 30 seconds = 30 counts, average of last 30 seconds = "
should be:
"total count of last 30 seconds = 30 counts, average rate of last 30 seconds = "
The constants "SAMPLE_TIME_MS" and "PERIODS_TO_AVG" can be changed to change each sampling period (in milliseconds) and the averaging time.
The average will be incorrect until a full set of samples has been taken (30 seconds in the above example).
Sorry the clkfreq*60 produced an overflow in the calculation of the CPM. Here is an improved code: The previous code produced negative numbers when the time between two events was more than 27 seconds. That's an effect of the 32bit resolution of the CNT register. This new code tests for that and produce no negative numbers, but the value will be too low for some time once the measured time was longer than 27 seconds.
@Duane
My code detects the startbit of a serial byte, and waits then until the whole byte was transfered, then it waits for the next startbit. So you can spare the serial object. The transfered value contains anyway no useful information, its only a trigger.
Andy
Okay, I think I'm starting to understand. I thought an "1" indicated an event to count and a "0" was just to let the uC know the device was working but didn't detect an event. After reading the description again, I think the ones and zeros are to aid in generating random numbers?
Thanks for clarifying.
I cannot recall but I think thats what I noticed when I viewed the serial output on a pc termnial.
Its as simple as counting the time between transmissions to determine cpm.
The sparkfun programming has an upper limit of 40 cpm.
As per the sparkfun description.
The sparkfun chip is 5v, so be sure to use a resistor on the connection to the prop. (i use a calculated resistor divider)
I also would not bother with bypassing the logic on the sparkfun board, (attaching the prop to the tube ttl output), I would just read the serial output timing interval.
The more you mess with the tube the higher chances are that you will zap something. (that tube is 500v)
Duane,
I successfully implemented your code in my program and it has been working okay, but is it only counting the ones? My understanding is that either a zero or a one is an event in the Geiger tube, and my original tests with only the Geiger counter connected to my laptop by USB seemed to confirm that. Otherwise, I haven't knowingly encountered any issues with the code you provided.
Thanks again,
Andrew
Andrew,
Yes, the code I posted only counts ones. I missunderstood how the Geiger counter worked.
I think my code could be fixed by changing the line:
to:
While several constants in the program may be changed, you need to make sure the constant "SAMPLE_TIME_MS" is large enough for each of the two cogs in the object to complete their respective loops. The lower limit of "SAMPLE_TIME_MS" is dependant on the baud of the debug line and the number of characters sent through the debug line. It's also dependant on the time it takes to read a character from the Geirger counter.
If you changed the output from:
to something like:
should allow you to use a smaller value for "SAMPLE_TIME_MS".
It might be interesting to set "SAMPLE_TIME_MS" equal to 500 and "PERIODS_TO_AVG" equal to 120. This combination should give you a running average over a full minute with a 2Hz update frequency.
The running average isn't accurate until a full set of samples (120 in the above example) have been collected.
Your code has been working excellently with the Sparkfun Geiger counter. The program that is being used in my project records several other variables to a MicroSD card such as altitude, temperature, and humidity. I have added your code into the program but unfortunately have not had as much success as when it was running by itself.
I have included your Geiger counter code program which works on its own, and the latest version of my program. The values being recorded to the SD card, no matter how high of a count rate shows up as zero. I tried adding Parallax Serial Terminal statements to figure out where the issue resides but have not had any success in doing so. I'm sure I am overlooking something simple, but have not been able to tackle it in my attempts the past few days.
Your ideas and suggestions are appreciated!
Andrew
I don't see what's causing the problem myself but I did find some code (mine) that bothers me.
The code:
Will be a problem if the constant "SAMPLE_TIME" isn't a multiple of 1000.
You probably better off using:
I don't see this line in the version that doesn't work.
The code only checks for ones like my original flawed code instead of checking for both ones and zeros as it should.
This shouldn't be the cause of your program only writing zero though. I can't find what the main problem is.
Thank you for the response. I have made the changes you advised, but as you suspected, they were not the cause of only zeroes being written to the file. Could it be another routine in the program preventing the Geiger counter code from working properly? I've looked over the code many times now and I haven't been able to find the culprit.
If others wish to chime in, I'd love to hear your thoughts. My limited experience has me at a dead end on this one.
Andrew
I think you've run out of cogs. I'm betting you have more serial objects than you need. I think this is another case where a four port object would help.
That would seem to be the issue! I disabled the GPS_SmartMode object which uses its own instance of FullDuplexSerial. The Geiger counter readings now seem to be writing to the MicroSD card successfully. I will take a look at a four-port serial object as you suggested. I am currently looking at Tracy Allen's fullDuplexSerial4port; I will take a stab at implementing it later.
Thanks again for your help!
Andrew
That's the one I'd suggest.
Your welcome.