LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Riddle me this LabVIEW users -- losing data?

Solved!
Go to solution

I am reading data arrays that may be different sizes and adding them to a queue. In a parallel loop I am dequeing these arrays and using replace array subset and inserting them into a predefined array. I have a counter to keep track of the number of elements I have added so I know which index to replace at. Only thing is, it seems data is missing. I get all 204800 points for 1 second of acquisition (4 channels 51.2 kHz sampling) in my top loop, but data is missing in the parallel loop. Is there something in my method that is wrong? I will say the "index" value in the attached picture is 51198 for this example but sometimes it is 51196 or 52000 (52000 is what it should be as I'm taking data at 52 kHz). There is no consistency.

 

Please see picture it will explain more easily than I can 🙂

 

 

Message 1 of 6
(2,920 Views)

Could you reduce it to a simulation with random data (that still shows the problem) and attach the VI?

0 Kudos
Message 2 of 6
(2,891 Views)
Solution
Accepted by topic author GregFreeman

My money is on the "Decimate 1D Array" eating data. You must ensure in the FPGA read loop that only array lengths of multiples of 4 are being written to the queue, or (better method) in the consumer loop process the array in multiples of 4.

 

Run highlight execute on the following snippet and see what I mean:

 

DecimateEatsData.png

Message 3 of 6
(2,887 Views)
I believe you are right on jack. Notice I read whatever is currently in the buffer. That could be a varying number of elements thus causing the situation in your example. I'll change my read to be a fixed number and, assuming that fixes the problem, mark your solution
0 Kudos
Message 4 of 6
(2,873 Views)

I am sure Jack found the most likely problem. (Of course we need to assume that the chunks are not always multiples of four, which is of course not obvoius from the picture).

 

For a detailed related discussion, have a look at this old thread. 😄

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

@altenbach wrote:

(Of course we need to assume that the chunks are not always multiples of four, which is of course not obvoius from the picture).

 


 

This was my fault here; I should have clarified but just made an assumption everyone would know. With FPGA FIFOs, on the FPGA side you can only queue up single elements, but on the host side you read chunks in arrays. So, the common technique and what I am doing is you build an array in a known order then use an autoindexing for loop to queue up the single elements in that order. Then on the host side, you can use decimate array to get channel 1, channel 2, channel 3 and channel 4. However, the technique I'm using to read is do a read of 0 elements, get the number of elements remaining then read the whole buffer. The problem, as Jack said, is that what if that autoindexing for loop queueing up the elements has only queued up 3 of the 4, or 1021 of  the 1024 (or whatever the case may be) when I do the read? And therein lies the problem :).

0 Kudos
Message 6 of 6
(2,825 Views)