From c3171078f2feaa281a28422a04af83091728d62d Mon Sep 17 00:00:00 2001 From: Mark Rivers Date: Wed, 6 Nov 2024 16:40:21 -0600 Subject: [PATCH] Changed the WaveGen to save the current analog output values at the beginning of the scan, and to restore them at the end. This prevents the issue of the ao record values not matching the actual output voltage at the end of the scan. --- measCompApp/src/drvMultiFunction.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/measCompApp/src/drvMultiFunction.cpp b/measCompApp/src/drvMultiFunction.cpp index 88c675f..78d896a 100755 --- a/measCompApp/src/drvMultiFunction.cpp +++ b/measCompApp/src/drvMultiFunction.cpp @@ -774,6 +774,7 @@ class MultiFunction : public asynPortDriver { int numWaveGenChans_; int numWaveDigChans_; int pulseGenRunning_[MAX_PULSE_GEN]; + int waveGenSavedOutput[MAX_ANALOG_OUT]; int waveGenRunning_; int waveDigRunning_; int startPulseGenerator(int timerNum); @@ -1585,6 +1586,8 @@ int MultiFunction::startWaveGen() firstChan = i; firstType = waveType; } + // Save the current value of the analog output so it can be restored at the end of the scan + getIntegerParam(i, analogOutValue_, &waveGenSavedOutput[i]); // Cannot mix user-defined and internal waveform types, because internal modifies dwell time // based on frequency if (((firstType == waveTypeUser) && (waveType != waveTypeUser)) || @@ -1674,7 +1677,12 @@ int MultiFunction::startWaveGen() int MultiFunction::stopWaveGen() { int err; + int range; + int enable; + int status=0; waveGenRunning_ = 0; + static const char *functionName = "stopWaveGen"; + setIntegerParam(waveGenRun_, 0); ULMutex.lock(); #ifdef _WIN32 @@ -1682,6 +1690,21 @@ int MultiFunction::stopWaveGen() #else err = ulAOutScanStop(daqDeviceHandle_); #endif + + // Set the analog outputs back to their value before the scan + for (int i=0; i