Jump to content

Passing Data Out of a while loop


Recommended Posts

I've created a labview VI that allows me to parse information from a data string. This prcess uses a while loop to read the string, parse the data, and display the parsed data and update on a continuous basis. But I do not only need to display the data but also save it to a file fo later analysis. Unfortunately, I can't just save it all in one big file or else I would just build an aray within the loop and pass it out upon completion. I need to save the data in a sequence of seperate files, so that if something goes wrong I won't loose ALL the data. Besides I would rather work with smaller chucks of data than one big file. I would like to pass data out of the while loop after EACH iteration into a seperate data logging process( for loop within a seperate while loop to build an array to pass to a file save). Is there a way in labview to do this?

Link to comment

Salut.

You could use a notifier, a queue, a global or local variable or directly to the file by happending the data at each iteration...i advise you to search for those words in the LabVIEW help...for the direct to file, you can look at examples...search for "Write Datalog File Example.vi"....

Link to comment
Salut.

You could use a notifier, a queue, a global or local variable or directly to the file by happending the data at each iteration...i advise you to search for those words in the LabVIEW help...for the direct to file, you can look at examples...search for "Write Datalog File Example.vi"....

Thank you for your suggestions. I'll look them up immediately and let you know how it turned out. I've been banging my head for weeks. I can display the data beautifully. I just can't seem to log it correctly

Link to comment

If you did not go trough the entire help doc on globals, here is some advice on the subject :

- Every global in read mode creates a copy of the data in memory

- you can lose data if you write at 2 different places in the code before reading (race condition)

- they make the code harder to follow (no wires to follow)

- If you plan on using a global in many places, consider making all the global operations in one VI that you use everywhere, this will always keep the data to one copy in memory.

Link to comment
If you did not go trough the entire help doc on globals, here is some advice on the subject :

Thanks Jacemdom,

I was wondering about the read and write timing. But luckily most of my need for globals are only going to be used to logg the latest readings. But I do have one question about using only one Global Vi for all globals. Is there a chance of conflicts if a parallel VI attempt to read from the Global while another is writing to it?

Link to comment

You might also want to look in the examples for Queued Message Logging, see:

C:\Program Files\National Instruments\LabVIEW 7.1\examples\general\queue.llb\Queue Message Logging.vi

If you look this up with the example finder you'll get a couple more VIs open, or just look through the library above. With a little tweaking you can have the logger change file names based on various criteria. I've done this a couple different ways, like sensing when you pass midnight, close the old file and open a new log file with today's date. Etc.

Link to comment

I think this example show all too obvious why dataflow is not exactly rocket science in terms of compiler technology/programming paradigm. In my first larger project i was wondering about the exact same thing. I had one loop for logging and one loop for several PID controllers. The PID loop was run at a much slower rate than the logging, but at a steady rate independent of the logging loop which would change rate according to user specifications. I also ended up with using global variables, even though the manuals also back then said "use globals only when neccesary because they are inefficient and will break the data flow" or something like that + "dataflow make parallell operations easy and fool proof".

1. You cannot pass data out of a loop without breaking the dataflow.

2. The only way to run in parallel is to break the dataflow.

So that dataflow really makes parallel operations easy and straight forward is some big myth IMHO. Dataflow just as often prevent parallel operation where parallel operation are the only natural thing to do. With queues, goop, lcod etc all this is now more or less an academic discussion, except for newecomers to labview, and it is therefore a bit strange that NI still advocated that dataflow is THE big thing for parallel programming.

:beer: :)

Link to comment
I think this example show all too obvious why dataflow is not exactly rocket science in terms of compiler technology/programming paradigm. In my first larger project i was wondering about the exact same thing. I had one loop for logging and one loop for several PID controllers. The PID loop was run at a much slower rate than the logging, but at a steady rate independent of the logging loop which would change rate according to user specifications. I also ended up with using global variables, even though the manuals also back then said "use globals only when neccesary because they are inefficient and will break the data flow" or something like that + "dataflow make parallell operations easy and fool proof".

1. You cannot pass data out of a loop without breaking the dataflow.

2. The only way to run in parallel is to break the dataflow.

So that dataflow really makes parallel operations easy and straight forward is some big myth IMHO. Dataflow just as often prevent parallel operation where parallel operation are the only natural thing to do. With queues, goop, lcod etc all this is now more or less an academic discussion, except for newecomers to labview, and it is therefore a bit strange that NI still advocated that dataflow is THE big thing for parallel programming.

:beer: :)

simple parallel dataflow...

post-731-1157060429.jpg?width=400

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.