Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Need an example how to use SCAN_Start with a callback function

I would appreciate if someone helps me with a working example of how to use SCAN_Start with a callback function. I need just a basic functionality: to specify a channel list (with gains probably), to start a data acquisition task and to receive data buffers utilizing a callback function. t this time whatever I was trying to do caused computer hangups, though it is supposed to be one of the most regular tasks to perform.
Thank you in advance,
Mike
0 Kudos
Message 1 of 7
(4,332 Views)
Hello Mike,

Thank you for contacting National Instruments.

Attached is an example project which uses a callback function to begin analog acquisition (AI) by calling SCAN_Start. This project acquires from the first 2 channels on your DAQ device. Make sure to modify the device number in the code to match the number of your card.

Let me know if you have any further questions...

Sincerely,

Sean C.
Applcications Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,332 Views)
Thank you Sean,
I hope it will help. The only thing I missed posting the question, sorry, is that i am trying to do it in VC++ 6.0 rather than in Measurement Studio. Does it change anything? Do you have a pure C++ example available?
I greatly appreciate your help.
Mike
0 Kudos
Message 3 of 7
(4,332 Views)
Thank you Sean,
I hope it will help. The only thing I missed posting the question, sorry, is that i am trying to do it in VC++ 6.0 using the traditional NI DAQ driver rather than in Measurement Studio. Does it change anything? Do you have a pure C++ example available?
I greatly appreciate your help.
Mike
0 Kudos
Message 4 of 7
(4,332 Views)
Hello again Sean,
I looke the example you had sent through, thanks. It does not use a callback function though but rather still utilizes the call to DAQ_DB_HalfReady. I would like to avoid this, but want the driver to call a function I would supply every time the buffer is either half-full or full. I guess that one is the DAQ Event 1. Could you suggest anything in this respect?
Thank you,
Mike
0 Kudos
Message 5 of 7
(4,332 Views)
Hello Mike,

The example program uses the SCAN_Start function inside of a callback function. Also inside this callback function is the DAQ_DB_HalfReady function. This function returns a 1 when a half-buffer has been filled. The if statement directly below this executes a function everytime a half-buffer is filled. I believe this is what you are wanting. Using this as an example, you can replace the DAQ_DB_Transfer function with a function of your own that would execute everytime a half-buffer is filled.

I hope this helps.

Sincerely,
Sean C.
Applicationas Engineer
National Instruments
0 Kudos
Message 6 of 7
(4,332 Views)
Hello Sean,

and let me thank you again for your cooperation. In fact the approach presented in the example you had provided me with is not what I am looking for. I do not want to use DAQ_DB_HalfReady function. Instead, I want to configure a DAQ Event 1 so that the driver would call a callback function I would supply it with whenever the half-buffer - or the full buffer is ready, while the program could execute other tasks not being stuck polling the buffer state. The problem is that even though it should work it does not - and not a single working example around. Again, I use VC++ 6.0, Traditional NI DAQ and PCI6013/6014 DAQ.
Best regards,
Mike
0 Kudos
Message 7 of 7
(4,332 Views)