diff --git a/sis8300bcmApp/Db/sis8300bcm-acct.template b/sis8300bcmApp/Db/sis8300bcm-acct.template index 763832f77f3d5e3cea43ca4d9692b06ea776e636..c93c3c6978f1ce26dd874d52ef2a3eed2f6ab16e 100644 --- a/sis8300bcmApp/Db/sis8300bcm-acct.template +++ b/sis8300bcmApp/Db/sis8300bcm-acct.template @@ -1142,4 +1142,24 @@ record(ai, "$(P)$(R)CalibrationSample4R") field(PREC, "6") field(SCAN, "I/O Intr") } +record(ao, "$(P)$(R)BeamOverThreshold") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.BEAM_ABOVE_THRESHOLD") + field(EGU, "mA") + field(PREC, "4") + field(DRVH, "63.0") + field(DRVL, "-63.0") + field(VAL, "3.0") + field(ASG, "critical") + info(autosaveFields, "VAL") +} +record(ai, "$(P)$(R)BeamOverThresholdR") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.BEAM_ABOVE_THRESHOLD") + field(EGU, "mA") + field(PREC, "4") + field(SCAN, "I/O Intr") +} diff --git a/sis8300bcmApp/Db/sis8300bcm.template b/sis8300bcmApp/Db/sis8300bcm.template index e5fe5ffac7cf769269902123344639a3fa6d46b9..7aa9a050cd99d8d8d2047243aa68464c41a3a495 100644 --- a/sis8300bcmApp/Db/sis8300bcm.template +++ b/sis8300bcmApp/Db/sis8300bcm.template @@ -637,24 +637,3 @@ record(ao, "$(P)$(R)CalibrationActualCurrent") info(autosaveFields, "VAL") } -record(ao, "$(P)$(R)BeamOverThreshold") -{ - field(DTYP, "asynFloat64") - field(OUT, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.BEAM_ABOVE_THRESHOLD") - field(EGU, "mA") - field(PREC, "4") - field(DRVH, "63.0") - field(DRVL, "-63.0") - field(VAL, "3.0") - field(ASG, "critical") - info(autosaveFields, "VAL") -} - -record(ai, "$(P)$(R)BeamOverThresholdR") -{ - field(DTYP, "asynFloat64") - field(INP, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.BEAM_ABOVE_THRESHOLD") - field(EGU, "mA") - field(PREC, "4") - field(SCAN, "I/O Intr") -} diff --git a/sis8300bcmApp/src/sis8300bcm.cpp b/sis8300bcmApp/src/sis8300bcm.cpp index 4bafd276019cc0ce55498a32186a9142bbc3031c..00cb065d8bc760e2afcbedd37edc5a819cdd26ea 100644 --- a/sis8300bcmApp/src/sis8300bcm.cpp +++ b/sis8300bcmApp/src/sis8300bcm.cpp @@ -184,7 +184,6 @@ sis8300bcm::sis8300bcm(const char *portName, const char *devicePath, createParam(BCMHighVoltagePresenceString, asynParamInt32, &BCMHighVoltagePresence); createParam(BCMHighVoltageOKString, asynParamInt32, &BCMHighVoltageOK); createParam(BCMEnableCalibrationPulseString, asynParamInt32, &BCMEnableCalibrationPulse); - createParam(BCMBeamAboveThresholdString, asynParamFloat64, &BCMBeamAboveThreshold); // ACCT block, channel specific createParam(BCMAcctTriggerSourceString, asynParamInt32, &BCMAcctTriggerSource); createParam(BCMAcctPulseChargeString, asynParamFloat64, &BCMAcctPulseCharge); @@ -267,6 +266,7 @@ sis8300bcm::sis8300bcm(const char *portName, const char *devicePath, createParam(BCMAcctCalibrationSample2String, asynParamFloat64, &BCMAcctCalibrationSample2); createParam(BCMAcctCalibrationSample3String, asynParamFloat64, &BCMAcctCalibrationSample3); createParam(BCMAcctCalibrationSample4String, asynParamFloat64, &BCMAcctCalibrationSample4); + createParam(BCMAcctBeamAboveThresholdString, asynParamFloat64, &BCMAcctBeamAboveThreshold); // DIFF block, channel specific createParam(BCMDiffSourceAString, asynParamInt32, &BCMDiffSourceA); createParam(BCMDiffSourceBString, asynParamInt32, &BCMDiffSourceB); @@ -648,13 +648,6 @@ int sis8300bcm::readbackParameters() } setIntegerParam(BCMBeamTriggerSource, uintValue); - ret = sis8300drvbcm_get_beam_above_threshold(mDeviceHandle, &doubleValue); - if (ret) { - asynPrintError(pasynUserSelf, "sis8300drvbcm_get_beam_above_threshold returned %d", ret); - return ret; - } - setDoubleParam(BCMBeamAboveThreshold, doubleValue); - // readback channel configuration parameters for (int addr = 0; addr < SIS8300BCM_NUM_CHANNELS; addr++) { asynPrintDeviceInfo(pasynUserSelf, "readback acq %d parameters", addr); @@ -883,6 +876,13 @@ int sis8300bcm::readbackParameters() } setDoubleParam(addr, BCMAcctCalibrationSample4, doubleValue); + ret = sis8300drvbcm_get_channel_beam_above_threshold(mDeviceHandle, addr, &doubleValue); + if (ret) { + asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_beam_above_threshold returned %d", ret); + return ret; + } + setDoubleParam(addr, BCMAcctBeamAboveThreshold, doubleValue); + ret = sis8300drvbcm_get_channel_droop_rate(mDeviceHandle, addr, &doubleValue); if (ret) { asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_droop_rate returned %d", ret); @@ -1931,6 +1931,12 @@ asynStatus sis8300bcm::writeFloat64(asynUser *pasynUser, epicsFloat64 value) if (ret) { asynPrintError(pasynUser, "sis8300drvbcm_set_channel_errant_window_end returned %d", ret); } + } else if (function == BCMAcctBeamAboveThreshold) { + asynPrintDeviceInfo(pasynUserSelf, "set_channel_beam_above_threshold: addr %d, value %f", addr, value); + ret = sis8300drvbcm_set_channel_beam_above_threshold(mDeviceHandle, addr, value); + if (ret) { + asynPrintError(pasynUser, "sis8300drvbcm_set_channel_beam_above_threshold returned %d", ret); + } } else if (function == BCMDiffDelay) { ret = sis8300drvbcm_set_differential_delay(mDeviceHandle, addr, value); if (ret) { @@ -1995,11 +2001,6 @@ asynStatus sis8300bcm::writeFloat64(asynUser *pasynUser, epicsFloat64 value) if (ret) { asynPrintError(pasynUser, "sis8300drvbcm_set_differential_medium_window_width_inverse returned %d", ret); } - } else if (function == BCMBeamAboveThreshold) { - ret = sis8300drvbcm_set_beam_above_threshold(mDeviceHandle, value); - if (ret) { - asynPrintError(pasynUser, "sis8300drvbcm_set_beam_above_threshold returned %d", ret); - } } else if (function == BCMMinTriggerPeriod) { ret = sis8300drvbcm_set_minimum_trigger_period(mDeviceHandle, value); if (ret) { diff --git a/sis8300bcmApp/src/sis8300bcm.h b/sis8300bcmApp/src/sis8300bcm.h index 65fff9fa58f1f425ab332e3c5f002c89a3f30e72..48bcc27f6da516c1620f740c9ccf1b5f91d91c15 100644 --- a/sis8300bcmApp/src/sis8300bcm.h +++ b/sis8300bcmApp/src/sis8300bcm.h @@ -80,7 +80,6 @@ #define BCMHighVoltagePresenceString "BCM.HIGH_VOLTAGE_PRESENCE" #define BCMHighVoltageOKString "BCM.HIGH_VOLTAGE_OK" #define BCMEnableCalibrationPulseString "BCM.ENABLE_CALIBRATION_PULSE" -#define BCMBeamAboveThresholdString "BCM.BEAM_ABOVE_THRESHOLD" // ACCT block, channel specific #define BCMAcctTriggerSourceString "BCM.ACCT.TRIGGER_SOURCE" #define BCMAcctPulseChargeString "BCM.ACCT.PULSE_CHARGE" @@ -163,6 +162,7 @@ #define BCMAcctCalibrationSample2String "BCM.ACCT.CALIBRATION_SAMPLE2" #define BCMAcctCalibrationSample3String "BCM.ACCT.CALIBRATION_SAMPLE3" #define BCMAcctCalibrationSample4String "BCM.ACCT.CALIBRATION_SAMPLE4" +#define BCMAcctBeamAboveThresholdString "BCM.ACCT.BEAM_ABOVE_THRESHOLD" // DIFF block, channel specific #define BCMDiffSourceAString "BCM.DIFF.SOURCE_A" #define BCMDiffSourceBString "BCM.DIFF.SOURCE_B" @@ -282,7 +282,6 @@ protected: int BCMHighVoltagePresence; int BCMHighVoltageOK; int BCMEnableCalibrationPulse; - int BCMBeamAboveThreshold; // ACCT block, channel specific int BCMAcctTriggerSource; int BCMAcctPulseCharge; @@ -365,6 +364,7 @@ protected: int BCMAcctCalibrationSample2; int BCMAcctCalibrationSample3; int BCMAcctCalibrationSample4; + int BCMAcctBeamAboveThreshold; // DIFF block, channel specific int BCMDiffSourceA; int BCMDiffSourceB; diff --git a/vendor/ess/lib/sis8300bcm_reg.h b/vendor/ess/lib/sis8300bcm_reg.h index d503d54e1a7b66e6e5a032d0e054ec2c63a86f7b..cd9fc6cfcd84851b7b6ab61dcaeabca17bd3e147 100644 --- a/vendor/ess/lib/sis8300bcm_reg.h +++ b/vendor/ess/lib/sis8300bcm_reg.h @@ -42,7 +42,6 @@ extern "C" { #define SIS8300BCM_MIN_TRIG_PERIOD_REG 0x40D #define SIS8300BCM_MAX_PULSE_WIDTH_REG 0x40E #define SIS8300BCM_ENABLE_CALIBRATION_PULSE_REG 0x40F -#define SIS8300BCM_BEAM_ABOVE_THRESHOLD_REG 0x410 #define SIS8300BCM_STATUS_REG 0x411 #define SIS8300BCM_CLOCK_FREQUENCY_MEAS_REG 0x412 #define SIS8300BCM_TRIGGER_PERIOD_MEAS_REG 0x413 @@ -144,6 +143,7 @@ extern "C" { #define SIS8300BCM_ACCT_X_TRIGGER_SOURCE_OFF 0x02C #define SIS8300BCM_ACCT_X_FLATTOP_RISING_OFF 0x02F #define SIS8300BCM_ACCT_X_FLATTOP_FALLING_OFF 0x030 +#define SIS8300BCM_ACCT_X_BEAM_ABOVE_THRESHOLD_REG 0x034 /* DIFF block registers diff --git a/vendor/ess/lib/sis8300drvbcm.c b/vendor/ess/lib/sis8300drvbcm.c index d6f7a4b95a96d21c2b29842f20183fac52a794a1..25e5e095904adc442d6aaf8b1756e39922fb9340 100644 --- a/vendor/ess/lib/sis8300drvbcm.c +++ b/vendor/ess/lib/sis8300drvbcm.c @@ -2588,21 +2588,32 @@ int sis8300drvbcm_set_enable_calibration_pulse(sis8300drv_usr *sisuser, unsigned return ret; } -int sis8300drvbcm_set_beam_above_threshold(sis8300drv_usr *sisuser, double threshold) +// used to control beam above threshold +int sis8300drvbcm_set_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold) { + unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \ + (SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \ + SIS8300BCM_ACCT_BANK_OFF + \ + SIS8300BCM_ACCT_X_BEAM_ABOVE_THRESHOLD_REG; // register takes a signed value int value = (int)(threshold * 512); - return sis8300drv_reg_write(sisuser, SIS8300BCM_BEAM_ABOVE_THRESHOLD_REG, value); + // printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value); + return sis8300drv_reg_write(sisuser, reg, value); } -int sis8300drvbcm_get_beam_above_threshold(sis8300drv_usr *sisuser, double *threshold) +int sis8300drvbcm_get_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold) { + unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \ + (SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \ + SIS8300BCM_ACCT_BANK_OFF + \ + SIS8300BCM_ACCT_X_BEAM_ABOVE_THRESHOLD_REG; // register holds a signed value int value; - int ret = sis8300drv_reg_read(sisuser, SIS8300BCM_BEAM_ABOVE_THRESHOLD_REG, (unsigned *)&value); + int ret = sis8300drv_reg_read(sisuser, reg, (unsigned *)&value); if (ret) { return ret; } *threshold = (value / 512.0); + // printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value); return ret; } diff --git a/vendor/ess/lib/sis8300drvbcm.h b/vendor/ess/lib/sis8300drvbcm.h index 4bd291ad4c180b0119764fdc12dc88977d19d37f..d48a435517bc358674d497577ffb0c046774caf5 100644 --- a/vendor/ess/lib/sis8300drvbcm.h +++ b/vendor/ess/lib/sis8300drvbcm.h @@ -207,6 +207,8 @@ int sis8300drvbcm_set_channel_errant_window_start(sis8300drv_usr *sisuser, unsig int sis8300drvbcm_get_channel_errant_window_start(sis8300drv_usr *sisuser, unsigned int channel, double *start); int sis8300drvbcm_set_channel_errant_window_end(sis8300drv_usr *sisuser, unsigned int channel, double end); int sis8300drvbcm_get_channel_errant_window_end(sis8300drv_usr *sisuser, unsigned int channel, double *end); +int sis8300drvbcm_set_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold); +int sis8300drvbcm_get_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold); int sis8300drvbcm_set_probe_setup(sis8300drv_usr *sisuser, unsigned int channel, unsigned int source); int sis8300drvbcm_get_probe_setup(sis8300drv_usr *sisuser, unsigned int channel, unsigned int *source); int sis8300drvbcm_set_timestamp(sis8300drv_usr *sisuser, unsigned int sec, unsigned int nsec); @@ -271,8 +273,6 @@ int sis8300drvbcm_set_differential_fast_window_width_inverse(sis8300drv_usr *sis int sis8300drvbcm_get_differential_fast_window_width_inverse(sis8300drv_usr *sisuser, unsigned int channel, double *width); int sis8300drvbcm_set_differential_medium_window_width_inverse(sis8300drv_usr *sisuser, unsigned int channel, double width); int sis8300drvbcm_get_differential_medium_window_width_inverse(sis8300drv_usr *sisuser, unsigned int channel, double *width); -int sis8300drvbcm_set_beam_above_threshold(sis8300drv_usr *sisuser, double threshold); -int sis8300drvbcm_get_beam_above_threshold(sis8300drv_usr *sisuser, double *threshold); int sis8300drvbcm_set_enable_calibration_pulse(sis8300drv_usr *sisuser, unsigned int enable_calibration_pulse); int sis8300drvbcm_get_calibration_sample(sis8300drv_usr *sisuser, unsigned int channel, unsigned int index, double *sample);