#!/bin/bash # To be executed at RASPs source Commons.sh whoami="Devices/RASPs/Charger/Bt_Ecd" DirToDischargeParams=$SHM0/`dirname $whoami` COMMAND="netcat -w 1 ChargerOsc 5555" TheOscilloscope=ChargerOsc Drivers="Devices/uControllers/Drivers/UniPi" source Drivers/UniPi/driver.sh #Function test, see http://golem.fjfi.cvut.cz/shots/33132/ function HVon() { $LogFunctionPassing Relax #HV Ostry rezim: # ???? Mas URCITE odpojeny LV zdroj ?? # ==================================== PowerSupplyHVfansON HVlightON PowerSupplyHVcontactorON #LV Tupy rezim: # see Devices/PowerSupplies/RigolPS831A-a/HVsubstitute.sh # echo ":INST CH3;:CURR 0.1;:VOLT -30;:OUTP CH3,ON"|netcat -w 1 HVsubstitute 5555 Relax } function HVoff() { PowerSupplyHVcontactorOFF # Ostry rezim # see Devices/PowerSupplies/RigolPS831A-a/HVsubstitute.sh# Tupy rezim # echo ":OUTP CH3,OFF"|netcat -w 1 HVsubstitute 5555 # Tests on RigolPS $LogFunctionPassing HVlightOFF mRelax ChargingResistorsAllON } function ScopeConfiguration() { SCALE=300 OFFSET=-400 PROBE=100 #LV test setup #============== #SCALE=9 #OFFSET=0 #PROBE=100 #============== echo " CHANnel1:DISPlay ON;CHANnel1:PROBe $PROBE;CHANnel1:SCALe $SCALE;CHANnel1:OFFSet $OFFSET; CHANnel2:DISPlay ON;CHANnel2:PROBe 1;CHANnel2:SCALe 0.5;CHANnel2:OFFSet -4.3; CHANnel3:DISPlay ON;CHANnel3:PROBe $PROBE;CHANnel3:SCALe $SCALE;CHANnel3:OFFSet $OFFSET; CHANnel4:DISPlay ON;CHANnel4:PROBe $PROBE;CHANnel4:SCALe $SCALE;CHANnel4:OFFSet $OFFSET; TIMebase:DELay:ENABle OFF;TIMebase:MAIN:SCALe 10;TIMebase:MAIN:OFFSet 49; :STOP;:CLEAR; :SYSTem:KEY:PRESs MOFF"|$COMMAND } function PrepareSessionEnv@SHM() { MountCentralSHMEnvironment ScopeConfiguration } function UpperShortCircuitsEngage() { RelayON 3; } #obsolete function UpperShortCircuitsDisEngage() { RelayOFF 3; } #obsolete #function LowerShortCircuitsDisEngage() { RelayON 13; } #Before 062021 reconstruction #function LowerShortCircuitsEngage() { RelayOFF 13; } #Before 062021 reconstruction function LowerShortCircuitsDisEngage() { echo "*B1OS5H"|telnet 192.168.2.248 10001 1>&- 2>&-; } function LowerShortCircuitsEngage() { echo "*B1OS5L"|telnet 192.168.2.248 10001 1>&- 2>&-; } function HVlightON() { RelayON 14; } function HVlightOFF() { RelayOFF 14; } function ConnectOscill() { RelayON 12; } function DisConnectOscill() { RelayOFF 12; } #**************************************** #function PowerSupplyHVcontactorON() { RelayON 16; } #Before 062021 reconstruction #function PowerSupplyHVcontactorOFF() { RelayOFF 16; } #Before 062021 reconstruction function PowerSupplyHVcontactorON() { echo "*B1OS4H"|telnet 192.168.2.248 10001 1>&- 2>&-; } function PowerSupplyHVcontactorOFF() { echo "*B1OS4L"|telnet 192.168.2.248 10001 1>&- 2>&-; } #function PowerSupplyHVcontactorON() { RelayON 13; } #Test na Gabove Zdroji #function PowerSupplyHVcontactorOFF() { RelayOFF 13; } #Test na Gabove Zdroji #**************************************** function PowerSupplyHVfansON() { echo "*B1OS6H"|telnet 192.168.2.248 10001 1>&- 2>&-; } function PowerSupplyHVfansOFF() { echo "*B1OS6L"|telnet 192.168.2.248 10001 1>&- 2>&-; } function BtHVrelayON() { RelayON 4 ; } function BtHVrelayOFF() { RelayOFF 4 ; } function BtCommutatorClockWise() { RelayON 5 ;mRelax; RelayOFF 5; } function BtCommutatorAntiClockWise() { RelayON 6 ;mRelax; RelayOFF 6; } function BtChargeCommutatorClockWise() { RelayON 7 ;mRelax; RelayOFF 7; } function BtChargeCommutatorAntiClockWise() { RelayON 8 ;mRelax; RelayOFF 8; } function CdHVrelayON() { RelayON 2 ; } function CdHVrelayOFF() { RelayOFF 2 ; } function EtCommutatorClockWise() { RelayON 9 ;mRelax; RelayOFF 9; } function EtCommutatorOFF() { RelayON 10 ;mRelax; RelayOFF 10; } function EtCommutatorAntiClockWise() { RelayON 11 ;mRelax; RelayOFF 11; } function ChargingResistor_I_DisEngage() { RelayON 15 ; } function ChargingResistor_I_Engage() { RelayOFF 15 ; } #function ChargingResistor_II_DisEngage() { RelayON 6 ; } #function ChargingResistor_II_Engage() { RelayOFF 6 ; } ChargingFlag=0 ChargingResistors=0 #./Dirigent.sh --discharge --UBt 20 --TBt 1000 --Ucd 10 --Tcd 2000 --preionization 1 --gas H --pressure 0 --comment "LV test discharge" function GetReadyTheDischarge() { local UBt=`cat $SHMP/UBt` local Ucd=`cat $SHMP/Ucd` local comment=`cat $SHMP/comment` $LogFunctionStart if [ -e $SHMP/Bt_orientation ]; then Bt_orientation_request=`cat $SHMP/Bt_orientation` else LogIt "No request for Bt orientation, therefore Discharge with default Bt orientation" Bt_orientation_request=`cat $SHM/Management/DefaultParameters/Bt_orientation` cp $SHM/Management/DefaultParameters/Bt_orientation $SHMP/Bt_orientation fi echo $Bt_orientation_request > $DirToDischargeParams/Bt_orientation_request LogIt "Going with Bt_orientation $Bt_orientation_request" case $Bt_orientation_request in CW) LogIt "Discharge with Bt CW request" BtCommutatorClockWise ;; ACW) LogIt "Discharge with Bt ACW request" BtCommutatorAntiClockWise ;; esac if [ -e $SHMP/CD_orientation ]; then CD_orientation_request=`cat $SHMP/CD_orientation` else LogIt "No request for Bt orientation, therefore Discharge with default Bt orientation" CD_orientation_request=`cat $SHM/Management/DefaultParameters/CD_orientation` cp $SHM/Management/DefaultParameters/CD_orientation $SHMP/CD_orientation fi echo $CD_orientation_request > $DirToDischargeParams/CD_orientation_request LogIt "Going with CD_orientation $CD_orientation_request" case $CD_orientation_request in CW) LogIt "Discharge with CD CW request" EtCommutatorClockWise ;; ACW) LogIt "Discharge with CD ACW request" EtCommutatorAntiClockWise ;; esac echo $Ucd > $DirToDischargeParams/U_cd_discharge_request echo $UBt > $DirToDischargeParams/U_bt_discharge_request if [ "$comment" != "Dummy test discharge" ]; then OpenOscDVMchannel 1 if [ $UBt -gt 0 ]; then BtStatus=Charging; ShortCircuitsDisEngage; BtHVrelayON; Relax;HVon;Relax LogIt "Bt capacitor charging started" else LogIt "Bt capacitor charging not requested" BtStatus=Charged; fi if [ $Ucd -gt 0 ]; then CdStatus=Charging; ShortCircuitsDisEngage; CdHVrelayON; Relax;HVon;Relax LogIt "Cd capacitor charging started" else LogIt "Cd capacitor charging not requested" CdStatus=Charged; fi if [ $UBt -gt 100 ]; then ChargingResistorsAllOFF; fi #BtSlowLine=`echo "0.01725*$UBt + 76.43956"|bc|xargs printf '%4.0f\n'` BtSlowLine=98 LogIt "U_Bt: $UBt, Hrana: $BtSlowLine" CdSlowLine=98 LogIt "U_Et: $Ucd, Hrana: $CdSlowLine" while [ $BtStatus == Charging ] || [ $CdStatus == Charging ]; do PowSupVoltage=`ReadDVMOscilloscope RigolMSO5104Charger` LogIt "Charging ... HV=$PowSupVoltage V" echo -n $PowSupVoltage > $SHML/U_power_supply_now # record current voltage for remote status # ASSUMES that the same power supply voltage is on all capacitors # while they are being charged if [ "$BtStatus" = "Charging" ]; then cp $SHML/U_power_supply_now $SHML/U_Bt_now fi if [ "$CdStatus" = "Charging" ]; then cp $SHML/U_power_supply_now $SHML/U_CD_now fi if [ $PowSupVoltage -ge $UBt ] && [ "$BtStatus" = "Charging" ]; then if [ "$CdStatus" = "Charged" ]; then HVoff; mRelax; fi BtHVrelayOFF; BtStatus=Charged; LogIt "Bt capacitor charging finished @ $PowSupVoltage V" fi if [ $PowSupVoltage -ge $Ucd ] && [ "$CdStatus" = "Charging" ]; then if [ "$BtStatus" = "Charged" ]; then HVoff; mRelax; fi CdStatus=Charged; CdHVrelayOFF; LogIt "Cd capacitor charging finished @ $PowSupVoltage V" fi if [ $PowSupVoltage -gt $(($UBt*$BtSlowLine/100)) ] && [ $ChargingResistors == 0 ] && [ "$BtStatus" = "Charging" ]; then LogIt "Bt slow PowSup";ChargingResistorsAllON; fi if [ $CdStatus == Charging ] && [ $PowSupVoltage -gt $(($Ucd*$CdSlowLine/100)) ] && [ $ChargingResistors == 0 ] && [ "$CdStatus" = "Charging" ]; then LogIt "Cd slow PowSup";ChargingResistorsAllON;fi if [ "$CdStatus" = "Charged" ] && [ $ChargingResistors == 1 ] && [ $PowSupVoltage -lt $(($UBt*$BtSlowLine/100)) ]; then LogIt "Bt boost PowSup";ChargingResistorsAllOFF;fi echo -n $CdStatus > $SHML/status_CD echo -n $CdStatus > $SHML/status_Bt sleep 0.1; done HVoff else LogIt "It is a dummy discharge - without Charger action"; for i in `seq 1 5`; do echo DD charging ... $i;sleep 1; done fi cp $SHML/U_Bt_now $DirToDischargeParams/U_Bt_final cp $SHML/U_CD_now $DirToDischargeParams/U_CD_final $LogFunctionEnd } function SecurePostDischargeState() { GoToSafeState sleep 10 # to see discharging capacitors DVMDisable # ASSUMES it is off echo -n 0 > $SHML/U_power_supply_now # ASSUMES they are discharged and short-circuited echo -n 0 > $SHML/U_Bt_now echo -n 0 > $SHML/U_CD_now killall netcat PowerSupplyHVfansOFF $LogFunctionGoingThrough } function WebRecord() { echo $1 >> $DirToDischargeParams/$ThisDev.html } function Web() { cp $SHM/Management/imgs/Charger.jpg $DirToDischargeParams/ WebRecord "