From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9853 fifo overflow

Hi,

 

I have developed a CAN data logger.  I am using a cRIO 9024 and NI 9853 while sending dummy CAN messages from PCAN at 20 ms each.  Everything seems to work as desired until I start sending out more signals at which point the FIFO gets overflowed and the data stops being logged.  At the RT level I am asking for 0 elements so I can determine how many are remaining and then send those at a slower timeout than I have on the FPGA.  I suspect that I am logging at too slow of a rate compared to when it receives the data.  I have it set up to where it reads the frames, sends it to a for loop with iterations equal to the number of elements, determines the arb ID, sends that to a case structure, and then converts the frame to channels and outputs to an array.  After a sample and hold, the data is logged every 10th iteration.  It works fine for about 20 CAN signals.  What could I do to allow it to work with a much higher amount of signals? 

0 Kudos
Message 1 of 6
(2,670 Views)

Hi SRamirez,

 

It sounds like there is a bottleneck in your data communication architecture at the DMA FIFO read.

 

Are you processing the data (determining Arb ID and converting frames to arrays of channels) in the same for loop you are reading from the FIFO? 

 

Since we are not reading from DMA FIFO fast enough, I would recommend reading all available elements from the DMA FIFO and directly writing them to an RT FIFO to send the data to a parallel while loop that processes the frames one by one and converts them into channels. With a large enough buffer in your RT FIFO, you should be able to circumvent these problems. Additionally, parallelizing your code might help with your overall pipeline of logging the CAN frames.

 

There is an example that does something similar (ignoring waveform attributes) here:

https://decibel.ni.com/content/docs/DOC-4610

 

If I am not understanding your code correctly, please attach a screenshot of your RT code.

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 2 of 6
(2,643 Views)

I was able to fix the problem by placing the read FIFO in a seperate while loop from the convertion and logging.  I have the frames being sent to an array indicator which I then bring back to the other while loop with a local variable. The only question that comes to mind is whether or not this would cause me to lose data.

0 Kudos
Message 3 of 6
(2,637 Views)

Using a local variable, you probably will lose data since it can only hold one value at a time. You need to use something with a buffer to send the data from the acquisition loop to the processing and logging loop. I would recommend using a Single Process Shared Variable with RT FIFO enabled. This adds a buffer to the variable so that data points are not lost.

 

http://www.ni.com/white-paper/4679/en#toc2

Read section 2: "Single-Process Shared Variable" and read the instructions about how to enable the RT FIFO feature.

 

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 4 of 6
(2,624 Views)

Considering that I am using a sample and hold where in data is only logged every tenth iteration of the data logging loop, does it matter whether or not data is lost?  In otherwords, will using the Single Process Shared Variable with RT FIFO enabled negate my sample and hold by holding all of the data sent in the buffer and forcing it to log in a FIFO fashion?

0 Kudos
Message 5 of 6
(2,618 Views)

Whether losing data matters or not is up to you and your application.

 

If you only write every tenth data point to the FIFO, this data would then be losslessly transferred to the processing loop.

 

If you want to use a local variable (no FIFO): If you have the timing worked out perfectly for the local variable to be written to and then read from, it is possible this would work. You also will need to consider the possibility of the consumer (processing) loop reading from the local variable more often than it is written to, which will affect your data.

 

What sample rate are you acquiring at, and what sample rate do you want to record at? Why do you only need every tenth element if you are recording CAN frames?

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 6 of 6
(2,616 Views)