Consider two Geiger tubes placed on top of each other, if an energetic particle passes through both tubes, the output of both Geiger tubes will drop at the same time from ~3V to 0V for approximately 300 microseconds (measured with oscilloscope). Otherwise, both Geiger tubes will give these voltage drops randomly in time.
Is it possible to detect both signals simultaneously, and count these coincident signals with Arduino Uno? So far I manage to make it count individual signals from each Geiger tube using attachInterrupt(), but I do not know how to make it count two signals arriving at the same time (or within an acceptable short interval).
This is my progress so far, and it doesn't work the way I intended. I just modified it from earlier work - detecting signals coming from the tubes individually.
const int pb = 5;
int pbValue;
volatile unsigned long CNT_A; // variable for counting interrupts from Geiger tube A
volatile unsigned long CNT_B; // variable for counting interrupts from Geiger tube B
volatile unsigned long CNT_AB; // variable for counting interrupts from Geiger tube A and B
#include<LiquidCrystal.h> // adding LCD from the library
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // defining digital pinout for LCD
//========================================================================================
void setup() {
pinMode (pb, INPUT);
pbValue = 0; //initial pushbutton value
Serial.begin(9600);
lcd.begin(16,2); // initializes dimension of LCD display, 16 char x 2 lines
CNT_AB = 0; // CNT value for A and B initially 0
lcd.setCursor(0,0);
lcd.print("GM Detector V0.2");
lcd.setCursor(0,1);
lcd.print("ACJC 2021");
delay(2000);
cleanDisplay();
attachInterrupt(digitalPinToInterrupt(2), GetEvent_A, FALLING); // detect event in pin 2
attachInterrupt(digitalPinToInterrupt(3), GetEvent_B, FALLING); // detect event in pin 3
}
//========================================================================================
void loop() {
currentMillis = millis(); // capture the latest value of millis()
lcd.setCursor(0,0); // Sets cursor to character 0, row 0
lcd.print("COINCIDENCE: "); // Prints the defined word
lcd.print(CNT_AB);
GetEvent_AB();
pbValue = digitalRead(pb);
if (pbValue == HIGH) {
CNT_AB = 0;
}
}
//========================================================================================
void GetEvent_A() {
if (digitalRead(2) == LOW)
CNT_A = 1;
else CNT_A = 0;
}
//========================================================================================
void GetEvent_B() {
if (digitalRead(3) == LOW)
CNT_B = 1;
else CNT_B = 0;
}
//========================================================================================
void GetEvent_AB() {
if (CNT_A == 1 && CNT_B == 2){
CNT_AB++;
}
}
//========================================================================================
void cleanDisplay (){
lcd.clear();
lcd.setCursor(0,0);
lcd.setCursor(0,0);
}
CNT_A and CNT_B doesn't seem to return 0 after each pulse has passed, so the display just went counting really fast after the microcontroller registers a pulse from each tube.
I think I am missing something fundamental here. Perhaps attachInterrupt() cannot be used like this? I am an absolute beginner in any sort of programming. Very limited posts out there to find reference codes on detection of coincidence signal. Any help would be greatly appreciated.
Ideally, if Arduino Uno can count these coincident signals, I intend to use the coincident signal to trigger a sequence of relay switches that controls a camera, LED flash lamps, and a pneumatic valve.