Software for GR130 spectrum analyzer/survey/dose meter
Posted: Wed Dec 24, 2014 2:24 pm
Here's what I've come up with so far for the new cool toy. This is all in perl, and meant for linux, though you can make it run on windows if you install perl, some modules (and an edit for serial port module name), gnuplot, and the GTK runtime, all available, but it multiplies the effort considerably, and I run linux here anyway, being more or less in love with the Mint distribution and the Mate desktop, which is a fork of gnome 2 - that works right. I don't need my desktop to look or work like a phone or tablet, so I ditched Ubuntu awhile back. Version 17.1 of Mint even has compiz (rotating cubes of desktops and other frills) and it even works right. Stable and all that.
Here's the paydirt: There is one small problem, that shows up in different ways in both windows and linux. That that there are no real serial ports anymore, and no standard way to assign a USB<>serial dongle to either a com port or a tty???.
Therefore, I used a trick for linux that doesn't exist in windows at all - when you plug in a serial dongle in linux, a directory is created: /dev/serial/by-id and in this directory will be a list of all the dongles with their factory serial numbers. Thus, if you dedicate one to whatever, you can always look in there, find the matching virtual filename, and pass that to the perl serial port module (Device::SerialPort in linux, Win32::SerialPort in windows). So, since there is zero chance you've got the same dongle AND opsys I have, you're going to have to edit this code a little, for grgrab and grspec (GRplot just works from files, so no worries, other than getting gnuplot (for either opsys) and the other junk you need for windows that linux comes with already.
grgrab is a command line program. You just say that to a terminal, and it finds the serial port (reports that) and goes into wait mode for you to tell the unit to dump its data memory. When done, it will ask you to hit <CR> to exit. No harm is done if you download the same things twice, other than to date stamps in the filesystem. It uses the unit time/date as a filename regardless, and always puts them in your "home" directory under a directory it will create called /GR130 if it's not already there.
This of course, makes it really easy for grplot (which does have a minimal gui for file picking) to find them for plotting. The unit can make three types of files, which get one letter extensions depending on what type they are, so the code knows what type of plot to do on them - the rest is completely automatic, autoscaled and so on, and with real units. This code depends on your having set up the unit for 1 second time resolution in survey mode, and 5 seconds and Sievert units in dose mode,
In both cases, those are the highest resolution modes anyway, and Sieverts are what we use in modern times for dosages.
Here are some screenshots: Once you invoke grplot, you get this for a GUI - just enough to leverage the system file chooser button to get to the files. While you can navigate that anywhere, it already knows to look where grbrab puts things. Choosing a file will result in a plot from gnuplot, perhaps like this one, where I started with nothing near the unit, then placed the Cs137 sample on there for a bit, then took it back off. The unit was in "dose" mode, and set up to save that data in its memory for later dumping via grgrab. Anyone needing to know how to edit the perl (it's pretty easy) need only ask me. You'd change which module to use for the serial port for windows, for example, and of course, where it looks for a dongle, change the name there. There is an example of autodetecting some of this in our standard counter software, but it's laborious to do that for every project, and still doesn't really handle the fact that different dongles will have different ID's in either the linux filesystem or the windows registry.
In either opsys, unplugging and re-plugging the dongle results in assigning it to a new com port of tty. The linux way is far better since you can just look for the hardware ID, which so far, no one has figured out how to do in windows. You just have to guess which com port every time...
grspec is the first version of all this, since the unit allows just dumping a single (the most recent, unsaved in it's store) spectrum. It might be handy for some use-cases, so I left it in the bundle. It only handles one chunk of data, and only does spectra, nothing else.
Here's the paydirt: There is one small problem, that shows up in different ways in both windows and linux. That that there are no real serial ports anymore, and no standard way to assign a USB<>serial dongle to either a com port or a tty???.
Therefore, I used a trick for linux that doesn't exist in windows at all - when you plug in a serial dongle in linux, a directory is created: /dev/serial/by-id and in this directory will be a list of all the dongles with their factory serial numbers. Thus, if you dedicate one to whatever, you can always look in there, find the matching virtual filename, and pass that to the perl serial port module (Device::SerialPort in linux, Win32::SerialPort in windows). So, since there is zero chance you've got the same dongle AND opsys I have, you're going to have to edit this code a little, for grgrab and grspec (GRplot just works from files, so no worries, other than getting gnuplot (for either opsys) and the other junk you need for windows that linux comes with already.
grgrab is a command line program. You just say that to a terminal, and it finds the serial port (reports that) and goes into wait mode for you to tell the unit to dump its data memory. When done, it will ask you to hit <CR> to exit. No harm is done if you download the same things twice, other than to date stamps in the filesystem. It uses the unit time/date as a filename regardless, and always puts them in your "home" directory under a directory it will create called /GR130 if it's not already there.
This of course, makes it really easy for grplot (which does have a minimal gui for file picking) to find them for plotting. The unit can make three types of files, which get one letter extensions depending on what type they are, so the code knows what type of plot to do on them - the rest is completely automatic, autoscaled and so on, and with real units. This code depends on your having set up the unit for 1 second time resolution in survey mode, and 5 seconds and Sievert units in dose mode,
In both cases, those are the highest resolution modes anyway, and Sieverts are what we use in modern times for dosages.
Here are some screenshots: Once you invoke grplot, you get this for a GUI - just enough to leverage the system file chooser button to get to the files. While you can navigate that anywhere, it already knows to look where grbrab puts things. Choosing a file will result in a plot from gnuplot, perhaps like this one, where I started with nothing near the unit, then placed the Cs137 sample on there for a bit, then took it back off. The unit was in "dose" mode, and set up to save that data in its memory for later dumping via grgrab. Anyone needing to know how to edit the perl (it's pretty easy) need only ask me. You'd change which module to use for the serial port for windows, for example, and of course, where it looks for a dongle, change the name there. There is an example of autodetecting some of this in our standard counter software, but it's laborious to do that for every project, and still doesn't really handle the fact that different dongles will have different ID's in either the linux filesystem or the windows registry.
In either opsys, unplugging and re-plugging the dongle results in assigning it to a new com port of tty. The linux way is far better since you can just look for the hardware ID, which so far, no one has figured out how to do in windows. You just have to guess which com port every time...
grspec is the first version of all this, since the unit allows just dumping a single (the most recent, unsaved in it's store) spectrum. It might be handy for some use-cases, so I left it in the bundle. It only handles one chunk of data, and only does spectra, nothing else.