15
15
#define XSTR (s ) STR(s)
16
16
#define STR (s ) #s
17
17
18
+
19
+ #define RANGE 25 // histogram range
20
+ #define EVENTS 256 // maximal number of single events detection in memory
18
21
#define CHANNELS 1024 // number of channels in the buffer for histogram
19
22
20
23
String FWversion = XSTR(MAJOR)" ." XSTR(MINOR)" ." XSTR(GHRELEASE)" -" XSTR(GHBUILD)" -" XSTR(GHBUILDTYPE);
@@ -108,6 +111,9 @@ String filename = "";
108
111
uint16_t fn;
109
112
uint16_t count = 0 ;
110
113
boolean SDinserted = true ;
114
+ uint32_t hit_time[EVENTS]; // time of events
115
+ uint8_t hit_time_s100[EVENTS];
116
+ uint16_t hit_channel[EVENTS]; // energy of events
111
117
uint8_t histogram[CHANNELS];
112
118
uint8_t ADCconf1;
113
119
uint8_t ADCconf2;
@@ -396,6 +402,7 @@ void logHits() { // Hits out
396
402
digitalWrite (SDpower, LOW); // SD card power off
397
403
delay (1 );
398
404
hits_interval = 0 ;
405
+ hit_count = 0
399
406
}
400
407
401
408
// Data out
@@ -995,6 +1002,8 @@ void loop()
995
1002
SPI.transfer16 (0x0000 );
996
1003
digitalWrite (DRESET, HIGH);
997
1004
1005
+ uint16_t hit_count = 0 ; // clear events
1006
+
998
1007
store = 0 ;
999
1008
batt = 0 ;
1000
1009
env = 0 ;
@@ -1110,13 +1119,11 @@ void loop()
1110
1119
if (adcVal>320 ) digitalWrite (BUZZER, HIGH); // buzzer click on ADC conversion.
1111
1120
#endif
1112
1121
1113
- adcVal >>= 6 ;
1114
- if (histogram[adcVal]<255 ) histogram[adcVal]++;
1115
- digitalWrite (DRESET, HIGH);
1122
+ adcVal >>= 6 ; // squash to 10 bit value
1116
1123
1117
- if (adcVal > RANGE)
1124
+ if (adcVal < RANGE)
1118
1125
{
1119
- buffer [adcVal]++;
1126
+ if (histogram [adcVal]< 255 ) histogram[adcVal] ++; // increment histogram bin count and avoid overflow
1120
1127
}
1121
1128
else
1122
1129
{
@@ -1125,12 +1132,12 @@ void loop()
1125
1132
readRTC ();
1126
1133
1127
1134
hit_time[hit_count] = tm;
1128
- hit_time_s100[hit_count]=tm_s100;
1135
+ hit_time_s100[hit_count]=tm_s100;
1129
1136
hit_channel[hit_count] = adcVal;
1130
1137
}
1131
- hit_count++;
1132
1138
logHits ();
1133
1139
}
1140
+ digitalWrite (DRESET, HIGH);
1134
1141
1135
1142
#ifdef RADIATION_CLICK
1136
1143
digitalWrite (BUZZER, LOW);
0 commit comments