diff --git a/Makefile b/Makefile index 33245c0..4f05d7c 100644 --- a/Makefile +++ b/Makefile @@ -90,3 +90,5 @@ data/MDDM.HRP1: $(patsubst %.EI,%.EI.HRP1,$(wildcard data/20*-MDDM-[0-9]*.EI)) %_BifA.2dhist: %.EI ./RPi.awk -v U=uM 'isuMlight(A1,A2) && is2D(B1,B2) && Ai<500 && Aj<500 {do_2DHIST(Ai,Aj)}' $< > $@ +%.sethat: %.EI %.epoch + ./sethat.awk 'isI(){pr()}' file_epoch=$(shell cat $*.epoch) $< > $@ diff --git a/RPi.awk b/RPi.awk index 03b17ee..3f03b5c 100755 --- a/RPi.awk +++ b/RPi.awk @@ -164,7 +164,7 @@ function isH() { Vio = $5*Vref*2/4096 Vrpi = $6*Vref*2/4096 Tfpga = degC($7, 3.3, 3.3, 4500) - Tsh = degC($8, 3.3, 3.3, 4500) + Tsh = degC($8, 3.3, 10.0, 3940) Tair = degC($9, 3.3, 3.3, 4500) Ibias = $10*Vref/3.3*0.077 return 1 diff --git a/altera_ctrl.py b/altera_ctrl.py index 0351ebd..fc956ec 100644 --- a/altera_ctrl.py +++ b/altera_ctrl.py @@ -113,7 +113,7 @@ def altera_from_file(fn='rpirena.rbf', hz=30000000): sleep(1) CD = gpio_read(CONF_DONE) if not CD: - raise IOError("CONF_DONE did not go high after config") + raise IOError(f"CONF_DONE did not go high after config nSTATUS={gpio_read(nSTATUS)}") spidev.set_mode(cpol=0, cpha=1) def cmdstr(w): diff --git a/auto_run.py b/auto_run.py new file mode 100644 index 0000000..9f2b2b5 --- /dev/null +++ b/auto_run.py @@ -0,0 +1,2 @@ +import rpirena +from rpirena import tanos_jr as config diff --git a/i2c.py b/i2c.py index f326997..4117960 100644 --- a/i2c.py +++ b/i2c.py @@ -82,13 +82,13 @@ class i2c: s.cmdi(s.STOP) return 4 - def conf(self): - self.cmda(0) + def conf(self, a=0): + self.cmda(a) s = 0 for k, v in self.CONF.items(): s += self.conf1(k, v) self._log(2, f"I²C conf({self.name}), len={s}") - self.cmda(0, s) + self.cmda(a, s) def readi(s, k): s.cmdi(s.START, s.SAD) diff --git a/rpirena.py b/rpirena.py index b585374..1b07d1c 100755 --- a/rpirena.py +++ b/rpirena.py @@ -196,6 +196,7 @@ class configuration(object): hk = True, counter = True ) + self.NTC=[dict()]*8 self.stream.update(stream) self.iniz() @@ -269,24 +270,29 @@ threediodes = configuration("3Diodes", ) tanos_jr = configuration("TANOS", - nsamples=(1,), l1 = [ - dict(thr= 10.0*mV, flags=0b0110100001), # B2 - dict(thr= 12.0*mV, flags=0b0011100010), # CC - dict(thr= 12.0*mV, flags=0b0011100100), # AA - dict(thr= 10.0*mV, flags=0b0110001000), # B1 + dict(thr= 9.0*mV, flags=0b0100000001), # B2 + dict(thr= 12.0*mV, flags=0b1000000010), # CC + dict(thr= 12.0*mV, flags=0b1000000100), # AA + dict(thr= 10.0*mV, flags=0b0100001000), # B1 + dict(thr= 7.0*mV, flags=0b0000010000), # B2 + dict(thr= 10.0*mV, flags=0b0000100000), # CC + dict(thr= 10.0*mV, flags=0b0001000000), # AA + dict(thr= 8.0*mV, flags=0b0010000000), # B1 ], l2 = [ - dict(any=0b0000001110), # B1 & AA & CC - dict(any=0b0000001000, none = 0b0000100000), # B1 & ~(others) - dict(any=0b0000000001), # B2 + dict(any=0b0011100000), # B1 & AA & CC + dict(any=0b0000001000, none=0b0001110000), # B1 & ~(others) + dict(any=0b0100000000), # B1 | B2 dict(any=0b0000000010), # CC dict(any=0b0000000100), # AA - dict(any=0b0000001000), # B1 - dict(any=0b0000000110), # AA & CC - dict(any=0b0000001001), # B1 & B2 + dict(any=0b1000000000, none=0b0010010000 ), # (AA|CC) & ~B1 & ~B2 + dict(any=0b0001100000), # AA & CC + dict(any=0b0010010000), # B1 & B2 ], ) +tanos_jr.Vref = 3.337 +tanos_jr.NTC[4] = dict(R25=10e3) mddm = configuration("MDDM", nsamples=(1,), @@ -630,7 +636,7 @@ def monitor(): monitor_Vprim = 0; if "Tfpga" in monitor_flags and monitor_hk: hk = monitor_hk[-1] - Tfpga = degC(hk[4]) + Tfpga = degC(hk[4], **current.NTC[4]) global monitor_Tfpga, monitor_Tsleep print(f"T_fpga {Tfpga:.1f} °C" f" ({monitor_Tfpga_temp_sleep:.1f}/{monitor_Tfpga_temp_shutdown:.1f}" diff --git a/sethat.awk b/sethat.awk index ec46d8d..8a92c1c 100755 --- a/sethat.awk +++ b/sethat.awk @@ -1,6 +1,10 @@ #! /usr/bin/gawk -i -/^H/ { Time= $2 - 3 } +BEGIN { + file_epoch = 0 +} + +/^H/ { Time= $2 - 3 + file_epoch } function magc(d) { if (d >= 0x8000) @@ -42,9 +46,9 @@ isI() { acc_adc[1] = adcc($11) acc_temp = tempc($12) for (i=1; i<=18; i++) { - mag[i][0] = magc($(13 + 3*i)) - mag[i][1] = magc($(14 + 3*i)) - mag[i][2] = magc($(15 + 3*i)) + mag[i][0] = magc($(10 + 3*i)) + mag[i][1] = magc($(11 + 3*i)) + mag[i][2] = magc($(12 + 3*i)) } acc_status_fifo = $67 acc_status = $68 @@ -62,7 +66,7 @@ function pr() { printf "IS %d 0x%04x 0x%04x 0x%04x 0x%04x %.2f %.2f %.4f %.4f\n", Time, \ mag_status, acc_status, acc_status_aux, acc_status_fifo, \ mag_temp, acc_temp, acc_adc[0], acc_adc[1] - for (i=0; i<20; i++) if (i != 18) { + for (i=0; i<20; i++) { printf "IV %.1f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f\n", Time+i/10, \ mag[i][0], mag[i][1], mag[i][2], \ acc[i][0], acc[i][1], acc[i][2] diff --git a/www/cgi/rpirena-3Diodes b/www/cgi/rpirena-3Diodes index 4148508..6b110ef 100755 --- a/www/cgi/rpirena-3Diodes +++ b/www/cgi/rpirena-3Diodes @@ -1,6 +1,8 @@ #! /bin/bash # -*- sh -*- +DATA="/3diodes/data/" + cat <Process new data and show the plots. May time out for big files.
  • Start processing data, without waiting.
  • RPiRENA control. -
  • Data Files. +
  • Data Files. EOT @@ -130,11 +132,11 @@ set ylab "[counts/min]" set y2lab "p [mbar]" set term png set out "${cfn}-new" -array CN[13] = ["T0", "-", "T2", "T3", "X0", "X2", "X3", "C23", "C03", "C02", "C023", "L2", "L3"] +array CN[17] = ["T0", "-", "T2", "T3", "H0", "-", "H2", "H3", "X0", "X2", "X3", "C23", "C03", "C02", "C023", "L2", "L3"] plot \ - "File: $bfn -

    -

    -

    +

    +

    +

    Older Spectra:

      @@ -165,7 +167,7 @@ ls -r1 20??-??-??T??:??:??Z.EI | xargs -i echo '
    • +

      diff --git a/www/cgi/rpirena-tjr b/www/cgi/rpirena-tjr new file mode 100755 index 0000000..a1280e5 --- /dev/null +++ b/www/cgi/rpirena-tjr @@ -0,0 +1,184 @@ +#! /bin/bash +# -*- sh -*- + +DATA="/tanos/data/" + +cat < + + + RPiRENA Data + + +

      Live plots of TANOS-Jr on $(hostname)

      +
      +EOT + +exec 2>&1 +if [ -x ./rpirena.py ] +then + data=./data +else + data=../../www/data + cd /home/$(hostname)/stephan/rpirena || exit +fi +lf=${data}/rpirena-cgi.log +lkf=${data}/rpirena-cgi.lock + +declare -a QUERY=(${QUERY_STRING//&/ }) +ACTION=${QUERY[0]} +[ -z "$ACTION" ] && TARGET="" || TARGET=${QUERY[-1]} +[ "$TARGET" = "$ACTION" ] && TARGET="" +[ -z "$ACTION" ] && ACTION=old + +echo "$REMOTE_ADDR $HTTP_USER_AGENT $QUERY_STRING $ACTION $TARGET" >>$lf +[ -f "$lkf" ] && cat "$lkf" 2>/dev/null +[ -z "$TARGET" ] || cat <Actions for the selected old data file: +plot +old +trigger +replot +nomake +EOF +cat <Beware of the fake hwclock of the Raspberry Pi, the times in the filenames may be fake. +

      You may need to reload the page in your browser to see the latest plots (Ctrl-Shift-R). +EOF + +if [ "$ACTION" = "trigger" ] +then + export QUERY_STRING="replot&$TARGET" + nohup ../../www/cgi/rpirena > ${data}/rpirena-trigger.log 2>&1 & + ACTION="old" +fi +if [ "$ACTION" = "restart" ] +then + echo restart > auto-run + export ACTION="old" +fi +if [ "$ACTION" = "stop" ] +then + echo stop > auto-run + export ACTION="old" +fi + +fn=${data}/$TARGET +[ -f $fn ] || fn=$(ls -1 ${data}/20??-??-??T??:??:??Z.EI | tail -1) +bfn=$(basename $fn .EI) +pfn=${data}/$bfn +sfn=${pfn}-spectra.png +hfn=${pfn}-hk.png +cfn=${pfn}-counts.png + +REPLOT=$ACTION +[ -f "$fn" -a "$fn" -nt "$sfn" -a "$ACTION" = "plot" ] && REPLOT=replot +if [ -f "$fn" -a "$REPLOT" = "replot" ] && dotlockfile -r 0 $lkf +then + trap "rm $lkf" EXIT + date +"Processing $bfn since %Y-%m-%d %H:%M:%S UTC" > $lkf + + date +"Plot $bfn %Y-%m-%d %H:%M:%S" >>$lf + + [ "$ACTION" = "nomake" ] || make UNIT=TANOS ${pfn}.EmV ${pfn}.hist ${pfn}.HK ${pfn}.CP >>$lf 2>&1 + + cat <>$lf 2>&1 + +print "plot spectra" +set title "$(hostname) RPiRENA $bfn" noenh +set xrange [-10:160] +set yrange [-10:160] +set y2range [0.9:*] +set log y2 +set ytics nomirror +set y2tics +set xlab "pulse height [mV]" +set ylab "pulse height [mV]" +set y2lab "[counts/mV]" +set grid +set timestamp "%Y-%m-%d %H:%M:%S" +set term png size 1024,768 +set out "${sfn}-new" +plot \ + "$pfn.EmV" u "AA":"CC" tit "A vs C" with d, \ + "$pfn.EmV" u "B1":"B2" tit "B_1 vs B_2" with d, \ + for [c in "AA CC B1 B2"] "$pfn.hist" u "mV":c axis x1y2 tit c w histeps +unset out + +print "plot HK" +set xrange [*:*] +set xtics timedate +set format x "%d.%m.\n%Hh%M" time +set yrange [0:10<*<100] +set y2range [*:*] +unset log y2 +set xlab "time [UTC]" +set ylab "[V] [10nA]" +set y2lab "[°C]" +set term png +set out "${hfn}-new" +array HN[8] = [ "V_{CORE}", "V_{CC}", "V_{IO}", "V_{PRIM}", "T_{FPGA}", "T_{OUT}", "T_{EBOX}", "I_{BIAS}" ] +plot \ + for [c=8:8] ">$lf 2>&1 + mv -v $hfn-new $hfn >>$lf 2>&1 + mv -v $cfn-new $cfn >>$lf 2>&1 + + rm -f $lkf + trap EXIT +fi + +cat <File: $bfn +

      +

      +

      +

      + +

      Older Spectra:

      +
        +EOT +cd ${data} +ls -r1 20??-??-??T??:??:??Z.EI | xargs -i echo '
      • {}' +cat < + + + +EOT