From ae2f37c9aa1d78ce574045d989d02c329a4ccc72 Mon Sep 17 00:00:00 2001 From: Michael Huth Date: Sat, 21 Oct 2023 04:32:43 +0200 Subject: [PATCH] SI: Introduce channel type dependent sampling interval - there exists hardware that can have different sampling rates for DAC and ADC Thus, the function for determining the sampling interval must depend on the channel type. - the main utility function changes is DAP_GetSampInt that got a channel type argument added The scope of this change is only to introduce suppor tin the sample interval getter functions, it does not introduce acquisition support for channel dependent sample rates. --- Packages/MIES/MIES_DAEphys.ipf | 20 +++++++++----------- Packages/MIES/MIES_DataConfigurator.ipf | 12 ++++++------ Packages/MIES/MIES_Oscilloscope.ipf | 2 +- Packages/MIES/MIES_SamplingInterval.ipf | 5 ++--- Packages/MIES/MIES_TestPulse.ipf | 4 ++-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Packages/MIES/MIES_DAEphys.ipf b/Packages/MIES/MIES_DAEphys.ipf index 1334d80fa0..ae48f59207 100644 --- a/Packages/MIES/MIES_DAEphys.ipf +++ b/Packages/MIES/MIES_DAEphys.ipf @@ -1608,13 +1608,11 @@ End /// /// @param[in] device device /// @param[in] dataAcqOrTP one of @ref DataAcqModes +/// @param[in] channelType channel type, one of @ref XopChannelConstants /// @param[out] valid [optional] returns if the choosen /// sampling interval is valid or not (DAQ only) /// @see SI_CalculateMinSampInterval() -Function DAP_GetSampInt(device, dataAcqOrTP, [valid]) - string device - variable dataAcqOrTP - variable &valid +Function DAP_GetSampInt(string device, variable dataAcqOrTP, variable channelType, [variable &valid]) variable multiplier, sampInt string fixedFreqkHzStr @@ -1629,16 +1627,16 @@ Function DAP_GetSampInt(device, dataAcqOrTP, [valid]) sampInt = 1 / (str2num(fixedFreqkHzStr) * KILO_TO_ONE) * ONE_TO_MICRO if(!ParamIsDefault(valid)) - valid = sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE) + valid = sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE, channelType) endif return sampInt else multiplier = str2num(DAG_GetTextualValue(device, "Popup_Settings_SampIntMult")) - return SI_CalculateMinSampInterval(device, dataAcqOrTP) * multiplier + return SI_CalculateMinSampInterval(device, dataAcqOrTP, channelType) * multiplier endif elseif(dataAcqOrTP == TEST_PULSE_MODE) - return SI_CalculateMinSampInterval(device, dataAcqOrTP) + return SI_CalculateMinSampInterval(device, dataAcqOrTP, channelType) else ASSERT(0, "unknown mode") endif @@ -1982,7 +1980,7 @@ Function DAP_CheckSettings(device, mode) return 1 endif - DAP_GetSampInt(device, mode, valid=validSampInt) + DAP_GetSampInt(device, mode, XOP_CHANNEL_TYPE_DAC, valid=validSampInt) if(!validSampInt) printf "%s: The selected sampling interval is not possible with your hardware.\r", device ControlWindowToFront() @@ -2891,7 +2889,7 @@ static Function DAP_CheckEpochLengthsOfStimset(string device, string setName) return 1 endif - sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI + sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI numEntries = DimSize(epochLengths, ROWS) for(i = 0; i < numEntries; i += 1) @@ -4459,7 +4457,7 @@ Function DAP_LockDevice(string win) WB_UpdateChangedStimsets(device=deviceLocked) DAP_UnlockCommentNotebook(deviceLocked) DAP_ToggleAcquisitionButton(deviceLocked, DATA_ACQ_BUTTON_TO_DAQ) - SI_CalculateMinSampInterval(deviceLocked, DATA_ACQUISITION_MODE) + SI_CalculateMinSampInterval(deviceLocked, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC) // deliberately not using the GUIState wave headstage = GetSliderPositionIndex(deviceLocked, "slider_DataAcq_ActiveHeadstage") @@ -4881,7 +4879,7 @@ Function DAP_UpdateDAQControls(device, updateFlag) endif if(updateFlag & REASON_HEADSTAGE_CHANGE) - SetValDisplay(device, "ValDisp_DataAcq_SamplingInt", var=DAP_GetSampInt(device, DATA_ACQUISITION_MODE)) + SetValDisplay(device, "ValDisp_DataAcq_SamplingInt", var=DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC)) endif if((updateFlag & REASON_HEADSTAGE_CHANGE) || (updateFlag & REASON_STIMSET_CHANGE)) diff --git a/Packages/MIES/MIES_DataConfigurator.ipf b/Packages/MIES/MIES_DataConfigurator.ipf index 2770d51306..62056be166 100644 --- a/Packages/MIES/MIES_DataConfigurator.ipf +++ b/Packages/MIES/MIES_DataConfigurator.ipf @@ -672,10 +672,6 @@ static Function DC_PlaceDataInDAQConfigWave(device, dataAcqOrTP) AddEntryIntoWaveNoteAsList(DAQConfigWave, CHANNEL_UNIT_KEY, str = unitList, replaceEntry = 1) - DAQConfigWave[][%SamplingInterval] = DAP_GetSampInt(device, dataAcqOrTP) - DAQConfigWave[][%DecimationMode] = 0 - DAQConfigWave[][%Offset] = 0 - if(dataAcqOrTP == DATA_ACQUISITION_MODE) variable hardwareType = GetHardwareType(device) switch(hardwareType) @@ -714,6 +710,10 @@ static Function DC_PlaceDataInDAQConfigWave(device, dataAcqOrTP) break endswitch endif + + DAQConfigWave[][%SamplingInterval] = DAP_GetSampInt(device, dataAcqOrTP, DAQConfigWave[p][%ChannelType]) + DAQConfigWave[][%DecimationMode] = 0 + DAQConfigWave[][%Offset] = 0 End /// @brief Get the decimation factor for the current channel configuration @@ -727,7 +727,7 @@ static Function DC_GetDecimationFactor(device, dataAcqOrTP) string device variable dataAcqOrTP - return DAP_GetSampInt(device, dataAcqOrTP) / (WAVEBUILDER_MIN_SAMPINT * MILLI_TO_MICRO) + return DAP_GetSampInt(device, dataAcqOrTP, XOP_CHANNEL_TYPE_DAC) / (WAVEBUILDER_MIN_SAMPINT * MILLI_TO_MICRO) End /// @brief Returns the longest sweep in a stimulus set across the given channel type @@ -1318,7 +1318,7 @@ static Function [STRUCT DataConfigurationResult s] DC_GetConfiguration(string de // MH: note with NI the decimationFactor can now be < 1, like 0.4 if a single NI ADC channel runs with 500 kHz // whereas the source data generated waves for ITC min sample rate are at 200 kHz s.decimationFactor = DC_GetDecimationFactor(device, dataAcqOrTP) - s.samplingInterval = DAP_GetSampInt(device, dataAcqOrTP) + s.samplingInterval = DAP_GetSampInt(device, dataAcqOrTP, XOP_CHANNEL_TYPE_DAC) WAVE/T allSetNames = DAG_GetChannelTextual(device, CHANNEL_TYPE_DAC, CHANNEL_CONTROL_WAVE) s.hardwareType = GetHardwareType(device) diff --git a/Packages/MIES/MIES_Oscilloscope.ipf b/Packages/MIES/MIES_Oscilloscope.ipf index 8e0e8df1c0..efe4ea8710 100644 --- a/Packages/MIES/MIES_Oscilloscope.ipf +++ b/Packages/MIES/MIES_Oscilloscope.ipf @@ -383,7 +383,7 @@ Function SCOPE_CreateGraph(device, dataAcqOrTP) if(gotDAQChan) Label/W=$graph bottomDAQ "Time DAQ (\\U)" NVAR stopCollectionPoint = $GetStopCollectionPoint(device) - sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI + sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_ADC) * MICRO_TO_MILLI SetAxis/W=$graph bottomDAQ, 0, stopCollectionPoint * sampInt ModifyGraph/W=$graph freePos(bottomDAQ)=-35 endif diff --git a/Packages/MIES/MIES_SamplingInterval.ipf b/Packages/MIES/MIES_SamplingInterval.ipf index 29ffce8ee4..e76f1c4121 100644 --- a/Packages/MIES/MIES_SamplingInterval.ipf +++ b/Packages/MIES/MIES_SamplingInterval.ipf @@ -503,11 +503,10 @@ End /// /// @param device device /// @param dataAcqOrTP one of @ref DataAcqModes, ignores TTL channels for #TEST_PULSE_MODE +/// @param channelType channel type @sa XopChannelConstants /// /// @returns sampling interval in microseconds (1e-6) -Function SI_CalculateMinSampInterval(device, dataAcqOrTP) - string device - variable dataAcqOrTP +Function SI_CalculateMinSampInterval(string device, variable dataAcqOrTP, variable channelType) variable hardwareType = GetHardwareType(device) switch(hardwareType) diff --git a/Packages/MIES/MIES_TestPulse.ipf b/Packages/MIES/MIES_TestPulse.ipf index a279fb8370..68b5d84f59 100644 --- a/Packages/MIES/MIES_TestPulse.ipf +++ b/Packages/MIES/MIES_TestPulse.ipf @@ -1538,8 +1538,8 @@ Function TP_UpdateTPSettingsCalculated(string device) calculated[%baselineFrac] = TPSettings[%baselinePerc][INDEP_HEADSTAGE] * PERCENT_TO_ONE calculated[%pulseLengthMS] = TPSettings[%durationMS][INDEP_HEADSTAGE] // here for completeness - calculated[%pulseLengthPointsTP] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, TEST_PULSE_MODE) * MICRO_TO_MILLI)) - calculated[%pulseLengthPointsDAQ] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI)) + calculated[%pulseLengthPointsTP] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, TEST_PULSE_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI)) + calculated[%pulseLengthPointsDAQ] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI)) calculated[%totalLengthMS] = TP_CalculateTestPulseLength(calculated[%pulseLengthMS], calculated[%baselineFrac]) calculated[%totalLengthPointsTP] = trunc(TP_CalculateTestPulseLength(calculated[%pulseLengthPointsTP], calculated[%baselineFrac]))