diff --git a/README.md b/README.md index b0cbf9a..876cc38 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,29 @@ command on any PC having the SINQ epics environment installed. iocsh -r sinqDAQ,0.4.0 -c 'epicsEnvSet(SET_SIM_MODE,"" )' -c 'epicsEnvSet(INSTR,SQ:TEST:)' -c 'epicsEnvSet(NAME, SPC)' -c 'runScript $(sinqDAQ_DIR)daq_soft_proton.cmd' ``` +### Default behavior: count as a counterbox +By default the proton current counter simulates the beahvior of the actual signals +routed to real counterboxes. That signal converts the current to frequency modulated signal +that can be counted the same way as monitors are counted by the counter box. + +Furthermore Urs Greuter wrote me the following as reference: +> 1500 uA Strahlstrom erzeugt ein 150 kHz Pulssignal (Rechteck-Frequenzsignal) +> Eine Messung von 1 s sollte bei 1500 uA Strahlstrom 150'000 Cts ergeben. +> => Ratio [frequency/proton_current] = 100 kHz/mA + +This is implemented by default, meaning it take the value in `uA` from HIPA and +multiplies by a factor 100. The rate, `R1`, then has the unit `cts/sec` and the +cumulative counter value has the unit `cts`. + +### Setup current based accumlation +To use proton current instead of counts conversion, the following can be added before `daq_soft_proton.cmd` is ran. +``` +epicsEnvSet(SCALE_FACTOR, 1) +epicsEnvSet(RATE_EGU, "uA") +epicsEnvSet(COUNTER_EGU, "uC") +``` +This means that the unit of the cumulative counter value also has to be changed to `uC`. + ### Example st.cmd declaration To include it in an existing st.cmd, add the following lines: diff --git a/db/daq_soft_proton.db b/db/daq_soft_proton.db index a3e981f..b8be6c6 100644 --- a/db/daq_soft_proton.db +++ b/db/daq_soft_proton.db @@ -278,7 +278,7 @@ record(aSub, "$(INSTR)$(NAME):EMULATION") record(int64in, "$(INSTR)$(NAME):M1") { field(DESC, "DAQ CH0, proton current") - field(EGU, "cts") + field(EGU, "$(COUNTER_EGU=cts)") } # The proton rate take by a PV over the network, PV named indicated by $(REMOTE_RATE_PV) macro @@ -291,9 +291,13 @@ record(calc, "$(INSTR)$(NAME):R1") field(INPC, "$(SHUTTER1_CLOSED_VAL=1)") field(INPD, "$(SHUTTER2_PV=0)") field(INPE, "$(SHUTTER2_CLOSED_VAL=1)") + # The proton current signal routed to real counterboxes + # transfer the current to frequency modulated signal. + # The relation ship 1uA -> 100Hz, meaning that nominal 1500uA -> 150kHz + field(INPF, "$(SCALE_FACTOR=100)") # If either shutter is closed we have no rate - field(CALC, "B != C && D != E ? A : 0") - field(EGU, "cts/sec") + field(CALC, "B != C && D != E ? A * F : 0") + field(EGU, "$(RATE_EGU=cts/sec)") } # Store previous rate value, so we can average over the period @@ -326,4 +330,3 @@ record(bi, "$(INSTR)$(NAME):S1") field(ONAM, "CLEARING") } - diff --git a/db/sim_proton_current.db b/db/sim_proton_current.db index e49a202..eb94300 100644 --- a/db/sim_proton_current.db +++ b/db/sim_proton_current.db @@ -1,12 +1,13 @@ # This is database that provides a simulated proton current # for testing purposes. # -record(calc, "$(INSTR)$(NAME):SIM_PROTON_CURR") { +record(calc, "$(INSTR)$(NAME):SIM-PROTON-CURR") { field(SCAN, ".1 second") field(CALC, "1500 + 101 * SIN(A)") - field(INPA, "$(INSTR)$(NAME):PROTON_CURR_VAR PP") + field(INPA, "$(INSTR)$(NAME):PROTON-CURR-VAR PP") } -record(calc, "$(INSTR)$(NAME):PROTON_CURR_VAR") { +# Incrementing value to pass to the Sinus +record(calc, "$(INSTR)$(NAME):PROTON-CURR-VAR") { field(CALC, "VAL + 0.001") } diff --git a/scripts/daq_soft_proton.cmd b/scripts/daq_soft_proton.cmd index 3ab7803..4fea727 100644 --- a/scripts/daq_soft_proton.cmd +++ b/scripts/daq_soft_proton.cmd @@ -1,8 +1,8 @@ #var softProtonDebug 1 -$(SET_SIM_MODE=#)dbLoadRecords("$(sinqDAQ_DB)sim_proton_current.db", "INSTR=$(INSTR), NAME=$(NAME), REMOTE_RATE_PV=NULL") -$(SET_SIM_MODE=#)epicsEnvSet("REMOTE_RATE_PV", "$(INSTR)$(NAME):SIM_PROTON_CURR") +$(SET_SIM_MODE=#)dbLoadRecords("$(sinqDAQ_DB)sim_proton_current.db", "INSTR=$(INSTR), NAME=$(NAME)") +$(SET_SIM_MODE=#)epicsEnvSet("REMOTE_RATE_PV", "$(INSTR)$(NAME):SIM-PROTON-CURR") -dbLoadRecords("$(sinqDAQ_DB)daq_soft_proton.db", "INSTR=$(INSTR), NAME=$(NAME), REMOTE_RATE_PV=$(REMOTE_RATE_PV)") +dbLoadRecords("$(sinqDAQ_DB)daq_soft_proton.db", "INSTR=$(INSTR), NAME=$(NAME), REMOTE_RATE_PV=$(REMOTE_RATE_PV=MHC6:IST:2), RATE_EGU=$(RATE_EGU=cts/sec), COUNTER_EGU=$(COUNTER_EGU=cts), SCALE_FACTOR=$(SCALE_FACTOR=100)") iocInit