Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Read an analog input from fpga on line

Hi,

I developed LV model using FPGA and Host to read one analog input using while loop

the sampling frequency is 1000 Hz and the loop time is 100 ms

1- I want to run the loop for 5 sec then stop the while loop, How to do that? or is it possible to use control and simulation loop?

2- I want to save the acquired data on disk form time zero to five for further analysis 

attached FPGA.vi and Host.vi

Download All
0 Kudos
Message 1 of 4
(7,147 Views)

Supposing I got this right, you want to acquire an analog signal for five seconds and save the data?

1: The easiest way to stop the loop is by counting iterations. A frequency of 1kHz means you need 5000 iterations to run 5 secs. So compare the iterations of the loop to 5000

2: To get all the data you will need to use a DMA FIFO ( http://www.ni.com/white-paper/4534/en ). Make it at least 5000 samples long, write to the FIFO in every iteration on the FPGA. Read the values when you're done on the host and save the array (you will get an array on the host) the way you want. There are plenty of examples for buffered acquisition with FPGAs using DMA FIFOs.

Hope this helps..

LabVIEW 2012 32 bit

I am not an expert!
0 Kudos
Message 2 of 4
(7,132 Views)

Just some quick clarification:

 

BillTur above is absolutely correct on the architecture you should use. One specific line caught my attention though:

   "Make it [the DMA FIFO] at least 5000 samples long, write to the FIFO in every iteration on the FPGA."

 

I just want to clarify that there are actually 2 buffers used in DMA, one on the host and one on the target(FPGA). There is no reason that the FIFO on the FPGA side (the # of elements field in the project FIFO) needs to be 5000 elements long. The way the process works is that data is fed into the FPGA buffer, and then cyclicly transferred to the host (which has a much larger buffer). If you are going to total 5000 elements, not all of them will need to be stored in the FPGA side buffer at once. If you're only writing one element to the FPGA side buffer every 100ms, you can likely get away with a much smaller buffer (without benchmarking, I would guess 100-500 would be significantly more than enough depending on the element).

 

Since it's applicable, I am attaching some slides on the subject that someone in marketing spent way too much time animating Smiley LOL

 

Hope this helps to clarify things!

Cheers!

TJ G
Message 3 of 4
(7,128 Views)

My apologies, thanks for the clarification!

LabVIEW 2012 32 bit

I am not an expert!
0 Kudos
Message 4 of 4
(7,125 Views)