~~SS~~

Hot Projects

DIY Food Hacking

Open Solar Power

picoReflow

DIY Reflow Soldering

PiGI

RasPi Geiger Counter

Wideband Antenna

Map everything!

~~TAGCLOUD:50~~

Personal Log: PiGI Testing

Some time ago i stumbled upon the PiGI project, joined the chatroom and somehow convinced chrono to send me a prototype board. Thanks for that! So here will be a summary of my testing of the PiGI.

The Geiger-Mueller-Tube

I bought an old russian SBM-20 tube on ebay for 26\$ and soldered some cable to both ends and isolated the ends with heat-shrink tubing. Then i soldered it to my PiGI with some leads that I thougt had sufficient isolation for high voltages.

The PiGI and my Pi

Well, connecting the PiGI is pretty easy, just push it onto the pin headers. But I also came up with some other possibilities. To connect the PiGI to a breadboard (and Arduino and stuff) I soldered my own breadboard-adapter.

And if you build two and get a ribbon cable, you can also connect your PI to the breadboard.

I compiled the software examples you can find here and got it to work, but right now I can't even remeber how I focussed more on the Arduino stuff below.

The PiGI and Arduino

Connecting the PiGI to an Arduino (or other microcontroler) is easy. Just connect 3.3V to pin 1, 5.0V to pin 2, GND to pin 25, and connect the interrupt D2 of the Arduino to pin 7 of your PiGI.

Simple Beeper

// Simple PiGI beeper for Arduino, 2014, by "JamesT42"
// Written in Arduino 1.0.5 IDE

// Connect the PiGI to D2, which is Interrupt 0
// This program lights up a LED and plays a tone. You can also use a small beeper (the ones you simply connect
// to 5V and where you cant vary the frequency of the tone) connected to the same Pin as the LED.

#define TonePin           A2            // Pin for the speaker
#define ToneFreq          200           // Frequency of the tone
#define LED               13            // Pin for optical signal, you can also connect a beeper here

volatile long counter = 0;
long lastcounter = 0;

void setup() {
/*
Activating the Interrupt: If the signal on Pin 2 drops below the threshold "FALLING",
the function CountInterrupt() is called
*/
attachInterrupt(0, CountInterrupt, FALLING);
pinMode(LED, OUTPUT);
pinMode(TonePin, OUTPUT);
}

void loop() {

if (counter > lastcounter) {
maketone();
lastcounter = lastcounter + 1;
if (counter > lastcounter + 10) {
lastcounter = counter;
}
}

}

void maketone() {
// play tone and turn on LED
tone(TonePin, ToneFreq);
digitalWrite(LED, HIGH);
// delay blocks the program, only usable for lower count rates, should upgrade to something without delay!
delay(25);
// stop the tone playing and turn off LED
noTone(TonePin);
digitalWrite(LED, LOW);
}

void CountInterrupt() {
// just count the events
counter = counter + 1;
}


Simple counter

// Simple PiGI counter for Arduino, 2014, by "JamesT42"
// Written in Arduino 1.0.5 IDE

// Connect the PiGI to D2, which is Interrupt 0
// This program counts the events in a predefined timespan (countingtime) and outputs the resulting cpm
// (counts per minute) to the serial port of your PC. So open up the Serial Monitor!

long lasttime = 0;
long counter = 0;
long countingtime = 30000;  // 30 seconds
float cpm = 0.0;

void setup() {
/*
Activating the Interrupt: If the signal on Pin 2 drops below the threshold "FALLING",
the function CountInterrupt() is called
*/
attachInterrupt(0, CountInterrupt, FALLING);
// Init the serial port
Serial.begin(57600);
Serial.println("PiGI Simple Counter");
}

void loop() {

if (millis() - lasttime > countingtime) {
lasttime = millis();
cpm = (float)counter / countingtime * 60000;
Serial.print("I counted ");
Serial.print(counter);
Serial.print(" events in the last ");
Serial.print(countingtime/1000);
Serial.print(" seconds, that amounts to ");
Serial.print(cpm);
Serial.println(" cpm");
counter = 0;
}
}

void CountInterrupt() {
// just count the events
counter = counter + 1;
}

To improve the program, one should calculate some type of running average on the cpm values.

Generating random numbers (proof-of-concept)

Recently, i visited a lecture about computer physics, and when we discussed different random number generators I had the idea to implement a random number generator based on radioactive decay. See this Sparfun tutorial for the principles or this page.

// Geiger-Mueller-Counter for random numbers, 2013, by "JamesT42"
// Written in Arduino 1.0.5 IDE

// Connect the PiGI to D2, which is Interrupt 0

// Defining the variables
volatile unsigned long t1 = 0;
volatile unsigned long t2 = 0;
volatile unsigned long t3 = 0;
volatile unsigned long t4 = 0;
volatile unsigned long T1 = 0;
volatile unsigned long T2 = 0;
volatile unsigned long time = 0;
volatile unsigned long counter = 0;
volatile int number = -1;

void setup() {

// Init the serial port
Serial.begin(57600);
Serial.println("Geiger-Mueller-Interface for random numbers");

/*
Activating the Interrupt: If the signal on Pin 2 drops below the threshold "FALLING",
the function Interrupt() is called
*/
attachInterrupt(0, Interrupt, FALLING);
}

void loop() {

// Does nothing

}

void Interrupt() {   // Interrupt-function

time = micros();   // Save the current time
counter = counter + 1;   // Count all events

switch (counter % 4)     // Division modulo 4
{
case 0:
t1 = time;
break;
case 1:
t2 = time;
break;
case 2:
t3 = time;
break;
case 3:
t4 = time;
T1 = t2 - t1;
T2 = t4 - t3;
if (T1 == T2)
{
// Do nothing, this can happen if the clock resolution is not high enough
}
else
{
if (T1 > T2)
{
number = 0;
Serial.print(number);
}
if (T1 < T2)
{
number = 1;
Serial.print(number);
}
}
break;
}
return;
}

To improve the program, you should switch the logic of what is 0 and 1 every time. That can be accomplished by changing to modulo 8 and copying cases 0/1/2 to 4/5/6 and switching the 0/1 in case 3 to be case 7.

Discussion

, 2014/02/14 19:52

Nice one! For me it felt the opposite of convincing, you just jumped in and started to dis/prove the dead-time calculation - which I had my doubts about but didn't feel confident enough to tackle alone - and seemed generally excited about becoming/being part of the loose team of people who actually work on it. You freely and generously gave the most precious thing we can give: time.

Therefore, it seemed only logical and fair to build another prototype board for you, so that you can experiment with it and report back how it went, sort of like a Ghetto-Peer-Review. :)

And here you did, so thank you :)

Enter your comment. Wiki syntax is allowed:
  ____    _  __ __  __   ___    __ __
/ __ \  / |/ / \ \/ /  / _ \  / //_/
/ /_/ / /    /   \  /  / // / / ,<
\___\_\/_/|_/    /_/  /____/ /_/|_|