Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Tasks vs events in DAQmxRegisterDoneEvent

The daqmxcfunc help file says that the DAQmxRegisterDoneEvent function registers a callback when a finite acquisition task completes execution.  The help file also says that the callback function is called when the event occurs.
 
1.  What is the difference between a task and an event?
2.  When does the call occur, at completion or when it occurs?
3.  What is a finite acquisition task?
4.  Is DAQmxCfgAnlgEdgeStartTrig a finite acquisition task?
5.  Are there any examples of using DAQmxRegisterDoneEvent besides stopping due to an error?
 
Thanks,
 
Kevin
0 Kudos
Message 1 of 10
(5,809 Views)
Kevin,

I will attempt to answer your questions below:

1.) A Task is a DAQmx concept which defines an acquisition or generation. This acquisition can be either finite (you know how long it will last before it begins), or continuous (the task will run forever unless you stop it). Here is a brief introduction to some basic DAQmx concepts.

2.) This particular callback will execute as soon as the task completes. For a continuous task, this event will never occur. For a finite task, this event will fire as soon as the acquisition finishes.

3.) A finite task specifies a set number of samples to acquire (analog input) or generate (analog output).

4.) This function actually controlls the triggering of the task (when it starts). In this case, an analog edge will start the task. This task can be either finite, or continuous.

5.) A great example which uses the DoneEvent is called "MultVoltUpdates-IntClk-DoneEvent.c" and can be found in the C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Events\Done\Mult Volt Updates-Int Clk-Done Event directory.

Please let me know if you have any more questions.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 2 of 10
(5,798 Views)
Hi Ryan,
 
I would like to write a program that uses DAQmxRegisterDoneEvent CALLBACK and DAQmxCfgAnlgEdgeStartTrig for one analog input when the signal crosses a level once.
 
Why doesn't the CALLBACK ever occur?
 
1.DAQmxCreateTask(“”, &taskHandle);
2.DAQmxCreatAIVoltageChan(taskHandle, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, 0, 6, DAQms_Val_Volts, NULL);
3.
1.DAQmxCfgSampClkTiming(taskHandle, “”, 10000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1);
4.
1.DAQmxCfgAnlgEdgeStartTrig(taskHandle, "Dev1/ai0", DAQmx_Val_RisingSlope, 4.5);
5.
1.
DAQmxRegisterDoneEvent(taskHandle, 0, DoneCallback, NULL);
DAQmxStartTask(taskHandle);
 
Kevin
0 Kudos
Message 3 of 10
(5,776 Views)
Kevin,

Are you checking for errors in your program? I noticed that you misspelled the "DAQmxCreatAIVoltageChan" function. If this function does not properly execute, all subsequent calls will not matter and you will not be waiting on your trigger condition. I would recommend using the error checking method from the above example.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 4 of 10
(5,774 Views)
That is my typo in the post.  It is correct in the program.  It compiles without error.
0 Kudos
Message 5 of 10
(5,771 Views)
Hi Ryan,
 
You mentioned that DAQmxCfgAnlgEdgeStartTrig triggers when the task starts.
 
Do you know why DoneEvent never executes?
 
Kevin

Message Edited by EW on 04-25-2006 08:40 AM

0 Kudos
Message 6 of 10
(5,760 Views)
Kevin,

You are providing a rising analog edge from below to above 4.5 volts on ai0, correct? The only reason I could figure why your code does not function correctly is that your hardware does not support analog triggering. What device are you using? Are you using error checking in your code? If you do not check for errors and your hardware does not support analog triggering, then you will never get the error informing you of this.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 7 of 10
(5,755 Views)

I would like to trigger on the rising edge of ACH0 on my BNC-2090.  I have a 0 to 5 V pulse train analog input.  I picked 4.5 V but it doesn't have to be that.  I am using a NI PCI-6251 DAQ Card.  The SPEC says the card has 1 analog trigger

I am not using error checking.

Is Dev1/ai0 a valid trigger source?

 

 

0 Kudos
Message 8 of 10
(5,753 Views)
I have added error checking.  But DoneEvent never executes.
0 Kudos
Message 9 of 10
(5,748 Views)
EW,

It sounds like everything should be working. Does the Done Event occur if you comment out the DAQmx trigger function call? Are you sure of your connections? If you simply perform a DAQmx Read for the total number of samples in your acquisition instead of waiting on an event, do you get the data back? Is this data the 0 to 5V signal you expect? Please let me know.

Regards,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 10 of 10
(5,733 Views)