12-08-2020 10:53 AM
Hi,
I am trying to transfer analogue current data from NI9149 Crio chassis (module 9205) to PC. I am reading samples right now from 1 channel only. The sampling rate I can vary up to 250 KS/s. I am getting data on my PC side at the same rate for example 50kS/s if I use a sampling rate of 50kS/s.
On the PC side, I am using producer-consumer architecture to get and analyze my data. I am getting data in producer loop using DMA FIFO and then analyzing it in the consumer loop. In the analysis, I am trying to save the last 2 second data and at every second the old data goes out and new data comes in. I have a threshold value set on FPGA so when the threshold will reach the channel will close and I will have the last 2 sec data to analyze. The data transfer between the producer-consumer loop is done by queues.
The problem is that the consumer loop is running very slow as compare to producer loop. For example, to pick 50kS/s the producer loop takes 1 sec but consumer loop is taking to 12 sec and it increases with time.
I have attached my code.
12-09-2020 01:35 AM
Hi kazmi,
@kazmi12 wrote:
I have attached my code.
Whih is fine. It would be even better if you would attach the whole project including the lvproj file as it contains all the FPGA related definitions (like FIFO)!
@kazmi12 wrote:
On the PC side, I am using producer-consumer architecture to get and analyze my data. I am getting data in producer loop using DMA FIFO and then analyzing it in the consumer loop. In the analysis, I am trying to save the last 2 second data and at every second the old data goes out and new data comes in. I have a threshold value set on FPGA so when the threshold will reach the channel will close and I will have the last 2 sec data to analyze. The data transfer between the producer-consumer loop is done by queues.
Why do you try to read exactly 1000 samples from the FIFO when your FPGA can stop writing to the FIFO at any time?
Why do you wire a "1000" constant to the FOR loop in the producer loop? Don't you trust that autióindexing input tunnel?
Why do you wire the "i" terminal of the consumer loop to the FOR loop count input?
Why do you try to read 50k samples from the queue in the consumer loop in the inner FOR loop?
Why do you initialize that shift register in the consumer loop to hold 100k samples? (Samplerate=50kS/s)
When the outer FOR loop iterates 10 times you are already trying to read 500k samples in those stacked FOR loops!
There is so much unclear/buggy in the PC code you really should cleanup and document/comment the code much better…
12-09-2020 03:16 AM
Hi kazmi,
As GerdW pointed out, your PC-side code could be improved a little.
Some additional points that might help:
12-10-2020 12:28 PM
Thanks for the suggestions I will try to implement what both of you have mentioned and check the results