LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recording data at desired instants in FPGA using Memory Method

Hi All,

 

I want to record data triggered by certain events by FPGA memory method node to Block Memory. I did that. But I want download this data at a later time. The loop rate at which the code in the FPGA runs is much faster than the rate of the events.

 

I know how to send data from FPGA to RT side through FIFO's and write the data in RT and download it later. But in this method there is an issue of elements remaining.

 

Is there any way I can save/record the data from the FPGA directly to memory? Given the fact that I don't need it in RT, only need to download it later.

0 Kudos
Message 1 of 11
(3,016 Views)

I dont think I fully understand the question. So please excuse my answer if I misinterpret the problem.

The way I see it, you dont want to use the DMA fifo because the number of events can differ, so the amount of data in the FIFO isn't fixed.

 

If this is the only problem you can get around it by doing a FIFO.Read as you normally would, but wire in 0 into elements to read.

You will get no data back but you get a value out of the "Elements Remaining" output.

Now do another FIFO.read with this elements remaining from the first block wired into its "elements to read" terminal.

This way you will retrieve all of the elements present in the FIFO.

 

0xDEAD

 

 

0 Kudos
Message 2 of 11
(3,010 Views)

@0xDEAD: That trick is not working properly. I tried it before. I tried it now as well. There are still elements remaining.

0 Kudos
Message 3 of 11
(2,989 Views)

How do you know there are elements remaining? Is the value out of "elements remaining" in the second node not zero?

This can happen if there were more elements written on the FPGA in the time between the first and second call of the FIFO.Read.

 

Do you reach a point where you stop writing from the FPGA side?

If not, there are always going to be possiblilities of elements remaining.

 

What FPGA target are you using?

 

0xDEAD

0 Kudos
Message 4 of 11
(2,983 Views)

You can fill (local fpga) memory in one loop, and read it in another.

 

So the second loop can use a control to index into that memory and put he value of that memory address in an indicator. So one loop fills the memory, the other communicates the desired address value to the host. Only detail is the memory is filled, so you need to manage the pointers. One for writing, on for reading. And if the writing pointer catches up with the reading pointer, you have a problem...

 

Another scenario would be to fill in one loop, and read when done, using the same second loop. It's very simple and works really well. On the RT, simply wait till done, an increase the memory address, read the value, in a loop.

0 Kudos
Message 5 of 11
(2,971 Views)

The value out of the second node is zero sometimes then multiple of the number of data streams being transferred the other times. If I am transferring 5 data streams from the FPGA to RT side the elements remaining is multiple to that or may be some other number as well. Then it switches to zero next instant.

 

I was writing the data for 4-5 minutes. And this is happening every 4-5 seconds or sometimes every 1-2 minutes. The interval is not fixed.

 

The Target is cRIO-9039 (Kintex-7 325T FPGA).

 

 

0 Kudos
Message 6 of 11
(2,926 Views)

In that case I expect the cause is the reason I mentioned before (new data getting added to the FIFO at the FPGA end between the 1st and 2nd call to the FIFO.Read).

 

As long as the program stops filling the FIFO at some point (and signals that to you), you should be able to collect all of the data.

 

You have the option also for reading large blocks at a time through most of the program (for example FIFO.read for 2000 elements), then when the FPGA signals that no more data will come, you can grab the remaining elements using the method I mentioned earlier.

You can also keep track of the number of elements put into the FIFO on the FPGA side and use an IRQ to signal to the RT that for example 2000 elements are available.

 

I believe the wait on IRQ is a thread gobbler, but it was always giving me better benchmarks than polling for elements on the VxWorks cRIOs.

I haven't benchmarked it on a Linux one so cant comment on that.

 

0xDEAD

 

 

0 Kudos
Message 7 of 11
(2,919 Views)

In the title of the thread you say you want to use memory. Jet you seem to be using FIFO's and streams instead. Why did you ask "using memory method"?

0 Kudos
Message 8 of 11
(2,902 Views)

@wiebe: I wanted to know if write a data on some memory location at 25 kHz rate for couple minutes to couple hours, is it possible to download the data later. And how to do this without using FIFO's.

0 Kudos
Message 9 of 11
(2,890 Views)

@0xDEAD: Going for larger chunks of data at a time helps. But there is still some elements remaining, say once every 3-4 minutes.

 

I will try the IRQ method to notify that data needs to be collected on the RT side. That seems to be interesting. Thanks.

0 Kudos
Message 10 of 11
(2,886 Views)