This is how it looks on my table !
Well, you wrote about your childhood, talked about your plans, but what about the code? Are you going to fix it?
Without this, your project is unlikely to be successfully completed.
Even OP is not answering on the following:
IĀ“m talking of hundred thousand.
I think I know how to programm it for "longer periodes". But I just donĀ“t know how to count the overflow and set the timer right on that moment to zero bevore it goes negativ. If I know how to do that, I could get back to coding.
...until I get to the next problem somewhere ?
Yes, I still didnĀ“t find a solution. But I will. CanĀ“t be too hard. I guess !
It is just not easy to find someone in the internet that explains exactly what I need to know. I would like to have someone just sitting next to me who is able to show me and explane me some thing. That would be so much easyer and faster.
It just sucks to learn coding if you donĀ“t know anybody that has an idea of it.
Hard life !
1. This is (Fig-1) TC1-based counter to accomodate the pulses coming from the Geoger Muller Counter.
Figure-1:
Working Principle:
TCNT1/TC1 (Timer/Counter 1) is an upcounter. It begins counting the driving pulses (clkTC1) from 0 (zero) and arrives at the maximum count (0xFFFFF = 1111 1111 1111 1111). When the next clkcTC1 pulse arrrives, the TC1 turns from all 1s to all 0s. This event is known as roll-over/overflow and is said that TC1 has made a full count. At this time, the TOV1-flag (TC1 Overflow) bit becomes HIGH to indicate that TC1 has finishied counting 216 = 65536 pulses.
Total counts in n-minute = number of overflows x 65536 + TCNT1 (residual count)
2. You are expecting more than 100 thousand (say: 125000) counts in 1-minute from the Geiger. You count for 5-minute and then make an average. The control codes are:
Configure TC1 as upcounter
TCNT1 = 0;
unsigned long int pulseCounter = 0;
while(elapseTime != 5-minute) //you can use millis() function to track 5-min time
{
while(TC1 has not made full count) //full count happens after 65536 counts
{
; //wait
}
pulseCounter += 65536; //16-bit TCNT1/TC1 overflows after counting 65536 pulses
}
float averageCount = (pulseCounter+TCNT1)/5.0;
Serial.print("Geiger Count: "); Serial.print(avarageCount, 2); Serial.println(" /min");
3. Convert control codes of Step-2 into Arduino Codes and upload into Arduino UNO.
4. Report the result.
TC1 was not declared in this scope !
ThatĀ“s what I get ! This is not gonna work.
How does the millis() funktion work ? There must be an example how to use the interupt ?
I tried to understand all the things about the timer but this is too complicated to get into it by watching youtube videos and reading in forums.
TC1 was not declared in this scope !
TC1 stands for Timer/Counter 1 of ATmega328P MCU. It is the textual name; the software name is TCNT1.
Please, post your sketch? Which Arduino (UNO, NANO, MEGA) you are using?
But I just donĀ“t know how to count the overflow and set the timer right on that moment to zero bevore it goes negativ.
The timer is an unsigned device so it will never go negative. It counts up to 0xFFFF and then overflows to zero. When an overflow ISR occurs, you know that it has counted 65536 pulses and starts over with 0. You don't need to do anything with the counter itself. Only read it if you want to know the actual counts, and count the overflows.
Of course you can reset it to zero when starting a new count periode.
3. Convert control codes of Step-2 into Arduino Codes and upload into Arduino UNO.
(untested sketch)
void setup()
{
Serial.begin(9600);
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
}
void loop()
{
unsigned long int pulseCounter = 0;
TCCR1B = 0x07; //start TC1 with external clock rising edge
unsigned long int presentMillis = millis();
while (millis() - presentMillis < 5 * 60 * 1000UL) //5-minute duration
{
if (bitRead(TIFR1, TOV1) == HIGH)
{
bitSet(TIFR1, TOV1); //clear the flag bit
pulseCounter += 65536;
}
}
TCCR1B = 0x00; //stop TC1
float avrgCount = pulseCounter / 5.0;
Serial.print("Average Count: "); Serial.print(avrgCount, 2); Serial.println(" /min");
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.