diff --git a/RELEASE.md b/RELEASE.md index 9108859c..9577c62f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,13 +4,22 @@ The versions of EPICS base, asyn, ADCore, and other synApps modules used for eac the configure/RELEASE file in each release of quadEM. ## Release 9-8 (November XXX, 2026) -- Improved support for the FX4 quad electrometer. +- Improved support for the FX4. - Add support for high-speed gating and triggering up to 5 kHz. This requires updated firmware, version 26.10.151957 or higher. - Added diagnostic records to read the FX4 CPU %, trigger level, and trigger counter. - Added records to configure the trigger input settings on the FX4 at iocInit. +- Improved External Trigger mode support for the TetrAMM. + Previously it required that the trigger period be longer than the AveragingTime. + If a trigger pulse arrived before the averaging time was complete it was ignored. + This required clients to know what the minimum trigger period would be and to + set the AveragingTime to be at least slightly less than this. + Now if the next trigger arrives before the averaging time is complete it immediately + computes the average of the samples so far and starts the next acquisition. + This means that external trigger mode is the same as external bulb mode if the trigger + period is less than the averaging time. - Fixed error in the fanout records for the PREC fields. - Increased the PREC field for the averaging times from 2 to 4. - Tweaked the device-dependent sub-screens to display better on Phoebus. diff --git a/docs/source/databases.rst b/docs/source/databases.rst index 442a2d5b..64b4a321 100644 --- a/docs/source/databases.rst +++ b/docs/source/databases.rst @@ -446,7 +446,7 @@ minimum, maximum, and other statistics, including a histogram of array values. - Provides the number of values that will be accumulated in the ring buffer before they are read out into NDArray objects and any registered plugins are called. NumAverage_RBV is computed as (int)((AveragingTime / SampleTime_RBV) + 0.5). - , On the TetrAMM when TriggerMode=External Bulb and on the AH501BE when TriggerMode=External + On the FX4 and TetrAMM when TriggerMode=External Bulb and on the AH501BE when TriggerMode=External Gate the AveragingTime is ignored and NumAverage_RBV will be 0. The averaging is done on all samples collected when the external gate signal is asserted. * - QE_NUM_AVERAGED @@ -459,8 +459,8 @@ minimum, maximum, and other statistics, including a histogram of array values. before they were read out into NDArray objects and any registered plugins were called. If AveragingTime>0 then NumAveraged_RBV will be the same as NumAverage_RBV. However, if AveragingTime=0. then NumAverage_RBV=0 and NumAveraged_RBV gives the actual number - of values read from the ring buffer when the ReadData record was processed. This - is also true on the TetrAMM when TriggerMode=ExternalBulb. + of values read from the ring buffer when the ReadData record was processed. + This is also true on the FX4 and TetrAMM in ExternalTrigger or ExternalBulb modes. * - N.A. - $(P)$(R)FastAveragingTime, $(P)$(R)FastAveragingTime_RBV - ao, ai @@ -488,8 +488,9 @@ minimum, maximum, and other statistics, including a histogram of array values. - All - The number of acquisitions to acquire when AcquireMode=Multiple. An acquisition is complete when the callbacks are called. This normally occurs when the AveragingTime - has elapsed. However when TriggerMode=Ext. Bulb then the callbacks are called and - an acquisition is complete on the trailing edge of each external gate pulse. + has elapsed. However when TriggerMode=Ext. Bulb (and sometimes Ext. Trig) + then the callbacks are called and an acquisition is complete on the trailing edge of each + external trigger pulse. * - QE_NUM_ACQUIRED - $(P)$(R)NumAcquired - longin @@ -534,10 +535,11 @@ minimum, maximum, and other statistics, including a histogram of array values. - 0: "Free Run" (all models). Ignores any external gate or trigger signal. - 1: "Software" (possible future choice for TetrAMM) This will trigger a single acquisition each time a software trigger command is sent. - - 2: "Ext. Trigger" (TetrAMM, FX4, AH401B, PCR4) This is an edge-sensitive trigger. On the - TetrAMM this will collect samples for the AveragingTime and then wait for the next - trigger. On the FX4 if the next trigger arrives before the AveragingTime is complete - then it immediately averages the existing samples and begins a new average. + - 2: "Ext. Trigger" (TetrAMM, FX4, AH401B, PCR4) This is an edge-sensitive trigger. + On the leading edge of each trigger pulse it will collect samples for the AveragingTime + and then wait for the next trigger. However, on the FX and TetrAMM if the next trigger + arrives before the AveragingTime is complete then it immediately averages the existing + samples and begins a new average. - 3: "Ext. Bulb" (TetrAMM, FX4, AH501D) This is a level-sensitive trigger. It acquires data while the external gate signal is asserted. On the trailing edge of the gate signal the callbacks will be called. In this mode the AveragingTime is ignored and @@ -784,6 +786,8 @@ minimum, maximum, and other statistics, including a histogram of array values. The following is the medm screen to control the quadEM with the records in quadEM.template. +This is the version for the TetrAMM. The versions for the other models differ only in the device-specific +widgets in the left center of the screen. .. figure:: quadEM.png :align: center diff --git a/docs/source/quadEM.png b/docs/source/quadEM.png index 7d602a14..5d240ade 100755 Binary files a/docs/source/quadEM.png and b/docs/source/quadEM.png differ diff --git a/docs/source/sscan_fx4_triggered.png b/docs/source/sscan_fx4_triggered.png new file mode 100755 index 00000000..b9b2daab Binary files /dev/null and b/docs/source/sscan_fx4_triggered.png differ diff --git a/docs/source/sscan_tetramm_base.png b/docs/source/sscan_tetramm_base.png index ebb80275..6e391312 100755 Binary files a/docs/source/sscan_tetramm_base.png and b/docs/source/sscan_tetramm_base.png differ diff --git a/docs/source/sscan_tetramm_free_run.png b/docs/source/sscan_tetramm_free_run.png deleted file mode 100755 index 746cd089..00000000 Binary files a/docs/source/sscan_tetramm_free_run.png and /dev/null differ diff --git a/docs/source/sscan_tetramm_free_run_plot.png b/docs/source/sscan_tetramm_free_run_plot.png deleted file mode 100755 index 0147aba3..00000000 Binary files a/docs/source/sscan_tetramm_free_run_plot.png and /dev/null differ diff --git a/docs/source/sscan_tetramm_triggered.png b/docs/source/sscan_tetramm_triggered.png index 27ec20e4..c4eb6f40 100755 Binary files a/docs/source/sscan_tetramm_triggered.png and b/docs/source/sscan_tetramm_triggered.png differ diff --git a/docs/source/sscan_tetramm_triggered_plot.png b/docs/source/sscan_tetramm_triggered_plot.png deleted file mode 100755 index 926ff506..00000000 Binary files a/docs/source/sscan_tetramm_triggered_plot.png and /dev/null differ diff --git a/docs/source/tetramm_fly_bulb.png b/docs/source/tetramm_fly_bulb.png deleted file mode 100755 index 86d23f3c..00000000 Binary files a/docs/source/tetramm_fly_bulb.png and /dev/null differ diff --git a/docs/source/tetramm_fly_bulb_statistics_mean.png b/docs/source/tetramm_fly_bulb_statistics_mean.png deleted file mode 100755 index c6747fd5..00000000 Binary files a/docs/source/tetramm_fly_bulb_statistics_mean.png and /dev/null differ diff --git a/docs/source/tetramm_fly_bulb_time_series_plot.png b/docs/source/tetramm_fly_bulb_time_series_plot.png deleted file mode 100755 index 7ba5044e..00000000 Binary files a/docs/source/tetramm_fly_bulb_time_series_plot.png and /dev/null differ diff --git a/docs/source/tetramm_fly_triggered.png b/docs/source/tetramm_fly_triggered.png index d5db98f9..117e0e56 100755 Binary files a/docs/source/tetramm_fly_triggered.png and b/docs/source/tetramm_fly_triggered.png differ diff --git a/docs/source/tetramm_fly_triggered_common_plugins.png b/docs/source/tetramm_fly_triggered_common_plugins.png new file mode 100755 index 00000000..2bb55a6a Binary files /dev/null and b/docs/source/tetramm_fly_triggered_common_plugins.png differ diff --git a/docs/source/tetramm_fly_triggered_current1_mean_plot_after.png b/docs/source/tetramm_fly_triggered_current1_mean_plot_after.png new file mode 100755 index 00000000..ef5ca11e Binary files /dev/null and b/docs/source/tetramm_fly_triggered_current1_mean_plot_after.png differ diff --git a/docs/source/tetramm_fly_triggered_current1_mean_plot_before.png b/docs/source/tetramm_fly_triggered_current1_mean_plot_before.png new file mode 100755 index 00000000..bb54afa4 Binary files /dev/null and b/docs/source/tetramm_fly_triggered_current1_mean_plot_before.png differ diff --git a/docs/source/tetramm_fly_triggered_current1_stats.png b/docs/source/tetramm_fly_triggered_current1_stats.png new file mode 100755 index 00000000..9dce6a11 Binary files /dev/null and b/docs/source/tetramm_fly_triggered_current1_stats.png differ diff --git a/docs/source/tetramm_fly_triggered_time_series.png b/docs/source/tetramm_fly_triggered_time_series.png deleted file mode 100755 index 35cd9984..00000000 Binary files a/docs/source/tetramm_fly_triggered_time_series.png and /dev/null differ diff --git a/docs/source/tetramm_fly_triggered_time_series_plot.png b/docs/source/tetramm_fly_triggered_time_series_plot.png deleted file mode 100755 index a838551c..00000000 Binary files a/docs/source/tetramm_fly_triggered_time_series_plot.png and /dev/null differ diff --git a/docs/source/tetramm_modes.rst b/docs/source/tetramm_modes.rst index b59414c4..b08f1aef 100644 --- a/docs/source/tetramm_modes.rst +++ b/docs/source/tetramm_modes.rst @@ -1,19 +1,25 @@ -TetrAMM and FX4 Acquisition Modes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The TetrAMM and FX4 can be used in 8 different acquisition modes, depending on the values -of the TriggerMode and AcquireMode records. The following table describes these -modes. Note that AcquireMode=Single is completely equivalent to AcquireMode=Multiple -and NumAcquire=1, so the table does not list AcquireMode=Single. +TetrAMM and FX4 Trigger Modes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The TetrAMM and FX4 can be used in 4 different acquisition modes. +The following table describes these modes. -Note that the TetrAMM supports triggering and gating modes in the firmware, using the -commands shown in the table below. The FX4 does not support triggering or gating for -ADC acquisition. However, it does support streaming of a high-speed position counter +For each trigger mode AcquireMode can be Continuous, Multiple, or Single. +When AcquireMode=Multiple acquisition stops after NumAcquire acquisition are complete. +Note that AcquireMode=Single is completely equivalent to AcquireMode=Multiple +and NumAcquire=1. + +Note that the TetrAMM supports triggering and gating modes in the firmware. +The nominal maximum trigger rate is 2000 Hz. However, with ValuesPerRead=10 +I have found that it reliably triggers at 1500 Hz and is not reliable at 1800 Hz. + +The FX4 does not support triggering or gating for ADC acquisition. +However, it does support streaming of a high-speed position counter at the same rate that it streams the ADC data. The position counter is configured to increment on both the rising and falling edge of the first digital input (D1). Each ADC measurement and the position counter has a precise timestamp. The EPICS support streams the position counter, and does the triggering and gating operations in the driver software, using the counter -transitions and the timestamps. This has been tested to work with 2000 point acquisition +transitions and the timestamps. This has been tested to work with 10000 point acquisition with 5 kHz trigger signal and ValuesPerRead=10. .. cssclass:: table-bordered table-striped table-hover @@ -22,60 +28,23 @@ with 5 kHz trigger signal and ValuesPerRead=10. :widths: auto * - TriggerMode - - AcquireMode - Description - - TetrAMM commands * - Free Run - - Continuous - Values are acquired continuously and are averaged each time the AveragingTime is reached. - - NRSAMP=ValuesPerRead, NAQ=0, TRG:OFF - * - Free Run - - Multiple - - Data is acquired for the AveragingTime. This is repeated NumAcquire times and then - acquisition stops. The plugins will be called NumAcquire times, each time with NumAverage - samples. - - NRSAMP=ValuesPerRead, NAQ=0, TRG:OFF * - Ext. Trig. - - Continuous - - A fixed number of samples is acquired starting on each leading edge of the external trigger input. - For the TetrAMM the AveragingTime must be set to a value less than the time between trigger pulses. - If the next trigger arrives before the averaging time is complete then that trigger will be ignorred. - For the FX4 the time between triggers can be less than the averaging time. + - NumAcquire samples are acquired starting on each leading edge of the external trigger input. + NumAcquire is determined by the AveragingTime and ValuesPerRead. If the next trigger arrives before the averaging time is complete then it will immediately average the values received so far, and start accumulating the next time point. - It thus effectively runs in Ext. Bulb mode if the triggers are faster than the averaging time. - ValuesPerRead must be set to a value less than AveragingTime/1e5. - - NRSAMP=ValuesPerRead, NAQ=AveragingTime/1e5/ValuesPerRead, TRG:ON - * - Ext. Trig. - - Multiple - - This is the same as Ext. Trig. above, except that acquisition stops once NumAcquire - triggers have been received. - - NRSAMP=ValuesPerRead, NAQ=AveragingTime*1e5/ValuesPerRead, TRG:ON + This means that Ext. Trig functions the same as Ext. Bulb mode if the trigger period is less + than the averaging time. * - Ext. Bulb - - Continuous - Samples are acquired while the external trigger input is asserted. On each trailing - edge of the external trigger signal the plugins are called. ValuesPerRead must be - set to a value less than (external trigger asserted time * 1e5). AveragingTime is + edge of the external trigger signal the plugins are called. AveragingTime is ignored in this mode. - - NRSAMP=ValuesPerRead, NAQ=0, TRG:ON - * - Ext. Bulb - - Multiple - - This is the same as Ext. Bulb. above, except that acquisition stops once NumAcquire - triggers have been received. - - NRSAMP=ValuesPerRead, NAQ=0, TRG:ON * - Ext. Gate - - Continuous - - Samples are acquired while the external trigger input is asserted. When NumAverage + - Samples are acquired while the external trigger input is asserted. When NumAverage samples have been acquired the plugins are called. The actual averaging time between calling the plugins will be longer than AverageTime, and is controlled by the duty cycle of the external gate signal. The trailing edge of the gate pulse is ignored - in this mode. ValuesPerRead must be set to a value less than (external trigger asserted - time * 1e5). - - NRSAMP=ValuesPerRead, NAQ=0, TRG:ON - * - Ext. Gate - - Multiple - - The is the same as Ext. Gate above except that when the plugins have been called NumAcquire - times acquisition is stopped. Note that the actual number of gate pulses received - will be > NumAcquire, and is also controlled by the duty cycle of the external - gate signal. - - NRSAMP=ValuesPerRead, NAQ=0, TRG:ON + in this mode. diff --git a/docs/source/tetramm_scanning.rst b/docs/source/tetramm_scanning.rst index b57d6082..d744dc14 100644 --- a/docs/source/tetramm_scanning.rst +++ b/docs/source/tetramm_scanning.rst @@ -9,34 +9,6 @@ Each scan described below used most of these settings, with the changes in the s .. figure:: sscan_tetramm_base.png :align: center -Step scan with quadEM in free-run mode -....................................... -This scan type uses a step-scan for the positioner and runs the quadEM in free running mode. -The quadEM averaging time is set a small amount less than the time it takes the motors to move -each step. This mode is faster than stopping and starting the quadEM at each point. The error -due to the quadEM not being strictly synchronized to the motor position are likely to be acceptable -in many cases. - -The following is screen shot of the sscan record moving a single motor and reading the 4 currents from the quadEM. -There is no detector trigger. - -.. figure:: sscan_tetramm_free_run.png - :align: center - -The scan is 201 points and took 11.7 seconds. The time per point is thus 0.058 ms. - -The quadEM was configured as follows: - -- AcquireMode=Continuous -- ValuesPerRead=5 -- AveragingTime=.05 s. This is a little less than the time per point in the scan, so there will be a new reading at each point. -- The sscan record detectors are Current1:MeanValue_RBV, Current2:MeanValue_RBV, etc. - -This is a plot of Current1 after the scan. - -.. figure:: sscan_tetramm_free_run_plot.png - :align: center - | Step scan with quadEM in single acquire mode @@ -45,30 +17,36 @@ This scan type uses a step-scan for the positioner and runs the quadEM in single This guarantees that the quadEM was only counting when the motor was at the target position for each step. -The following is screen shot of the sscan record moving a single motor and reading the 4 currents from the quadEM. +For both of the following scans the quadEM was configured as follows: + +- AcquireMode=Single +- ValuesPerRead=10 +- AveragingTime=.01 s + +The following is screen shot of the sscan record reading the first current from the TetrAMM. +There is no positioner for this test, which is designed to measure the step-scan overhead. +The first positioner readback is TIME, so the elapsed time for the scan can be measured. +In practice a motor or other positioner would be used. The detector trigger is the quadEM Acquire PV. .. figure:: sscan_tetramm_triggered.png :align: center -The scan is 201 points and took 31.3 seconds. -This scan took 20 seconds longer than the scan where the quadEM AcquireMode is Continuous. -10 seconds of this are because the scan needs to wait for the quadEM averaging for 50 ms at each point. -The additional 10 seconds is due to overhead with restarting the quadEM at each point. - -The quadEM was configured as follows: +| -- AcquireMode=Single -- ValuesPerRead=50 -- AveragingTime=.05 s +The scan is 200 points and took 12.0 seconds. The actual collection time was 200*0.01 = 2 seconds. +The overhard was thus 10.0 seconds, or 50 ms per point. -This is a plot of Current1 after the scan. +The following is screen shot of the sscan record for the same scan using the FX4. -.. figure:: sscan_tetramm_triggered_plot.png +.. figure:: sscan_fx4_triggered.png :align: center | +The scan is 200 points and took 7.0 seconds. The actual collection time was 200*0.01 = 2 seconds. +The overhard was thus 5.0 seconds, or 25 ms per point. This is half the overhead of the TetrAMM. + Fly scan with quadEM in free-run mode ............................................. This scan type uses a fly-scan for the positioner and runs the quadEM in free-run continuous mode. @@ -108,106 +86,54 @@ This is a plot of Current1 after the scan. | -Triggered scan using quadEM time series plugin -............................................... -This scan type uses triggers from the positioner to collect the quadEM data in the NDPluginTimeSeries plugin. -This guarantees that the positioner and detector data are perfectly synchronized. +Fly scan in external triggered mode with the statistics plugin +............................................................... +This scan type uses triggers from the positioner to collect the quadEM data in the time series of the +NDPluginStats plugin. This guarantees that the positioner and detector data are perfectly synchronized. For this test the triggers came from a Measurement Computing USB-CTR08 pulse generator, but they could have been coming from position based triggers from a motor controller. -The scan is configured by first determining the period at which trigger pulses will be arriving. -For a motor scan this will be calculated from the distance interval per trigger and the motor velocity. -For this test it was set by the following: - -- The pulse generator is configured to output 201 pulses at 100 Hz, i.e. .01 second period. +The pulse generator is configured to output 2000 pulses at 100 Hz, i.e. .01 second period. However, this will work +even if the trigger period is changing, e.g. during the acceleration phase of a motor. +In this example the AveragingTime was set to 1.0 second, much longer than the 0.01 second pulse period. The quadEM was configured as follows: - AcquireMode=Multiple -- NumAcquire=201 +- NumAcquire=2000 - TriggerMode=Ext. Trig. -- ValuesPerRead=5 -- AveragingTime=.0099 s, 1% (0.1 ms) less than the trigger period. +- ValuesPerRead=10 +- AveragingTime=1 second. Because this is longer than the pulse period it is irrelevant. This is the configuration of the quadEM in this mode. .. figure:: tetramm_fly_triggered.png :align: center -When TriggerMode=Ext. Trig. the driver tells the quadEM to collect the number of samples determined by the -AveragingTime (i.e. NumAverage_RBV) on receipt of each trigger pulse. NumAverage_RBV is 198 in the example above. -The AveragingTime must be slightly less than the trigger pulse period to allow for slight clock frequency differences -between the trigger source and the quadEM. In this case the AveragingTime is 1% (0.1 ms) less than the pulse period. -The only consequence of this is that there is 1% during each acquire period (0.1 ms) when the quadEM is not collecting data. - -The quadEM TimeSeries plugin is configured as follows: - -- AveragingTime=0.0099 s -- NumPoints=201 +| -This is the configuration of the TimeSeries plugin: +Open in Plugins/QE common plugins. This is this screen: -.. figure:: tetramm_fly_triggered_time_series.png +.. figure:: tetramm_fly_triggered_common_plugins.png :align: center -The AveragingTime of the time series plugin must be the same as that for the quadEM. This guarantees that each -external trigger will move to the next point in the time series. - -The following steps are used to perform as scan in this mode: - -- Set the TimeSeries TSAcquire (labeled Erase/Start) PV to 1 -- Set the quadEM Acquire PV to 1 -- Start the trigger source. In this test that is the pulse generator, but it would normally be the motor - generating the trigger pulses. -- Wait for the motion to complete and then read the time series waveform records, e.g. TS:Current1, etc. +| -This is a plot of Current1 after the scan. The retrace to 0 on the last point is a bug in medm. +Press More for Current 1, which opens NDStats.adl for Current 1. +This is this screen: -.. figure:: tetramm_fly_triggered_time_series_plot.png +.. figure:: tetramm_fly_triggered_current1_stats.png :align: center -Note while the scan actually took 2.01 seconds (201 points at 100 Hz) the last point horizontal scale -of this plot is 1.98 seconds. -This is because the time between triggers is 1% more than the averaging time, but the -plugin has no way to know what the actual time between trigger pulses is. - -Triggered scan using quadEM in bulb mode with the statistics plugin -.................................................................... -The time series plugin used in the previous example above can only be used when each trigger generates the same -number of ADC samples. If the time between triggers is not know or is variable then bulb mode. -This will average all samples between the leading and trailing edge of the trigger pulse. -When using bulb mode or Ext. Trigger mode on the FX4 with triggers faster than the averaging time, -the time series feature of the statistics plugin must be used. It computes the statistics at the end -of each trigger period, regardless of the number of samples collected. - -For this test the triggers came from a Measurement Computing USB-CTR08 pulse generator, but they could -have been coming from position based triggers from a motor controller. - - -The pulse generator is configured to output 201 pulses at 100 Hz, i.e. .01 second period. However, this will work -even if the trigger period is changing, e.g. during the acceleration phase of a motor. - -The quadEM was configured as follows: - -- AcquireMode=Multiple -- NumAcquire=201 -- TriggerMode=Ext. Trig. -- ValuesPerRead=5 -- AveragingTime is irrelevant and is not used. It is set to 1 second to illustrate this. - -This is the configuration of the quadEM in this mode. - -.. figure:: tetramm_fly_bulb.png - :align: center +| -Open in Plugins/QE common plugins. Press More for Current 1, which opens NDStats.adl for Current 1. -Open Statistics/Time series plots/Mean. That is this screen: +Open Statistics/Time series plots/Mean. That is this screen before the scan: -.. figure:: tetramm_fly_bulb_statistics_mean.png +.. figure:: tetramm_fly_triggered_current1_mean_plot_before.png :align: center -The number of points is set to 201. +The number of points is set to 2000. The following steps are used to perform as scan in this mode: @@ -219,9 +145,11 @@ The following steps are used to perform as scan in this mode: This is a plot of Current1:TSMeanValue after the scan. The retrace to 0 on the last point is a bug in medm. -.. figure:: tetramm_fly_bulb_time_series_plot.png +.. figure:: tetramm_fly_triggered_current1_mean_plot_after.png :align: center -Note that this scan actually took 2 seconds but the horizontal scale in this plot is incorrect (20 seconds) +| + +Note that this scan actually took 20 seconds but the horizontal scale in this plot is incorrect (200 seconds) because it has no way of knowing the actual time between triggers. Each point in the plot is the mean of all ADC values between the leading and trailing edge of the trigger pulse. diff --git a/iocBoot/iocFX4/FX4.cmd b/iocBoot/iocFX4/FX4.cmd index 1da95281..1c4f866d 100644 --- a/iocBoot/iocFX4/FX4.cmd +++ b/iocBoot/iocFX4/FX4.cmd @@ -3,7 +3,7 @@ epicsEnvSet("RECORD", "FX4:") epicsEnvSet("PORT", "FX4") epicsEnvSet("TEMPLATE", "FX4") epicsEnvSet("QSIZE", "20") -epicsEnvSet("RING_SIZE", "10000") +epicsEnvSet("RING_SIZE", "50000") epicsEnvSet("TSPOINTS", "20000") epicsEnvSet("IP", "10.54.161.11") epicsEnvSet("EPICS_CA_ADDR_LIST", "$(EPICS_CA_ADDR_LIST) $(IP)") diff --git a/iocBoot/iocTetrAMM/TetrAMM.cmd b/iocBoot/iocTetrAMM/TetrAMM.cmd index 9b87b9a6..c82b9163 100644 --- a/iocBoot/iocTetrAMM/TetrAMM.cmd +++ b/iocBoot/iocTetrAMM/TetrAMM.cmd @@ -3,8 +3,8 @@ epicsEnvSet("RECORD", "TetrAMM:") epicsEnvSet("PORT", "TetrAMM") epicsEnvSet("TEMPLATE", "TetrAMM") epicsEnvSet("QSIZE", "20") -epicsEnvSet("RING_SIZE", "10000") -epicsEnvSet("TSPOINTS", "2048") +epicsEnvSet("RING_SIZE", "50000") +epicsEnvSet("TSPOINTS", "20000") epicsEnvSet("IP", "10.54.160.186:10001") #drvAsynIPPortConfigure("portName","hostInfo",priority,noAutoConnect, @@ -14,10 +14,10 @@ asynOctetSetInputEos("IP_$(PORT)", 0, "\r\n") asynOctetSetOutputEos("IP_$(PORT)", 0, "\r") # Set both TRACE_IO_ESCAPE (for ASCII command/response) and TRACE_IO_HEX (for binary data) -asynSetTraceIOMask("IP_$(PORT)", 0, 6) +#asynSetTraceIOMask("IP_$(PORT)", 0, 6) #asynSetTraceFile("IP_$(PORT)", 0, "AHxxx.out") #asynSetTraceMask("IP_$(PORT)", 0, 9) -asynSetTraceIOTruncateSize("IP_$(PORT)", 0, 4000) +#asynSetTraceIOTruncateSize("IP_$(PORT)", 0, 4000) # Load asynRecord record dbLoadRecords("$(ASYN)/db/asynRecord.db", "P=$(PREFIX), R=asyn1,PORT=IP_$(PORT),ADDR=0,OMAX=256,IMAX=256") diff --git a/quadEMApp/caenSrc/drvTetrAMM.cpp b/quadEMApp/caenSrc/drvTetrAMM.cpp index 25c59062..92643d25 100644 --- a/quadEMApp/caenSrc/drvTetrAMM.cpp +++ b/quadEMApp/caenSrc/drvTetrAMM.cpp @@ -188,6 +188,7 @@ void drvTetrAMM::readThread(void) int nextExpectedEdge=0; int numTrigStarts=0; int numTrigEnds=0; + int numAverage; int i; asynUser *pasynUser; asynInterface *pasynInterface; @@ -235,6 +236,7 @@ void drvTetrAMM::readThread(void) nextExpectedEdge = 0; getIntegerParam(P_TriggerMode, &triggerMode); getIntegerParam(P_ReadFormat, &readFormat); + getIntegerParam(P_NumAverage, &numAverage); readingActive_ = 1; } if (readFormat == QEReadFormatBinary) { @@ -275,11 +277,18 @@ void drvTetrAMM::readThread(void) case 0xfff40002ffffffffull: // This is a signalling Nan at the end of normal data for (i=numChannels_; i<4; i++) f64Data[i] = 0.0; + if (triggerMode == QETriggerModeExtTrigger) { + numTriggerSamplesReceived_++; + if (numTriggerSamplesReceived_ > numAverage) continue; + } computePositions(f64Data); break; case 0xfff40000ffffffffull: // This is a signalling Nan on the rising edge of a trigger numTrigStarts++; + if (triggerMode == QETriggerModeExtTrigger) numTriggerSamplesReceived_ = 0; + asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s rising edge, numTrigStarts=%d\n", + driverName, functionName, numTrigStarts); if (nextExpectedEdge != 0) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s Extra trigger start, numTrigStarts=%d, numTrigsEnds=%d\n", @@ -290,7 +299,9 @@ void drvTetrAMM::readThread(void) case 0xfff40001ffffffffull: // This is a signalling Nan on the falling edge of a trigger numTrigEnds++; - if (triggerMode == QETriggerModeExtBulb) { + asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s falling edge, numTrigEnds=%d\n", + driverName, functionName, numTrigEnds); + if ((triggerMode == QETriggerModeExtTrigger) || (triggerMode == QETriggerModeExtBulb)) { triggerCallbacks(); } if (nextExpectedEdge != 1) { @@ -521,6 +532,7 @@ asynStatus drvTetrAMM::setAcquire(epicsInt32 value) // Call the base class function because it handles some common tasks. drvQuadEM::setAcquire(1); + numTriggerSamplesReceived_ = 0; // For now we call setAcquireParams(). This seems to be necessary when sending NAQ, and only takes 20 ms. // It also has the effect of flusing any stale input setAcquireParams(); @@ -629,9 +641,7 @@ asynStatus drvTetrAMM::setAcquireParams() // Send the NAQ command naq = 0; - if ((triggerMode == QETriggerModeExtTrigger) || - ((triggerMode == QETriggerModeFreeRun) && - (acquireMode == QEAcquireModeSingle))) { + if ((triggerMode == QETriggerModeFreeRun) && (acquireMode == QEAcquireModeSingle)) { naq = numAverage; } sprintf(outString_, "NAQ:%d", naq); diff --git a/quadEMApp/caenSrc/drvTetrAMM.h b/quadEMApp/caenSrc/drvTetrAMM.h index 8a245aaa..266928ed 100644 --- a/quadEMApp/caenSrc/drvTetrAMM.h +++ b/quadEMApp/caenSrc/drvTetrAMM.h @@ -50,6 +50,7 @@ class drvTetrAMM : public drvQuadEM { asynUser *pasynUserMeter_; epicsEventId acquireStartEvent_; int readingActive_; + int numTriggerSamplesReceived_; int numResync_; char *QEPortName_; char firmwareVersion_[MAX_COMMAND_LEN];