LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to grab value on command and keep it available?

This should be obvious but I don't see it!
 
I want to grab a value on a wire whenever the user presses a button, and hold that value for use at any time.
 
So for instance I can rezero an instrument when the user presses the button, by grabbing the instrument output at that time, and by displaying the difference between current instrument output and the grabbed value.
 
I tried wiring the output of a select node back to one of its inputs to hold the value, and connecting the wire to be grabbed from to the other input, and tying the button momentary output to the control input on the node, but it doesn't like having its output fed back.
 
Thanks!
0 Kudos
Message 1 of 8
(4,000 Views)
Use a shift register in a while loop.

Lynn
0 Kudos
Message 2 of 8
(3,993 Views)
For details, do a search on the forum for the word "tare". Different application - same concept.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 8
(3,981 Views)

Thanks, but I'm still not getting it.

I don't already have a while loop. I tried adding one just to hold the value, but after some debugging with another LabVIEW programmer found that the wires inside the loop keep updating their values when the loop does not run, and maintain their values when the loop does run, which is the reverse of what we expect. In any case, I don't want my measurement, which feeds the wire with the value I want to grab, to keep running repetitively - I only want to measure on command (including whenever a "tare" is needed).

The only "tare" demo I found in a search failed to run on my machine due to version imcompatibilities.

Maybe I can break it down more simply:

1) How do I copy a numeric data value from one location in memory to another location?

2) How do I run a block of code on command?

Then I can copy the value of the measurement to someplace in memory, at a time of my choosing.

These both seem like very simple tasks for a computer but I haven't figured out how to do either in LabVIEW. Can anybody help the clueless?

0 Kudos
Message 4 of 8
(3,959 Views)
First of all your questions betray a basic lack of understanding of how LV works. For example, in LV you don't copy data from one memory location to another. And if you don't know how to run a VI you apparently haven't completed the first exercise. I would suggest that you take some time going through the "Getting Started" materials that come with LV and perhaps take a class.

Second when you do have code that you have specific questions about, post the code so we can comment on it.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 8
(3,954 Views)

There are some on-line tutorials at http://www.ni.com/academic/lv_training/how_learn_lv.htm.

You say you don't have a while loop but without a while loop, how can you be checking to see whether a button has been clicked? Do not run your VI with the run continuous button on the toolbar!

0 Kudos
Message 6 of 8
(3,942 Views)

Mike, I think I irritated you, and I'm sorry. I have a big machine I programmed years ago in Forth and Assembly, and am reworking it in LabVIEW to be more in step with the rest of the world, but am finding it surprisingly hard and a little intimidating. Many things that were easy before still look hard or impossible, at least at first. I'm irritated at how difficult some things seem, and I let the post show it, so - I appologize!

>First of all your questions betray a basic lack of understanding of how LV works. For example, in LV you don't copy data from one memory location to another.

It's true, I don't have a basic understanding of how LV works. I hear about dataflow, and gather that implicitly this is trying to make a stack-oriented system map to our human ability to navigate through physical spaces, whereas systems that use more named variables are using our language abilities instead. I bet you do, though, copy data from one memory location to another, whether it's apparent or not, whether you use names and assignment statements or not. I think to tare a gage you must copy the present value to someplace for storage. I have stopped looking for the "copy" node, but still have to accomplish the same effect, and have to do so at an arbitrarily specified time.

>And if you don't know how to run a VI you apparently haven't completed the first exercise.

I know how to run some VI's. Somebody else's VI that gives a version compatibility error, no, I don't know how to run that, not without digging into it further. Which I will do. Feel free to ignore this thread until I report back on that. Or longer, of course.

>I would suggest that you take some time going through the "Getting Started" materials that come with LV and perhaps take a class.

Yes. I went through a bunch of "Getting Started" materials, wrote and ran a hundred or so VI's, and took a week of classes from NI. But there still seem to be big pieces missing.

>Second when you do have code that you have specific questions about, post the code so we can comment on it.

OK, here are two VI's that work together: AnalogInstrument01 has a measurement that I now offset with the constant "53.5". Tester01 sets up a task and executes a loop containing AnalogInstrument01, passing that task into it and getting values of the scaled and offset measurement returned to it. In my project I will have other bigger VIs like Tester01, running an asynchronous loop containing AnalogInstrument01 plus others like it. Some are counters that may not miss a beat. Some take varying time to execute. I must maintain one to one correspondence between all the measurement events within that loop. I am pretty sure it would compromise the goodness of data that my system generates to move away from this asynchronous calling loop strategy.

I want to be able to readjust the offset instead of using 53.5 all the time. However, when it's tared, it should appear similarly tared, and behave the same way, to any VI that calls it. Therefore I think this tare should be part of the AnalogInstrument VI and not part of the other parent VIs that call it. However, the instrument must be ready for on-demand reading by a parent asynchronous loop, therefore (I think) not having its own while loop. Can somebody suggest a way of grabbing and holding the value here?

It's obvious how to do it if you can have the loop in the same VI as the tare value. You just pass the tare value around in the shift register for that loop. I added that example as AllOneHasTare01, which reads and tares just fine. Only problem is you can't call it from another asynchronous loop because its own loop keeps it busy.

To be more clear about what I think I need, you can imagine doing this in an object oriented text language instead, say C++. You'd create a Measurement class with a tare method. The constructor would load a private tare field with zero at object instantiation. There's be a tare method that copies the output of the measure function into the tare field. There'd also be a measure method that returns the difference between a fresh raw measurement and the tare field value. Then another class like Tester would own an instance of Measurement and would call the measure function from inside its loop. This sounds easy - but how would I do it in LabVIEW?

Download All
0 Kudos
Message 7 of 8
(3,934 Views)

Hi, Chris

After answering your other post, I found this one which seems unresolved.

I think what you are after is what we call a Functional Global.  It's a VI that stores values in an uninitialized shift register.  You can either read the current value of it or write a new value based on the Operation input.  This is one of the best ways to store data which is being used in multiple asynchronous loops and similar situations.

Let me know if this makes sense...there are a lot of docs that describe functional globals, also called LV 2 style globals.

Download All
0 Kudos
Message 8 of 8
(3,871 Views)