Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

My program is crashing when I use DAQmxStartTask & DAQmxIsTaskDone

I have just gotten my USB-6210.  I'm trying to learn DAQmx commands & techniques.  I know the device works - I have downloaded & used some NI example programs.  Now I'm trying to figure out how to use it with tasks created in Measurement&AutomationExplorer.  I can't figure out why the following causes VB 6.0 to crash & close out with no error messages or any warning at all.  Most perplexing is that the program bombs when executing the very last statement! - which is a simple string command.  Any clue as to what's going on?
 
  Call DAQmxErrChk(DAQmxLoadTask(TaskName, TaskHandle))
  Tsec = Timer
  Call DAQmxErrChk(DAQmxStartTask(TaskHandle))
  Do
    Call DAQmxErrChk(DAQmxIsTaskDone(TaskHandle, TaskDone))
    DoEvents
  Loop Until TaskDone = True
  TsecForDone = Timer - Tsec
  Call DAQmxErrChk(DAQmxReadAnalogF64(TaskHandle, DAQmx_Val_Auto, 10, DAQmx_Val_GroupByScanNumber, Data(0), 300, TrueNbrReadsPerColor, Null))
  Do
    Call DAQmxErrChk(DAQmxIsTaskDone(TaskHandle, TaskDone))
    DoEvents
  Loop Until TaskDone = True
  Call StopTask
  TsecForTransfer = Timer - Tsec - TsecForDone
  Txt = "Sec For Done: " + Format(TsecForDone, "00.000") + vbCrLf
0 Kudos
Message 1 of 2
(2,433 Views)

Hi hjehan,

If you comment out that line for the time being, does the program still crash? Is the TaskHandle in MAX named "TaskHandle"? Also, are you getting any sort of error message? Is this the final line of your program and the program being finished being mistaken for crashing?

It doesn't appear there is any gross DAQ programming errors so this may be a simple variable declaration made above.

PBear
NI RF
0 Kudos
Message 2 of 2
(2,399 Views)