Skip to content

Commit

Permalink
DC: Add BorderVals check for sutter hardware
Browse files Browse the repository at this point in the history
- cleaned up function DC_CheckIfDataWaveHasBorderVals
- use also HW_GetVoltageRange for ITC
- use the same approach for NI and Sutter
- return the proper channel index for NI (was always 0 before)
- adapt user message
  • Loading branch information
MichaelHuth committed Aug 15, 2024
1 parent d8f6166 commit 7e70668
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions Packages/MIES/MIES_DataConfigurator.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ static Function DC_PlaceDataInDAQDataWave(device, numActiveChannels, dataAcqOrTP
[ret, row, column] = DC_CheckIfDataWaveHasBorderVals(device, dataAcqOrTP)

if(ret)
printf "Error writing into DataWave in %s mode: The values at [%g, %g] are out of range. Maybe the DA/AD Gain needs adjustment?\r", SelectString(dataAcqOrTP, "DATA_ACQUISITION", "TestPulse"), row, column
printf "Some values in DataWave exceed device limits for %s mode (channel index %g, position %g). Maybe the DA/AD Gain needs adjustment?\r", SelectString(dataAcqOrTP, "DATA_ACQUISITION", "TestPulse"), column, row
ControlWindowToFront()
Abort
endif
Expand Down Expand Up @@ -1909,53 +1909,55 @@ End

static Function [variable result, variable row, variable column] DC_CheckIfDataWaveHasBorderVals(string device, variable dataAcqOrTP)

variable i, minVal, maxVal
variable hardwareType = GetHardwareType(device)
WAVE configWave = GetDAQConfigWave(device)

switch(hardwareType)
case HARDWARE_ITC_DAC:
WAVE/Z ITCDataWave = GetDAQDataWave(device, dataAcqOrTP)
ASSERT(WaveExists(ITCDataWave), "Missing DAQDataWave")
ASSERT(WaveType(ITCDataWave) == IGOR_TYPE_16BIT_INT, "Unexpected wave type: " + num2str(WaveType(ITCDataWave)))

FindValue/UOFV/I=(SIGNED_INT_16BIT_MIN) ITCDataWave
// border vals are the same for all channels for ITC, so just use first
[minVal, maxVal] = HW_GetVoltageRange(hardwareType, configWave[0][%ChannelType], 1)

FindValue/UOFV/I=(minVal) ITCDataWave
if(V_Value != -1)
return [1, V_row, V_col]
endif

FindValue/UOFV/I=(SIGNED_INT_16BIT_MAX) ITCDataWave

FindValue/UOFV/I=(maxVal) ITCDataWave
if(V_Value != -1)
return [1, V_row, V_col]
endif

return [0, NaN, NaN]
break
case HARDWARE_NI_DAC:
WAVE/WAVE NIDataWave = GetDAQDataWave(device, dataAcqOrTP)
ASSERT(IsWaveRefWave(NIDataWave), "Unexpected wave type")
variable channels = numpnts(NIDataWave)
variable i
for(i = 0; i < channels; i += 1)
WAVE NIChannel = NIDataWave[i]
case HARDWARE_NI_DAC: // intended drop through
case HARDWARE_SUTTER_DAC:
WAVE/WAVE dataWave = GetDAQDataWave(device, dataAcqOrTP)
ASSERT(IsWaveRefWave(dataWave), "Unexpected wave type")

for(WAVE channel : dataWave)

FindValue/UOFV/V=(NI_DAC_MIN)/T=1E-6 NIChannel
[minVal, maxVal] = HW_GetVoltageRange(hardwareType, configWave[i][%ChannelType], !IsNaN(configWave[i][%HEADSTAGE]))

FindValue/UOFV/V=(minVal)/T=1E-6 channel
if(V_Value != -1)
return [1, V_row, V_col]
return [1, V_row, i]
endif

FindValue/UOFV/V=(NI_DAC_MAX)/T=1E-6 NIChannel

FindValue/UOFV/V=(maxVal)/T=1E-6 channel
if(V_Value != -1)
return [1, V_row, V_col]
return [1, V_row, i]
endif

return [0, NaN, NaN]
i += 1
endfor
break
case HARDWARE_SUTTER_DAC:
// @todo Determine what to check here
break

return [0, NaN, NaN]
default:
ASSERT(0, "Unsupported hardware type")
endswitch
End

Expand Down

0 comments on commit 7e70668

Please sign in to comment.