Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQMX RT

Hi all!

I've got a problem, and i hope someone can help me. Well I've done an application in RT. The aim of this application is :

1) To read data coming from CAN bus and to send these data in AO, DO or PWM.
2) To read AI, DI, PWM and to send CAN messages
3) The time between getting the data and sending them must be 1ms

I made some test in order to know if it's possible to reach this performance i.e. i put all read and write vi in a software timed loop, and i analyse the time using the labview execution trace tool. The resultats are the following:

It takes more than 200 µs to write 70 DO (in 8 tasks), 180 µs to read 50 DI (in 2tasks), and approximatively 80µs fot the others tasks : AI, AO, CAN, PWMI, PWMO ... The problem is with all this stuff together, i can't reach 1ms cycle !!!

I suppose these times come from the hardware, and my questions is, what are the average time to access a card PXI-6254, PXI-6713, PXI-6602... ? (I didn't found these information in the handbook)...

Is there a way to improve these performances ????

Thanks a lot for your future answers ... !
0 Kudos
Message 1 of 8
(8,668 Views)
Hi KaBooOoom,

200 µs is longer than I would expect to write to 8 tasks. (That would be 25 µs per DAQmx write). What is your system speed?

You might want to try the following (if you haven't already)
* Make sure you start the tasks outside your control loop. If you start outside your loop, DAQmx will not have to start and stop the task every time you write data.
* Use the Digital Port Write VIs. The Boolean 1D Array reads have additional overhead because it splitS the digital port into one boolean per line.
0 Kudos
Message 2 of 8
(8,633 Views)
Hello,

Concerning the average time to access hardware, you can use the VI attached based on a count event task in order to benchmark a portion of code. Typically, the VI attached is able to determine the average time loop to access one analog input during a software timed loop. With this template, you should be able to determine the time loop to access the AI, AO, DIO or CAN ports.

In case of a hardware timed loop, you can check if the software operations are keeping up with the hardware timing by using specific RT VIs provided with NI-DAQmx 7.4.
* DAQmx Hardware-Timed Single Point Lateness Checking
http://zone.ni.com/devzone/conceptd.nsf/webmain/5B71E273769CBDD286256FD200677B70

The PID loop rate is in major part dependent of the CPU speed. For example, for a PXI-8186 controller (2,2 GHz P4), the maximum PID loop rate for one AI-AO is 42kHz. However, performance results vary depending on the particular system and the specific computations that occur within a given PID control loop.

If you have an important number of AI to read, you can increase the Analog Input Conversion Rate manually through the DAQmx Timing Property Node. This reduces the total amount of time spent converting the requested number of samples. It is important to consider the minimum settling time specifications for the complete data acquisition system to avoid signal degradation and interference.


Hope this helps.
Regards.

Matthieu G.
AE, NI France
0 Kudos
Message 3 of 8
(8,630 Views)
Hi Jonathan, and thanks for your answer!

I use a PXI-8186 (2.2GHz Pentium IV), but i don't know if these time come from the speed of the processor, i guess they come from the acquisition card (time tho access the card)! But you may be right i'm not sure, that's only suppositions...

Anyway, I start and stop the tasks outside the timed loop.. so these performances don't come from here.

Sorry I didn't understand your second suggestion : "Use the Digital Port Write VIs". I use the DAQmx read/write vi and i configure them to read multiple digital channels or to write one digital channel!

I contacted Ni to have more informations, but if anyone has others ideas ... i would really appreciate !
0 Kudos
Message 4 of 8
(8,626 Views)
Thanks Mathieu!
I tested your vi and that's the results i obtained :

1) I run your vi without any modifications, It takes approximatively:
- 180µs to read one sample of one AI
- 800µs to read one sample of 32 AI of the same card (=> The time to read one or multiple AI is not proportional)

2) First modification in the vi : i start the read task manually before the sequence:
- 30 µs to read one sample of one AI
- 600 µs to read one sample of 32 AI of the same card
=> If you don't start the task manually, does DAQMx starts the task each time you want to make a read ???

3) Second modification in the vi : i added a sample clock (10000) to acquire more than one sample i didn't enter the number of sample to acquire (=> we will acquire all sample available)
- 60 µs to read severeal sample of one AI
- 50 µs to read severeal sample of 32 AI of the same card
=> it takes approximatively the same time to read one or severeal channels , maybe because the data are ready !

4) Third modification in the vi : i specified to number of sample i want to read (2 for example)
- 173 µs to read 2 sample of 32 AI of the same card
=> I think this is because the data aren't available in the buffer : we read 500 * 32 channels *2 = 32000 samples

5) Fifth modification in the vi: i put a wait 1 s (in a sequence before starting the counter) to be sure all sample are available!
- 30 µs to read 2 sample of 32 AI of the same card !

6) Last try: I add a property node to read the number of sample available, and i make the read only if there is more tha one sample.
- 70 µs to read sample avaiable of 32 AI of the same card !
=> I don't understand why i lost 40µs .. does the property made an access to the card ??


My Conclusions are the following:
- I think you cant' go under 30µs that's the time to access the card!
- You must be sure all sample are available otherwise, the Daqmx read, will wait until they are here! And if you specify read all sample available you must be sure that there is at least one available !

Well i think the problem come from here sometime the samples aren't available, and i wait ... i will try to find a solution to be sure at least one sample is available !
0 Kudos
Message 5 of 8
(8,622 Views)
Hi KaBooOoom,

I want to explain the DAQmx Digital Port Read/Write a little better. There are multiple types of DAQmx Read/Write VIs. If you click on the Poly VI selector under the DAQmx Read or Write VI on your diagram, you can select which type of Read or Write you want to use from the pop-up menu. The fastest Digital Read/Write VIs are the Digital Port (U8, U16, or U32) VIs. The Digital Boolean 1-D Array is slower because of the array manipulation. As for Analog reads and writes, if you are looking for the best performance, use use something other than the Waveform read and write, because there is extra overhead to return the additional Waveform information. Also, the "single sample" VIs are in general faster than the "multiple sample" VIs, again because they require less array manipulation.
0 Kudos
Message 6 of 8
(8,615 Views)
Hi KaBooOoom,

A couple more thoughts. It sounds like you have a pretty fast system (the 8186), but there may be some other factors that would slow down your application. If the system has a USB port and you are not using it, then you may want to go into the BIOS and disable it. The USB driver will slow down overall system performance. Also, in your LabVIEW program are you running multiple loops at the same time in parallel, or just one loop? If you are running multiple loops, that will complicate the timing because the loops will be interrupting each other.
0 Kudos
Message 7 of 8
(8,613 Views)
KaBoom, it looks like you need to decide between single-point I/O or waveform based I/O for your AI operations. You can definitely go under 30us if you configure the board to do single point I/O. See the attached trace capture image of a VI that does a single point read from one channel of an E-Series device. Notice that the actual time it takes to read the point is considerably less than 30 usec. See the examples under LabVIEW 7.1\examples\real-time\ETS\RT Control.llb for VIs that use the hardware timed single point method for acquisition.
0 Kudos
Message 8 of 8
(8,603 Views)