06-15-2015 09:17 PM
I have a typical task creation, setup, read and stop process in VB6 code. The acquisition part is shown below. This code fails to compile when I include the Timing Mode call (bold). Sub or Function not found. If I remove the bolded line the code runs correctly and acquires data. However the default mode is HighResolution and I want HighSpeed.
Note that all Timing Mode Constants and Functions appear in NIDAQmx.h, and I can in fact get this device to work in HighResolution or HighSpeed mode using python. However I'd rather not have to rewrite the entire VB6 application because of a single function call if I can avoid it.
So why is this function not found? btw - I'm using DAQmx 14.2 on Windows XP 32bit
' create task
DAQmxErrChk DAQmxCreateTask("", taskHandle)
'Add an analog input thermocouple channel to the task.
DAQmxErrChk DAQmxCreateAIThrmcplChan(taskHandle, "cDAQ-9214/ai:0", "", minTemp, maxTemp, DAQmx_Val_TemperatureUnits1_DegC, _
DAQmx_Val_ThermocoupleType1_J_Type_TC, DAQmx_Val_CJCSource1_BuiltIn, 25, "")
' set timing mode
DAQmxErrChk DAQmxSetAIADCTimingMode(taskHandle, Ksystem.txtAIDev.Text, DAQmx_Val_HighSpeed)
'Configure task for finite sample acquisition and read in data
DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", frequency, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_FiniteSamps, numSampsPerChannel)
' Set up required memory space
DAQmxErrChk DAQmxGetTaskNumChans(taskHandle, numChannels)
arraySizeInSamps = numSampsPerChannel * numChannels
ReDim data(arraySizeInSamps)
' start the task and read data
DAQmxErrChk DAQmxStartTask(taskHandle)
DAQmxErrChk DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, timeout, fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
'Call the StopTask module to stop the DAQmx task.
DAQmxErrChk DAQmxStopTask(taskHandle)
DAQmxErrChk DAQmxClearTask(taskHandle)
Solved! Go to Solution.
06-16-2015 01:22 AM
I managed to solve this and put the solution here in case its of value to anyone.
I ended up declaring the function and calling from the NIDAQmx dll (nicaui.dll) directly as follows. Worked a treat with either timing mode.
Declaration at top of form code
' original function header and enumerations can be found in in NIDAQmx.h
'int32 __CFUNC DAQmxSetAIADCTimingMode(TaskHandle taskHandle, const char channel[], int32 data);
'
Private Declare Function DAQmxSetAIADCTimingMode Lib "nicaiu.DLL" (ByVal taskHandle As Long, ByVal channel As String, ByVal Val As Long) As Long
Const DAQmx_Val_HighSpeed As Long = 14712
Const DAQmx_Val_HighResolution As Long = 10195
Function Call
' see DAQmxSetAIADCTimingMode function declaration at top
DAQmxErrChk DAQmxSetAIADCTimingMode(taskHandle, myChannel, DAQmx_Val_HighSpeed)