LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DMA FIFO: RT Host reads really fast but still have element remaining

Hi All,

 

I'm reading data from FPGA using DMA FIFO.

In the FPGA side:  100 kHz

In the Host RT side: 1 MHz (I'm reading 10 times faster than the FPGA sending to make sure that I will not miss any data)

I set the timeout = 0 to advoid underflow error.

 

PROBLEM:

 - Eventhough I'm reading very fast, the element remaining is stil a non-zeros number (vary from around 1 - 12). And because of that, I'm losing data in the next statemachine.

 

I've attached the screenshot of my Host VI. The indicator: "buffer at wait" ranges from 0-12 when I ran it.

 

I appreciate any suggestions and ideas on what the problem is and how to solve it.

 

--Mindy--

undefined-

0 Kudos
Message 1 of 9
(4,368 Views)

Addition information:

 

When I ran the HOST RT, the CPU core is also occupied up to 90 -100 % too. Which I think it is not supposed to be.

And I'm pretty sure it was caused because of the DMA FIFO. But I'm not sure why.

 

Mindy

0 Kudos
Message 2 of 9
(4,363 Views)

Why are you only reading 1 sample at a time?  You should read more like 10 samples at a time (since the FPGA is 10x faster than the RT).

 

And since a DMA FIFO is a polling read, you will use 100% CPU while waiting for data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 9
(4,343 Views)

Does this even need to be done on RT? We don't see the rest of your code but what you have here could be easily done on the FPGA. If you need to be reading your inputs element by element and making decisions based on that, it sounds exactly like something that should be done on an FPGA.

 

It's pretty normal to have your elements remaining fluctuate a bit, as long as it remains relatively low and isn't continuously growing it's not usually a problem.

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 9
(4,326 Views)

You set the RT loop to run at 1 MHz, but does it actually work at that frequency? In my experience a DMA call (read or write) on the RT takes several us. Did you check the actual loop rate of the RT code?

I would also suggest lowering the RT loop rate but reading several elements at once.

 

 

0 Kudos
Message 5 of 9
(4,301 Views)

Hi crossrulz,

Thanks for your reply.

"Why are you only reading 1 sample at a time?" ==> Since there is a header check that need to be done to make sure that it is a "good packet" and the header is a few elements. Because if I read more than one element, I have to deal with the vector manipulation. I was just trying to advoid that because I thought I can read faster than the rate it is sending.

 

And Thanks for the information about the CPU, I didn't know that.

 

 

Mindy

0 Kudos
Message 6 of 9
(4,282 Views)

Hi Jacobson,

Thanks for your reply.

 

"Does this even need to be done on RT? We don't see the rest of your code but what you have here could be easily done on the FPGA. If you need to be reading your inputs element by element and making decisions based on that, it sounds exactly like something that should be done on an FPGA."

==> In my system, the FPGA is ready data from the RS 422 protocol. My task is the received it in the FPGA, and send data to the RT Host and Window host. I need the RT is because there are more than 1 FPGa that I need to use.  This task is to packetized the message.

The rest of my codes in the RT host are just case structure.

The FPGA code is just to send 8 bits  (aka 1  byte) if U8 at a time.

My VI is just to transmitt data from the sensor, store it somewhere (like a shared variable so everyone in the system can use it). I can packet them in the FPGA but when I send it to the RT, it will just be a bit stream, and then I have to compute the header check again.

 

Do you have better idea to do that?

 

Thanks Jacobson,

 

Mindy

0 Kudos
Message 7 of 9
(4,277 Views)

Hi dan,

Thanks for your reply,

 

"You set the RT loop to run at 1 MHz, but does it actually work at that frequency? In my experience a DMA call (read or write) on the RT takes several us. Did you check the actual loop rate of the RT code?"  ==> IS there a tool in Labview to check the actual loop rate?

 

"I would also suggest lowering the RT loop rate but reading several elements at once." ==> If I read in more than 1, I will have to deal with the array manipulation to find the header and to store the packet. I mean it is do-able but more complicated. If reading one element at a time didn't work, I will have to read more than one elements at once.

 

Thanks dan,

 

Mindy

0 Kudos
Message 8 of 9
(4,266 Views)

The timed loop already provides that information. Expand the "Output Node" on the left inside the timed loop (where you see "Error" now), and you'll get information about the loop iterations (like expected end, actual end, finished late, ...).

 

0 Kudos
Message 9 of 9
(4,260 Views)