I am using the RIO-9215 with DAQmx and VB6. I am attempting to digitize a second of data and would like to use DAQmxRegisterDoneEvent to catch the end of the digitizing process. I am using the code below. The code works with no errors when the comment is removed from the call to my DAQDone sub which contains . But when it is in place the event sub never fires and DAQDone is never called. All of this code is in a single .BAS module.
Anyone have an idea what I am doing wrong?
Sub DAQStart()
Dim n As Integer
Dim NumChannels As Long
Dim ChanNumberString As String
'Create the DAQmx task.
DAQmxErrChk DAQmxCreateTask("", TaskHandle)
ChanNumberString = ""
For n = 0 To DAQChnl - 1
ChanNumberString = ChanNumberString & "Dev1/AI" & DAQMsg(1, n) & ","
Next n
ChanNumberString = left(ChanNumberString, Len(ChanNumberString) - 1)
If KillIt Then Exit Sub
'Add analog input channels to the task.
DAQmxErrChk DAQmxCreateAIVoltageChan(TaskHandle, ChanNumberString, "", _
DAQmx_Val_Cfg_Default, -10, 10, _
DAQmx_Val_VoltageUnits1_Volts, "")
'Configure task for sample acquisition and read in data
'int32 DAQmxCfgSampClkTiming (TaskHandle, const char source[], float64 SampleRate, int32 activeEdge,
' int32 sampleMode, uInt64 sampsPerChanToAcquire);
DAQmxErrChk DAQmxCfgSampClkTiming(TaskHandle, "OnboardClock", DAQSampleRate, DAQmx_Val_Rising, _
DAQmx_Val_AcquisitionType_FiniteSamps, DAQSamples)
DAQmxErrChk DAQmxGetTaskNumChans(TaskHandle, NumChannels)
DAQArraySize = DAQSamples * NumChannels
ReDim Data(DAQArraySize)
DAQmxErrChk DAQmxRegisterDoneEvent(TaskHandle, 0, AddressOf DAQmxEvent, Null)
DAQmxErrChk DAQmxStartTask(TaskHandle)
'DAQDone
End Sub
Public Function DAQmxEvent(TaskHandle As Long, Status As Long, Data As Long) As Long '#ErrLinesDone#
Stop
DAQDone
End Function
Public Sub DAQDone()
Dim VoltBuf() As Double
ReDim VoltBuf(DAQArraySize)
'Get the data from DAQ
DAQmxErrChk DAQmxReadAnalogF64(TaskHandle, DAQmx_Val_Auto, 10#, _
DAQmx_Val_GroupByScanNumber, VoltBuf(0), DAQArraySize, DAQSamples, ByVal 0&)
'Task is done so clear it.
DAQmxErrChk DAQmxClearTask(TaskHandle)
'Format data into the DAQData(Chnl, Sample) array.
'... more stuff here
'Clear unused array.
Erase VoltBuf
End Sub