Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

multi-rate output closed loop not run fast enough

I am running a PCI-6289 card with DAQmx and LabVIEW8.2.
 
I am writing some codes to perform a task on 2 AI and 1 AO channels to configure 2 closed PID loop. The feedback signal of Loop 1 is sent out by the AO channel while the feedback signal of Loop 2 can only be sent to the device that i want to control by the GPIB interface. I want Loop 1 to finish each iteration by less than 1 mili second, while Loop 2 to finish in several tens of mili seconds (this parameter can not be changed since the time for the device under control to handle the command via GPIB is fixed).
 
The problem is that I put the two loops in a hardware TIMED loop by LABVIEW itself. And the fastest speed I can achieve is only 50Hz.
 
My code is like that all the 2 loops are performed simultaneously with highest sampling rate of 1KHz as required by Loop1. The binary array is sent to the PID.vi. Then the output array is split. The signal corresponding to Loop 1 is sent to the Daqmx write. The other signal is sent to a case structure who excutes once every N times the TIMED loop excutes (N equals the ratio of feedback rate between Loop1 and Loop2). And the timed loop fails due to the long time that the case structure takes to excecute.
 
Is there anybody kindly enough to give me some suggestion?
0 Kudos
Message 1 of 4
(3,355 Views)
Hi maggie_ok,

My name is Mas Chano, an applications engineer from National Instruments Japan. I'd be glad to help out.

Just to make sure I understand your code, can you confirm the following.
  1. Loop 1 performs both Ai and Ao.
  2. Data is sampled in loop 1 at a rate of 1kHz.
  3. The data acquried from Ai1 and Ai2 are sent to PID.vi, which is placed in Loop 1.
  4. The output from PID.vi is split into two arrays.
  5. One array is sent to the Ao task in Loop 1.
  6. The other array is sent to the GPIB task in Loop 2.
  7. Inside Loop 2, there is a case structure that executes once every N x the time it takes Loop 1 to execute, where N is the ratio of feedback rate between Loop 1 and Loop 2. (So if Loop 1 takes 1ms and Loop 2 takes 10ms, N=1/10. Therefore, the case structure should execute once every 1/10 * 1ms = 100us? Does this mean the case structure executes several times per loop iteration?)
  8. Loop 2 fails because it takes too long to execute the case structure.
  9. Now, when you say the fastest speed you can achieve is 50Hz, I assume you mean Loop 2 takes 20 ms per iteration execute.
Are my above assumptions correct? It would also be really helpful if you could provide a screenshot of your VI or perhaps a block diagram so that I can see if I am understanding your situation correctly.

Now, a few other questions.
  1. Are you using regular LabVIEW or LabVIEW Real Time?
  2. What are you using to transfer data between the two loops? (Queues, local variables, etc)
Thanks.

Mas Chano
Applications Engineer
National Instruments Japan
0 Kudos
Message 2 of 4
(3,333 Views)

Hi, Mas Chano:

Thanks for your kind reply.

I think there is some misunderstanding about my system (so i posted the .vi file in the attachment). For the two loops, it means the physical loop. However, as i have only one DAQ card (16 channel, up to 500k samples/s), so i put them both in ONE "software" loop. (Might this be the problem??? Should i buy another card???)

In Piont 7 of your reply, i thought N=10. Because what i wrote in the previous post is the RATE. So this might not be the problem.
 
answer to your questions:
(1) regular LABVIEW
(2) no data transfer (they are in the same software loop)
 
Can you give me some suggestion after having a look at my code? Thanks a lot.
 
0 Kudos
Message 3 of 4
(3,315 Views)
Hi maggie_ok,

I took a look at your VI and see what you're trying to do. If you are doing this on a Windows system or any regular OS, you're probably not going to be able to make your Timed Loop execute much faster. 50Hz is actually already pretty fast. You'll probably need to do this on an FPGA to get better timing.

One thing you could try is to move the GPIB write section of your code (the code in the case structure) to a separate while loop. That would probably allow your main timed loop to execute faster. You could send the data needed for the GPIB write to a queue and have your while loop wait for data to appear in the queue before it executes a GPIB write.

Also, I just want to make sure I understand your timing requirements.
1. You need the timed loop to execute each turn at 1kHz.
2. You want to perform a GPIB write every tens of milliseconds.
3. You want to sample Ai at 1kHz.
4. You want to perform Ao at 1kHz.

I can't guarantee that you will be able to get the timing you need by using two separate loops and a queue, but it will probably be faster than your current code.

Hope this helps and let me know if you have any questions.

Mas Chano
Applications Engineer
National Instruments Japan
0 Kudos
Message 4 of 4
(3,294 Views)