From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Write Measurement File at maximum sample rate

Hello:

 

I am doing an application in which I read 4 channels from a NI9234 and write the values in a 1024 size FIFO in order to transmit this information from a cRIO-9053 FPGA to the CPU part.

 

In the part of the CPU I read those fifo and write a measurement file in csv each 5 seconds.

 

If I put the sample rate of the acquisition module at 51.2 Ks/S and i measure during 5 seconds, I should have 256000 samples in the file, but when I open it I only have 94000.

 

There are two main VI, the FPGA VI where i read the inputs and another two, one in the CPU of the cRIO and a similar VI in a Host PC.

 

I can not understand what is wrong with the code

0 Kudos
Message 1 of 8
(1,817 Views)

Why don't you stop using "Write to Measurement File"? It does too much operation.

How to Write Data to File Faster in LabVIEW 

 

Then, try those ways

High CPU Usage When Reading Data from Target-to-Host DMA FIFOs

Creating Deterministic Applications Using the Timed Loop (Real-Time Module)

Certified LabVIEW Developer
There are only two ways to tell somebody thanks: Kudos and Marked Solutions

GCentral
0 Kudos
Message 2 of 8
(1,803 Views)

Hello:

 

 


@Tepig  ha escrito:

Why don't you stop using "Write to Measurement File"? It does too much operation.

How to Write Data to File Faster in LabVIEW 

 

 


I am using the "Write to measurement File" cause I need storage the values.

What's the different of what i am implementing.

 


 

Then, try those ways

High CPU Usage When Reading Data from Target-to-Host DMA FIFOs

Creating Deterministic Applications Using the Timed Loop (Real-Time Module)


I have read those links, but I can not figure how that write the values in a file.

 

 

0 Kudos
Message 3 of 8
(1,790 Views)

File IO is SLOW.  And the Write Measurement File makes it even slower since it is constantly opening and closing the file.  So it is very likely you are getting FIFO overflows, causing data loss.  So my suggestions are as follows:

1. Do not use a CSV file.  Converting the values to text is overhead you cannot afford at this stage.  Instead, write to a TDMS file and the TDMS API.

2. Create/Open the file only when you have to and close it when that file is complete.

3. Use a Producer/Consumer setup to do the logging in a separate loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(1,787 Views)

@crossrulz  ha escrito:

File IO is SLOW.  And the Write Measurement File makes it even slower since it is constantly opening and closing the file.  So it is very likely you are getting FIFO overflows, causing data loss.  So my suggestions are as follows:

1. Do not use a CSV file.  Converting the values to text is overhead you cannot afford at this stage.  Instead, write to a TDMS file and the TDMS API.

2. Create/Open the file only when you have to and close it when that file is complete.

3. Use a Producer/Consumer setup to do the logging in a separate loop.


I put the data in a CSV because I need to make different analysis once the file has been captured. TDMS I think is not the most functional file to handle with python scripts.

 As I said before, I need the complete data values during 5 second, after 5 seconds i need a new file with new data.

It is the reason because I use a write measurement file because once the time elapsed it send a bit to close the file a reset it

Do you know a better way to do it?

 

Thank you

0 Kudos
Message 5 of 8
(1,777 Views)

Looking a little closer, I see you are using the cRIO-9053 and not really anything special in the FPGA.  So I would get rid of the FPGA and perform the readings with DAQmx.  You can then use the DAQmx Configure Logging to save the data to a TDMS file.  There are settings so that you can have DAQmx start a new file every X samples.  This would GREATLY simplify your code.

 

Once the acquisition and logging is complete, you can run a small application to convert from the TDMS format into a csv to allow Python to parse it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(1,768 Views)

@crossrulz  ha escrito:

Looking a little closer, I see you are using the cRIO-9053 and not really anything special in the FPGA.  So I would get rid of the FPGA and perform the readings with DAQmx.  You can then use the DAQmx Configure Logging to save the data to a TDMS file.  There are settings so that you can have DAQmx start a new file every X samples.  This would GREATLY simplify your code.

 

Once the acquisition and logging is complete, you can run a small application to convert from the TDMS format into a csv to allow Python to parse it.


I have tried your suggestion but I need to research more about to get the tdms file to transform to use with python

0 Kudos
Message 7 of 8
(1,730 Views)

https://pypi.org/project/npTDMS/

 

I've been using the Python package in the link above to do data analysis on data stored in TDMS files without any issue. It's pretty quick, I was up and running with it in under 15 minutes.

0 Kudos
Message 8 of 8
(1,655 Views)