10-21-2008 12:12 PM
Hello,
I am setting AO and looping back the signal into the AI of the same card. I am setting voltage increment of 10mv every iteration and reading back the voltage. I have used the timed loop for this. I have attached the VI and data(image) for your reference. I should see the the voltage that I set in the AO in AI in the next iteration. But actually I am reading the same voltage for 2 iterations (1 and 2). I see a time loop finishing late for iteraiton 1. This behavior is consistent for every run of the VI. What is the reason for finishing late?
The following is the RT configuration is used to run the test VI.
- PXI 8106 Controller- PXI 6229 M Series Card- LabVIEW Real Time 8.2.1- DAQmx 8.5.0
Thanks in advance for your help. Thanks,A Senthilnathan
10-22-2008 05:05 PM
Hello,
If you are going to use timed loops with hardware-timed single point acquisition, you should use the DAQmx Create Timing Source VI and select the "Control Loop From Task" instance.
I recommend that you take a look at the PID Control-Control Loop from Task example. You can find it in the example finder, see the attachments.
Gerardo
10-23-2008 07:42 AM
Hello Gerardo,
Thanks for pointing out the example. It works well for me with one DAQ card. Actually in my application, I have 2AOs from one card and Max of 56 AIs in 2 cards. I have to read analog inputs from 2 cards with in 1ms. This means that i have to read 2 times in a forloop or place DAQmx read VI in parallel. When I do like this, the timed loop always finishes late and it tasks 2 ms for each iteration. I am able to run the code without problem with one card. Is there a way to read from 2 or more cards simultaneusly from with in the timed loop?
Thanks for your help in advance.
-A Senthilnathan
10-23-2008 09:51 AM
10-23-2008 10:17 AM
Hello,
I have attached the test VI with this. I have added one more AI to read. I have set the sampling rate of AI to 10000s/s and set timed loop to 1ms. So I read 10 points every 1ms and average. This is necessary to average the noise in the signal. When I run this VI with my PXI RT, it works well with one card. When I include the next card, the timed loop elapses. The VI has default data in it for your reference.
With one card, the loop iteration takes 0.9ms and with two cards the loop takes 1.8ms. I have tested with AI in for loop and also direct calls (2 instances). In both case, it takes 1.8ms. I guess it takes time to read 2 cards sequencially. since there's no buffer. How should I read from multiple cards?
Thanks in advance
-A Senthilnathan
10-24-2008 09:31 AM
Hello,
Sorry, I had misunderstood your original intent. The Hardware-Timed Single Point mode for DAQmx is designed for reading one point at a time at a determined rate so that you can process each point in software and respond to it. In this mode you're data acquisition rate and your timed loop rate should generally be the same. This mode was created with a 1 pt/channel in -> process -> 1/pt/channel out.
In your case, you actually want to read 10 samples at a time and average them. I think the continuous acquisition mode is more efficient for this type of acquisition. There are a lot of examples that demostrate how to do this. Also, you probably don't need the timed loop to do this - since it's not giving you any benefits and adds a small bit of overhead. You can use a regular while loop and set the VI priority to time-critical. You can still synchronize your devices via their hardware clocks. If you do want to use the timed loop, take a look at the Cont Acq&Graph Voltage-Int Clk-Timed Loop.vi example.
Finally, reading 10 samples at a time is not as efficient as reading 100 or a 1000 samples at a time - so one question you have to ask yourself is whether you really need to read 10 at a time. Are you closing the loop based on the 10 sample average? If not, consider taking larger sample sizes, this way your loop doesn't have to run at 1ms, it can run at 5 or 10ms instead.
I hope this is helpful.
Gerardo