LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using queue for real time signal processing

hello

my task is to Acquire data from serial COMM and plot it at real time after achieving this now I want to process that acquired data ( lowpass/Bandpass Filtering)

and further display on waveform chart as real time signal processing.

I have already tried by directly wiring filter block in the same loop but it slows down my acuiqsition speed.

After going through queue (producer and cosumer) examples , I have included queue in my loop but no use still after sometime the displaying speed of waveform chart slows down and it looses real time display.

Is there another way to use queue for my purpose..?

Or I am doing something wrong. Please Suggest.

here is VI

 

0 Kudos
Message 1 of 10
(3,796 Views)

You are building an array indefinitely in the Dequeue loop.  This will require memory re-allocation as the array grows.  This is probably what is slowing your VI.  Search the Froums for many posts on how to better manage the memory.

 

How do you stop the upper loop? Nothing in the program appears to force an error in the VISA Read.

 

Lynn

0 Kudos
Message 2 of 10
(3,792 Views)

There is one confusing point in my mind , that if queue is holding data then how it can be used in real time signal.

I have studied queue basic example i got that how queue is used but still confused about real time relation with queue.

 

0 Kudos
Message 3 of 10
(3,785 Views)

Along with Lynn's points above, I have two more suggestions. Notice that you have an uninitialized shift register on your bottom loop. This means that until the VI leaves memory, it will retain the values from the last time your program was run. So, if your array has a million points in it and your program stops, but then you start it again without the VI being closed first, your array will still have 1 million points in it! You should initialize yoru shift register with an empty array (right click the SR-> create -> constant).

 

Next, there is no reason to have a dequeue speed. If you set your dequeue speed to be slower than your enqueue speed, your queue will back up. Think of it like a line at a cash register (i.e. a queue). If one person is checking out (being dequeued) every one minute, but 2 people are getting in line (being enqueued) every minute, your line will keep getting longer and longer (run out of memory eventually). Just let your top loop manage the enqueue speed, and let the dequeue loop consume at the rate it wants to. No timing necessary, because the dequeue VI has a timeout of -1. Therefore, it will run when it gets an element in the queue, or will sit idle if an element is not there.

 

That's my two cents. May not solve your problem, but those are a couple things to think about.

 

Edit: One more thought. You are updating your waveform chart on every loop iteration. About how many points are you plotting on the chart? Sometimes things can slow down dramatically when you get too many points on a chart and continue trying to add points. What is your chart buffer size?

0 Kudos
Message 4 of 10
(3,781 Views)

Okay I got your points and added empty array constant .

Chart history Lenght is 6000.

I am using array for filter block because it take input in array format and i think this is the main thing which slows down my VI speed

I have checked that when array size becomes 50,000 after that my acquire and procees display becomes desynchronize.

Is there any alternate way.

Or If It is porssible to clear array after specifier size have been achived.

Please give me some idea because I have to processe two more channels.

 

0 Kudos
Message 5 of 10
(3,775 Views)

Please guys give me some suggestions how to overcome this problem , just want to process two column signal in real timeSmiley Sad

0 Kudos
Message 6 of 10
(3,771 Views)

Not only is it possible, it's recommended to have a fixed buffer size that's is overwritten in order to avoid exactly what you're seeing. Here is an example. I put it in a picture so you have to actually code it up. It will force you to understand what's going on by doing so. Also, this shouldn't be seen as two separate loops, I just copied and pasted so you coudl see the true and false cases.

 

0 Kudos
Message 7 of 10
(3,762 Views)

hi thanks for(imstuck) for the help..

and sorry for late reply actually i was stuck , between initialize and build array blocks .. 🙂

this loop solves my slow response problem but when I am connecting the array (array send to filter)  with my butterworth filter it is giving filtered array in 0.00000 values on the other side if I am using build array and shift register as in my previous posts and putting that array into filter then filter response is good enough ..

I have noticed that when I am using Initialize array block with filter it is not giving me right response but build array give good one.

Whats the problem

Thank you

0 Kudos
Message 8 of 10
(3,724 Views)

I think we will need to see some code.  The images posted by for(imstuck) represent code which should work.  How are you using that code? As a subVI? If so, How are you stopping it?

 

Please post your VI, preferably with some data saved as default so we can see what is going on.

 

Lynn

0 Kudos
Message 9 of 10
(3,715 Views)

Hello C3-C4,

 

I am trying to understand why you are filtering an entire array of data, but then only plotting the last point in the filtered array onto a waveform chart.  In this scenario, the waveform chart will not accurately portray the filtered data because each plotted point does not include subsequent data from the array.  In order to accurately display your entire filtered set of data I would recommend not indexing your array with the iteration count and just plot the entire array to a waveform graph.  

 

Also, instead of converting your entire array of integers into doubles every consumer loop, it would be better to use a numeric conversion to transform the serial read integer data to a double before feeding it into the queue.  To do this go to the Programming Pallet, choose Numeric->Conversion->To Double Precision Float and wire this between your serial output and enqueue element.  Hopefully this will speed up the consumer loop and keep the real time display sychronized.

 

Good luck,

 

Brian

Brian G.
Message 10 of 10
(3,693 Views)