diff --git a/.gitignore b/.gitignore index 65aeeb7..d089512 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,3 @@ nm64file mustang_scripts nm64/nm64 ahepam/seth -leia/ -irena/d3direna/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 482e84f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "avr"] - path = avr - url = ../irena-avr.git diff --git a/Makefile b/Makefile index 37e6f3e..936adca 100644 --- a/Makefile +++ b/Makefile @@ -76,8 +76,6 @@ ProductId-NMAHEPAM = 0x0c SerialNo-NMAHEPAM = 14 ProductId-SETH = 0x0c SerialNo-SETH = 15 -ProductId-LEIA = 0x0c -SerialNo-LEIA = 16 #sirena: ProductId-Torsten = 0x04 @@ -230,10 +228,8 @@ FATNAME_flash_TANOS=TANOS FATNAME_flash_CHAOS=CHAOS FATNAME_flash_µM=IRENAuM FATNAME_flash_NMAHEPAM=NMAHEPAM -FATNAME_flash_LEIA=LEIA FATNAME=$(FATNAME_$(FLASH)) -FATSIZE_flash_tarena=1M FATSIZE_flash_pirena=1M FATSIZE_flash_darena=1M FATSIZE_flash_erena=1M diff --git a/adam/irenafile.c b/adam/irenafile.c index b5e0c7d..215a663 100644 --- a/adam/irenafile.c +++ b/adam/irenafile.c @@ -160,7 +160,6 @@ int main(int argc, const char * const * argv) n_counters = 25; if (!nl2) switch (nch) { - case 9: case 18: nl2=6; break; default: nl2=8; break; } diff --git a/ahepam/2025-07-24-seth-9-fit.gpt b/ahepam/2025-07-24-seth-9-fit.gpt deleted file mode 100644 index 01d7b39..0000000 --- a/ahepam/2025-07-24-seth-9-fit.gpt +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/local/bin/gnuplot - -fn = "2025-07-24-seth-9" - -set tit fn - -set samples 10000 -set xrange [ 10.6473 : 72.0818 ] noreverse writeback -set yrange [ 0.0824143 : 319.883 ] noreverse writeback -set logscale y -set fit logfile fn.".fitlog" brief errorvariables - -landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -mips(i, x)=a[i]*landau((x-e[i])/s[i]) - -Itime = 1 - -array a[13] = [,,,,,,, \ - 859.092052918976, 836.661498376021, 774.308992188805, \ - 868.7682895186, 886.040923070115, 839.914159064545 ] -array e[13] = [,,,,,,, \ - 23.1129960324349, 23.7449670595066, 24.6546072882361, \ - 21.9335751062165, 21.1775893511824, 22.8589648291739 ] -array s[13] = [,,,,,,, \ - 2.93026673210812, 3.02173616155514, 3.36397159128985, \ - 2.83639020739353, 2.83826477232856, 3.01391842919058 ] - -a_8__err = 17.0887311070516 -e_8__err = 0.0889472501153327 -s_8__err = 0.0935171552631583 -a_9__err = 17.4032436542983 -e_9__err = 0.097488036256732 -s_9__err = 0.106290500933751 -a_10__err = 15.7027910610272 -e_10__err = 0.105569403248042 -s_10__err = 0.114612006466013 -a_11__err = 20.7697327629865 -e_11__err = 0.100670852522929 -s_11__err = 0.102334658647667 -a_12__err = 16.5452708067998 -e_12__err = 0.0803181922085788 -s_12__err = 0.0845228040571695 -a_13__err = 18.1355609385629 -e_13__err = 0.105214047154568 -s_13__err = 0.118194681270004 - - -plot for [c=8:13] "seth/".fn.".seth_hist" \ - u 1:(column(2+c)/Itime) \ - t "".c." ".columnhead(2+c) \ - w histeps, \ - for [c=8:13] mips(c,x)+0.1 not w l lt c-7 -do for [c=8:13] { - fit [] [a[c]/10.:*] \ - mips(c,x) \ - "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) \ - zerror \ - via a[c],e[c],s[c] - replot -} diff --git a/ahepam/2025-07-24-seth-9.fitlog b/ahepam/2025-07-24-seth-9.fitlog deleted file mode 100644 index 17b51f1..0000000 --- a/ahepam/2025-07-24-seth-9.fitlog +++ /dev/null @@ -1,468 +0,0 @@ - - -******************************************************************************* -Fri Jul 25 13:03:18 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [85.9092 : *] - #datapoints = 48 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[8] e[8] s[8] - 0 6.4318474790e+01 0.00e+00 2.93e+01 8.590921e+02 2.311300e+01 2.930267e+00 - 1 6.4318474759e+01 -4.89e-05 2.93e+00 8.590923e+02 2.311300e+01 2.930265e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 64.3185 -rel. change during last iteration : -4.88767e-10 - -degrees of freedom (FIT_NDF) : 45 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.19553 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.4293 -p-value of the Chisq distribution (FIT_P) : 0.0307724 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[8] = 859.092 +/- 17.09 (1.989%) -e[8] = 23.113 +/- 0.08895 (0.3848%) -s[8] = 2.93027 +/- 0.09352 (3.191%) - -correlation matrix of the fit parameters: - a[8] e[8] s[8] -a[8] 1.000 -e[8] -0.251 1.000 -s[8] -0.719 0.383 1.000 - - -******************************************************************************* -Fri Jul 25 13:03:18 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [83.6661 : *] - #datapoints = 48 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[9] e[9] s[9] - 0 6.8507114449e+01 0.00e+00 2.75e+01 8.366615e+02 2.374497e+01 3.021736e+00 - 1 6.8507114449e+01 -2.07e-11 2.75e+04 8.366615e+02 2.374497e+01 3.021736e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 68.5071 -rel. change during last iteration : -2.07436e-16 - -degrees of freedom (FIT_NDF) : 45 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.23385 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.52238 -p-value of the Chisq distribution (FIT_P) : 0.0135097 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[9] = 836.661 +/- 17.4 (2.08%) -e[9] = 23.745 +/- 0.09749 (0.4106%) -s[9] = 3.02174 +/- 0.1063 (3.518%) - -correlation matrix of the fit parameters: - a[9] e[9] s[9] -a[9] 1.000 -e[9] -0.211 1.000 -s[9] -0.725 0.297 1.000 - - -******************************************************************************* -Fri Jul 25 13:03:19 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [77.4309 : *] - #datapoints = 54 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[10] e[10] s[10] - 0 7.6078685857e+01 0.00e+00 2.44e+01 7.743090e+02 2.465461e+01 3.363972e+00 - 1 7.6078685837e+01 -2.66e-05 2.44e+00 7.743093e+02 2.465461e+01 3.363969e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 76.0787 -rel. change during last iteration : -2.66022e-10 - -degrees of freedom (FIT_NDF) : 51 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.22137 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.49174 -p-value of the Chisq distribution (FIT_P) : 0.0129596 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[10] = 774.309 +/- 15.7 (2.028%) -e[10] = 24.6546 +/- 0.1056 (0.4282%) -s[10] = 3.36397 +/- 0.1146 (3.407%) - -correlation matrix of the fit parameters: - a[10] e[10] s[10] -a[10] 1.000 -e[10] -0.179 1.000 -s[10] -0.726 0.235 1.000 - - -******************************************************************************* -Fri Jul 25 13:03:19 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [86.8768 : *] - #datapoints = 49 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[11] e[11] s[11] - 0 9.5016426174e+01 0.00e+00 2.83e+01 8.687683e+02 2.193358e+01 2.836390e+00 - 1 9.5016426174e+01 -1.50e-11 2.83e+06 8.687683e+02 2.193358e+01 2.836390e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 95.0164 -rel. change during last iteration : -1.49562e-16 - -degrees of freedom (FIT_NDF) : 46 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.43721 -variance of residuals (reduced chisquare) = WSSR/ndf : 2.06557 -p-value of the Chisq distribution (FIT_P) : 2.90326e-05 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[11] = 868.768 +/- 20.77 (2.391%) -e[11] = 21.9336 +/- 0.1007 (0.459%) -s[11] = 2.83639 +/- 0.1023 (3.608%) - -correlation matrix of the fit parameters: - a[11] e[11] s[11] -a[11] 1.000 -e[11] -0.203 1.000 -s[11] -0.722 0.280 1.000 - - -******************************************************************************* -Fri Jul 25 13:03:19 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [88.6041 : *] - #datapoints = 47 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[12] e[12] s[12] - 0 5.5243080524e+01 0.00e+00 2.81e+01 8.860409e+02 2.117759e+01 2.838265e+00 - 1 5.5243080524e+01 -1.73e-08 2.81e+02 8.860409e+02 2.117759e+01 2.838265e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 55.2431 -rel. change during last iteration : -1.72738e-13 - -degrees of freedom (FIT_NDF) : 44 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.1205 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.25552 -p-value of the Chisq distribution (FIT_P) : 0.119174 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[12] = 886.041 +/- 16.55 (1.867%) -e[12] = 21.1776 +/- 0.08032 (0.3793%) -s[12] = 2.83826 +/- 0.08452 (2.978%) - -correlation matrix of the fit parameters: - a[12] e[12] s[12] -a[12] 1.000 -e[12] -0.245 1.000 -s[12] -0.723 0.358 1.000 - - -******************************************************************************* -Fri Jul 25 13:03:19 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [83.9914 : *] - #datapoints = 46 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[13] e[13] s[13] - 0 6.7709403756e+01 0.00e+00 2.49e+01 8.399142e+02 2.285896e+01 3.013918e+00 - 1 6.7709403750e+01 -9.61e-06 2.49e+01 8.399142e+02 2.285897e+01 3.013919e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 67.7094 -rel. change during last iteration : -9.60902e-11 - -degrees of freedom (FIT_NDF) : 43 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.25485 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.57464 -p-value of the Chisq distribution (FIT_P) : 0.00947836 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[13] = 839.914 +/- 18.14 (2.159%) -e[13] = 22.859 +/- 0.1052 (0.4603%) -s[13] = 3.01392 +/- 0.1182 (3.922%) - -correlation matrix of the fit parameters: - a[13] e[13] s[13] -a[13] 1.000 -e[13] -0.137 1.000 -s[13] -0.728 0.143 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [85.9092 : *] - #datapoints = 48 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[8] e[8] s[8] - 0 6.4318474790e+01 0.00e+00 2.93e+01 8.590921e+02 2.311300e+01 2.930267e+00 - 1 6.4318474759e+01 -4.89e-05 2.93e+00 8.590923e+02 2.311300e+01 2.930265e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 64.3185 -rel. change during last iteration : -4.88767e-10 - -degrees of freedom (FIT_NDF) : 45 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.19553 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.4293 -p-value of the Chisq distribution (FIT_P) : 0.0307724 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[8] = 859.092 +/- 17.09 (1.989%) -e[8] = 23.113 +/- 0.08895 (0.3848%) -s[8] = 2.93027 +/- 0.09352 (3.191%) - -correlation matrix of the fit parameters: - a[8] e[8] s[8] -a[8] 1.000 -e[8] -0.251 1.000 -s[8] -0.719 0.383 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [83.6661 : *] - #datapoints = 48 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[9] e[9] s[9] - 0 6.8507114449e+01 0.00e+00 2.75e+01 8.366615e+02 2.374497e+01 3.021736e+00 - 1 6.8507114449e+01 -2.07e-11 2.75e+04 8.366615e+02 2.374497e+01 3.021736e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 68.5071 -rel. change during last iteration : -2.07436e-16 - -degrees of freedom (FIT_NDF) : 45 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.23385 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.52238 -p-value of the Chisq distribution (FIT_P) : 0.0135097 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[9] = 836.661 +/- 17.4 (2.08%) -e[9] = 23.745 +/- 0.09749 (0.4106%) -s[9] = 3.02174 +/- 0.1063 (3.518%) - -correlation matrix of the fit parameters: - a[9] e[9] s[9] -a[9] 1.000 -e[9] -0.211 1.000 -s[9] -0.725 0.297 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [77.4309 : *] - #datapoints = 54 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[10] e[10] s[10] - 0 7.6078685857e+01 0.00e+00 2.44e+01 7.743090e+02 2.465461e+01 3.363972e+00 - 1 7.6078685837e+01 -2.66e-05 2.44e+00 7.743093e+02 2.465461e+01 3.363969e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 76.0787 -rel. change during last iteration : -2.66022e-10 - -degrees of freedom (FIT_NDF) : 51 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.22137 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.49174 -p-value of the Chisq distribution (FIT_P) : 0.0129596 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[10] = 774.309 +/- 15.7 (2.028%) -e[10] = 24.6546 +/- 0.1056 (0.4282%) -s[10] = 3.36397 +/- 0.1146 (3.407%) - -correlation matrix of the fit parameters: - a[10] e[10] s[10] -a[10] 1.000 -e[10] -0.179 1.000 -s[10] -0.726 0.235 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [86.8768 : *] - #datapoints = 49 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[11] e[11] s[11] - 0 9.5016426174e+01 0.00e+00 2.83e+01 8.687683e+02 2.193358e+01 2.836390e+00 - 1 9.5016426174e+01 -1.50e-11 2.83e+06 8.687683e+02 2.193358e+01 2.836390e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 95.0164 -rel. change during last iteration : -1.49562e-16 - -degrees of freedom (FIT_NDF) : 46 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.43721 -variance of residuals (reduced chisquare) = WSSR/ndf : 2.06557 -p-value of the Chisq distribution (FIT_P) : 2.90326e-05 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[11] = 868.768 +/- 20.77 (2.391%) -e[11] = 21.9336 +/- 0.1007 (0.459%) -s[11] = 2.83639 +/- 0.1023 (3.608%) - -correlation matrix of the fit parameters: - a[11] e[11] s[11] -a[11] 1.000 -e[11] -0.203 1.000 -s[11] -0.722 0.280 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [88.6041 : *] - #datapoints = 47 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[12] e[12] s[12] - 0 5.5243080524e+01 0.00e+00 2.81e+01 8.860409e+02 2.117759e+01 2.838265e+00 - 1 5.5243080524e+01 -1.73e-08 2.81e+02 8.860409e+02 2.117759e+01 2.838265e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 55.2431 -rel. change during last iteration : -1.72738e-13 - -degrees of freedom (FIT_NDF) : 44 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.1205 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.25552 -p-value of the Chisq distribution (FIT_P) : 0.119174 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[12] = 886.041 +/- 16.55 (1.867%) -e[12] = 21.1776 +/- 0.08032 (0.3793%) -s[12] = 2.83826 +/- 0.08452 (2.978%) - -correlation matrix of the fit parameters: - a[12] e[12] s[12] -a[12] 1.000 -e[12] -0.245 1.000 -s[12] -0.723 0.358 1.000 - - -******************************************************************************* -Fri Jul 25 13:04:41 2025 - - -FIT: data read from "seth/".fn.".seth_hist" u 1:2+c:(sqrt(column(2+c)+1)) zerror - format = x:z:s - function range restricted to [83.9914 : *] - #datapoints = 46 -function used for fitting: mips(c,x) - mips(i, x)=a[i]*landau((x-e[i])/s[i]) - landau(l)=sqrt(exp(-l-exp(-l))/2/pi) -fitted parameters initialized with current variable values - -iter chisq delta/lim lambda a[13] e[13] s[13] - 0 6.7709403756e+01 0.00e+00 2.49e+01 8.399142e+02 2.285896e+01 3.013918e+00 - 1 6.7709403750e+01 -9.61e-06 2.49e+01 8.399142e+02 2.285897e+01 3.013919e+00 - -After 1 iterations the fit converged. -final sum of squares of residuals : 67.7094 -rel. change during last iteration : -9.60902e-11 - -degrees of freedom (FIT_NDF) : 43 -rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 1.25485 -variance of residuals (reduced chisquare) = WSSR/ndf : 1.57464 -p-value of the Chisq distribution (FIT_P) : 0.00947836 - -Final set of parameters Asymptotic Standard Error -======================= ========================== -a[13] = 839.914 +/- 18.14 (2.159%) -e[13] = 22.859 +/- 0.1052 (0.4603%) -s[13] = 3.01392 +/- 0.1182 (3.922%) - -correlation matrix of the fit parameters: - a[13] e[13] s[13] -a[13] 1.000 -e[13] -0.137 1.000 -s[13] -0.728 0.143 1.000 diff --git a/ahepam/AHEPAM.awk b/ahepam/AHEPAM.awk index ce1cf91..f5801a2 100755 --- a/ahepam/AHEPAM.awk +++ b/ahepam/AHEPAM.awk @@ -1,10 +1,5 @@ #!/usr/bin/gawk -i -@include "../pressure.awk" - -/^EDB /{skip_ED++} -skip_ED && /^ED / {next} - function isE(d,c) { if (!/^EDB?/ || $3!=d || $4!=c) return 0 Ch = NDCh * d + c @@ -35,20 +30,10 @@ function isEE() { return 1 } -function doEPOCH(t) { - if (t < 0x00ffffff && TLAST > 0xff000000) { - EPOCH += 0x100000000 - TLAST = t - } else if (t > TLAST) { - TLAST = t - } - return t+EPOCH -} - function isCC() { N = 0 if (!/^EDB? /) return 0 - if (NE && ($2 > T0+7 || $2+7 < T0)) { + if (NE && ($2 > T0+20 || $2+20 < T0)) { N = NE TE0 = T0 save = $0 @@ -75,7 +60,10 @@ function isCC() { i = NDCh * $3 + $4 ELINES[i] = $0 NE++ - if (N) doEPOCH(TE0) + if (N) { + if (TE0 < 0x40000000 && TLAST > 0xc0000000) EPOCH += 0x100000000 + TLAST = TE0 + } return N } @@ -109,10 +97,8 @@ BEGIN { } function isSETH() { - if (/^H /) Time=$2 tBGO=10 if (!isCC()) return - if (!Time) return EBGO0 = 0 EBGO1 = 0 EHETB = EE[11] @@ -129,8 +115,6 @@ function isSETH() { } ETRIG0 = 0 ETRIG1 = 0 - iTRIG0 = -1 - iTRIG1 = 48 for (i in cTRIG) { if (EE[i] > ETRIG0) { ETRIG0 = EE[i] @@ -145,15 +129,18 @@ function isSETH() { } function doSETH() { - printf "%.0f %d %d %g %g %g %g %g %g\n", TE0+EPOCH, \ - iTRIG0, iTRIG1, ETRIG0, ETRIG1, \ - EHETB, EHETA, EBGO0, EBGO1 + printf "%.0f %g %g %g %g %d %g %d %g\n", TE0+EPOCH, \ + EBGO0, EBGO1, EHETB, EHETA, \ + iTRIG0, ETRIG0, iTRIG1, ETRIG1 + for (i in cBGO) printf " %g", EE[i] + for (i in cBGO) printf " %g", EE[i+24] + printf "\n" } function doSETHBGO() { - printf "%u %.0f %d %d %g %g %g %g %g %g", Time, TE0+EPOCH, \ - iTRIG0, iTRIG1, ETRIG0, ETRIG1, \ - EHETB, EHETA, EBGO0, EBGO1 + printf "%.0f %g %g %g %g %d %g %d %g", TE0+EPOCH, \ + EBGO0, EBGO1, EHETB, EHETA, \ + iTRIG0, ETRIG0, iTRIG1, ETRIG1 for (i in cBGO) printf " %g", EE[i] for (i in cBGO) printf " %g", EE[i+24] printf "\n" @@ -305,7 +292,7 @@ function doS() { for (i in SLINES[d]) { $0 = SLINES[d][i] if ($2 > T0+40 || $2 < T0-20) continue - print d, c, T0, A, P, Phase(P), E, $2-T0, S0, $(4+c), ($(4+c)-S0)/E + print d, c, T0, A, P, Phase(P), EE, $2-T0, S0, $(4+c), ($(4+c)-S0)/EE } N++ } @@ -359,42 +346,6 @@ function doHIST(Ch, x) { } } -function doSETHhist() { - if (NHCh != 14) { - NHCh = 14 - name[ 0] = "iT0" - name[ 1] = "iT1" - name[ 2] = "T0" - name[ 3] = "T1" - name[ 4] = "HETB" - name[ 5] = "HETA" - name[ 6] = "BGO0" - name[ 7] = "BGO1" - name[ 8] = "BGO00" - name[ 9] = "BGO01" - name[10] = "BGO02" - name[11] = "BGO10" - name[12] = "BGO11" - name[13] = "BGO11" - } - if (EBGO0 > 46 && EBGO1 > 46) { - doHIST(0, 10*resV*iTRIG0) - doHIST(1, 10*resV*iTRIG1) - doHIST(2, ETRIG0) - doHIST(3, ETRIG1) - doHIST(4, EHETB) - doHIST(5, EHETA) - } - if (ETRIG0 > 12 && ETRIG1 > 12) { - doHIST(6, EBGO0) - doHIST(7, EBGO1) - for (i in cBGO) { - doHIST( 8 + cBGO[i], EE[i]) - doHIST(11 + cBGO[i], EE[i+24]) - } - } -} - BEGIN { NDCh = 24 NCh = 48 @@ -409,16 +360,15 @@ BEGIN { } function print_HIST(fn) { - if (!NHCh) NHCh = NCh printf "mV" > fn - for (i=0; i fn } print "" > fn nx = int((maxV-minV)/resV)+1; for (xx=0; xx fn - for (i=0; i fn } print "" > fn @@ -489,12 +439,6 @@ BEGIN { B3[d,c] = 12898 / 0x8000 B4[d,c] = 24618 / 0x8000 } - # 2025-07-25-seth-10 fix ch 04 - # --banana=4,-4404,10830,-23912,45271 - B0[0,4] = -4404 / 0x4000 - B2[0,4] = 10830 / 0x4000 - B3[0,4] = -23912 / 0x8000 - B4[0,4] = 45271 / 0x8000 } function BANANA(d,c, p) { diff --git a/ahepam/Makefile b/ahepam/Makefile index 607ba35..f8e0297 100644 --- a/ahepam/Makefile +++ b/ahepam/Makefile @@ -4,19 +4,10 @@ include ../irena/libirena.make .PRECIOUS: %.dat %.AHA %.AHA: %.dat ahepamfile - ./ahepamfile $(CAT_BANANA) < $< > $@ - -%.Itime: %.AHA - ../irena/Itime.awk $< > $@ - -ifneq ($(BANANA),) - CAT_BANANA := `cat $(BANANA)` -endif - -doScut=100 + ./ahepamfile < $< > $@ %.doS: %.AHA - ./AHEPAM.awk 'doS(){}' doScut=$(doScut) $< > $@ + ./AHEPAM.awk 'doS(){}' $< > $@ %.AES: %.dat ahepamfile ./ahepamfile < $< | grep '^[ES]' | grep -v 'X' | sort -nk2,2 -k1 > $@ @@ -34,11 +25,6 @@ doScut=100 %.HDORN: %.AHA HDORN.awk ./HDORN.awk 'isHDORN(){doHDORN()}' $< > $@ -HDINST=--seth -HDTYPE=cooked -%.HD: %.AHA - ../dorn_hk.py $(HDINST) --what=$(HDTYPE) $< | tr -d '[],' > $@ - SIGMA=600 %.HD4BIAS: %.HDORN @@ -55,9 +41,6 @@ EE=E %.SETH: %.AHA ./AHEPAM.awk 'isSETH(){doSETHBGO()}' $< > $@ -%.seth_hist: %.AHA - ./AHEPAM.awk 'isSETH(){doSETHhist()}' $< > $@ - CUT=P CUT_P=&&P>-0.398&&P<=-0.105 CUT_nP=&&(P<=-0.398||P>-0.105) diff --git a/ahepam/pulser-fit.gpt b/ahepam/pulser-fit.gpt index bc6005b..268a2a8 100644 --- a/ahepam/pulser-fit.gpt +++ b/ahepam/pulser-fit.gpt @@ -2,9 +2,9 @@ if (ARG1 ne "") { Emin = "1100" - Emax = "1500" - Pmin = "-0.6" - Pmax = "0.1" + Emax = "1300" + Pmin = "-0.5" + Pmax = "0.05" fn = ARG1 prefix = "seth/" suffix = ".ED" @@ -25,8 +25,6 @@ a0 = 1200 set fit errorvar results logfile bfn.".log" ptime = 0 -set samples 10000 -set xra [Pmin:Pmax] set style data dot plot dpab u 1:2, dpab u 1:($2*banana($3/$2)), a0/banana(x) w l lw 4 fit a0/banana(x) dpab u 1:2 via a0 diff --git a/ahepam/seth.banana b/ahepam/seth.banana index 50dcd12..a406cd7 100644 --- a/ahepam/seth.banana +++ b/ahepam/seth.banana @@ -1,2 +1 @@ --banana=-1,-3686,16027,12898,24618 ---banana=4,-4404,10830,-23912,45271 diff --git a/altera.c b/altera.c index f53d803..b9bbeb0 100644 --- a/altera.c +++ b/altera.c @@ -1048,7 +1048,6 @@ const struct keywords altera_variable_names[] = { {"ssp_block_size", {.par=&ssp_block_size}}, {"ssp_write_ptr", {.par=&ssp_injection_write_ptr}}, {"ssp_read_ptr", {.par=&ssp_injection_read_ptr}}, - {"ssp_nobuffer_count",{.par=&ssp_nobuffer_count}}, {"alterastatus", {.par=&alterastatus}}, {"altera2status", {.par=&altera2status}}, {"psconfig2", {.par=&psconfig2}}, diff --git a/armlib.py b/armlib.py index c839856..ca5284a 100755 --- a/armlib.py +++ b/armlib.py @@ -198,13 +198,6 @@ class irena_ifc(object): def Flush(self): self._data.Flush() - def Sync(self, on=True): - if not self._data: - self._log("no data thread") - return - self._log(f"data.Sync: {self._data.Sync} → {on}") - self._data.Sync = on - def Status(self, verbose=9): if self._data: return self._data.Status(verbose) @@ -608,44 +601,6 @@ class irena_ifc(object): except EOFError: pass - -class Keep_Alive_Schedule: - - interval = 30 - ioffset = 1 - cmd = "e/in 'staying alive'" - clock_interval = 900 - clock_args = {"fudge": True} - - def __init__(self, cmd=None, interval=None): - if cmd: - self.cmd = cmd - if interval: - self.interval = interval - pass - - - def __call__(self, interval=None): - if interval: - self.interval = interval - t0 = time.time() - try: - while True: - sys.stderr.write(" \r") - print(_ifc.cmd(self.cmd)) - sys.stderr.write(f"Pinging every {self.interval:.3g} seconds, type Ctrl-C to end\r") - t = time.time() - tping = self.interval - t % self.interval + self.ioffset - tclock = self.clock_interval - t % self.clock_interval - if tclock < tping: - time.sleep(tclock) - _ifc.set_clock(**self.clock_args) - tping -= tclock - if tping > 0.1: - time.sleep(tping) - except KeyboardInterrupt: - pass - def init_irena(scope, name="xRENA", prod=None, options="", long_options=[]): global _ifc, _ifc_uart, _opt _ifc = None diff --git a/avr b/avr deleted file mode 160000 index a7e45f2..0000000 --- a/avr +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a7e45f235d59d5f8d815bf7daf9734e9ee0f2a2c diff --git a/cvphase.py b/cvphase.py index 56d261d..d2c003d 100755 --- a/cvphase.py +++ b/cvphase.py @@ -46,7 +46,6 @@ tek.verbosity = verbosity while fmin + fres < fmax: f = (fmin + fmax)/2 pulser.cmd(f"FREQ {f:.1f}") - tek.cmd("ACQ:NUMAVG 1") tek.cmd("ACQ:NUMAVG 512") t = time.time() + t_settle phi = tek.cmd(f":MEASU:MEAS{i_phi}:VAL?")[1] diff --git a/dorn.py b/dorn.py index abcc0bd..60dbcd4 100644 --- a/dorn.py +++ b/dorn.py @@ -20,7 +20,7 @@ def HK_fmt(s, i, n, d): def HK3_fmt(s, i, n, d): return f"""{i}. {n} - T = {d[5]:6.2f} °C, GND = {d[0]:6.3f} V, + T = {d[5]:6.2f} °C" GND = {d[0]:6.3f} V, Vff = {d[1]:6.3f} V, Vnn = {d[2]:6.3f} V, Vpp = {d[3]:6.3f} V, Vdig = {d[4]:6.3f} V, Vcc = {d[6]:6.3f} V, Vss = {d[7]:6.3f} V. """ @@ -47,24 +47,9 @@ def HK7_SETH_fmt(s, i, n, d): return f"""{i}. {n} na = {repr(d[:4])} Text = {d[6]:.1f} °C, - Ibias = {d[4]:.1f} nA, + Ibias = {d[4]:.1f} nA. Ibias⁺ = {d[7]:.1f} nA, Vbias⁺ = {d[5]:.1f} V. """ -def HK3_LEIA_fmt(s, i, n, d): - return f"""{i}. {n} - Tadc = {d[0]:6.2f} °C, - Vadc = {d[1]:6.3f} V, - VbiasD = {d[7]:6.2f} V, - Vbias2 = {d[6]:6.1f} V, - Vpp = {d[3]:6.3f} V, Vnn = {d[2]:6.3f} V, - Vcc = {d[5]:6.3f} V, Vss = {d[4]:6.3f} V. -""" -def HK4_LEIA_fmt(s, i, n, d): - return f"""{i}. {n} - Ibias1 = {d[3]:.1f} nA, Ibias2 = {d[2]:.1f} nA, IbiasD = {d[0]:.1f} nA, - VbiasG = {d[1]:.1f} V, Vbias1 = {d[4]:.1f} V, - Tpa0 = {d[5]:6.2f} °C, Tpa1= {d[6]:6.2f} °C, Tpa2 = {d[7]:6.2f} °C. -""" class DORN_CONFIG: # stis_ana_core 2×24 ch @@ -169,12 +154,11 @@ class DORN_CONFIG: # ! change the class attribute .HK self.HK[4] = ("HK PA", self.HK4_SETH, HK4_SETH_fmt) self.HK[7] = ("HK_PWR", self.HK7_SETH, HK7_SETH_fmt) - self.BGO = [(0,3), (0,12), (0,20), (1,3), (1,12), (1,20)] HK4_AHBGO = [[ ("Tbgo₁", (degC, {})), ("Tbgo₂", (degC, {})), - ("Vbias1", -1/0.047), + ("Vbias", -1/0.047), ("Tbgo₃", (degC, {})), ("Ibias₁", 10470/470 * 51/1051 * 100), ("Ibias₂", 10470/470 * 51/1051 * 100), @@ -186,56 +170,9 @@ class DORN_CONFIG: # ! change the class attribute .HK self.HK[4] = ("HK PA", self.HK4_AHBGO, HK4_AHBGO_fmt) - # calib 2025-11-25 - Fluke_cal = 1/0.862 - # SN2 dac, 14*HK3H, VbiasD - VbiasD_SN2 = [ - [ 64, 0.51, 0.5 * Fluke_cal ], - [ 960, 1.85, 1.6 * Fluke_cal ], - [ 1984, 3.36, 2.9 * Fluke_cal ], - [ 4992, 7.85, 6.7 * Fluke_cal ], - [ 9984, 15.27, 13.1 * Fluke_cal ], - [ 14976, 22.56, 19.3 * Fluke_cal ], - [ 19968, 29.91, 25.6 * Fluke_cal ], - [ 20992, 31.42, 26.9 * Fluke_cal ], - [ 21440, 32.06, 27.5 * Fluke_cal ], - [ 21952, 32.83, 28.0 * Fluke_cal ], - [ 24960, 37.36, 28.6 * Fluke_cal ], - ] - VbiasD_a = 0.033 - VbiasD_b = 0.9918 - - HK3_LEIA = [[ - ("Tadc", (degC, {})), - ("Vadc", 2.0), - ("Vnn", 2.5, ("Vpp", -1.5)), - ("Vpp", 2.0), - ("Vss", 2.5, ("Vcc", -1.5)), - ("Vcc", 2.0), - ("Vbias2", -1/0.022 * 66.6/75.2), - ("VbiasD", -14 * VbiasD_b - VbiasD_a), - ]] - - HK4_LEIA = [[ - ("IbiasD", 100., -1.4), - ("VbiasG", 46.3, ("Vref", -45.3)), - ("Ibias2", 10470/470 * 51/1051 * 100, -71.0), - ("Ibias1", 10470/470 * 51/1051 * 100, -52.0), - ("Vbias1", -1/0.047 * 44.7/48.5), - ("Tpa0", (degC, {})), - ("Tpa1", (degC, {})), - ("Tpa2", (degC, {})), - ]] - - def leia(self): - self.VREF = (3.342,) - self.slices=(0,) - self.HK[3] = ("HK_AD", self.HK3_LEIA, HK3_LEIA_fmt) - self.HK[4] = ("HK_PA", self.HK4_LEIA, HK4_LEIA_fmt) - CONFIG = DORN_CONFIG() -def hk(sl=0, what="print", data=None): +def hk(sl, what="print", data=None): if not data: ecmd("alt/stream/off") _ifc.menable() @@ -250,26 +187,25 @@ def hk(sl=0, what="print", data=None): if isinstance(data, str): # HDORN … data line if "x" in data: - return sl, None + return data = data.split() if data[0] != "HDORN": - return sl, None + return data = list(map(int, data[1:])) if sl is None: sl = data[0] & 3; if data[0] & 3 != sl: - return sl, None + return None if what=="data": - return sl, data + return data ND = CONFIG.n_adc() NV = ND data = [d & 0xfff for d in data] data = [data[ND*i+1:ND*i+1+NV] for i in range(8)] if what=="raw": - return sl, data + return data Vref = CONFIG.Vref(sl)/4096 ddata = [] - VV = {"Vref": CONFIG.Vref(sl)} for a in range(8): V = {} ddata.append(V) @@ -291,20 +227,19 @@ def hk(sl=0, what="print", data=None): else: data[a][c] *= Vref*H[1] V[H[0]] = data[a][c] - VV.update(V) for c in range(8): H = HK[c] if len(H) > 2: if isinstance(H[2], tuple): - data[a][c] += VV[H[2][0]] * H[2][1] + data[a][c] += V[H[2][0]] * H[2][1] else: data[a][c] += H[2] V[H[0]] = data[a][c] if what=="cooked": - return sl, data + return data if what=="dict": - return sl, ddata + return ddata r = [] for a in range(8): @@ -314,7 +249,7 @@ def hk(sl=0, what="print", data=None): if what=="print": sys.stderr.write("".join(r)) - return sl, r + return r def dorn_config(a, v=None, mes=None, slice=0): verb = CONFIG.verbose @@ -396,7 +331,7 @@ def enable_trigger(sl, triggers, det=False, sa=False): i = 2 if sa else 0 if det else 1 dorn_config(0x008 | i, triggers, slice=sl) -def nsamples(sl, n=None, m=None): +def nsamples(sl, n=None, m=None, **slice): if n is None: return dorn_config(0x00b, slice=sl) if m is None: @@ -705,15 +640,3 @@ def mem_op(addr=None, hist=None, bank=None, data=None, read=None, clear=None, ba dorn_config(base+1, h, "mem data high") dh = h dorn_config(base, d & 0xffff, "mem data write") - -def VbiasD(V): - a = 0.48 - b = 95.97 - if V < 0: - V = -V - if V>32: - raise valueError(f"VbiasD too large {V}V > 32V") - d = int(0x10000/b*(V-a) + 32) - if d<0: - d = 0 - ecmd(f"v dac={d}", verb=True) diff --git a/dorn_hk.py b/dorn_hk.py index 4d9ae1a..4705d18 100755 --- a/dorn_hk.py +++ b/dorn_hk.py @@ -6,7 +6,7 @@ import sys, getopt oo,ff = getopt.getopt(sys.argv[1:], "saw:n:c:", ["seth", "ahbgo", "what=", "slice=", "channels="]) -what="pretty" +what="print" sl = None ch = list(range(8)) @@ -22,23 +22,17 @@ for o,v in oo: if o=="-c" or o=="--channels": ch = list(map(int, v.split(","))) -def hk_file(f): - T = 0 - for l in f: - if l[:2] == "H ": - T = int(l.split()[1]) - continue - if not T: - continue - s, h = dorn.hk(sl, what=what, data=l) - if not h: - continue - for c in ch: - print(T, s, c, h[c]) - -if not ff: - hk_file(sys.stdin) -else: - for fn in ff: - with open(fn) as f: - hk_file(f) +T = 0 +for fn in ff: + with open(fn) as f: + for l in f: + if l[:2] == "H ": + T = int(l.split()[1]) + continue + if not T: + continue + h = dorn.hk(sl, what=what, data=l) + if not h: + continue + for c in ch: + print(T, c, h[c]) diff --git a/flash_IRENA/CRONGD4.RC b/flash_IRENA/CRONGD4.RC deleted file mode 100644 index 5816311..0000000 --- a/flash_IRENA/CRONGD4.RC +++ /dev/null @@ -1,2 +0,0 @@ -@s/if !ssp_dma: s/exit -@nm/count/clear/float diff --git a/flash_LEIA/CRON.RC b/flash_LEIA/CRON.RC deleted file mode 100644 index 39475fc..0000000 --- a/flash_LEIA/CRON.RC +++ /dev/null @@ -1,8 +0,0 @@ -@clock/short -@v S=sec%12 -@s/if hk_mes>1: v hk_count=1 -@s/if !S: nm/cou/re/cl/fl; s/exit -@s/if S&1: s/exit -@s/if S&2: pres/inj; s/exit -@s/if S&4: v hk_count=1; s/exit -@s/if S&8: dorn/fifo/strobe/inj 0x10; s/exit diff --git a/flash_LEIA/DORN.RC b/flash_LEIA/DORN.RC deleted file mode 100644 index 9f3fd9a..0000000 --- a/flash_LEIA/DORN.RC +++ /dev/null @@ -1,12 +0,0 @@ -@v/cache iter -@s/for 24: s/exe 'DORNCC.RC' 0, i, 0x10000 -@dorn/l3 [0,4,0] -4404 -@dorn/l3 [0,4,1] 10830 -@dorn/l3 [0,4,2] -23912 -@dorn/l3 [0,4,3] 0x7fff (overflow: 45271) -@dorn/fifo/enable/inj 0xdb1 -@dorn/enable/samples/inj 0 -@v $T = 0 -@dorn/enable/t1/inj $T -@dorn/enable/t2/inj $T / 0x10000 + $T * 0x100 -@dorn/enable/t3/inj $T / 0x100 diff --git a/flash_LEIA/DORNCC.RC b/flash_LEIA/DORNCC.RC deleted file mode 100644 index ab202db..0000000 --- a/flash_LEIA/DORNCC.RC +++ /dev/null @@ -1,30 +0,0 @@ -@v $C = 24*$1 + $2 -@s/if !Z[$C]: v Z[$C]=8 -@dorn/thr [$1,$2] Z[$C] -@s/if !$3: v $3 = 0x10000 -@v $A[0] = -1203 -@v $A[1] = -1203 -@v $A[2] = -1203 -@v $A[3] = -1186 -@v $A[4] = -39 -@v $A[5] = 1709 -@v $A[6] = 2000 -@v $A[7] = 1125 -@v $X = 0 -@s/for 7: v $Y=$A[7-i]*$3/0x10000; v $X=$X-$Y; dorn/a [$1,$2,7-i] $Y -@dorn/a [$1,$2,0] $X -@v $A[0] = 0 -@v $A[1] = 0 -@v $A[2] = 0 -@v $A[3] = 0 -@v $A[4] = 2000 -@v $A[5] = 970 -@v $A[6] = -1082 -@v $A[7] = -1888 -@v $X = 0 -@s/for 7: v $Y=$A[i]*$3/0x10000; v $X=$X-$Y; dorn/b [$1,$2,i] $Y -@dorn/b [$1,$2,7] $X -@dorn/l3 [$1,$2,0] -3686 -@dorn/l3 [$1,$2,1] 16027 -@dorn/l3 [$1,$2,2] 12898 -@dorn/l3 [$1,$2,3] 24618 diff --git a/flash_LEIA/INIT.RC b/flash_LEIA/INIT.RC deleted file mode 100644 index 768a204..0000000 --- a/flash_LEIA/INIT.RC +++ /dev/null @@ -1,10 +0,0 @@ -@sleep 1 -@var/set verb=3 -@var/set script_cron_prio = 3 -@var/set dac=0 -@s/if product==0xee0a: altera/file "NMLEIAV1.RBF" -@s/if errno>=500: s/exit -@s/if product==0xee0c: altera/file "NMLEIAV2.RBF" -@s/if errno>=500: s/exit -@e/eval "s/exe 'SN%d.RC'", serial -@s/exe "DORN.RC" diff --git a/flash_LEIA/NMLEIAV1.RBF b/flash_LEIA/NMLEIAV1.RBF deleted file mode 100644 index ee48900..0000000 Binary files a/flash_LEIA/NMLEIAV1.RBF and /dev/null differ diff --git a/flash_LEIA/NMLEIAV2.RBF b/flash_LEIA/NMLEIAV2.RBF deleted file mode 100644 index 5077411..0000000 Binary files a/flash_LEIA/NMLEIAV2.RBF and /dev/null differ diff --git a/flash_LEIA/README.TXT b/flash_LEIA/README.TXT deleted file mode 100644 index 88f7eb9..0000000 --- a/flash_LEIA/README.TXT +++ /dev/null @@ -1,7 +0,0 @@ -FAT12 2MByte Filesystem for NMAHEPAM - -INIT.RC script loaded at startup -NMAHEPAM.RBF Altera FPGA bitfile, Cyclone 10CL025 -CRON.RC cron script, to to HK every Minute -SN14.RC unit config -I2C.RC SETH magnetometer and accelerometer config diff --git a/flash_LEIA/SN16.RC b/flash_LEIA/SN16.RC deleted file mode 100644 index 25bc7f1..0000000 --- a/flash_LEIA/SN16.RC +++ /dev/null @@ -1,2 +0,0 @@ -@v bate_hash = 0x29ef -pres/read/verify diff --git a/flash_LEIA/SN2.RC b/flash_LEIA/SN2.RC deleted file mode 100644 index 32343dd..0000000 --- a/flash_LEIA/SN2.RC +++ /dev/null @@ -1,2 +0,0 @@ -@v bate_hash = 0x3921 -pres/read/verify diff --git a/flash_NMAHEPAM/CRONFLY.RC b/flash_NMAHEPAM/CRONFLY.RC index f9fadfc..201af59 100644 --- a/flash_NMAHEPAM/CRONFLY.RC +++ b/flash_NMAHEPAM/CRONFLY.RC @@ -7,7 +7,7 @@ @s/if S&1: i2c/run; s/exit @s/if S&2: pres/inj; s/exit @s/if S&4: v hk_count=1; s/exit -@dorn/fifo/strobe/inj 0x30 +dorn/fifo/strobe/inj 0x30 @s/if sd_status & 0xc00: var sd_write_size=0 @s/if ! sd_write_size: s/exe "MICROSD.RC" @s/if ! udp_rx_cmd: var udp_size=0 diff --git a/flash_NMAHEPAM/DESCENT.SPY b/flash_NMAHEPAM/DESCENT.SPY index 48a3bec..fa88b5a 100644 --- a/flash_NMAHEPAM/DESCENT.SPY +++ b/flash_NMAHEPAM/DESCENT.SPY @@ -1,3 +1,3 @@ @s/if pres<8000 or pres>11000 or temp > 3432 or temp < 2432: s/exit s/exec "SAFE.RC" 3 -@e not reached after three hits +@e not reached, spy file is closed diff --git a/flash_NMAHEPAM/DORN.RC b/flash_NMAHEPAM/DORN.RC index 37ce523..4045264 100644 --- a/flash_NMAHEPAM/DORN.RC +++ b/flash_NMAHEPAM/DORN.RC @@ -1,17 +1,29 @@ @v/cache iter -@s/for 24: s/exe 'DORNCC.RC' 0, i, 0x10000 -@s/for 24: s/exe 'DORNCC.RC' 1, i, 0x10000 -@s/exe 'DORNCC.RC' 0, 3, 0x0ea90 -@s/exe 'DORNCC.RC' 0, 12, 0x0e451 -@s/exe 'DORNCC.RC' 0, 20, 0x0dbe5 -@s/exe 'DORNCC.RC' 1, 3, 0x0f72d -@s/exe 'DORNCC.RC' 1, 12, 0x10000 -@s/exe 'DORNCC.RC' 1, 20, 0x0ed2b -@s/exe 'DORNCC.RC' 0, 4, 0xe38e -@dorn/l3 [0,4,0] -4404 -@dorn/l3 [0,4,1] 10830 -@dorn/l3 [0,4,2] -23912 -@dorn/l3 [0,4,3] 0x7fff (overflow: 45271) +@s/for 24: s/exe 'DORNCC.RC' 0, i +@s/exe 'DORNCC.RC' 1, 0, 0x0f385 +@s/exe 'DORNCC.RC' 1, 1, 0x0f75d +@s/exe 'DORNCC.RC' 1, 2, 0x0f13b +@s/exe 'DORNCC.RC' 1, 3, 0x0f635 +@s/exe 'DORNCC.RC' 1, 4, 0x0f914 +@s/exe 'DORNCC.RC' 1, 5, 0x0f248 +@s/exe 'DORNCC.RC' 1, 6, 0x10000 +@s/exe 'DORNCC.RC' 1, 7, 0x0fd86 +@s/exe 'DORNCC.RC' 1, 8, 0x0eb56 +@s/exe 'DORNCC.RC' 1, 9, 0x0f4af +@s/exe 'DORNCC.RC' 1, 10, 0x0f984 +@s/exe 'DORNCC.RC' 1, 11, 0x0fe83 +@s/exe 'DORNCC.RC' 1, 12, 0x0f507 +@s/exe 'DORNCC.RC' 1, 13, 0x0f58b +@s/exe 'DORNCC.RC' 1, 14, 0x0ed1f +@s/exe 'DORNCC.RC' 1, 15, 0x0f0d1 +@s/exe 'DORNCC.RC' 1, 16, 0x0ecb2 +@s/exe 'DORNCC.RC' 1, 17, 0x0f4b3 +@s/exe 'DORNCC.RC' 1, 18, 0x0fa8b +@s/exe 'DORNCC.RC' 1, 19, 0x0f43d +@s/exe 'DORNCC.RC' 1, 20, 0x0f442 +@s/exe 'DORNCC.RC' 1, 21, 0x0f380 +@s/exe 'DORNCC.RC' 1, 22, 0x0fae5 +@s/exe 'DORNCC.RC' 1, 23, 0x0fb39 @dorn/fifo/enable/inj 0xdb3 @s/for 2: dorn/enable[i]/samples/inj 0 @v $T = 0x101808 diff --git a/flash_NMAHEPAM/DORNCC.RC b/flash_NMAHEPAM/DORNCC.RC index ab202db..b43df2b 100644 --- a/flash_NMAHEPAM/DORNCC.RC +++ b/flash_NMAHEPAM/DORNCC.RC @@ -22,8 +22,8 @@ @v $A[6] = -1082 @v $A[7] = -1888 @v $X = 0 -@s/for 7: v $Y=$A[i]*$3/0x10000; v $X=$X-$Y; dorn/b [$1,$2,i] $Y -@dorn/b [$1,$2,7] $X +@s/for 7: v $Y=$A[7-i]*$3/0x10000; v $X=$X-$Y; dorn/b [$1,$2,7-i] $Y +@dorn/b [$1,$2,0] $X @dorn/l3 [$1,$2,0] -3686 @dorn/l3 [$1,$2,1] 16027 @dorn/l3 [$1,$2,2] 12898 diff --git a/flash_NMAHEPAM/ETH.RC b/flash_NMAHEPAM/ETH.RC index e315da1..cee6711 100644 --- a/flash_NMAHEPAM/ETH.RC +++ b/flash_NMAHEPAM/ETH.RC @@ -1,7 +1,7 @@ -eth/source/ip 172.16.18.121 +eth/source/ip 172.16.18.112 echo eth config SETH -@eth/dest/str/mac/ip/port 3c:97:0e:ce:30:48 172.16.18.120 1112 -@eth/dest/mes/mac/ip/port 3c:97:0e:ce:30:48 172.16.18.120 1113 +@eth/dest/str/mac/ip/port 3c:97:0e:ce:30:48 172.16.18.110 1112 +@eth/dest/mes/mac/ip/port 3c:97:0e:ce:30:48 172.16.18.110 1113 @eth/init/full @s/if errno>=500: s/exit @var/set eth_verbosity = 4 diff --git a/flash_NMAHEPAM/INIT.RC b/flash_NMAHEPAM/INIT.RC index c3eb2da..8fdf8da 100644 --- a/flash_NMAHEPAM/INIT.RC +++ b/flash_NMAHEPAM/INIT.RC @@ -3,12 +3,8 @@ @var/set script_cron_prio = 3 sd/init @var/set dac=0 -@s/exec "ETH.RC" @s/if product!=0xee0c: s/exit altera/file "NMAHEPAM.RBF" -@s/if errno==852: altera/file "NMAHEPAM.RBF" -@s/if errno==852: altera/file "NMAHEPAM.RBF" -@s/if errno==852: altera/file "NMAHEPAM.RBF" @s/if errno>=500: s/exit @e/eval "s/exe 'SN%d.RC'", serial @s/exe "DORN.RC" diff --git a/flash_NMAHEPAM/MEASURE.RC b/flash_NMAHEPAM/MEASURE.RC index fd8b41f..1066117 100644 --- a/flash_NMAHEPAM/MEASURE.RC +++ b/flash_NMAHEPAM/MEASURE.RC @@ -1,16 +1,16 @@ @alt/stream/off @s/exe "PRESSURE.RC" -var spi_min_qtime = 665 -@var udp_reset = 1000000 +var/set spi_min_qtime = 665 +@var/set udp_reset = 1000000 @al/fifo/clear 1 @al/fifo/set 10 @al/fifo/reset 0x1f0 -@var sd_write_size = 0 -@var sd_write_count = 0 -@var udp_count = 0 -@var udp_size = 0 -@var W=600 -@var R=-1 +@var/set sd_write_size = 0 +@v/set sd_write_count = 0 +@v/set udp_count = 0 +@v/set udp_size = 0 +@V W=600 +@v/set R=-1 @script/cron/none @var/cache ssp_dma spy_return second time hk_count hk_mes @var/cache sd_status udp_rx_cmd udp_size enc altera diff --git a/flash_NMAHEPAM/PRESSURE.RC b/flash_NMAHEPAM/PRESSURE.RC index 449331e..7809783 100644 --- a/flash_NMAHEPAM/PRESSURE.RC +++ b/flash_NMAHEPAM/PRESSURE.RC @@ -1,9 +1,9 @@ @var/cache pressure temp @var F=4 -pres/read/verify +@pres/read/verify @s/if errno >= 500: s/exit @pressure/spy/on -s/spy "ASCENT.SPY" +script/spy "ASCENT.SPY" @var F=1 @var N=0 @var script_cron_prio=3 diff --git a/flash_NMAHEPAM/SN15.RC b/flash_NMAHEPAM/SN15.RC index 16fa2fe..44c52df 100644 --- a/flash_NMAHEPAM/SN15.RC +++ b/flash_NMAHEPAM/SN15.RC @@ -4,10 +4,3 @@ pres/read/verify @s/if errno >= 500: s/exit @v F=5 -@v Z[11] = 15 -@v Z[ 3] = 15 -@v Z[12] = 15 -@v Z[20] = 15 -@v Z[27] = 15 -@v Z[36] = 15 -@v Z[44] = 15 diff --git a/flash_NMAHEPAM/UDP.RC b/flash_NMAHEPAM/UDP.RC index 383129f..0de1e53 100644 --- a/flash_NMAHEPAM/UDP.RC +++ b/flash_NMAHEPAM/UDP.RC @@ -2,4 +2,3 @@ eth/init/full @s/if enc == 0xb: eth/rx/en @s/if enc == 0xf: var/set udp_size=R -@v spi_min_q = 665 diff --git a/flash_alke/CRON.RC b/flash_alke/CRON.RC index c1cbbb8..fd80566 100644 --- a/flash_alke/CRON.RC +++ b/flash_alke/CRON.RC @@ -1,2 +1,2 @@ -@clock/short -@s/if !(sec % M): nm/cou/clear/short +@pressure/inject +@s/if sd_status & 0xc00: sd/init diff --git a/flash_alke/IRENA.RC b/flash_alke/IRENA.RC index 66d7291..6f13805 100644 --- a/flash_alke/IRENA.RC +++ b/flash_alke/IRENA.RC @@ -21,25 +21,25 @@ irena/nsamples 0 0x3f irena/adcmask 0x02664 irena/windows 2 5 8 echo Thresholds 100*mV high gain -@var/set mV=14000 -@irena/l1t 0 1000*mV 0x000 -@irena/l1t 1 100*mV 0x000 -@irena/l1t 2 100*mV 0x001 -@irena/l1t 3 1000*mV 0x000 -@irena/l1t 4 1000*mV 0x000 -@irena/l1t 5 100*mV 0x001 -@irena/l1t 6 100*mV 0x001 -@irena/l1t 7 1000*mV 0x000 -@irena/l1t 8 1000*mV 0x000 -@irena/l1t 9 100*mV 0x001 -@irena/l1t 10 100*mV 0x001 -@irena/l1t 11 1000*mV 0x000 -@irena/l1t 12 1000*mV 0x000 -@irena/l1t 13 100*mV 0x001 -@irena/l1t 14 100*mV 0x000 -@irena/l1t 15 1000*mV 0x000 -@irena/l1t 16 1000*mV 0x000 -@irena/l1t 17 100*mV 0x000 +@var/set V=14000 +@irena/l1t 0 1000*V 0x000 +@irena/l1t 1 100*V 0x000 +@irena/l1t 2 100*V 0x001 +@irena/l1t 3 1000*V 0x000 +@irena/l1t 4 1000*V 0x000 +@irena/l1t 5 100*V 0x001 +@irena/l1t 6 100*V 0x001 +@irena/l1t 7 1000*V 0x000 +@irena/l1t 8 1000*V 0x000 +@irena/l1t 9 100*V 0x001 +@irena/l1t 10 100*V 0x001 +@irena/l1t 11 1000*V 0x000 +@irena/l1t 12 1000*V 0x000 +@irena/l1t 13 100*V 0x001 +@irena/l1t 14 100*V 0x000 +@irena/l1t 15 1000*V 0x000 +@irena/l1t 16 1000*V 0x000 +@irena/l1t 17 100*V 0x000 @irena/l2t/ch=0/any=0x001/read=0x02664 All @irena/l2t/ch=1/disable @irena/l2t/ch=2/disable diff --git a/flash_alke/IRENA2TH.RBF b/flash_alke/IRENA2TH.RBF deleted file mode 100644 index be9c659..0000000 Binary files a/flash_alke/IRENA2TH.RBF and /dev/null differ diff --git a/flash_alke/SOIRENA.RBF b/flash_alke/SOIRENA.RBF index 0805269..9661731 100644 Binary files a/flash_alke/SOIRENA.RBF and b/flash_alke/SOIRENA.RBF differ diff --git a/flash_tarena/TARENA.RBF b/flash_tarena/TARENA.RBF deleted file mode 100644 index 4a44a1f..0000000 Binary files a/flash_tarena/TARENA.RBF and /dev/null differ diff --git a/irena.py b/irena.py index d30a9dc..244f608 100755 --- a/irena.py +++ b/irena.py @@ -191,4 +191,5 @@ if ifc.is_a("USB"): try: armlib._exec_file("irenarc.py", globals()) except IOError as e: - sys.stderr.write(repr(e)) + sys.stderr.write(e) + diff --git a/irena/IRENA.awk b/irena/IRENA.awk index 3cfa597..b4e79aa 100755 --- a/irena/IRENA.awk +++ b/irena/IRENA.awk @@ -467,7 +467,7 @@ function AHBGO_B() { isMUONf="isAHBGOmuonB" } -function jFETTOLD() { +function jFETT() { NC=9 O1 = 1; thr[O1] = 45; ch[0] = O1; name[0]="O1" O2 = 2; thr[O2] = 45; ch[1] = O2; name[1]="O2" @@ -492,31 +492,6 @@ function jFETTOLD() { PP[-1][3] = 0 } -function jFETT() { - NC=9 - O1 = 0; thr[O1] = 45; ch[0] = O1; name[0]="O1" - O2 = 3; thr[O2] = 45; ch[1] = O2; name[1]="O2" - O3 = 5; thr[O3] = 45; ch[2] = O3; name[2]="O3" - B1 = 6; thr[B1] = 45; ch[3] = B1; name[3]="B1" - B2 = 9; thr[B2] = 30; ch[4] = B2; name[4]="B2" - B3 = 11; thr[B3] = 30; ch[5] = B3; name[5]="B3" - N1 = 12; thr[N1] = 30; ch[6] = N1; name[6]="N1" - N2 = 15; thr[N2] = 30; ch[7] = N2; name[7]="N2" - N3 = 17; thr[N3] = 25; ch[8] = N3; name[8]="N3" - BB[O3][0] = -0.0212738 # ± 1.042e-05 - BB[O3][1] = 0 - BB[O3][2] = 25.3283 # ± 0.07168 - BB[O3][3] = 0 - BB[-1][0] = -0.0212738 # ± 1.042e-05 - BB[-1][1] = 0 - BB[-1][2] = 25.3283 # ± 0.07168 - BB[-1][3] = 0 - PP[-1][0] = -0.0353472 # +/- 5.721e-06 - PP[-1][1] = 35.2581 # +/- 0.01238 - PP[-1][2] = 0 - PP[-1][3] = 0 -} - function SOPA() { NC=9 P1 = 1; thr[P1] = 45; ch[0] = P1; name[0]="P1" @@ -738,10 +713,6 @@ function ismuonMM() { function isPHA(i) { if (!/^EI/) return 0; A = $(3*i+6)/mV - if (A>10) - P = $(3*i+8)/mV/A - else - P = 0 if ($(3*i+7)<2) return 1; return 2 } diff --git a/irena/Itime.awk b/irena/Itime.awk index a2e05f7..0da9282 100755 --- a/irena/Itime.awk +++ b/irena/Itime.awk @@ -2,7 +2,7 @@ END { print Itime } -/^H / { +/^H/ { Time = $2 Diff = Time - Last if (Diff>0 && Diff<=120) Itime += Diff diff --git a/irenarc-chaos.py b/irenarc-chaos.py index 687c994..084a82f 100644 --- a/irenarc-chaos.py +++ b/irenarc-chaos.py @@ -84,7 +84,42 @@ def CHAOS_NAMES(): { "any": 0x100, "read": 0x3ffff }, # DL ] -Keep_Alive = armlib.Keep_Alive_Schedule( +class Keep_Alive_Schedule: + + interval = 30 + ioffset = 1 + cmd = "e/in 'staying alive'" + clock_interval = 900 + clock_args = {"fudge": True} + + def __init__(self, cmd=None, interval=None): + if cmd: + self.cmd = cmd + if interval: + self.interval = interval + pass + + + def __call__(self): + t0 = time.time() + try: + while True: + sys.stderr.write(" \r") + print(cmd(self.cmd)) + sys.stderr.write(f"Pinging every {self.interval:.3g} seconds, type Ctrl-C to end\r") + t = time.time() + tping = self.interval - t % self.interval + self.ioffset + tclock = self.clock_interval - t % self.clock_interval + if tclock < tping: + time.sleep(tclock) + ifc.set_clock(**self.clock_args) + tping -= tclock + if tping > 0.1: + time.sleep(tping) + except KeyboardInterrupt: + pass + +Keep_Alive = Keep_Alive_Schedule( cmd = "e/in" " '%u.%u %u.%u mbar %d %d °C F=%u H=%u'," " pre/10, pre%10, pre[1]/10, pre[1]%10," diff --git a/irenarc-default.py b/irenarc-default.py index 4b75b76..d151227 100644 --- a/irenarc-default.py +++ b/irenarc-default.py @@ -1,9 +1,9 @@ -HW.update({ - "NCH" : 18, - "NPEEK" : 18, -}) +HW = { + "NCH" : 18, + "NPEEK" : 18, +} def defaults(nch=18, ntr=6): adcmask() @@ -58,10 +58,8 @@ pulse_desy = [ pulse_desy.reverse() def shaper2u2(nch=18, ntr=6, **kk): - HW["NCH"] = nch global mV mV=14000 - Var("mV", mV) defaults(nch=nch, ntr=ntr) pulse(range(nch), pulse2u2, **kk) readconfig(nch=nch, ntr=ntr) @@ -279,11 +277,12 @@ def TANOS(): readconfig() def Gd4(): - shaper2u2() + global mV + mV=14000 readmask=0x6666 adcmask(readmask) windows(2,3,4,5) - for c in (0,3,4,7,8,11,12,15,16,17): + for c in (0,3,4,7,8,11,12,15,16): thres(c, 100*mV, mask=0) for i in range(4): thres(4*i+1, 100*mV, mask=(1<= 2 - c = ord(cmd[0]) - arg2 = 0 - if len(cmd)>1: - cc = f"{self._cmd_prefix} {cmd!r} 0x{arg:x}" - else: - if isinstance(arg, str): - arg = arg.encode() - if isinstance(arg, bytes): - arg = arg[0] - if len(arg) > 1: - arg2 = arg[1] - if argh is not None: - arg2 = argh - if arg & 0xff00: - cc = f"{self._cmd_prefix} {cmd!r} 0x{arg:x}" - else: - cc = f"{self._cmd_prefix} {cmd!r} 0x{arg:x} 0x{arg2:x}" - while True: - if sleep: - time.sleep(sleep) - r = self.ifc.cmd(cc, timeout=1000) - if r is None and eth_retry: - continue - if verbose: - print(cc, r, file=sys.stderr) - if self.ifc.cmdn(r) != 280: - if retry and self.ifc.cmdn(r) == 780 and r.split()[-1] == "130": - continue - raise self.Stepper_Error(r) - rr = r.split() - r1 = int(rr[2],0) - r = int(rr[3],0) - if retry and r1==0x45: - r2 = r & 0xff - if r2==0x53: - # "ES" SPI too slow or early - continue - r3 = r >> 8 - if r2==0x45 and r3 != c: - # "EE" unknown command - continue - if r1 != c: - if Error: - r |= r1<<16 - else: - rc = chr(r1) - if rc.isprintable(): - raise self.Stepper_Error(f"{rc} {rr[3]}") - raise self.Stepper_Error(f"{rr[2]} {rr[3]}") - break - return r - - def id(self): - n = self.cmd('v', 0xff, verbose=False) >> 8 - return bytes(self.cmd('v', i, verbose=False) & 0xff for i in range(n)).decode() - - CONFN = [ - "magic", - "version", - "flags", - "period", - "slen", - "lmask", - "lval", - "step", - "enable", - "reset", - "dir", - "n_steps", - "dac_ramp", - "dac_step", - "adc_incr", - "adc_period", - "awake", - "ledoff", - "disable", - "dac_ref", - ("padc", struct.Struct("<6B")), - ("adc_ch", struct.Struct("<16B")), - ("adc", struct.Struct("<16H")), - "dac", - "adc_idx", - "eewr_n", - "eewr_a", - ("pads", struct.Struct("<42B")) - ] - CONFM = b'\x1a\x1e' - CONFV = (1,) - CONFF = struct.Struct("= self.CONFF.size: - break - b = bytes(b) - if unpack and b[:2]==self.CONFM and b[2] in self.CONFV: - return self.confdict(b) - return b - - def read_eeprom(self, a=0, n=CONFF.size): - return bytes([self.cmd('x', aa | 0x800, sleep=0.001) & 0xff - for aa in range(a, a+n)]) - - def read_ram(self, a=0x100, n=0x800): - return bytes([self.cmd('y', aa, sleep=0.001) & 0xff - for aa in range(a, a+n)]) - - def read_rom(self, a=0, n=0x8000): - return bytes([self.cmd('y', aa|0x8000, sleep=0.001) & 0xff - for aa in range(a, a+n)]) - - def readhex(self, fn, a=0, unpack=False): - import intelhex - b = bytes(intelhex.IntelHex(fn).tobinarray())[4*a:] - if not unpack: - return b - return self.confdict(b) - - def verify_conf(self, b, a=0): - f = self.confbytes(b, a)[:self.CONFF.size] - c = self.read_conf(unpack=False)[:self.CONFF.size] - return [(4*a+i, b, f[i]) for i, b in enumerate(c) if b != f[i]] - - def dictdiff(self, a, b): - return [(k, a[k], b[k]) for k in a if a[k] != b[k]] - - def get_confs(self, ihex="avr/leia.eeprom", eaddr=0): - self.conf = self.read_conf(unpack=True) - if ihex: - self.ihex = self.readhex(ihex, unpack=True) - if eaddr is not None: - self.econf = self.confdict(self.read_eeprom(eaddr)) - print("eeprom → conf: ", self.dictdiff(self.econf, self.conf), file=sys.stderr) - if ihex: - print("ihex → conf: ", self.dictdiff(self.ihex, self.conf), file=sys.stderr) - - def write_conf(self, b, a=0): - b = self.confbytes(b,a) - n = 0 - for i, bb in enumerate(b): - self.cmd('X', i, bb) - n = i+1 - return b[:n] - - def write_eeprom(self, a=0, b=None): - if b is not None: - self.write_conf(b) - self.cmd('zW', 4*a, verbose=True) - while self.cmd('x', 83, verbose=True, Error=True) & 0xff00ff: - time.sleep(0.1) - return self.cmd('?', verbose=True) - - ADC_V = { - "data": 0, - "mux": 1, - "idx": 2, - "incr": 3, - "period": 4, - "ADMUX": 5, - "ADCSRA": 6, - "ADCH": 7, - } - - def adc(self, ch=0, what=None, val=None, enable=None, **aa): - "send one 'a' or 'A' command" - if what in self.ADC_V: - what = self.ADC_V[what] - for a in aa: - if what is not None or val is not None: - raise ValueError("multiple whatsits not supported") - what = self.ADC_V[a] - val = aa[a] - what = what or 0 - if isinstance(val, float): - if what == self.ADC_V["period"]: - val = int(val/self.T0TICK + 0.5) # ms - else: - raise ValueError("float not supported for this whatsit") - if enable is not None: - if what and enable and val is not None: - raise ValueError("cannot enable and read a whatsit") - what != 0x80 - what = (what << 4) | ch; - c = 'A' if val is not None or enable else 'a' - val = val or 0 - r = self.cmd(c, val, what); - if not what & 0x70: - return r - if (r>>8) != what: - raise self.Stepper_Error(f"{c}, {val}, {what} → {r}") - return r & 0xff - - def dac(self, volt=None, dac=None, ramp=True, ms=None): - if ms is not None: - t = self.adc(what="period")*self.T0TICK - p = int(t * 64/ ms + 0.5) - if p < 1: - p = 1 - if p > 1024: - p = 1024 - self.cmd('P', p) - if self._verbose >= 1: - print(f"DAC ramp speed {t*64/p:.1f} ms/step", file=sys.stderr) - if dac is None: - if volt is None: - return self.cmd('d') - dac = int(volt/2.5*0x10000) - if dac < 0 or dac >= 0x10000: - raise ValueError(f"DAC voltage out of range {volt}, {dac}") - if not ramp: - self.cmd('P', 0) - old = self.cmd('D', dac) - if self._verbose >= 1: - print(f"DAC set to 0x{dac:04x}, old value: 0x{old:04x}", - file=sys.stderr) - - def Temp(self, a, Vref, **aa): - a *= Vref/self.Vcc - return armlib.NTC(a, β=3940) - - def AVR_Temp(self, a, Vref, **aa): - return a/64 * 2.5/Vref - 273 - - ADC_MUX = { - 3: ("Iprim", 1.0, "A"), - 8: ("NTC1", Temp, "°C"), - 9: ("NTC2", Temp, "°C"), - 10: ("NTC3", Temp, "°C"), - 11: ("Temp", AVR_Temp, "°C"), - 12: ("Vcc", 4.0, "V"), - 17: ("Bandgap", 1.0, "V"), - 18: ("GND", 1.0, "V"), - } - - Vcc = 3.3 - T0TICK = 0.0925925925925926 - T1TICK = T0TICK/4 - - def read_adcs(self, chs=tuple(range(16)), update_vcc=True): - r = [] - for ch in chs: - mux = self.cmd('a', 0, 0x10+ch) - if not mux & 0x40: # REFS0 - r.append((ch, mux)) - continue - Vref = 2.5 if mux & 0x80 else self.Vcc; # REFS1 - a = self.cmd('a', 0, ch) - if not mux & 0x1f in self.ADC_MUX: - r.append((ch, mux, a)) - continue - avg = not mux & 0x20 - n = self.ADC_MUX[mux & 0x1f] - v = a - if mux & 0x20: - # ADLAR, single conversion - # !ADLAR: exponential average, τ=64 conversions - v &= 0xffc0 - if isinstance(n[1], float): - v *= Vref/0x10000 * n[1] - else: - v = n[1](self, v, mux=mux, Vref=Vref) - r.append((ch, mux, a, n[0], v, n[2], Vref)) - if (mux & 0xff) == 0xcc: - self.Vcc = v - for rr in r: - try: - ch, mux, a, n, v, u, Vref = rr - except: - continue - print(f"{ch:2d} 0x{mux:04x} 0x{a:04x} {n:7s} {v:6.3f} {u:5s} {'single' if mux & 0x20 else 'avg '} ({Vref:.2f} V)") - return r - - def avrdude(self): - print(self.ifc.cmd("v spi_ssel = 0"), file=sys.stderr) - print(self.ifc.cmd("spi/reset"), file=sys.stderr) - try: - print("SPI reset for programming the AVR", file=sys.stderr) - print("Press ^C when done …", end="", file=sys.stderr) - while True: - sys.stderr.flush() - time.sleep(60) - print(" …", end="", file=sys.stderr) - except KeyboardInterrupt: - pass - print(" done.\n", self.ifc.cmd("spi/reset/ssel"), file=sys.stderr) - print("commit: ", self.id(), file=sys.stderr) - - E_reset = { - None: 0, - "assert": 0x2000, - "home": 0x8000, - } - - E_what = { - None: 0, - "reset": 0x10000, - "enable": 0x10100, - "led": 0x10200, - "sleep": 0x10300, - } - - E_port = bitnames({ - "ALL": 0x78, - "RESET": 0x08, - "ENABLE": 0x10, - "LEDON": 0x20, - "SLEEP": 0x40, - "NONE": 0x00, - }) - - E_mode = { - None: 0, - True: 0x51c00, - False: 0x51d00, - "emit": 0x01000, - "reset": 0x03000, - "init": 0x04000, - "home": 0x08000, - "assert": 0x21800, - "deassert":0x21400, - "enable": 0x51c00, - "disable": 0x51d00, - "ledoff": 0x51e00, - "sleep": 0x51f00, - "!enable": "disable", - "!disable": "enable", - "!ledoff": "disable", - "!sleep": "disable", - } - - def enable(self, mode=None, what=None, bits=None, **aa): - """spi/stepper 'r' …""" - a = 0 - # eqiv: - # what="reset", bits=("RESET") - # what="reset", RESET=1 - # reset=("RESET") - # or any other whatsit - # (In case the port config jumpers were changed) - # - # sleep=True: assert SLEEP (clear bit) - # led=False: deassert LEDON (set bit) - # emit=False: do not change the port bits - # init=True: initialize the stepper - # reset = "assert": assert RESET (clear port bit) - # reset = "home": start stepper with a reset pulse - if len(aa)==1: - k = list(aa.keys())[0] - if mode is None and aa[k] is False: - mode = self.E_mode["!"+k] - aa = None - elif mode is None and aa[k] is True: - mode = k - aa = None - elif what is None: - what = k - aa = aa[k] - if aa is True or aa is False: - aa = None - if aa: - if bits is None: - bits = aa - else: - raise ValueError("too many bits") - - if what is None and mode is None: - mode = True - - a |= self.E_what[what] - c = 'r' - if bits is not None: - bits = self.E_port.bits(bits) - if a & 0x10000: - c = 'R' - a |= bits & self.E_port.bits("ALL") - else: - raise ValueError("no what") - bits = self.E_port.str(a & 0xff) - if self.E_mode[mode] & a & 0x50f00: - raise ValueError("too many hows") - a |= self.E_mode[mode] - r = self.cmd(c, a & 0xffff) - old = self.E_port.str(r & 0xff) - port = self.E_port.str(r>>8 & self.E_port.bits("ALL")) - return mode, what, bits, old, port - - MS = { - 1: 0x02, - 2: 0x0a, - 4: 0x06, - 8: 0x0e, - 16: 0x04, - 32: 0x0c, - -1: 0x00, - -2: 0x08, - } - - def ms(self, n=1, ms=None, torque=False): - """calculate microstepping bits - n: microsteps per step (1|2|4|8|16|32|-1|-2) - n: -1|-2: full torque - torque=True: n=1|2: full torque - """ - if ms is not None: - ms = (ms&1)<<3 | (ms&2)<<1 | (ms&4)>>1 - else: - ms = self.MS[-n if torque else n] - return ms - - def microstep(self, *a, emit=True, **aa): - """set microstepping bits - *a, **aa: see: .ms() - """ - c = 'i' - if emit: - c = 'I' - ms = self.ms(*a, **aa) - ms |= (~ms & 0x0e)<<8 - return self.cmd(c, ms) - - def dir(self, d=None): - """set/read direction - d = 0|1 (False|True) - higher bits are ignored - """ - if d is None: - return self.cmd('i') - return self.cmd('i', d&1 | (~d&1)<<8) - - MIN_SPEED = 21 - - def speed(self, period=None): - """set/read stepper cadence - period (int) in T1TICS = 23.148 µs - period (float) in ms - """ - if period is None: - r = self.cmd('q') - return r, r*self.T1TICK - if isinstance(period, float): - period = int(period/self.T1TICK) - 1 - if period < self.MIN_SPEED: - period = self.MIN_SPEED - return self.cmd('Q', period) - - LIMITS = bitnames( - ALL = ("LEDS", "FAULTS"), - FAULTS = ("FAULT1", "FAULT2"), - FAULT1 = 0x80, - FAULT2 = 0x20, - LEDS = ("LED1", "LED2"), - LED1 = 0x01, - LED2 = 0x02, - NONE = 0x00, - LOCK = (0x100, "ALL") - ) - - def limit(self, mask=None, val="ALL", **aa): - if isinstance(mask, dict): - aa = mask - if aa: - mask, val = self.LIMITS.mask_val(**aa) - else: - if mask is None: - b = self.cmd('m') - return self.LIMITS.str(b&0xff), self.LIMITS.str(b>>8) - mask = self.LIMITS.bits(mask) - val = self.LIMITS.bits(val) - if mask >= 0x100: - mask = 0 - val &= 0xff - else: - val &= mask - return self.cmd('M', mask & 0xff, val) - - def step(self, stepper=None, n=0, dir=None, cont=False, - reset=False, ms=None, dac=None, limit=None, speed=None): - if cont: - s = self.cmd('s') - if s: - return self.cmd("012"[stepper], dir) - if limit is not None: - self.limit(limit) - if dac is not None: - self.dac(dac) - if speed is not None: - self.speed(speed) - if ms: - self.microstep(n=ms) - if reset: - self.cmd('r', 0x8000) - if stepper is None: - if dir is not None: - self.dir(dir) - return self.cmd('S', n) - if not n: - return self.cmd('0') - nn = n & ~(n-1) - if n//nn < 0x100: - while not n & 1 and dir < 0xf0: - n >>= 1 - dir += 16 - return self.cmd("012"[stepper], dir, n) - return self.cmd('S', n) - self.cmd("012"[stepper], dir) diff --git a/nm64/nmdbstream.py b/nm64/nmdbstream.py index f8e2729..5894ea0 100755 --- a/nm64/nmdbstream.py +++ b/nm64/nmdbstream.py @@ -84,14 +84,14 @@ while True: if port and fd==sock.fileno(): s = sock.accept() logger("connection from %s\n" % repr(s[1])) - try: - sockets[sockets.index(None)] = s - except ValueError: - if len(sockets)>=10: - logger("too many connections %s\n" % repr(sockets)) - s[0].send(b"too many connections, good bye\n") - s[0].close() - else: + if len(sockets)>=10: + logger("too many connections %s\n" % repr(sockets)) + s[0].send(b"too many connections, good bye\n") + s[0].close() + else: + try: + sockets[sockets.index(None)] = s + except ValueError: sockets.append(s) while not pipe and files: diff --git a/nm64/rsync-cron.sh b/nm64/rsync-cron.sh index f2015ff..1ce5a2d 100755 --- a/nm64/rsync-cron.sh +++ b/nm64/rsync-cron.sh @@ -2,7 +2,7 @@ export SSH_AUTH_SOCK=/home/falbala/stephan/.ssh/nm64/agent #rsync -av nm64data:/home/irena/eda/arm/nm64/data/ /data/falbala/nm64/data/kiel/ -rsync -av --exclude '/*/' --exclude '*.xz' nm64kiel:/home/nm64kiel/nm64/solo/eda/arm/nm64/data/ /data/falbala/nm64/data/kiel/ +rsync -av --exclude '/*/' --exclude '*.xz' nm64kiel:/home/nm64kiel/nm64/arm/nm64/data/ /data/falbala/nm64/data/kiel/ cd /home/falbala/stephan/solo/eda/arm/nm64/ export TZ=UTC ls $(date +'nm64/kiel/nm64_kiel_%Y-%m-%dT*Z.dat' -d -1day) $(date +'nm64/kiel/nm64_kiel_%Y-%m-%dT*Z.dat') | sed 's,.dat$,.nm_raw,' | xargs make 2>&1 diff --git a/nmahepam.py b/nmahepam.py index 0505d36..6f5b1b9 100755 --- a/nmahepam.py +++ b/nmahepam.py @@ -8,7 +8,7 @@ def HK(): Vss = hk2mvolt("adc_Vmcsa")*(-0.002) Icc = hk2mvolt("adc_Ipcsa")*0.1 Iss = hk2mvolt("adc_Imcsa")*(-0.1) - Vprim = hk2mvolt("adc_Vprim")*(0.0163) + Vprim = hk2mvolt("adc_Vprim")*(0.011) Vbias = hk2mvolt("adc_Vbias")*(-0.05) Ibias = hk2mvolt("adc_Ibias")*0.0955 Ibiasp = hk2mvolt("adc_dac")*0.0955 @@ -20,7 +20,7 @@ def HK(): return Vcc, Vss, Icc, Iss, Vprim, Vbias, Ibias, Ibiasp, Tntc7, Tntc8 def findnmahepam(): - findxrena(prod=(0xee0c,0xee0a)) + findxrena(prod=(0xee0c,)) if connected_p(): set_clock() messages() @@ -52,47 +52,33 @@ def AHBGOa(): SSDe = SSDb default_config() atriggers(1,TBITS(BGO)) - for c in SSDa+SSDb+SSDc: thres(1,c,5) - for c in BGO: thres(1,c,5) - for c in SSDd+SSDe: thres(0,c,5) + for c in SSDa+SSDb+SSDc: thres(1,c,8) + for c in BGO: thres(1,c,8) + for c in SSDd+SSDe: thres(0,c,8) -def aenable(sl=None, hk=True, ev=True, what=None, **aa): +def aenable(sl=None, hk=True, ev=True, **aa): cmd("s/cron 'CRON.RC'") fifo_enable(sl=sl, hk=hk, ev=ev, **aa) - enable(what=what) + enable() def adisable(): cmd("s/cron/none") disable() -Keep_alive = armlib.Keep_Alive_Schedule( - cmd="e/in" - " '%u.%u mbar %d.%d °C F=%u'," - " pre/10, pre%10," - " (te-2731)/10, (te-2731)%10," - " F" - ) - if __name__=="__main__": - ifc,_oo = armlib.init_irena(scope = globals(), name = "AHEPAM", prod = (0xee0c,0xee0a), - long_options=["seth", "ahbgo", "leia"]) - if ifc.is_a("USB"): - findnmahepam() + ifc,_oo = armlib.init_irena(scope = globals(), name = "AHEPAM", prod = (0xee0c,), + long_options=["seth", "ahbgo"]) for o,v in _oo[0]: if o=="--seth": dorn.CONFIG.seth() armlib.set_prompt("SETH") - ifc._stream_control=0x000a if o=="--ahbgo": dorn.CONFIG.ahbgo() armlib.set_prompt("AHBGO") - if o=="--leia": - dorn.CONFIG.leia() - armlib.set_prompt("LEIA") - import leia_stepper - st = leia_stepper.leia_stepper(ifc) ifc._stream_fifos = 'hk1/f1/f2/f3' + if ifc.is_a("USB"): + findnmahepam() from dorn import * dorn._connect(ifc) ifc._stream_reset |= 0x000c diff --git a/pressure.awk b/pressure.awk old mode 100755 new mode 100644 diff --git a/script.c b/script.c index 5e8d97e..c922405 100644 --- a/script.c +++ b/script.c @@ -83,13 +83,13 @@ int script_execute_fd(int fd, struct command *cmd) unsigned int locals[36]; unsigned int labels[NLABELS]; memset(labels, 0, sizeof(labels)); - unsigned int *old_locals = local_variables; if (local_variables) memcpy(locals, local_variables, sizeof(locals)); else memset(locals, 0, sizeof(locals)); if (cmd && cmd->cmd && *cmd->cmd && cmd->csize) parse_parameters(cmd, locals); + unsigned int *old_locals = local_variables; while ((n=file_gets(fd, scmd_buf, sizeof(scmd_buf)))) { char sres[MSG_SIZE]; local_variables = locals; diff --git a/ssp.c b/ssp.c index 95e60f1..b24e725 100644 --- a/ssp.c +++ b/ssp.c @@ -29,7 +29,6 @@ unsigned int ssp_dma_size; unsigned int ssp_min_size = 1; unsigned int ssp_block_idle = 256; unsigned int ssp_block_size = 3; -unsigned int ssp_nobuffer_count; unsigned int ssp_get_status(void) { @@ -140,8 +139,6 @@ static void ssp_isr(void) // Try again. if (!j->buf_count) { if (get_new_buffer(j->buf_start)) { - SSPIMSC = 0; - ssp_nobuffer_count++; VICVectAddr = 0; return; } diff --git a/ssp.h b/ssp.h index 1952641..9df37e9 100644 --- a/ssp.h +++ b/ssp.h @@ -21,7 +21,6 @@ extern unsigned int ssp_lastword; extern unsigned int ssp_dma_size; extern unsigned int ssp_block_idle; extern unsigned int ssp_block_size; -extern unsigned int ssp_nobuffer_count; enum ssp_flags { ssp_compress = 1, diff --git a/tarena.py b/tarena.py index b60d6af..a4fe097 100755 --- a/tarena.py +++ b/tarena.py @@ -13,8 +13,6 @@ arena._connect(ifc) if ifc.is_a("USB"): findarena() -lasc.lasc_init(ifc) - def enable(what="usb/f3/hk"): Cmd("altera/fifo/set 8") Cmd("altera/fifo/reset 0x080") @@ -130,29 +128,29 @@ lasc.LA.update({a: 1<1: os.fsync(self.logfile.fileno()) self.blocks += 1 - if self.Jobs: - t = time.time() - for j in self.Jobs: - j.poll(t) - + def Status(self, name): return "%s socket %s file %s blocks %d" % (name, repr(self), repr(self.logfile), self.blocks)