Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous analog multi-channel acquisition with events (C++, NI 6036E)

I tried to find working examples in the NI website and CD-s and all the places I found available but I still have some problems.
I have a NI 6036E card.
I am trying to write a C++ (for WinXp) program that inputs data continuously on N channels (1-16) with a sampling frequency F (ex:200Hz). Five times a second I want to be able to copy the new samples from all channels(in my ex: 200Hz/5=40 (samples/channel)) in a different buffer. For this I tried double buffer operations and interrupt generation functions.
Each time half-buffer gets filled an interrupt is generated and the data from this buffer can be copied to another buffer for further processing.
I need to know:
1. If I want to have a sampli
ng frequency of 500Hz on each channel what do I have to set and to what values?
2. What are the functions I need to use for my application and their order in the program?
3. The examples provided by NI use 100%CPU, how can I minimise this?
Thank you very much your your help.
0 Kudos
Message 1 of 2
(2,810 Views)
In answer to part 2:

I think you need:
For initialisation of the hardware:
Init_DA_Brds();
AI_Configure();

To initialise the double-buffered acquisition:
Timeout_Config();
DAQ_DB_Config(); // to turn db mode on
SCAN_Setup(); // to set up which channels to read from, and the appropriate gain values to use for each

To start the double-buffered acquisition:
SCAN_Start();

To test to see if a half buffer is ready for transfer:
DAQ_DB_HalfReady(); // you need to call this often enough to catch when the buffer is half full, and before it gets overwritten

To transfer the half buffer of data:
DAQ_DB_Transfer();

When you've finished getting data, and before you try to start DB transfer again:
DAQ_Clear ();
DAQ_DB_Config(); // to turn DB off


I
think that the key to part 1 of your question is the call to SCAN_Setup() and it is here that you set parameters for scan frequency etc. Refer to the documentation to find out what the various parameters do - if you find it confusing - I may be able to clarify it some more - but it confuses me too.

I'm surprised at the 100% CPU usage as most of the stuff is going on in hardware. The bigger you make your buffer for DB operation, the more time your processor has for other tasks, but you then have to access the data less frequently. Perhaps the examples didn't use DAQ_DB_HalfReady(); ?

Hope this helps
0 Kudos
Message 2 of 2
(2,810 Views)