diff --git a/CS_scan.sh b/CS_scan.sh index aa8f251..17ce3da 100644 --- a/CS_scan.sh +++ b/CS_scan.sh @@ -1,55 +1,117 @@ #!/bin/bash -frames=640 -sls_detector_put clearbit 0x5d 16 -sls_detector_put clearbit 0x5d 17 -#source set_quarter_speed_NF.sh 0 # aldo says this line is wrong +# to run do: bash CS_scan.sh -sls_detector_put status stop +# prerequisites: +# - the hostname is set +# - source /afs/psi.ch/project/sls_det_software/slsDetectorsPackage/bin/setup_SL6_64bit.sh +# - PATH=$PATH:/afs/psi.ch/project/sls_det_software/slsDetectorsPackage/bin/ +# - detector is on + +# prepare detector as in v0_5/prepare_mpc2012.sh + +# set dacs as in setDacs_Fmodule_LCLS.sh +sls_detector_put dac:5 1000 +sls_detector_put dac:0 1220 +sls_detector_put dac:4 750 +sls_detector_put dac:6 480 +sls_detector_put dac:7 420 +sls_detector_put dac:3 1450 +sls_detector_put dac:2 1053 +sls_detector_put dac:1 3000 + +# power on the chips +sls_detector_put reg 0x5e 0x1 + +# reset_adc +sls_detector_put adcreg 0x08 0x3;sls_detector_put adcreg 0x08 0x0; sls_detector_put adcreg 0x14 0x40; +sls_detector_put adcreg 0x4 0xf +sls_detector_put adcreg 0x5 0x3f +# vrefs +sls_detector_put adcreg 0x18 0x2 + +# set ADCINVERSionreg (by trial and error) +sls_detector_put reg 0x43 0x453b2a9c + +# set adc_pipeline +sls_detector_put reg 0x42 0x20 +sls_detector_put reg 0x59 0x1000 +sls_detector_put reg 0x4d 0x00100000 +sleep 1 + +# set adc_clock_phase in unit of 1/(52) clock period (by trial and error) +sls_detector_put adcphase 72 + +# storage cell f +sls_detector_put reg 0x5d 0xf00 + +# reset mem machine fifos fifos +sls_detector_put reg 0x4f 0x4000 +sls_detector_put reg 0x4f 0x0 + +# reset run control +sls_detector_put reg 0x4f 0x0400;sls_detector_put reg 0x4f 0x0; + +# delay +sls_detector_put delay 0 +# cycles +sls_detector_put cycles 1 +# frames +sls_detector_put frames 640 +# period sls_detector_put period 0.005 -sls_detector_put frames $frames -sls_detector_put vhighvoltage 200 +# exposure time sls_detector_put exptime 0.000010 -sls_detector_put reg 0x5c 0 +# high voltage +sls_detector_put vhighvoltage 200 -echo "setting to G0" -sls_detector_put clearbit 0x5d 0 -sls_detector_put clearbit 0x5d 1 -sls_detector_put clearbit 0x5d 12 -sls_detector_put clearbit 0x5d 13 +# configure for receiver on mpc2012 +sls_detector_put 0:rx_udpport 32410 +sls_detector_put 0:rx_udpip 10.1.3.105 +sls_detector_put 0:rx_udpmac 3C:FD:FE:A2:14:D9 +sls_detector_put 0:detectorip 10.1.3.9 +sls_detector_put 0:detectormac 00:ab:be:cc:dd:e2 +sls_detector_put 0:configuremac 0 + +sls_detector_put reg 0x5c 0 # what is this? does it have an effect? + + +echo "The receiver should be waiting for data" +echo "Please check and press any key to continue, or press q to exit this script" +read -n 1 -s input +if [ $input = "q" ]; then + echo "Exiting script" + exit 1 +fi + + +echo "recording G0 pede" sls_detector_put status start -#sleep 5 sleep 4 -echo "setting to G1" +echo "recording G1 pede" sls_detector_put setbit 0x5d 12 - sls_detector_put status start -#sleep 5 sleep 4 -echo "setting to G2" +echo "recording G2 pede" sls_detector_put setbit 0x5d 13 - sls_detector_put status start -#sleep 5 sleep 4 - sls_detector_put clearbit 0x5d 12 sls_detector_put clearbit 0x5d 13 -# this line enables current source +# turn on current source +# bit 16 high bit 17 low = automatic cal col sweep +# bit 16 high bit 17 high = cal col selected with bits 26-20 sls_detector_put setbit 0x5d 16 -#bit 16 high bit 17 low = automatic cal col sweep -#bit 16 high bit 17 high = cal col selected with bits 26-20 -#sleep 5 sleep 1 @@ -59,15 +121,13 @@ do tint_sec=$(printf %.9f $(echo "$tint/1000000000" | bc -l)) echo "setting integration time to (s) " $tint_sec sls_detector_put exptime $tint_sec -sls_detector_get reg 0x68 +sls_detector_get reg 0x68 # what is this doing? #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done - # loop 2a for tint in {50..100..5} do @@ -77,10 +137,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done + # loop 2b for tint in {110..200..10} do @@ -90,10 +150,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done + # loop 2c for tint in {225..450..25} do @@ -103,12 +163,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done - # loop 3a for tint in {50..100..5} do @@ -118,10 +176,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done + # loop 3b for tint in {110..200..10} do @@ -131,10 +189,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done + # loop 3c for tint in {225..450..25} do @@ -144,13 +202,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done - - # loop 4a for tint in {50..100..5} do @@ -160,10 +215,10 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done + # loop 4b for tint in {110..250..10} do @@ -173,14 +228,13 @@ sls_detector_put exptime $tint_sec sls_detector_get reg 0x68 #sleep 1 sls_detector_put status start -#sleep 5 sleep 4 done - -echo "DONE!" +echo "Finished scan" sls_detector_put exptime 0.000010 sls_detector_put period 0.002 sls_detector_put frames 1000000 sls_detector_put clearbit 0x5d 16 +echo "Script finished" \ No newline at end of file