====== Personal Log: PiGI Testing ====== Some time ago i stumbled upon the [[lab:pigi|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. {{ :mission:log:2014:02:08:pigi-jamest42.jpg?200 |}} ===== 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. {{ :mission:log:2014:02:08:sbm-20.jpg?200 |}} ===== 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. {{ :mission:log:2014:02:08:adapter-back.jpg?200 |}} {{ :mission:log:2014:02:08:adapter-front.jpg?200 |}} And if you build two and get a ribbon cable, you can also connect your PI to the breadboard. {{ :mission:log:2014:02:08:pigi-arduino-pi.jpg?200 |}} I compiled the software examples you can find [[lab:pigi:software|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. {{ :mission:log:2014:02:08:pigi-arduino-breadboard.jpg?200 |}} ==== 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 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 // 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 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 [[https://www.sparkfun.com/tutorials/132|this Sparfun tutorial for the principles]] or [[http://www.ciphergoth.org/crypto/unbiasing/|this page]]. // 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. {{tag>pigi raspberry pi hardware arduino random software research}} {{keywords>Apollo-NG apollo next generation hackerspace hacker space research development makerspace fablab diy community open-resource open resource mobile hackbus pigi raspberry pi hardware arduino random software}} ~~DISCUSSION~~