LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about how to use myRIO DMA FIFO "Invoke Method" Read and Write

Hello,

 

I am working on learning myRIO FPGA, and I have gotten confused on reading / writing a DMA FIFO. I have been able to use the "VI - Defined FIFO" to read and write between loops on a Target FPGA, but I'm struggling with the array-based nature of reading / writing across a network.

 

When I say "array-based" nature, I am referring to the fact that the elements that I read from a DMA FIFO are arrays. My confusion arises from the fact that these are called FIFOs, so I thought that I would only be able to extract the "first-out", but it seems to me that I am able to extract a user-defined number of elements. I doubt that I have the correct idea here, but being able to write to a parameter called "Number of elements" makes me feel this way.

 

In addition, I have found that when I start a VI (in my case, an ultrasonic distance sensor), that the value read for the FIFO is the final value of the last session. When I abort the Host VI then restart it, the value extracted from the DMA FIFO is the final one, but it doesn't update over time like how using the "Read/Write Control" to read a value from an FPGA indicator updates. Is there a way for this to occur with the DMA FIFOs?

 

In a nutshell, I was wondering if there is a way for my DMA FIFOs to update in real time, or is that reserved for the "Read / Write Control"? I know that there is documentation out there to assist with me understanding this, but the light bulb has not yet went off for me through those methods, so I am seeing if someone here can explain it.

 

- Thank you, ExactPlace441

Download All
0 Kudos
Message 1 of 7
(465 Views)

Are you resetting the FPGA code and the FIFO?

0 Kudos
Message 2 of 7
(410 Views)

@ExactPlace441 wrote:

When I say "array-based" nature, I am referring to the fact that the elements that I read from a DMA FIFO are arrays. My confusion arises from the fact that these are called FIFOs, so I thought that I would only be able to extract the "first-out", but it seems to me that I am able to extract a user-defined number of elements. I doubt that I have the correct idea here, but being able to write to a parameter called "Number of elements" makes me feel this way.

 


A FIFO is a buffer of values that are stored as an "array". You can read single element out of the buffer but it will still be an array. Your single elements will be the first (and only) value in the array. You can also read multiple elements at a time which also returns an array. If you read multiple elements you will have an array of values in the order that they were written to the buffer. 

 

This is one way to read a buffer whenever there is data in the buffer.

Spoiler
ReadBuffer.png
0 Kudos
Message 3 of 7
(407 Views)

"In a nutshell, I was wondering if there is a way for my DMA FIFOs to update in real time, or is that reserved for the "Read / Write Control"?"

 

The answer to your question depends on what you expect to be updating.

  • The status of a FIFO, (i.e. number of elements in the FIFO) will update in real time. Every time you call a read node on a FIFO, it will operate on the most up to date status of the FIFO.
  • The data inside of a FIFO itself (u32 time of flight in your example) does not update in real time. An element written into a FIFO will not change while it is inside of the FIFO. 

 

It sounds like the behavior you desire is what is sometimes called a "tag value". This behavior is similar to an FPGA read/write control node where you simply read the latest value of a requested variable/control. If you simply want to get the latest value written into a FIFO, you should read all of the elements in the FIFO (adekruif posted a great example of how to do this) and then index the LAST element of the returned array to get your latest value. This is because FIFOs return elements in "First-In-First-Out" order. If you want the latest element, index the last value. 

<script type="text/javascript" async src="//cdn.youracclaim.com/assets/utilities/embed.js"></script>
0 Kudos
Message 4 of 7
(392 Views)

Thank you for your response, adekruif.

 

Your explanation and attached code help for me to understand the FIFO's functionality. I guess that I was getting confused about the "first-in-first-out" referring to the first value or the first collection of values. However, I see now that the first-in-first-out nature does not necessarily mean that what comes out has to be the first singular value. It can be one or more values, but these values came before other ones.

 

- Best regards, ExactPlace441

0 Kudos
Message 5 of 7
(360 Views)

Hello jprazak. Thank you for making this distinction between updating FIFO Status and Data. I had not considered that there would be a difference, but I am glad to know how they do differ.

 

I will use your and adekruif's method of the "tag value" to grab my desired data from the FIFO.

 

- Best regards, ExactPlace441

0 Kudos
Message 6 of 7
(358 Views)

Hello Intaris,

 

I have not been resetting the FPGA code or the FIFO, at least not directly. I had been Running and Stopping an RT Host. This RT Host Ran and Aborted the FPGA Target. However, I could play around with Resetting the values of the FIFO and of the FPGA, if this is what you are implying.

 

- Best regards, ExactPlace441

0 Kudos
Message 7 of 7
(355 Views)