cancel
Showing results for 
Search instead for 
Did you mean: 

Get # elements in RT FIFO without affecting it

sgregor249
Member

Get # elements in RT FIFO without affecting it

My goal is to get the number of elements in an RT FIFO without changing the FIFO. I see that the RT FIFO read and RT FIFO write VIs return the number of elements in the RT FIFO, but calling these VIs will either remove or add an element from the FIFO. Does anyone know of a workaround for this? The only thing I've been able to think of is to typecast the RT FIFO Refnum to a regular Queue Refnum and use the the Get Queue Status VI to get the nubmer of elements, but this does not work. I've also tried to convert type using variants and flattened strings to no success.

7 REPLIES 7
Highlighted

Re: Get # elements in RT FIFO without affecting it

You can create a shift register with the number of elements and update it each time you read or write to the FIFO
Rodrigo Cuenca
www.cidesi.com

sgregor249
Member

Re: Get # elements in RT FIFO without affecting it

I'm going to be obtaining the RT FIFO in a separate VI from where it's created and I want to monitor the number of elements in it. I would run the separate VI after the original has been running, so modifying the code of the VI that does the RT FIFO Read/Write is out of the pictutre

WillD
Member

Re: Get # elements in RT FIFO without affecting it

If you are reading the FIFO in the RT host you can read 0 elements with 0 timeout and effectively poll the FIFO for the number elements remaining.  If you are writing to the FIFO in the RT host you can write a null valued array with 0 timeout to the FIFO and poll the empty elements remaining.
sgregor249
Member

Re: Get # elements in RT FIFO without affecting it

How do i tell the RT FIFO Read VI to read 0 elements? The only inputs are the FIFO refnum, timeout, error, and element which is the deafult value to return if the FIFO is empty.
WillD
Member

Re: Get # elements in RT FIFO without affecting it

Message contains an image

I am showing number of elements as an input to the FPGA method as well:

fiforead.png

 

Edit:

... unless I misunderstood and this is just a FIFO that ison the RT host, and not a DMA FIFO to an FPGA.

Message Edited by WillD on 04-15-2010 11:14 AM
sgregor249
Member

Re: Get # elements in RT FIFO without affecting it

Message contains an image

I'm using the RT FIFO VIs, not the FPGA VIs.

RT FIFO.png

 

 

Message Edited by sgregor249 on 04-15-2010 11:54 AM
GoCougs
NI Employee (retired)

Re: Get # elements in RT FIFO without affecting it

Message contains a hyperlink

There isn't the functionallity within the RT FIFO.  You can use a normal LabVIEW queue on a real-time system, it just won't guarantee determinism.  If you need to know the number of elements in an RT FIFO, you can follow this KB for more information.

 

http://digital.ni.com/public.nsf/allkb/42E85A333767918B862570D800667FD8?OpenDocument

National Instruments
Applications Engineer