From a6f2a090bae161a061c80f4c3faa1a56e222692c Mon Sep 17 00:00:00 2001 From: Maps Date: Mon, 12 Jan 2015 18:37:37 +0100 Subject: [PATCH] added working scurve script for current VHDL code in repo --- tools/scurve_control.sh | 134 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100755 tools/scurve_control.sh diff --git a/tools/scurve_control.sh b/tools/scurve_control.sh new file mode 100755 index 0000000..34ecb9e --- /dev/null +++ b/tools/scurve_control.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +## Uncomment the following line to debug this script: +#set -x + +### ------------ Interpret the command line arguments ------------ + +usage () { echo -e "\nUsage: ./scurve_new2.sh [ELab/Vacuum] [Number of Runs] [Step Size]\n"; } + +if [ -z "$1" ] # check if first parameter is empty +then + usage + 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 + + +### ------------------------------------------------------------------ + +# Setting up general properties of the ROC: + +# 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 0x8001 0x1 # set testmode was 8006 + +trbcmd w 0x8880 0xc0 0xf4 +trbcmd w 0x8880 0xc1 0xf4 +trbcmd w 0x8880 0xc3 0xf4 + + +# Starting the configuration / readout cycles + +for BANK in 0 +do +echo -e "\nBank $BANK" +for i in $(seq 180 $stepsize 240) +do + echo Threshold $i + + printf -v threshhex '%02x' $i + + trbcmd w $trbaddr 0x8002 0x1 # set soft reset to 1 (skip run 0) was 8005 + + # change sensor settings, i.e. thresholds to $i + if [[ $BANK -eq 0 ]]; then + #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 + elif [[ $BANK -eq 1 ]]; then + 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 + elif [[ $BANK -eq 2 ]]; then + 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 + elif [[ $BANK -eq 3 ]]; then + 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 + fi + + # programming the sensor via JTAG + if [ $1 == 'Vacuum' ] + then + ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml + #./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup.xml + elif [ $1 == 'ELab' ] + then + ./init_setup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml + #./startup.pl /local.1/htdocs/mvdconfig/setup/scurve2_setup_ELab2.xml + fi + sleep 0.3 # wait until the run is finished (throw away data, because dirty) + + # Start taking data and cycle through runs: + for j in $(seq 1 1 $numruns) # for all runs, to gather statistics + do + echo "run $j" + + printf -v runhex '%05x' $j + check="0" + #while [ "$check" -eq "0" ]; do + trbcmd w $trbaddr 0x8002 0x1 # reset the FPGA buffers was 8005 + # result=$(trbcmd r $trbaddr 0x8005) + # check=${result:17:1} + echo "attempting soft-reset..." + #done + trbcmd w $trbaddr 0x8002 0x0 # clear the previous reset was 8005 + trbcmd w $trbaddr 0x8003 0x$threshhex$BANK$runhex # write current scan parameters to ROC-FPGA (later in data) was 8007 + + trbcmd w $trbaddr 0xb00b 0x1 # start the next run in the s-curve mode + sleep 0.3 # wait until run is finished + done + +done +done -- 2.43.0