LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx basic questions

I posted this into another thread, but I guess it got burried.
It's just some pretty basic questions in regard to DAQmx.


I'm new to using DAQmx (as opposed to the old DAQ) and I'm not very
clear yet on how it operates. I'm currently doing things this way on a
PCI-6025E:
DAQmxCreateTask
DAQmxCreateAIVoltageChan
DAQmxStartTask
DAQmxReadAnalogF64 (single sample, repeat calls in a timer loop)
DAQmxStopTask
DAQmxClearTask
But I notice that after a minute or so the CPU maxes out to 100%, so
there must be something wrong. Why would the CPU increase ?

The UIR timer runs at 10Hz, but I'm pretty sure there must be a better
way to get callbacks on acquired samples. Only problem is that I need
Digital input as well as analog input together with another input from a
non-NI card.


--
Guillaume Dargaud
http://www.gdargaud.net/Photo/
"First we thought the PC was a calculator. Then we found out how to
turn numbers into letters with ASCII — and we thought it was a
typewriter. Then we discovered graphics, and we thought it was a
television. With the World Wide Web, we've realized it's a brochure." —
Douglas Adams (1952—2001)

--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 1 of 5
(3,331 Views)
Hello Guillaume,
 
Typically if you want to read multiple times a DAQmx timer is used so that the samples are hardware timed instead of software timed.  For efficiency, typically several samples are buffered before they are read by the application.  The DAQmx read then acquires the number of samples specified.  For this a DAQmx EveryNCallback is typically used. If samples are not yet available a wait occurs. This behavior can be changed with the DAQmx Wait Mode property.
 
You may also want to compare your application with one of the DAQmx examples.  These will be located in your National Instruments folder under \NI-DAQ\Examples\DAQmx ANSI C.  Specifically since you are doing synchronized analog and digital tasks you may be interested in the Synchronization\Multi-Function example. This example demonstrates the timing configuration outlined above.
 
I hope this helps,
 
Jennifer O.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,306 Views)
Thank you for the answer,

> Hello Guillaume, Typically if you want to read multiple times a DAQmx
> timer is used so that the samples are hardware timed instead of
> software timed. For efficiency, typically several samples are
> buffered before they are read by the application. The DAQmx read then
Yes and it makes perfect sense... only I need to sync with a 3rd party
card and doing it at 10Hz is good enough for a UIR timer (using hardware
timer would complicate things a great deal).

> acquires the number of samples specified. For this a DAQmx
> EveryNCallback is typically used. If samples are not yet available a
> wait occurs. Please refer to
> <http://digital.ni.com/public.nsf/websearch/
> 09D80223FA84113D86256D6A004B97C3?OpenDocument>DAQmx CPU Usage at 100%.
> This knowledgebase outlines the behavior of the DAQmx read and CPU
> usage. This behavior can be changed with the DAQmx Wait Mode
It's good to know as this was a weird behavior (several minutes to reach
100% CPU, I tried tracking down some memory leak or somesuch for 2 days).

> property. You may also want to compare your application with one of
> the DAQmx examples. These will be located in your National
> Instruments folder under \NI-DAQ\Examples\DAQmx ANSI C. Specifically
> since you are doing synchronized analog and digital tasks you may be
> interested in the Synchronization\Multi-Function example. This example
> demonstrates the timing configuration outlined above. I hope this
> helps, Jennifer O.Applications EngineerNational Instruments

I did try some of the examples, in particular to sync AI with Digital
Input (on the same device), but something escapes me:

NON-FATAL RUN-TIME ERROR: "ContAI-ReadDigChan.c", line 158, col 9,
thread id 0x00000A68: Function DAQmxCfgSampClkTiming: (return value ==
-200077 [0xfffcf273]). Requested value is not a supported value for this
property. Property: DAQmx_SampTimingType You Have Requested:
DAQmx_Val_SampClk You Can Select: DAQmx_Val_OnDemand,
DAQmx_Val_Handshake Task Name: _unnamedTask<1> Status Code: -200077

I have no idea where this attribute is set as there's no reference to it
in that function call.



As an unrelated note: what is wrong with the news.ni.com server ? Most
messages contain html tags (in particular &nbsp;) but they are labeled
as text so all the tags display in my newsreader. Is it coming from an
improperly done "web to usenet" conversion ? Very annoying to read.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 3 of 5
(3,300 Views)
Hello Guillaume,
 
I apologize for my oversight - this example was created specifically for M-Series devices and some S-Series devices. To see the supported devices, navigate in CVI to Help>>Find Examples. The supported devices for a selected example will be displayed in the lower right-hand corner of the Example Finder.  
 
This example requires that the device support hardware-timed digital I/O.  Unfortunately your card does not support this feature as indicated by the error message you are receiving.  Your card can use handshaking or on-demand for the timing.  Refer to the NI-DAQmx Help or your device manual for more information on these timing options.
 
With your existing hardware, you can read or write a single sample to one or more of your digital lines each time you read your analog samples by making the two calls together.  If you require hardware timed digital I/O I recommend upgrading to an M Series board.
 
I have shared your feedback regarding the html tags with our web group.
 
Regards,
 
Jennifer O.
0 Kudos
Message 4 of 5
(3,272 Views)
Hello Guillaume,

Thank you for the feedback regarding the &nbsp tags you see in your newsreader.  We are aware of the issue - It stems from the fact that we synchronize posts between forums.ni.com and our newsgroups.  In the future, if you have questions or feedback pertaining to the Discussion Forums, you can always go to the feedback forum to share your concerns.

Regards,
Laura
Web Support & Operations
0 Kudos
Message 5 of 5
(3,267 Views)