Search This Blog

Saturday, March 24, 2012

Simulation mode for the Geiger Counter

While obtaining samples of materials radioactive above background is not an easy task (fortunately for the sake of human health), I had to find a way of testing the dose measurement algorithm in a different way. As I have explained in a previous post, the device is divided in two modules: a UI module, and the detector device. Each has its own digital logic, and communicate with each other through an I2C bus. As such creating a simulation mode would be a simple mather of programming a new function in the detector that would allow randomly spaced pulses to be generated, instead of being triggered by the Geiger tube. This have been done simply by using the Atmel standard libraries random() function. Using the interrupt generated by the watchdog timer overflow, the following code is executed periodically:

ISR(WDT_vect) {
int i;


if(current_time.value < MAX_SHORT)
current_time.value = 0;

if(simul_mode) {
new_event = (random() % 2 == 0);

if(new_event) {
if(rad_count.value < 0xFFFF)
rad_count.value = 0;

for(i = 0; i < 3; i++) {
cbi(PORTB, PB1);
sbi(PORTB, PB1);

new_event = 0;


Basically it checks if simulation mode is enabled, in this case getting a new random value every 16 millisseconds. Depending on the value being divisible by 2 or not, a pulse is produced, and just like in normal operation, the event counter is increased. As such on the UI module, these are treated just like real events.

Simulation mode can be enabled or disabled just by writing commands via I2C. The current status (simulation or real mode) can be read by reading the corresponding register through the I2C bus as well.

As such the firmware on the UI module was modified to include this as a new menu function.

The video below demonstrates the new function in operation.

A tone sequence is now triggered during bootup to test the audio amplifier and provide the user an indication of the current volume level.


Rui Martins said...

Nice, but use a file or similar device to remove those ruff edges, to improve the finishing look of the device.

Luis Teixeira said...

You are right. It's pretty rough looking for a measurement instrument. It is however a bit of a challenge getting the crappy plastic of that box to be smoothed like we want. I might ask for donations to buy a plastic sintering 3d printer :)