User Tools

Site Tools


Navigation Menu

Rustic Retreat

Live broadcasts and documentation from a remote tech outpost in rustic Portugal. Sharing off-grid life, the necessary research & development and the pursuit of life, without centralized infrastructure.

Rustic RetreatSubscribe to our new main project Rustic Retreat on the projects own website.

Hot Projects

SEEDStack

SEEDStack - Open 3D printable seed/sprouting systemDIY Food Hacking

UCSSPM

UCSSPM - Unified Clear-Sky Solar Prediction ModelOpen Solar Power

picoReflow

picoReflow - DIY PID Reflow Oven Controller based on RaspberryPiDIY Reflow Soldering

PiGI

PiGI - DIY Geiger Counter based on RaspberryPiRasPi Geiger Counter

DIY ARA-2000

Active Wideband Receiver Antenna for SDR - ARA-2000Wideband Antenna

DSpace

DSPace - Map everythingMap everything!

Mission-Tags

This is an old revision of the document!


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.

-Picture 1327 here-

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.

-Picture 1332 -

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.

-Picture 1338 1340 -

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

-Picture 1342 -

I compiled the software examples you can find here and got it to work, but right now I can't even remeber how LOL 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.

- Pic 1344 -

Simple Beeper

// Simple PiGI beeper for Arduino, 2014, by "JamesT42"
// Written in Arduino 1.0.5 IDE
// License:  Creative Commons - Attribution - Share Alike http://creativecommons.org/licenses/by-sa/3.0/

// 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 Interrupt() 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
// License:  Creative Commons - Attribution - Share Alike http://creativecommons.org/licenses/by-sa/3.0/

// 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 Interrupt() 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.

// Geiger-Mueller-Counter for random numbers, 2013, by "JamesT42"
// Written in Arduino 1.0.5 IDE
// License:  Creative Commons - Attribution - Share Alike http://creativecommons.org/licenses/by-sa/3.0/

// 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.