Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx function holding windows xp

Hi there,
I noticed when I run the following code, that any timer or event is holded in my VB6 application until this function returns. Is there any other way to prevent this? I need to check for function timeout for safety while the function is acquiring the data.
 
Thanks in advanced.
 
Code is:
    DAQmxErrChk DAQmxCreateTask("", taskHandle)
    Scaneo.taskIsRunning = True
 
    'Add an analog input channel to the task.
    DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, Scaneo.ChanDescrip, "", _
                    DAQmx_Val_InputTermCfg_Diff, -10#, 10#, DAQmx_Val_VoltageUnits1_Volts, "")
                   
   
    'Configure task for finite sample acquisition and read in data
    DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", Scaneo.frequency, DAQmx_Val_Rising, _
                    DAQmx_Val_AcquisitionType_FiniteSamps, CLng(Scaneo.sampsPerChanToRead))
                   
    DAQmxErrChk DAQmxGetTaskNumChans(taskHandle, Scaneo.numChannels)
    Scaneo.arraySizeInSamps = Scaneo.sampsPerChanToRead * Scaneo.numChannels
    ReDim DatosCanales(Scaneo.arraySizeInSamps)
   
    DAQmxErrChk DAQmxReadAnalogF64(taskHandle, Scaneo.sampsPerChanToRead, 10#, _
                    Scaneo.fillMode, DatosCanales(0), Scaneo.arraySizeInSamps, Scaneo.LecturasxCanalLeidos, ByVal 0&)
   
 
    'Call the StopTask module to stop the DAQmx task.
    StopTask
0 Kudos
Message 1 of 4
(2,802 Views)

Hi Charly2007,

I don’t readily see anything wrong with the code you’ve posted, but I would like to understand your overall application better. It sounds like you are trying to run different processes simultaneously, such as acquiring data and processing events (like updating the user interface). Is that correct?

I’m not quite sure what you mean when you say you “need to check for function timeout for safety while the function is acquiring the data”. Are you asking about how to program a timeout into a data acquisition function or to do something different?

Please explain your overall program and how you envision the flow. Also, list what steps you’ve tried and what has/hasn’t worked so that the problem/resolution are clear for other community user. Thanks.

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 2 of 4
(2,772 Views)
Thanks for responding. Iin my application , I have to start a motor, then keep reading two voltages for 5 secs ( collecting data ), then stop the motor, using the functions below, I'm using a VB6 timer to stop the motor if this process goes beyond 5 secs. (I start the timer before calling NI functions). But I noticed that when a call these functions, my VB6 application freezes until data collection is complete and the function returns, my app doesn't respond to any event , including the timer while NI functions are working,
This can be a problem since I'm not be able to emergency stop the motor until NI functions comes back.
 
I need to know how can I measure the voltages without this problem.
 
Any more details please let me know.
 
Thx.
0 Kudos
Message 3 of 4
(2,762 Views)

Hi Charly2007,

Right now you are doing a finite acquisition, which will not allow other processes to execute until it’s done. Another way of acquiring data is with a continuous acquisition. I suggest starting with the example code to see how it’s set up. You would specify how many samples to read per loop iteration, and the program would do this until you tell it to stop. In this loop you could check the status of a stop button or’d with some logic (like a timer control) that checks to see if 5 minutes has elapsed. That way your program will stop if either the time has elapsed or you press the stop button.

Hope that helps!

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 4 of 4
(2,739 Views)