Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help using DAQmxRegisterDoneEvent with VB6 and Measurement Studio 8.6

Sir, I am working on migrating a data acquisition app from "E series" and

traditional NI-DAQ to USB (6281), and NI-DAQmx using VB6 and Measurement

Studio 8.6. I'm hoping that you can help me with this.

With E Series DAQ, Traditional NI-DAQ, and Measurement Studio 6, I used the

"Acquired Data" ESR to process acquired data efficiently. This arrangement

works very well since there is no need to wait for the data acquisition

task

to complete - the software triggers the "Acquired Data" event when it is

ready so that useful processing can continue while the acquisition is in

progress.

I've experimented a bit with NI-DAQmx and the C API and although I have the

app working, the computer is un-responsive while the acquisition is in

progress. Can you please explain the required calling sequence when using

DAQmxRegisterDoneEvent for a basic, simple period measurement.

Thank you,

Alan Sanderson

Vector Solutions

905 571 0702

asanderson0702@rogers.com

 

0 Kudos
Message 1 of 9
(3,879 Views)

vecsol,

 

DAQmxRegisterDoneEvent is used to:

Registers a callback function to receive an event when a task stops due to an error or when a finite acquisition task or finite generation task completes execution. A Done event does not occur when a task is stopped explicitly, such as by calling DAQmxStopTask.

 

Are we doing a finite or continuous acquisition?  Are you using a counter for your period measurement?  If finite as I suspect then this will only give you notification when the acquisition has completed.  Thus an event will not be registered until the entire acquisition has completed.

 

Have you looked at some of the examples

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 9
(3,872 Views)

I can't find documentation re DAQmx and continuous vs finit acquisitions. The code I used is:

    DAQmxErrChk DAQmxCreateTask("", TaskHandle)
    TaskIsRunning = True
    DAQmxErrChk DAQmxCreateCIPeriodChan(TaskHandle, "Dev1/ctr0", "Ch1", 0.001, 1#, DAQmx_Val_TimeUnits3_Seconds,  DAQmx_Val_Edge1_Rising, DAQmx_Val_CounterFrequencyMethod_LowFreq1Ctr, 10#, 1, "")
    DAQmxErrChk DAQmxRegisterDoneEvent(TaskHandle, 0, SingleTaskDone, 0)
    ' Start the task running.
    DAQmxErrChk DAQmxStartTask(TaskHandle)
Following the link in your reply re Examples gets me to Traditional NI-DAQ examples. I've also been able to find examples for VB6 / Measurement Studio 6 with Traditional NI-DAQ, but I can't find relevant examples for VB6 with DAQmx. I have found this link http://www.ni.com/swf/demos/us/mstudio/vb6daq/default.htm

to point me at some helpful material.

0 Kudos
Message 3 of 9
(3,864 Views)

vecsol,

 

You may also find this document helpful especially the part towards the bottom titled "Visual Basic 6.0 with Measurement Studio for Visual Studio 2003/2005/2008"

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 4 of 9
(3,852 Views)

Hi there Jason. My problem is knowing the correct sequence of DAQmx calls from VB6 in order to take advantage of DAQmxRegisterDoneEvent so that the computer is not unresponsive while waiting for the measurement to complete.

I have found that the best source for examples is

 

 c:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0

 

but there isn't anything to demonstrate the correct use of DAQmxRegisterDoneEvent. Any guidance you can provide will be most helpful. How can I determine which of the DAQmx calls are finite vx continuous?

 

Many Thanks ,

vecsol

0 Kudos
Message 5 of 9
(3,849 Views)

vecsol,

 

Why are we using a counter?  Is it the timing source for a different part of the application you have not posted?

 

You may be interested in this forum and the example linked at the bottom.  This example uses the done function.  Finite would be a task that has a specific time it is set to run while continous will run until stopped. 


I probably need some more info as far what you are exactly trying to do.  It seems like from the code you have given me that it is not the register done event that is locking your computer but the way you have your "data acquisition" set up.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 6 of 9
(3,838 Views)

The input signal is used to gate internally generated timing pulses. The pulse count (between two consecutive edges of the same polarity on the gate) is used to calculate the period from a knowledge of the internally generated timing pulse frequency, and the number of pulses between two consecutive gate pulses.

Is there a better way ?

vecsol.

0 Kudos
Message 7 of 9
(3,832 Views)

The measured signal comes from a "once per turn" marker on a rotating shaft and corresponds to a pulse rate in the range 3 to 60 Hz i.e. too low to count pulses in the measured input signal. The result of measurements must update rapidly - hence the decision to count timing pulses generated internally with the input signal acting as a gate. This method provides best accuracy for our input signal (3-60 Hz) within the update time constraints. I'm looking at the example code you've provided and hopefully this will resolve my issue. Documentation for using NI-DAQmx with VB6 is not very good. Where can I find a VB6 function reference for NI-DAQmx that explains which measurements are finite and which are continuos ?

Jason, your input and assistance is much appreciarted.

Regards, vecsol..

0 Kudos
Message 8 of 9
(3,829 Views)

vecsol,

 

Take a look at the DAQmx C Reference Help.  You can find it at Start»Programs»National Insturments»NI-DAQ look at the DAQmxCfgSampClkTiming.  You may already be using this function for your AI but it will allow you to set Finite/Cont.  Also take a look at the Generic Programing charts they will give you a lot of good documentation about the difference and how to code for each.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 9 of 9
(3,813 Views)