diff --git a/Geigerzaehler/main.c b/Geigerzaehler/main.c index 82fd270..4b319b6 100644 --- a/Geigerzaehler/main.c +++ b/Geigerzaehler/main.c @@ -45,11 +45,11 @@ int main() PORTD |= (1<<3); // Enable pull-up-resistor Pin-D3 // Interrupt for INT0 Pin-D2 High-voltage check - EICRA |= (0 << ISC01)|(1 << ISC00); // Only at any edge [0|1] + EICRA |= (0 << ISC01)|(1 << ISC00); // Only at any edge [Code: 01] EIMSK |= (1 << INT0); // Activate Interrupt INT0 // Interrupt for INT1 Pin-D3 Counter-click - EICRA |= (1 << ISC11)|(1 << ISC10); // Only at rising edge [1|1] + EICRA |= (1 << ISC11)|(1 << ISC10); // Only at rising edge [Code: 11] EIMSK |= (1 <= signal_Output_nextTick) // If we are on or after the tick it should be executed { // Set pin according to next exec - if(boost_highVoltage_nextHigh) // Set it high + if(signal_Output_nextHigh) // Set it high { bit_set(PD5, 1); bit_set(PD6, 1); - boost_highVoltage_nextHigh = false; // Next is low + signal_Output_nextHigh = false; // Next is low } else // Set it low { bit_set(PD5, 0); bit_set(PD6, 0); - boost_highVoltage_nextHigh = true; // Next is high + signal_Output_nextHigh = true; // Next is high } // When the signal should stop - boost_highVoltage_nextTick = currTick + 101 // Todo: Add calculation for PWM high/low time + signal_Output_nextTick = currTick + 101 // Todo: Add calculation for signalOutput low time } } } @@ -119,7 +119,8 @@ int main() * Interrupt-handler * ISR - Interrupt service routine */ -// Address: 0x001 INT0 +// Address: 0x001 INT0 - Only at any edge [Code: 01] +// Handles: Over/Below working voltage ISR(INT0_vect) { if(PIND&0x20 == 0x00) // Falling edge @@ -136,11 +137,14 @@ ISR(INT0_vect) reti(); // Exit interrupt-handler } - +// Address: 0x002 INT1 - Only at rising edge [Code: 11] +// Handles: Counter tube "tick" ISR(INT1_vect) { // Tick detected, signalOutput enable_signalOutput = true; + // Execute immediately + signal_Output_nextTick = 0; reti(); // Exit interrupt-handler } diff --git a/README.md b/README.md new file mode 100644 index 0000000..5338905 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +## School project - Geiger counter based on a Geiger-Müller counter tube + +Microcontroller code written in C + +Microcontroller: AtMega328P
+Board: Arduino Nano \ No newline at end of file