LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to downsample a 2D array?

Solved!
Go to solution

I have a loop that I need to run at 100hz to collect continuous analog data from multiple channels but I want to write that data at ~0.1hz. How do I go about discarding the extra data?

0 Kudos
Message 1 of 7
(331 Views)

Define "write". Write to file?

Does the loop run at 100Hz or is the data rate 100Hz? (how many point per iterations per channel).

Is this on windows or LabVIEW RT?

What kind of downsampling? (drop most points? Average adjacent points? etc.)

What is your program architecture?

 

We can typically give specific advice once we see a simplified version of your VI.

 

0 Kudos
Message 2 of 7
(311 Views)

Thanks for the response. I've been trying dozens of different solutions but they all seem to just break my program and I don't have the familiarity to know what the issue is. If there's a different solution like a producer/consumer loop running at different rates I'm open to other options. 

 

Define "write". Write to file? - Yes, write to file.

Does the loop run at 100Hz or is the data rate 100Hz? (how many point per iterations per channel). - The loop runs at 100Hz. The data rate is 60Hz but I have a cycle counting portion that misses cycles if I slow the loop so I'm stuck with a rate that's much faster than the rate I want to collect data at.

Is this on windows or LabVIEW RT? - I'm not sure what this is.

What kind of downsampling? (drop most points? Average adjacent points? etc.) - Drop most points. I need to keep track of the cycle count so it doesn't make sense to average that. 

What is your program architecture? - attached

 

0 Kudos
Message 3 of 7
(286 Views)

Your data gets only written to the file after the while loop terminates, so just decimate right before saving, inside the case structure where the saving happens.

 

Of course the entire code is a bit clumsy. Don't you want hardware timed acquisition independent of the loop rate?

 

.

0 Kudos
Message 4 of 7
(270 Views)

My question is how do I decimate? 

rdobro_0-1757451775785.png

I got this working using "decimate 1D array" which sort of works, but it doesn't have an input for "n" elements so I'd have to drag it down or chain them together to get a large reduction. Is there a more elegant way to do this?

 

"Of course the entire code is a bit clumsy. Don't you want hardware timed acquisition independent of the loop rate?"

 

Sorry, I'm completely new to this and am prioritizing getting it functional to begin with even if the code is very clunky. What do you mean by hardware independent of loop rate? The 60Hz for the hardware and 100Hz for the loop? I'm having issues with the hardware missing signals when I have multiple inputs connected so I was trying to test lower hardware sample rates to see if that would help. The DAQ module I'm using says it can read 500 samples/second so I though maybe reducing the sample rate to keep it under 500Hz would help (6 channels at 60Hz should only be 360 samples/second). Unfortunately it didn't work, but that's what the different rates are from. 

0 Kudos
Message 5 of 7
(259 Views)

@rdobro wrote:

My question is how do I decimate? 

rdobro_0-1757451775785.png

I got this working using "decimate 1D array" which sort of works, but it doesn't have an input for "n" elements so I'd have to drag it down or chain them together to get a large reduction. Is there a more elegant way to do this?

 


Of course the down-sampling goes after the while loop, because it only needs to be done once. Just transpose, use a FOR loop, and do conditional indexing for a suitable multiple of [i], then transpose again.

0 Kudos
Message 6 of 7
(238 Views)
Solution
Accepted by rdobro

@altenbach wrote:
Of course the down-sampling goes after the while loop, because it only needs to be done once. Just transpose, use a FOR loop, and do conditional indexing for a suitable multiple of [i], then transpose again.

Quick draft that should give you some ideas...

 

altenbach_0-1757464348888.png

 

Message 7 of 7
(227 Views)