Add default behavior to mimic counterbox current to cts conversion
Example Action / Lint (push) Successful in 2s
Example Action / BuildAndTest (push) Failing after 9s

Document how to use proton current instead of cts.
This commit is contained in:
2026-02-26 11:54:44 +01:00
parent 5b772152c9
commit ed1f3f8b28
4 changed files with 37 additions and 10 deletions
+23
View File
@@ -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:
+7 -4
View File
@@ -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")
}
+4 -3
View File
@@ -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")
}
+3 -3
View File
@@ -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