LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FIFO with queues

I am trying to use the Analog data with queues. Queues are new for me, so I study some example for queues and develop my VI.

I applied the analog input with multi channel, producer consumer loop but the data is only available when the VI is stopped.

1.I wish to see the array output in real-time changing, continuously while running the VI.

2. I wish add some new elements within, user input data

0 Kudos
Message 1 of 11
(4,324 Views)

You have not set up your prodecer consumer correctly, your code is producing then looking at the queue after the acq loop is stoped.  The producer consumer is a design pattern for concurrent multithreaded applications.  Look at the template or examples to better understand this pattern.  Also you will want to use de-queue and if memory is a concern, you can use the lossy queue instead of rolling your own like you have in ther code you posted.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 11
(4,309 Views)

I tried to modify my VI, I think queues are difficult to understand.

I think I used Enque at the end and also tried to add lossy queue but still I am confused.

Please can you pass me some link or modification of my VI.

0 Kudos
Message 3 of 11
(4,292 Views)

Under new, select template->framework->Design Patterns->producer consumer design pattern (data)

Add your daq to the top loop is you have done in your example, the dequeue in the second loop is for your async processing/display.

 

You need parallel loops for this design pattern.

 

Show the help on the queue to understand it better, it is really for buffering data between loops with minimal coding.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 11
(4,283 Views)

Thank you, I used the logic you told.

1. I tried with it but some error is coming.

2. I tried with other design which seems better but some errors

Download All
0 Kudos
Message 5 of 11
(4,263 Views)

What errors?

 

It could be one of a million possible errors.  Should we guess?

 

Please tell us clearly what are the errors, providing error code numbers and messages.

 

Also, in queues-prod-cons, you aren't doing anything with any data being dequeued in the consumer loop.  And I don't understand the point of checking the Queue size against itself.  That should always be true.

0 Kudos
Message 6 of 11
(4,259 Views)

Sorry!

1. Producer and consumer VI show error 200088. Also stop is not working.

2. Queue test VI, there is no error ,actually does not show up the user input values in data removed array values.

I wish to attain FIFO concept with these VIs, as metined previously.

 

0 Kudos
Message 7 of 11
(4,252 Views)

Error -200088 is "Task specified is invalid or does not exist."  You should have seen that message when you got the error number.  I think it is pretty clearly telling you what is wrong.  Check that the task you called outin your Task control actually exists.

 

 

For #2, your method of not doing anything with the data coming from the dequeue element makes no sense.  But instead you seem to be doing something convoluted with the Queue Status function.  You are autoindexing out the data you get from that.  You are trying to use the Elements output, but you aren't going to get any elements.  You failed to wire up a connector in the Queue Status function.  I'll let you turn on context Help and look over Queue Status to see which one you are missing that would give you the data out of the Elements output.

 

Even once you do fix that, I still don't thing this VI will work for you.  You will have created a race condition between where it is very likely that any elements you enqueue will get dequeue in the consumer loop before the Queue status function ever has a chance to see them.

 

Don't use the queue status function.  And all of the array processing after the producer loop is odd.  You should be doing the array processing in the consumer loop which is doing absolutely nothing for you right now.

0 Kudos
Message 8 of 11
(4,240 Views)

See atached VI, I only spent 2 mins on it but it should show the pattern you are looking for, or at least a start

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 9 of 11
(4,236 Views)

I forgot to mention that you should handle errors in the producer to stop acq otherwise it will not be detected, thisd is not a complete solution (just in case the criticts want to tare apart this code, it is a toy example).

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 10 of 11
(4,234 Views)