LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real time VI just runs once when using FIFO (Labview FPGA)

Hi guys.

 

I am wrestling with simple problem, I have NI 9211 on my cRIO chassis (9014). I want to collect tempreture data with high frequnecy (let's say 2000 Hz). I have couple of question:

 

1. searching here and there I realized that FIFO method should be used for this sampling rate. Am I right?

 

2. I made a FPGA and RT VI, but the problem is when I click to run the RT vi, it just runs once and then stop (I don't see any error)! I am using the parrarel method explained in the forum, to use the remaining elements in the FIFO and feed them to another FIFO read. (this thread: http://forums.ni.com/t5/LabVIEW/Error-50400-occurred-at-Invoke-Method-FIFO-Read-in-Host-vi/td-p/8814...

 

I am very confused about this FIFO thing, and any help/explanation would be appreciated.

 

Attached is my FPGA and RT VIs.

 

Download All
0 Kudos
Message 1 of 5
(2,487 Views)

Hi,

 

Probably you can try doing your application using Scan Engine first. I would suggest that you take a look at the LabVIEW example for NI 9211 in the example finder (NI 9211 - Getting Started - Scan Mode.lvproj)

 

This is a working example. However, you will need to configure the project to make it work with the hardware you have. There is a html documentation which guides how to use the example (configure the project to set your cRIO hardware as target).

 

Regarding the sampling rate, do take note that the 9211 sampling rate is 14S/s. This means setting the acquisiton rate at 2kHz causes each actual temperature samples to be repeated 142 times (2k/14). My question is what is the motivation behind using such high acquisition rate for temperature?

 

As for the VI you have attached, I used a sbRIO-9632 + NI 9211 to run the codes. It's working well, just that I had to configure the stop button on the RT VI. I change it from switch to latch. Could that have been the cause of the issue you are facing?

 

Regards,

Alan

 

Applications Engineer | National Instruments
Singapore (65) 6226 5886 | Malaysia (60) 3 7948 2000 | Thailand (66) 2 298 4800
Philippines (63) 2 659 1722 | Vietnam (84) 28 3911 3150 | Indonesia (62) 21 2783 2355
0 Kudos
Message 2 of 5
(2,442 Views)

Hi Alan,

 

thanks a lot for your reply. changing to "latch when pressed" fixed the problem (I spent a whole day trying to understand why it runs only once)

 

You are right, I was not aware of 14S/s for 9211. The reason I am trying to get so many samples is actually not related to tempreture module. I have NI 9215, to read strain gauge output, and for that I need fast sampling. 

 

Now that the problem is fixed, I have another question, sorry it may sound too simple

 

Assume I am still willing to acquire data with 2000hz with NI 9211, and save it on txt file. how can I do that? What I did before was making a shared variable (network shared), then creating another VI in the project, and use "write to measurment file" vi. With this sampling rate, how can I save my data on file?

 

Thanks again for the help.

 

 

0 Kudos
Message 3 of 5
(2,421 Views)

Hi,

 

Here are my thoughts. At 2kHz rate, it would be better not to use an express VI to do file I/O operations (in this case the write to measurement file.vi). Use the lower-level VIs instead (like Write to binary file, write to text file etc.). Also, you might want to put the file I/O operations in a separate while loop. This is so that the file I/O operations does not slow down the loop where the program displays the reading on a graph.

 

For the file I/O operations, take a look at the example given in LabVIEW. You may want to try looking at binary file type, instead of text file. Text files takes up more space compared to binary file type. So if you are looking to log data and save to the local drive on the cRIO for extended period of time, you may run out of space pretty quickly if you use text file type. The example is called simple binary file.lvproj. Use the example finder to look for this project.

 

As for separating the File I/O operations in another while loop, you may want to consider using queues. This a method to pass data between to parallel loops asynchronously. Take a look at producer/consumer design pattern from the link below:

http://www.ni.com/white-paper/3023/en/

An easy start is to take a look at the simple queue.vi from the example finder.

 

A snippet of the modified RT code would look something like this:

 

Code Snippet.gif

 

You will notice that I combined queues and the file I/O VIs. Take note that you will need to modify your code based on the examples that I have given you, so I suggest that you try out both examples first in separate VIs. Make sure both codes work properly before you intergrate to the main code. Hope you find this useful. Happy coding.

 

Regards,

Alan 

Applications Engineer | National Instruments
Singapore (65) 6226 5886 | Malaysia (60) 3 7948 2000 | Thailand (66) 2 298 4800
Philippines (63) 2 659 1722 | Vietnam (84) 28 3911 3150 | Indonesia (62) 21 2783 2355
0 Kudos
Message 4 of 5
(2,400 Views)

Thank you so much Alan for the help and information

 

for now, I switeched back to scan mode, and trying to learn the ways to write data and time using tdms. I will try your code soon and will let you know

 

thanks again for the help

0 Kudos
Message 5 of 5
(2,396 Views)