LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

any way to get 2 readings from while structure??.

Hi,
 
I have one while structure where I got readings from acquisition data. Each interation i recieve one value of one sensor. I would like to know if is possible get one couple of readings in array then send out of inner while structure. I know inside while structure I can read each value or read outside of while loop all the data generated inside.
I would like read inside of this while loop couple of figures. Since I need 2 values to do calculates before to show it. I have the problem, since with 1 value i can't calculate the correct values and showing in graph. And wait to pass all the data out of while loop is bad for me, i would like do it midle real time.
I try it, but i ddint get, i would like to hear if it is possible.
 
0 Kudos
Message 1 of 25
(3,280 Views)

From what i could understand, you want to use the data that is being generated/read inside a while loop, from outside the loop, even as the while loop is running

For this, try implementing the producer/consumer pattern or master slave patters

Hope this helps

Regards

Dev

 

0 Kudos
Message 2 of 25
(3,260 Views)

Hi all,

Well i didn't understand the problem exactly...

As someone talked before about that those structures can be a solution if that is the problem.

If u are making a data acquisition with a single point and u need 2 points... why dont u make 2 point acquisitions????

if you need the actual and previous values use shift registers in the while loop... you can add as many as you want to see previous data.. (just clicking right on the mouse and add element)... se example attached.

Don't know if any of those solutions solves your problem...

If not just say something and try to explain some more (examples, vi's ???) to let us understand better your problem,

Regards,

Jaime Cabrera

NI Applications Engineering Spain

Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Message 3 of 25
(3,255 Views)

devchander

Thanks for the links, will be very useful for me to learn more on labview programation.

Jaime

Thanks for your entry.

You are right. I am using while loop with serial port, so each iteration show one value of sensor. I could expect 2 readings on serial port while loop and use this data. I did that and it works. Right now I am using queues to get the data from while loop to another parallel while loop, in this I show the dials and anothers calculates, here is where I can show the graph using 2 values, which will give 1 sample to show in graph.

With your first advise, I got readings 16 bytes, instead 8. And each iteration of queue in parallel while I got 2 readings to work in it.

I put one capture, you can see the queue with 2 while loops, in this case I read 5 numbers each iteration.

With the second, i would like to see your example, but I can't since it is LV8.0, I am working on LV7.1. CAn you fit to previous version?.

I would like to use this case, so I could remember the last value and use to get the sample. But i Didnt get it. I use shift registers, but only show the array one time the while loop has finished. Show me in LV7.1 or any capture if it is possible.

Gracias por tu ayuda, yo también soy de España, concretamente de Cartagena.

0 Kudos
Message 4 of 25
(3,245 Views)
Hi Fonsi,

could you add some comments to your code?

I see the 'Array' this is only updated when you press cancel OR an error occurs
The second loop (consumer) will wait on items in the queue forever, use a timeout or send dummy data into it then the first loop has terminated
You can feed the array in "one" message just feed the 'acquire' queue with an array of I16's

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 5 of 25
(3,236 Views)

Hai

You can use two clusters ( NewData and OldData). Update the NewData Cluster with your typecasted output.

Use In second loop check the new data perform process and update with OldData Cluster.

You no need to use queue to get data, you can use a local variable or property node to get Cluster data.

So every time you will get a NewData Cluster and an Olddata Cluster to compare.

0 Kudos
Message 6 of 25
(3,236 Views)

Hi Tom, thanks for your help!

Well Keep in mind, this vi, really is subvi. I have main panel where I push bottom, then appear this window to acquire the data.

When I push start, begin the acquire data. In this case 8 bytes. 3 of 2 bytes and 2 1byte.

In this window i show the rpm and km/h reading from sensors. I used queues to get in real time each value and not slow the main while loop. The stop is so, since I stop the acquisition on 2 ways. First is pushing cancel, then the acquisition stop and all the data pass to `array' other way is when I push external bottom to stop the pic to sends, then the vi show the error in time outs in serial vi and therefore stop spent this time. After array is feed and this subvi is connect in main vi, which gets the full data, do calculates and show differents graphs. But on this system I only see the graph when the acquisition is finished. In this case works fine.

Now, I would like improve a little and show the graph drawing in real time. That's why I can get 2 values and get 1 sample. But I can't use the external array of dequeue. I am trying get the old value and put another subvi inside and draw the graph.

I dont understand your last advise.

I would like to hear any posibility.

0 Kudos
Message 7 of 25
(3,227 Views)

Hi Soundar,

It seems interesting. But i dont get very clear.

Can you show me any example??. Or any way to do it?.

Thanks.

0 Kudos
Message 8 of 25
(3,225 Views)

I added simplified vi.

 

0 Kudos
Message 9 of 25
(3,220 Views)

I have one problem trying to get it.

When i send the sample to draw in graph, I only got draw one point and later it it disappears. Any way the maintain all the points or better to connect all the samples in a curve???.

I attached one example to fit.

Thanks.

0 Kudos
Message 10 of 25
(3,192 Views)