]> jspc29.x-matter.uni-frankfurt.de Git - mvd_soft.git/commitdiff
Adding the Bash script to take s-curve measurements
authorPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Tue, 2 Sep 2014 12:51:13 +0000 (14:51 +0200)
committerPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Tue, 2 Sep 2014 12:51:13 +0000 (14:51 +0200)
Taken from
/d/jspc55.1/htdocs/mvdsensorcontrol/tools/scurve_new2.sh

s-curves/scurve.sh [new file with mode: 0755]

diff --git a/s-curves/scurve.sh b/s-curves/scurve.sh
new file mode 100755 (executable)
index 0000000..c48f6b3
--- /dev/null
@@ -0,0 +1,240 @@
+#!/bin/bash
+
+#set -x
+
+echo
+echo   "   "Usage: ./scurve_new2.sh [ELab/Vacuum] [Number of Runs] [Step Size]
+echo
+
+if [ -z "$1" ]  # check if second parameter is empty
+then
+  echo Error: Specify the system! Use Vacuum or ELab as first parameter.
+  exit -1;
+fi
+
+if [ $1 == 'ELab' ]
+then
+  printf -v trbaddr '%s' '0xd882'
+  export DAQOPSERVER=localhost:88
+elif [ $1 == 'Vacuum' ]
+then
+  printf -v trbaddr '%s' '0xd000'
+  export DAQOPSERVER=localhost:7
+else
+  echo Error: system unspecified! Use ELab or Vacuum as the first parameter.
+  exit -1
+fi
+
+if [ -z "$2" ]  # check if second parameter is empty
+then
+  echo Error: run-parameter is empty! Specify the number of runs as second parameter.
+  exit -1;
+elif [ $2 \< 0 ]  # check if second parameter is positive
+then
+  echo Error: run-parameter $2 needs to be positive!
+  exit -1;
+else
+  if ! printf -v numruns '%d' $2  # check if second parameter is a number and store it to the numruns variable
+  then
+    echo Error: $2 is not a number!
+    exit -1;
+  fi
+fi
+
+if [ -z "$3" ]  # check if second parameter is empty
+then
+  echo Error: Specify the step size as third parameter.
+  exit -1;
+elif [ $2 \< 1 ]  # check if second parameter is positive
+then
+  echo Error: step-size parameter $3 needs to be positive!
+  exit -1;
+else
+  if ! printf -v stepsize '%d' $3  # check if second parameter is a number and store it to the stepsize variable
+  then
+    echo Error: $3 is not a number!
+    exit -1;
+  fi
+fi
+
+
+
+# trbcmd w $trbaddr 0x8002 0xaaa0aaa0 # set sensor ID for sensor 0
+# trbcmd w $trbaddr 0x8402 0xbbb0bbb0 # set sensor ID for sensor 1
+trbcmd w $trbaddr 0x8006 0x1 # set testmode
+
+echo Bank A
+for i in `seq 0 $stepsize 255`
+do
+  trbcmd w $trbaddr 0x8005 0x1 # set soft reset to 1 (skip run 0)
+  echo Iteration $i
+  printf -v hex '%04x' $i
+  printf -v param '%04x' 0
+  trbcmd w $trbaddr 0x8007 0x$hex$param # write external info to FPGA (ROC) which is the pair "threshold - run"
+  # so I know the scanning parameters for every frame
+  # TEST DISCRI A ONLY: echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  #echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=$i;DAC_BIAS/IVDREF1C=$i;DAC_BIAS/IVDREF1D=$i;DIS_DISCRI/DisDiscri=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  # change sensor settings, i.e. thresholds to $i
+
+  if [ $1 == 'Vacuum' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+  elif [ $1 == 'ELab' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+  fi
+  sleep 0.3 # wait until the run is finished (throw away data, because dirty)
+  
+  for j in `seq 1 1 $numruns` # for all runs, to gather statistics
+  do
+    echo "run $j"
+    printf -v run '%04x' $j
+    check="0"
+    while [ "$check" -eq "0" ]; do
+      trbcmd w $trbaddr 0x8005 0x1 # reset the FPGA buffers
+      result=$(trbcmd r $trbaddr 0x8005)
+      check=${result:17:1}
+      echo "attempting soft-reset..."
+    done
+    trbcmd w $trbaddr 0x8005 0x0 # clear the previous reset
+    trbcmd w $trbaddr 0x8007 0x$hex$run # write current scan parameters to FPGA (later in data)
+    trbcmd w $trbaddr 0xb00b 0x1 # start the next run in the s-curve mode
+    sleep 0.3 # wait until run is finished
+  done
+  
+done
+
+echo Bank B
+for i in `seq 0 $stepsize 255`
+do
+  trbcmd w $trbaddr 0x8005 0x1 # set soft reset to 1 (skip run 0)
+  echo Iteration $i
+  printf -v hex '%04x' $i
+  printf -v param '%04x' 0
+  trbcmd w $trbaddr 0x8007 0x$hex$param # write external info to FPGA (ROC) which is the pair "threshold - run"
+  # so I know the scanning parameters for every frame
+  # TEST DISCRI A ONLY: echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  #echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=$i;DAC_BIAS/IVDREF1C=$i;DAC_BIAS/IVDREF1D=$i;DIS_DISCRI/DisDiscri=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  echo "DAC_BIAS/IVDREF1A=255;DAC_BIAS/IVDREF1B=$i;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  # change sensor settings, i.e. thresholds to $i
+
+  if [ $1 == 'Vacuum' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+  elif [ $1 == 'ELab' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+  fi
+  sleep 0.3 # wait until the run is finished (throw away data, because dirty)
+  
+  for j in `seq 1 1 $numruns` # for all runs, to gather statistics
+  do
+    echo "run $j"
+    printf -v run '%04x' $j
+    check="0"
+    while [ "$check" -eq "0" ]; do
+      trbcmd w $trbaddr 0x8005 0x1 # reset the FPGA buffers
+      result=$(trbcmd r $trbaddr 0x8005)
+      check=${result:17:1}
+      echo "attempting soft-reset..."
+    done
+    trbcmd w $trbaddr 0x8005 0x0 # clear the previous reset
+    trbcmd w $trbaddr 0x8007 0x$hex$run # write current scan parameters to FPGA (later in data)
+    trbcmd w $trbaddr 0xb00b 0x1 # start the next run in the s-curve mode
+    sleep 0.3 # wait until run is finished
+  done
+  
+done
+
+echo Bank C
+for i in `seq 0 $stepsize 255`
+do
+  trbcmd w $trbaddr 0x8005 0x1 # set soft reset to 1 (skip run 0)
+  echo Iteration $i
+  printf -v hex '%04x' $i
+  printf -v param '%04x' 0
+  trbcmd w $trbaddr 0x8007 0x$hex$param # write external info to FPGA (ROC) which is the pair "threshold - run"
+  # so I know the scanning parameters for every frame
+  # TEST DISCRI A ONLY: echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  #echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=$i;DAC_BIAS/IVDREF1C=$i;DAC_BIAS/IVDREF1D=$i;DIS_DISCRI/DisDiscri=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  echo "DAC_BIAS/IVDREF1A=255;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=$i;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  # change sensor settings, i.e. thresholds to $i
+
+  if [ $1 == 'Vacuum' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+  elif [ $1 == 'ELab' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+  fi
+  sleep 0.3 # wait until the run is finished (throw away data, because dirty)
+  
+  for j in `seq 1 1 $numruns` # for all runs, to gather statistics
+  do
+    echo "run $j"
+    printf -v run '%04x' $j
+    check="0"
+    while [ "$check" -eq "0" ]; do
+      trbcmd w $trbaddr 0x8005 0x1 # reset the FPGA buffers
+      result=$(trbcmd r $trbaddr 0x8005)
+      check=${result:17:1}
+      echo "attempting soft-reset..."
+    done
+    trbcmd w $trbaddr 0x8005 0x0 # clear the previous reset
+    trbcmd w $trbaddr 0x8007 0x$hex$run # write current scan parameters to FPGA (later in data)
+    trbcmd w $trbaddr 0xb00b 0x1 # start the next run in the s-curve mode
+    sleep 0.3 # wait until run is finished
+  done
+  
+done
+
+echo Bank D
+for i in `seq 0 $stepsize 255`
+do
+  trbcmd w $trbaddr 0x8005 0x1 # set soft reset to 1 (skip run 0)
+  echo Iteration $i
+  printf -v hex '%04x' $i
+  printf -v param '%04x' 0
+  trbcmd w $trbaddr 0x8007 0x$hex$param # write external info to FPGA (ROC) which is the pair "threshold - run"
+  # so I know the scanning parameters for every frame
+  # TEST DISCRI A ONLY: echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=255" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  #echo "DAC_BIAS/IVDREF1A=$i;DAC_BIAS/IVDREF1B=$i;DAC_BIAS/IVDREF1C=$i;DAC_BIAS/IVDREF1D=$i;DIS_DISCRI/DisDiscri=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  echo "DAC_BIAS/IVDREF1A=255;DAC_BIAS/IVDREF1B=255;DAC_BIAS/IVDREF1C=255;DAC_BIAS/IVDREF1D=$i" | ./changeConfigVal.pl -c /local.1/htdocs/mvdconfig/config/sensorE0scurve2.xml
+  # change sensor settings, i.e. thresholds to $i
+
+  if [ $1 == 'Vacuum' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml # program the JTAG parameters to the sensor and start once
+  elif [ $1 == 'ELab' ]
+  then
+#     ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+    ./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml # program the JTAG parameters to the sensor and start once
+  fi
+  sleep 0.3 # wait until the run is finished (throw away data, because dirty)
+  
+  for j in `seq 1 1 $numruns` # for all runs, to gather statistics
+  do
+    echo "run $j"
+    printf -v run '%04x' $j
+    check="0"
+    while [ "$check" -eq "0" ]; do
+      trbcmd w $trbaddr 0x8005 0x1 # reset the FPGA buffers
+      result=$(trbcmd r $trbaddr 0x8005)
+      check=${result:17:1}
+      echo "attempting soft-reset..."
+    done
+    trbcmd w $trbaddr 0x8005 0x0 # clear the previous reset
+    trbcmd w $trbaddr 0x8007 0x$hex$run # write current scan parameters to FPGA (later in data)
+    trbcmd w $trbaddr 0xb00b 0x1 # start the next run in the s-curve mode
+    sleep 0.3 # wait until run is finished
+  done
+  
+done