The trigger point is fixed so the bulk of the pulse moves back & forth depending on its amplitude. The other thing I keep worrying about is minimizing the effect of pulse overlap on the system's FWHM.Do we ever have to be determining a variable length of pulse?
Big pulses, small pulses, when they start out, there is a duration for when they have all expired. The decline from a higher amplitude does take slightly longer, but big or small, all is over by 15 to 18 uS. Nothing is contributed to the integration after a certain time.
The stretched version should have the same property, only slowed down.
My thought is that variable pulse duration detecting an "it's over" threshold, might introduce a factor that adds jitter to the integration count.
Is the method to clip the noise off the bottom?
Since I did not have access to "everything" I just sort of put all the files into a common directory. I didn't install any libraries, save for the ADC library.What kind of errors are you getting? The MCA and FastPeak libraries should look pretty similar, in terms of the directory structure. There's an examples folder (which can be empty), the cpp and header files, then a file called "keywords.txt". The latter is used to help the Arduino IDE highlight functions, much like it does for built-in functions. I've attached an example, generated for a boilerplate "test" library. Hope that helps.
In file included from /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:84:
/home/bruce/Arduino/XRF_MCA/FastPeak.h:18:8: error: 'float_t' does not name a type; did you mean 'float'?
18 | extern float_t Fitdata[MAXPEAKDATA];
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.h:26:1: error: 'float_t' does not name a type; did you mean 'float'?
26 | float_t Fit_error(int, float_t*, float_t, float_t, float_t);
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.h:28:6: error: variable or field 'printMatrix' declared void
28 | void printMatrix(float_t);
| ^~~~~~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.h:28:18: error: 'float_t' was not declared in this scope; did you mean 'float'?
28 | void printMatrix(float_t);
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.h:34:19: error: 'float_t' has not been declared
34 | int FindPeak(int, float_t*, float_t*);
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.h:34:29: error: 'float_t' has not been declared
34 | int FindPeak(int, float_t*, float_t*);
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:89:1: error: 'float_t' does not name a type; did you mean 'float'?
89 | float_t Fitdata[MAXPEAKDATA];
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:93:1: error: 'float_t' does not name a type; did you mean 'float'?
93 | float_t M_Array[3][3], Det0;
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:103:1: error: 'float_t' does not name a type; did you mean 'float'?
103 | float_t *M00 = Mx(0,0), *M01 = Mx(0,1), *M02 = Mx(0,2); // row 0 entries
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:104:1: error: 'float_t' does not name a type; did you mean 'float'?
104 | float_t *M10 = Mx(1,0), *M11 = Mx(1,1), *M12 = Mx(1,2); // row 1 "
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:105:1: error: 'float_t' does not name a type; did you mean 'float'?
105 | float_t *M20 = Mx(2,0), *M21 = Mx(2,1), *M22 = Mx(2,2); // row 2 "
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:114:1: error: 'float_t' does not name a type; did you mean 'float'?
114 | float_t Det(float m[3][3]){
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:145:2: error: 'float_t' does not name a type; did you mean 'float'?
145 | float_t Det_Vector(int cnum, float_t vect[3]) {
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:173:1: error: 'float_t' does not name a type; did you mean 'float'?
173 | float_t Power(float_t a, int n) {
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'float PowerSum(int, int)':
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:184:9: error: 'float_t' was not declared in this scope; did you mean 'float'?
184 | float_t sum = 0;
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:17: error: 'sum' was not declared in this scope
187 | sum += Power((float_t) i, p);
| ^~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:39: error: expected ')' before 'i'
187 | sum += Power((float_t) i, p);
| ~ ^~
| )
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:24: error: 'Power' was not declared in this scope; did you mean 'PowerSum'?
187 | sum += Power((float_t) i, p);
| ^~~~~
| PowerSum
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:188:16: error: 'sum' was not declared in this scope
188 | return(sum);
| ^~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: At global scope:
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:196:25: error: 'float_t' has not been declared
196 | void MakeYArray(int n, float_t *yi, float_t y[3]) {
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:196:38: error: 'float_t' has not been declared
196 | void MakeYArray(int n, float_t *yi, float_t y[3]) {
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'void MakeYArray(int, int*, int*)':
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:205:23: error: 'float_t' was not declared in this scope; did you mean 'float'?
205 | x = (float_t) i;
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int MakeMasterMatrix(int)':
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:224:9: error: 'M_Array' was not declared in this scope; did you mean 'MakeYArray'?
224 | M_Array[0][0] = n; // appears only once in matrix
| ^~~~~~~
| MakeYArray
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:229:9: error: 'Det0' was not declared in this scope
229 | Det0 = Det(M_Array); // we can precompute this...
| ^~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:229:16: error: 'Det' was not declared in this scope
229 | Det0 = Det(M_Array); // we can precompute this...
| ^~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: At global scope:
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:252:1: error: 'float_t' does not name a type; did you mean 'float'?
252 | float_t Fit_error(int n, float_t *dx, float_t a0, float_t a1, float_t a2) {
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:264:1: error: 'float_t' does not name a type; did you mean 'float'?
264 | float_t MaxValue(int n, float_t *dx) {
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:281:6: error: variable or field 'printMatrix' declared void
281 | void printMatrix(float_t matrix[3][3]){
| ^~~~~~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:281:18: error: 'float_t' was not declared in this scope; did you mean 'float'?
281 | void printMatrix(float_t matrix[3][3]){
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:326:24: error: 'float_t' has not been declared
326 | int FindPeak(int npts, float_t *data, float_t *pvals) {
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:326:39: error: 'float_t' has not been declared
326 | int FindPeak(int npts, float_t *data, float_t *pvals) {
| ^~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int FindPeak(int, int*, int*)':
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:327:9: error: 'float_t' was not declared in this scope; did you mean 'float'?
327 | float_t Y_sums[3], A0,A1,A2, xmax, ymax, EX;
| ^~~~~~~
| float
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:328:16: error: expected ';' before 'D1'
328 | float_t D1, D2, D3;
| ^~~
| ;
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:333:33: error: 'Y_sums' was not declared in this scope
333 | MakeYArray(npts, data, Y_sums);
| ^~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:338:9: error: 'D1' was not declared in this scope
338 | D1 = Det_Vector(0, Y_sums);
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:338:14: error: 'Det_Vector' was not declared in this scope
338 | D1 = Det_Vector(0, Y_sums);
| ^~~~~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:339:9: error: 'D2' was not declared in this scope
339 | D2 = Det_Vector(1, Y_sums);
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:340:9: error: 'D3' was not declared in this scope
340 | D3 = Det_Vector(2, Y_sums);
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:341:9: error: 'A0' was not declared in this scope
341 | A0 = D1/Det0; // Det0 was precomputed in the MakeMasterMatrix() routine
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:341:17: error: 'Det0' was not declared in this scope
341 | A0 = D1/Det0; // Det0 was precomputed in the MakeMasterMatrix() routine
| ^~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:342:9: error: 'A1' was not declared in this scope
342 | A1 = D2/Det0;
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:343:9: error: 'A2' was not declared in this scope
343 | A2 = D3/Det0;
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:345:4: error: 'EX' was not declared in this scope
345 | EX = Fit_error(Numpts, data, A0, A1, A2);
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:345:9: error: 'Fit_error' was not declared in this scope
345 | EX = Fit_error(Numpts, data, A0, A1, A2);
| ^~~~~~~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:347:4: error: 'xmax' was not declared in this scope
347 | xmax = -1.0 *(A1/(2.0*A2));
| ^~~~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:348:4: error: 'ymax' was not declared in this scope
348 | ymax = A0 + xmax * (A1 + xmax*A2);
| ^~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:449:19: warning: variable 'pflag' set but not used [-Wunused-but-set-variable]
449 | uint16_t i, j, pflag, pulse_max; // pflag indicates if pulse is too long (1) or too short (2)
| ^~~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:509:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:478:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:519:20:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:499:17:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:490:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
exit status 1
Compilation error: 'float_t' does not name a type; did you mean 'float'?
The sample is a piece of 1018 steel. Due to fluorescence from my dratted aluminum focussing ring, I think a no-sample background is going to look very different compared to anything obtained with a sample. I'll give it a shot though to verify my suspicions.What is the sample? What does the new background look like?
IIRC, I ran into compile problems regarding float_t when I didn't #include <Arduino.h>. It's possible that your version of Arduino.h doesn't have macros to implement some of those things.Since I did not have access to "everything" I just sort of put all the files into a common directory. I didn't install any libraries, save for the ADC library.
The text file doesn't help enough, since my background in packaging libraries is currently non-existent.
As for errors, it's really ghastly at the moment.
In file included from /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:84: /home/bruce/Arduino/XRF_MCA/FastPeak.h:18:8: error: 'float_t' does not name a type; did you mean 'float'? 18 | extern float_t Fitdata[MAXPEAKDATA]; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.h:26:1: error: 'float_t' does not name a type; did you mean 'float'? 26 | float_t Fit_error(int, float_t*, float_t, float_t, float_t); | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.h:28:6: error: variable or field 'printMatrix' declared void 28 | void printMatrix(float_t); | ^~~~~~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.h:28:18: error: 'float_t' was not declared in this scope; did you mean 'float'? 28 | void printMatrix(float_t); | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.h:34:19: error: 'float_t' has not been declared 34 | int FindPeak(int, float_t*, float_t*); | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.h:34:29: error: 'float_t' has not been declared 34 | int FindPeak(int, float_t*, float_t*); | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:89:1: error: 'float_t' does not name a type; did you mean 'float'? 89 | float_t Fitdata[MAXPEAKDATA]; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:93:1: error: 'float_t' does not name a type; did you mean 'float'? 93 | float_t M_Array[3][3], Det0; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:103:1: error: 'float_t' does not name a type; did you mean 'float'? 103 | float_t *M00 = Mx(0,0), *M01 = Mx(0,1), *M02 = Mx(0,2); // row 0 entries | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:104:1: error: 'float_t' does not name a type; did you mean 'float'? 104 | float_t *M10 = Mx(1,0), *M11 = Mx(1,1), *M12 = Mx(1,2); // row 1 " | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:105:1: error: 'float_t' does not name a type; did you mean 'float'? 105 | float_t *M20 = Mx(2,0), *M21 = Mx(2,1), *M22 = Mx(2,2); // row 2 " | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:114:1: error: 'float_t' does not name a type; did you mean 'float'? 114 | float_t Det(float m[3][3]){ | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:145:2: error: 'float_t' does not name a type; did you mean 'float'? 145 | float_t Det_Vector(int cnum, float_t vect[3]) { | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:173:1: error: 'float_t' does not name a type; did you mean 'float'? 173 | float_t Power(float_t a, int n) { | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'float PowerSum(int, int)': /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:184:9: error: 'float_t' was not declared in this scope; did you mean 'float'? 184 | float_t sum = 0; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:17: error: 'sum' was not declared in this scope 187 | sum += Power((float_t) i, p); | ^~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:39: error: expected ')' before 'i' 187 | sum += Power((float_t) i, p); | ~ ^~ | ) /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:187:24: error: 'Power' was not declared in this scope; did you mean 'PowerSum'? 187 | sum += Power((float_t) i, p); | ^~~~~ | PowerSum /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:188:16: error: 'sum' was not declared in this scope 188 | return(sum); | ^~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: At global scope: /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:196:25: error: 'float_t' has not been declared 196 | void MakeYArray(int n, float_t *yi, float_t y[3]) { | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:196:38: error: 'float_t' has not been declared 196 | void MakeYArray(int n, float_t *yi, float_t y[3]) { | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'void MakeYArray(int, int*, int*)': /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:205:23: error: 'float_t' was not declared in this scope; did you mean 'float'? 205 | x = (float_t) i; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int MakeMasterMatrix(int)': /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:224:9: error: 'M_Array' was not declared in this scope; did you mean 'MakeYArray'? 224 | M_Array[0][0] = n; // appears only once in matrix | ^~~~~~~ | MakeYArray /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:229:9: error: 'Det0' was not declared in this scope 229 | Det0 = Det(M_Array); // we can precompute this... | ^~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:229:16: error: 'Det' was not declared in this scope 229 | Det0 = Det(M_Array); // we can precompute this... | ^~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: At global scope: /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:252:1: error: 'float_t' does not name a type; did you mean 'float'? 252 | float_t Fit_error(int n, float_t *dx, float_t a0, float_t a1, float_t a2) { | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:264:1: error: 'float_t' does not name a type; did you mean 'float'? 264 | float_t MaxValue(int n, float_t *dx) { | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:281:6: error: variable or field 'printMatrix' declared void 281 | void printMatrix(float_t matrix[3][3]){ | ^~~~~~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:281:18: error: 'float_t' was not declared in this scope; did you mean 'float'? 281 | void printMatrix(float_t matrix[3][3]){ | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:326:24: error: 'float_t' has not been declared 326 | int FindPeak(int npts, float_t *data, float_t *pvals) { | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:326:39: error: 'float_t' has not been declared 326 | int FindPeak(int npts, float_t *data, float_t *pvals) { | ^~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int FindPeak(int, int*, int*)': /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:327:9: error: 'float_t' was not declared in this scope; did you mean 'float'? 327 | float_t Y_sums[3], A0,A1,A2, xmax, ymax, EX; | ^~~~~~~ | float /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:328:16: error: expected ';' before 'D1' 328 | float_t D1, D2, D3; | ^~~ | ; /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:333:33: error: 'Y_sums' was not declared in this scope 333 | MakeYArray(npts, data, Y_sums); | ^~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:338:9: error: 'D1' was not declared in this scope 338 | D1 = Det_Vector(0, Y_sums); | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:338:14: error: 'Det_Vector' was not declared in this scope 338 | D1 = Det_Vector(0, Y_sums); | ^~~~~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:339:9: error: 'D2' was not declared in this scope 339 | D2 = Det_Vector(1, Y_sums); | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:340:9: error: 'D3' was not declared in this scope 340 | D3 = Det_Vector(2, Y_sums); | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:341:9: error: 'A0' was not declared in this scope 341 | A0 = D1/Det0; // Det0 was precomputed in the MakeMasterMatrix() routine | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:341:17: error: 'Det0' was not declared in this scope 341 | A0 = D1/Det0; // Det0 was precomputed in the MakeMasterMatrix() routine | ^~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:342:9: error: 'A1' was not declared in this scope 342 | A1 = D2/Det0; | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:343:9: error: 'A2' was not declared in this scope 343 | A2 = D3/Det0; | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:345:4: error: 'EX' was not declared in this scope 345 | EX = Fit_error(Numpts, data, A0, A1, A2); | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:345:9: error: 'Fit_error' was not declared in this scope 345 | EX = Fit_error(Numpts, data, A0, A1, A2); | ^~~~~~~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:347:4: error: 'xmax' was not declared in this scope 347 | xmax = -1.0 *(A1/(2.0*A2)); | ^~~~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:348:4: error: 'ymax' was not declared in this scope 348 | ymax = A0 + xmax * (A1 + xmax*A2); | ^~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:449:19: warning: variable 'pflag' set but not used [-Wunused-but-set-variable] 449 | uint16_t i, j, pflag, pulse_max; // pflag indicates if pulse is too long (1) or too short (2) | ^~~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:509:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:478:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:519:20: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:499:17: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:490:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ exit status 1 Compilation error: 'float_t' does not name a type; did you mean 'float'?
Some of this is lib's. Some might be old files. Other parts, I suspect is (0.58.3) 1.58.3beta. Pretty chatty, isn't it? Quite the complainer...
Getting closer. Yes, I had commented out #include <Arduino.h>. Now it compiles but still a bunch of warnings. Progress.IIRC, I ran into compile problems regarding float_t when I didn't #include <Arduino.h>. It's possible that your version of Arduino.h doesn't have macros to implement some of those things.
I get the same warning about pflag, even though it IS used in the routine. I haven't figured out how to make the compiler happy about that, since it's stubbornly claiming something that isn't true!
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int FindPeak(int, float_t*, float_t*)':
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:330:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
330 | if(npts < 3)
| ^~
/home/bruce/Arduino/XRF_MCA/FastPeak.cpp:333:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
333 | MakeYArray(npts, data, Y_sums);
| ^~~~~~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:449:19: warning: variable 'pflag' set but not used [-Wunused-but-set-variable]
449 | uint16_t i, j, pflag, pulse_max; // pflag indicates if pulse is too long (1) or too short (2)
| ^~~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:509:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:478:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:519:20:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:499:17:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
In function 'int GetString(char*, int)',
inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:490:18:
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
313 | s[i] = '\0'; // null-terminate the string
| ~~~~~^~~~~~
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()':
/home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32
445 | char buff[32];
| ^~~~
Opening Teensy Loader...
Memory Usage on Teensy 4.0:
FLASH: code:60096, data:9464, headers:8260 free for files:1953796
RAM1: variables:19584, code:58376, padding:7160 free for local variables:439168
RAM2: variables:12384 free for malloc/new:511904
I trawled all the OLD FETs, compared specs, discovered those now supposedly equivalent and overpriced for audiophiles.JLCPCB is a very low cost manufacturer. I sent my PCB files to them and got a sweetheart deal for $7 for 5 boards. Must have been a new customer special. My first KiCAD board was through hole and I assembled it myself. As far as I know they ship anywhere in the world. That $7 included shipping! I don't think my next order will be that inexpensive, but I was happy with the quality of the boards. Every board that was populated just worked. But that was a digital board... Analog is different.
If you can share the design or a board, I'd be very interested. I like the idea of the FET front end. I went off to look up parts and found a lot of the FETs mentioned in the old app notes are unavailable. The new FETs don't seem to have many specs published, like for noise. It's like the original manufacturer sold the formula to a small manufacturer and these guys just make them, but don't seem to understand them like the originators did.
Interesting that your compiler is picky about statement indentation. Looking at all the complaints about char buff[32], it looks to me like they're all related to the compiler backtracking GetString(buff, 32) and finding a possibility of writing past the end of the buffer. To test that, the easiest thing to do is to increase the length of the buffer, say: char buff[34] and see what happens.Getting closer. Yes, I had commented out #include <Arduino.h>. Now it compiles but still a bunch of warnings. Progress.
Code:/home/bruce/Arduino/XRF_MCA/FastPeak.cpp: In function 'int FindPeak(int, float_t*, float_t*)': /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:330:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation] 330 | if(npts < 3) | ^~ /home/bruce/Arduino/XRF_MCA/FastPeak.cpp:333:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' 333 | MakeYArray(npts, data, Y_sums); | ^~~~~~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:449:19: warning: variable 'pflag' set but not used [-Wunused-but-set-variable] 449 | uint16_t i, j, pflag, pulse_max; // pflag indicates if pulse is too long (1) or too short (2) | ^~~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:509:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:478:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:519:20: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:499:17: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ In function 'int GetString(char*, int)', inlined from 'void loop()' at /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:490:18: /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:313:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 313 | s[i] = '\0'; // null-terminate the string | ~~~~~^~~~~~ /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino: In function 'void loop()': /home/bruce/Arduino/XRF_MCA/XRF_MCA.ino:445:8: note: at offset 33 into destination object 'buff' of size 32 445 | char buff[32]; | ^~~~ Opening Teensy Loader... Memory Usage on Teensy 4.0: FLASH: code:60096, data:9464, headers:8260 free for files:1953796 RAM1: variables:19584, code:58376, padding:7160 free for local variables:439168 RAM2: variables:12384 free for malloc/new:511904