diff --git a/.gitignore b/.gitignore index 1a04676d7fcb39a0ec18fb5691cd79e12717451f..d4afc66924ab59dbfca92f5512176c41691660d0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ core.* *PVs.list *-loc/*.Makefile ts2evm-loc/*.Makefile +.vscode \ No newline at end of file diff --git a/cmds/.keep b/cmds/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/cmds/evm-simple.cmd b/cmds/evm-simple.cmd new file mode 100644 index 0000000000000000000000000000000000000000..d80de6e44de03002c41b55f61dd770261bbb2abc --- /dev/null +++ b/cmds/evm-simple.cmd @@ -0,0 +1,48 @@ +# .cmd +require "mrfioc2" "2.2.1rc1" +#require "supercycleEngine" "master" +require ts2evm,develop + +epicsEnvSet(REFTABS_DIR, "/home/iocuser/timing/reftabs") + +epicsEnvSet(PREFIX, "TD-RFLAB:TS-EVG-01") +epicsEnvSet(PSCE, "TD-RFLAB:TS-SCE-01") +epicsEnvSet(PEVG, "TD-RFLAB:TS-EVG-01") + +# Load standard timing modules environment +iocshLoad "$(mrfioc2_DIR)/mtca.iocsh" +iocshLoad "$(mrfioc2_DIR)/ts.iocsh" +iocshLoad "$(mrfioc2_DIR)/evm.iocsh" "P=$(PREFIX), OBJ=EVM, PCIID=09:00.0, U=:EVRU-, D=:EVRD-" + +dbLoadRecords("ts2_evm_controls.template", "P=$(PREFIX):, EVGPREFIX=$(PREFIX):") + +iocInit + +iocshLoad "$(mrfioc2_DIR)/evgr.iocsh" "P=$(PEVG), INTRF=, INTPPS=" + +dbpf $(PREFIX):Enable-Sel "Ena Master" +dbpf $(PREFIX):1ppsInp-Sel "Sys Clk" + +# Set MXC0 to generate 14 Hz +dbpf $(PREFIX):Mxc0-Prescaler-SP 6289464 +dbpf $(PREFIX):Mxc0-Polarity-Sel "Orginal" + +# Generate event 14 upon trigger on Mxc0 +dbpf $(PREFIX):TrigEvt0-EvtCode-SP 14 +dbpf $(PREFIX):TrigEvt0-TrigSrc-Sel "Mxc0" + +# Configure sequencers +dbpf $(PREFIX):SoftSeq0-RunMode-Sel "Normal" +dbpf $(PREFIX):SoftSeq0-TsResolution-Sel "uSec" +dbpf $(PREFIX):SoftSeq0-TrigSrc-0-Sel "Mxc0" +dbpf $(PREFIX):SoftSeq0-Load-Cmd "1" + +dbpf $(PREFIX):SoftSeq1-RunMode-Sel "Normal" +dbpf $(PREFIX):SoftSeq1-TsResolution-Sel "uSec" +dbpf $(PREFIX):SoftSeq1-TrigSrc-0-Sel "Mxc0" +dbpf $(PREFIX):SoftSeq1-Load-Cmd "1" + +dbpf $(PREFIX):SoftSeq2-RunMode-Sel "Single" +dbpf $(PREFIX):SoftSeq2-TsResolution-Sel "uSec" +dbpf $(PREFIX):SoftSeq2-TrigSrc-0-Sel "Mxc0" +dbpf $(PREFIX):SoftSeq2-Load-Cmd "1" diff --git a/configure/CONFIG_MODULE b/configure/CONFIG_MODULE index 587a4e0ecaaeed5b62e6198058479b2b1977d82a..e022fd4eea15070a269705e4074f0a443da069f5 100644 --- a/configure/CONFIG_MODULE +++ b/configure/CONFIG_MODULE @@ -3,7 +3,7 @@ EPICS_MODULE_NAME:=ts2evm EPICS_MODULE_TAG:=master # -E3_MODULE_VERSION:=master +E3_MODULE_VERSION:=develop # DEPENDENT MODULE VERSION # For Example, diff --git a/ts2evm-loc/ts2evmApp/Db/.keep b/ts2evm-loc/ts2evmApp/Db/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/ts2evm-loc/ts2evmApp/Db/ts2_evm_controls.template b/ts2evm-loc/ts2evmApp/Db/ts2_evm_controls.template new file mode 100644 index 0000000000000000000000000000000000000000..96393addcccc24da5bd5939feb077141e9f3ee47 --- /dev/null +++ b/ts2evm-loc/ts2evmApp/Db/ts2_evm_controls.template @@ -0,0 +1,166 @@ + +######################################################## +# Cycle frequency +######################################################## +record(ao, "$(P)$(R=)CycleFreq-SP") { + field(DESC, "Cycle frequency setpoint") + field(VAL, "14") + field(DRVL, "0") + field(DRVH, "14") +} + + +######################################################## +# RF Pulse Lenght +######################################################## +record(ao, "$(P)$(R=)RFPulseLen-SP") { + field(DESC, "RF Pulse Length") + field(VAL, "3000") + field(DRVL, "0") + field(DRVH, "3600") + field(EGU, "us") + field(PINI, "YES") + + field(FLNK, "$(P)$(R=)SeqSelecCalc PP") +} + + +######################################################## +# Proton Pulse Lenght +######################################################## +record(ao, "$(P)$(R=)PBLen-SP") { + field(DESC, "Beam Length") + field(VAL, "50") + field(DRVL, "5") + field(DRVH, "2863") + + field(FLNK, "$(P)$(R=)SeqSelecCalc PP") +} + +######################################################## +# Record logic to alternate usage of sequencers +######################################################## +record(calc, "$(P)$(R=)SeqSelecCalc") { + field(CALC, "A > 0 ? 0 : 1") + field(INPA, "$(P)$(R=)SeqSelecCalc") + field(VAL, "0") + field(FLNK, "$(P)$(R=)SeqSelecFOut") + field(TPRO, "1") +} + +record(fanout, "$(P)$(R=)SeqSelecFOut") { + field(SELM, "Specified") + field(SELL, "$(P)$(R=)SeqSelecCalc") + field(LNK0, "$(P)$(R=)Seq0-Write-aSub") + field(LNK1, "$(P)$(R=)Seq1-Write-aSub") + field(TPRO, "1") +} + +######################################################## +# aSub process - Sequencer 0 +######################################################## +record(aSub, "$(P)$(R=)Seq0-Write-aSub") { + field(DESC, "Sequencer arrays") + field(SNAM, "seqConfigure") + field(SCAN, "Passive") + + field(INPA, "$(P)$(R=)RFPulseLen-SP") + field(FTA, "FLOAT") + field(NOA, "1") + + field(INPB, "$(P)$(R=)PBLen-SP") + field(FTB, "FLOAT") + field(NOB, "1") + + + field(FTVA, "ULONG") + field(OUTA, "$(EVGPREFIX)SoftSeq0-EvtCode-SP CP") + + field(FTVB, "FLOAT") + field(OUTB, "$(EVGPREFIX)SoftSeq0-Timestamp-SP CP") + + field(FLNK, "$(P)$(R=)Seq0-Enable PP") + field(TPRO, "1") +} + +record(seq, "$(P)$(R=)Seq0-Enable") { + field(SELM, "All") + # Disable sequencer 1 + field(DOL1, "1") + field(LNK1, "$(EVGPREFIX)SoftSeq1-Disable-Cmd CP") + # Commit sequencer 0 + field(DOL2, "1") + field(LNK2, "$(EVGPREFIX)SoftSeq0-Commit-Cmd CP") + # Enable sequencer 0 + field(DOL3, "1") + field(LNK3, "$(EVGPREFIX)SoftSeq0-Enable-Cmd CP") + + field(TPRO, "1") +} + + +######################################################## +# aSub process - Sequencer 1 +######################################################## +record(aSub, "$(P)$(R=)Seq1-Write-aSub") { + field(DESC, "Sequencer arrays") + field(SNAM, "seqConfigure") + field(SCAN, "Passive") + + field(INPA, "$(P)$(R=)RFPulseLen-SP") + field(FTA, "FLOAT") + field(NOA, "1") + + field(INPB, "$(P)$(R=)PBLen-SP") + field(FTB, "FLOAT") + field(NOB, "1") + + + field(FTVA, "ULONG") + field(OUTA, "$(EVGPREFIX)SoftSeq1-EvtCode-SP CP") + + field(FTVB, "FLOAT") + field(OUTB, "$(EVGPREFIX)SoftSeq1-Timestamp-SP CP") + field(TPRO, "1") + + field(FLNK, "$(P)$(R=)Seq1-Enable PP") +} + +record(seq, "$(P)$(R=)Seq1-Enable") { + field(SELM, "All") + # Disable sequencer 0 + field(DOL1, "1") + field(LNK1, "$(EVGPREFIX)SoftSeq0-Disable-Cmd CP") + # Commit sequencer 1 + field(DOL2, "1") + field(LNK2, "$(EVGPREFIX)SoftSeq1-Commit-Cmd CP") + # Enable sequencer 1 + field(DOL3, "1") + field(LNK3, "$(EVGPREFIX)SoftSeq1-Enable-Cmd CP") + + field(TPRO, "1") +} + +######################################################## +# aSub process - Sequencer 2 +######################################################## +record(aSub, "$(P)$(R=)Seq2-Write-aSub") { + field(DESC, "Sequencer arrays") + field(SNAM, "seqConfigure") + field(SCAN, "Passive") + + field(INPA, "$(P)$(R=)RFPulseLen-SP") + field(FTA, "FLOAT") + field(NOA, "1") + + field(INPB, "$(P)$(R=)PBLen-SP") + field(FTB, "FLOAT") + field(NOB, "1") + + + field(FTVA, "ULONG") + field(OUTA, "$(EVGPREFIX)SoftSeq2-EvtCode-SP CP") + + field(FTVB, "FLOAT") + field(OUTB, "$(EVGPREFIX)SoftSeq2-Timestamp-SP CP") +} diff --git a/ts2evm-loc/ts2evmApp/src/.keep b/ts2evm-loc/ts2evmApp/src/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/ts2evm-loc/ts2evmApp/src/evm_subroutines.c b/ts2evm-loc/ts2evmApp/src/evm_subroutines.c new file mode 100644 index 0000000000000000000000000000000000000000..5667509ee8b2b38b10c142488effc33643337e03 --- /dev/null +++ b/ts2evm-loc/ts2evmApp/src/evm_subroutines.c @@ -0,0 +1,54 @@ +#include <stdio.h> +#include <aSubRecord.h> +#include <registryFunction.h> +#include <epicsExport.h> + +#include <string.h> + +#define EVT14HZ 14 +#define RF_ST 60 +#define RF_END 61 +#define BPULSE_ST 12 +#define BPULSE_END 13 +#define SEQ_END 127 + +#define MAX_SEQ_EVENTS 5 + +static long seqConfigure(aSubRecord *prec) +{ + int event_codes[MAX_SEQ_EVENTS]; + float tstamp_codes[MAX_SEQ_EVENTS]; + + // Get RF pulse length from INPA + float rflen = *(float *)prec->a; + + // Get Proton Beam pulse length from INPB + float pblen = *(float *)prec->b; + + // Create the array of events + event_codes[0] = RF_ST; + event_codes[1] = BPULSE_ST; + event_codes[2] = BPULSE_END; + event_codes[3] = RF_END; + event_codes[4] = SEQ_END; + + // Create the array of time stamps + tstamp_codes[0] = 10000.0; // RF_ST + tstamp_codes[3] = tstamp_codes[0] + rflen; // RF_END + + tstamp_codes[1] = tstamp_codes[0] + 738.2; // BPULSE_ST + tstamp_codes[2] = tstamp_codes[1] + pblen; // BPULSE_END + + tstamp_codes[4] = tstamp_codes[3] + 1.0; + + // Write the output arrays + memcpy(prec->vala, event_codes, MAX_SEQ_EVENTS * sizeof(int)); + prec->neva = MAX_SEQ_EVENTS; + + memcpy(prec->valb, tstamp_codes, MAX_SEQ_EVENTS * sizeof(float)); + prec->nevb = MAX_SEQ_EVENTS; + + return 0; +} + +epicsRegisterFunction(seqConfigure); diff --git a/ts2evm-loc/ts2evmApp/src/evm_subroutines.dbd b/ts2evm-loc/ts2evmApp/src/evm_subroutines.dbd new file mode 100644 index 0000000000000000000000000000000000000000..02c307286f6b7ccfd79471d42eb7c2bd47891eb6 --- /dev/null +++ b/ts2evm-loc/ts2evmApp/src/evm_subroutines.dbd @@ -0,0 +1 @@ +function(seqConfigure) diff --git a/ts2evm.Makefile b/ts2evm.Makefile index b1a708ee59594704bf1519085e0dc8e78afe8241..f60534ae7df4731b8f4707ecedf8d3379ca7795f 100644 --- a/ts2evm.Makefile +++ b/ts2evm.Makefile @@ -43,16 +43,13 @@ include $(E3_REQUIRE_CONFIG)/DECOUPLE_FLAGS #sequencer_VERSION=$(SEQUENCER_DEP_VERSION) #endif - - ## Exclude linux-ppc64e6500 -##EXCLUDE_ARCHS += linux-ppc64e6500 -##EXCLUDE_ARCHS += linux-corei7-poky - -# APP:=calcApp -# APPDB:=$(APP)/Db -# APPSRC:=$(APP)/src +EXCLUDE_ARCHS += linux-ppc64e6500 +EXCLUDE_ARCHS += linux-corei7-poky +APP:=ts2evmApp +APPDB:=$(APP)/Db +APPSRC:=$(APP)/src # USR_INCLUDES += -I$(where_am_I)$(APPSRC) @@ -66,7 +63,7 @@ include $(E3_REQUIRE_CONFIG)/DECOUPLE_FLAGS # TEMPLATES += $(wildcard $(APPDB)/*.db) # TEMPLATES += $(wildcard $(APPDB)/*.db) # TEMPLATES += $(wildcard $(APPDB)/*.proto) -# TEMPLATES += $(wildcard $(APPDB)/*.template) +TEMPLATES += $(wildcard $(APPDB)/*.template) # DBDINC_SRCS += $(APPSRC)/swaitRecord.c @@ -85,7 +82,7 @@ include $(E3_REQUIRE_CONFIG)/DECOUPLE_FLAGS # HEADERS += $(DBDINC_HDRS) -# SOURCES += $(APPSRC)/sCalcPostfix.c +SOURCES += $(APPSRC)/evm_subroutines.c # SOURCES += $(APPSRC)/sCalcPerform.c # SOURCES += $(APPSRC)/aCalcPostfix.c # SOURCES += $(APPSRC)/aCalcPerform.c @@ -103,7 +100,7 @@ include $(E3_REQUIRE_CONFIG)/DECOUPLE_FLAGS # # DBDINC_SRCS should be last of the series of SOURCES # SOURCES += $(DBDINC_SRCS) -# DBDS += $(APPSRC)/calcSupport_LOCAL.dbd +DBDS += $(APPSRC)/evm_subroutines.dbd # DBDS += $(APPSRC)/calcSupport_withSNCSEQ.dbd # DBDS += $(APPSRC)/calcSupport_withSSCAN.dbd