Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW FPGA : storing and synchronization of Analog data to Excel

Hi all,

I am using a USB 7856 EOM board. I am attaching the FPGA Board VI and the Host PC VI below.

I aim to generate an Analog signal of a certain frequency range and simultaneously read the Analog output of my sensor. I have used an RMS function to get the RMS value of the signal.(PS he signal from my sensor is sinusoidal). The graph displays the signal as I expect, which gives me hope that my FIFO and VI are functioning properly. Next, I want to store the Frequency and the corresponding RMS value to plot a graph for my research. I thought the best way to do that would be to extract the value to an excel. The issue I am running into now is when I try to do that on my host PC, certain values of the Frequencies are getting skipped and I cannot get the sample size right (about 100 RMS values for each frequency would be perfect for me). 

I have attached my DC and RMS values as well. I am generating Frequencies ranging from 1000 Hz to 200 KHz

I tried to vary the loop rate of my FPGA and the PC VI but kept running into Timeout Issues.

How do I adjust the sample rate such that I get 500 RMS values per frequency? 

Thank you very much in advance.

Download All
0 Kudos
Message 1 of 8
(850 Views)

There are a few problems with your PC VI.

1. It is a bad idea to have while loops inside while loops. Since there is no stop condition for your FPGA loop, your logging loop will never run.

ZYOng_0-1715949882837.png

 

2. Move the Run invoke method before the while loop. You only need to call it once.

ZYOng_1-1715949976627.png

 

3. You specify the FIFO.Read with timeout of 0. It will return all remaining elements (up to 50k), even when there is less than 50k of data in the FIFO. You won't get the same sample size for each loop. You should specify a non-zero timeout. See Designing a Host VI to Read Data in DMA Applications

ZYOng_2-1715950015424.png

 

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
Message 2 of 8
(819 Views)

Hello,

Firstly, thank you very much for your time.

I made the changes to my VI as recommended by you.

I moved the Run invoke outside my loop and I am using a local variable to send data into my Data logging loop.

1 More change I made to the FPGA VI is adding a loop timer to FPGA VI(The analog Input loop). I removed the

wait function in my host PC as well.

Now I can record the Frequency and corresponding amplitude values properly. I am attaching the Excel file that has recorded the frequency and corresponding amplitude, I have two issues with this.

1. How do I bring down the number of samples between each frequency?

2. The interval between each frequency is not constant, why is that? (I assume some sort of synchronization issue)

Can you please tell me the sample rate calculation or provide a documentation link?

Thank you once again.

Download All
0 Kudos
Message 3 of 8
(807 Views)

For FPGA VI, change the constant value of 25 wired to the Loop Timer to a control so that you can adjust the value in real time.

For PC VI, do not use local variables to share data between loops. Local variables are not buffered and susceptible to the loop jitter. Use Producer/Consumer Architecture instead.

 

Taking Your First Measurement in LabVIEW FPGA (Data Logging) is a great reference for you.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
Message 4 of 8
(796 Views)

Hello,

I took your advice and tried using the producer-consumer concept. but the data acquisition has a few skipped values. And also, you advised me to control the Tick count from the host VI. but when I did that, the "Element Remaining " went up rapidly and the FIFO timed out. I will attach the Producer consumer VI here, please have a look.

0 Kudos
Message 5 of 8
(746 Views)

What is your input value to the Tick Count in FPGA?

What is your actual Loop Time?

 

Based on your description, I believe that you are reading slower from the FIFO buffer than the data is generating, causing data to be overwritten, hence the skipped values.

 

Recommendations:

  • Add error handling. Use an OR operator to stop the while loop when the Start button is pressed or when an error occurs.
  • You wire a constant false value to the conditional terminal of the inner while loop. I don't see how you can stop the loop gracefully other than aborting the VI. As a rule of thumb, avoid loop inside loop.
  • Instead of reading 2000 elements, read more elements to clear the FIFO buffer faster.
-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 6 of 8
(740 Views)

the actual loop time was 184 ticks, but my tick count was 25. I realized this didn't make sense and changed it to a higher value. Now I don't have any timeout errors and the "elements remaining" are in the range of a few thousand which is good for now. But the data logging is where the problem is, the data that I have read out is completely unexpected. I watched videos on YouTube and they follow a similar code to write data into Excel and it works fine. Can you tell me if I'm missing something or is there a different method to store the data in the host?

Download All
0 Kudos
Message 7 of 8
(722 Views)

I use TDMS most of the time. TDMS can be opened using Excel.

You can refer to the shipping examples at Example Finder >> Fundamental >> File Input and Output >> TDMS

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 8 of 8
(710 Views)