From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Still learning LabView - How do I go about this?

Hi all - I have an array of linear displacement transducers that I'd like to sample.  I have them hooked up using the DAQAssist, and can sample, average, and display the values in a while loop.  What I'd like to do is the following:
 
First, I'd like to have two buttons.  The first is a "sample" button that, when pressed, will read the values for some time and display the value (just like the I've already accomplished, just for a set period of time).  The second is a "calibrate" button, which will again sample, but then store the current value as an offset, in effect rendering the displayed result as zero.  (The sample button will then subtract this value from the live values to come up with the actual displacement)
 
My problem is that I'm not sure how to go about hooking up the buttons to the loop - is there even a loop to deal with in this scenario?  I've been reading the "Learning Labview" sections I've found on the web but nothing relates enough to what I'm after. 
 
Where do I start?
 
Thanks in advance.
 
Mike
0 Kudos
Message 1 of 11
(3,217 Views)
Seems like a while loop containing an event structure to handle the button presses. Although I would add a second while loop to read the data continiously are for a set period of time.
Regards,
André (CLA, CLED)
0 Kudos
Message 2 of 11
(3,198 Views)
Look under File, select New > From Template > and have a look at the Event Structures. 
They are templates ready for you to populate.
 
Also look under Help > Find Examples and do a search on Event Structures.
 
Further to above is to do a search within this forum and enter "Event Structure" for the search keyword.
 
After exploring the above, start coding your solution.  If you have problems, post your questions to this thread and we can try to help you.
 
RayR
0 Kudos
Message 3 of 11
(3,167 Views)
Thanks for the suggestions.  I've found an example called "Using Buttons to Initiate Actions" and that was helpful, but also very confusing.  I'm an OO programmer, and am used to developing function calls and the like.  I can't seem to make the leap to the Labview way of programming. For my example, I'd like to use that button to go do some function - Go out, sample for some amount of time, average the results, store the values, and then be done.  When the user pushes a second button, I'd like it to go out, sample the values again, subtract the saved values from the other button, and then display the result.  I'm not even sure what to look at next.  Can I turn a while loop off and on somehow? I'm confused.  Do I need one while loop with 16 registers to store the values for me?  And then a seperate while loop to go off and do the sampling?
 
Any help would be greatly appreciated.
 
Thanks,
Mike
0 Kudos
Message 4 of 11
(3,129 Views)
Lesson # 1:  The wire is the variable.  You've probably figured that by now.
 
Labview uses dataflow model, and will execute parts of the code as soon as the data is available for it to execute. 
 
If you are familiar with state charts, then it is a good means to design your code.  Implementation is nearly a 1 to 1 relationship.
 
You amost have to forget your text-based language approach to programming.  Logic is the same.
 
And you learn by doing .... and looking at the forum 😉
 
RayR
0 Kudos
Message 5 of 11
(3,113 Views)

The wire is the variable? What does that mean? And I am doing - I'm spending a lot of time on this, trying to figure it out by myself.  It's not working.  The only other labview stuff I've done has been for "live" data acquisition stuff, which I just threw in a loop and everything was great. 

I guess I'm still waiting for answers to my questions to get me to the next challenge 😉

Mike

0 Kudos
Message 6 of 11
(3,094 Views)

LOL!  Yes... it may be shocking at first, but instead of having variables as in text-based languages, Labview uses a wire. 

The Locals & Globals are not to be used in the same way as text-based languages either.  Nor is the Sequence Structures.. They provide a somewhat similar ... hum... euh.... well... I don't want to use the word "environment".. because it's not.. well..  it provides something similar to text-based languages, but it's not..

So passing values is done using a wire.  Functions are actually vi's which can be run as stand-alone.  Subroutines are vi's (sub-vi's) configured as such.  They tpically clone themselves..  Maybe we shouldn't go there yet 😉  😮

For now....  think of wires as variables.  Every wire is a variable holding the value for that variable within the length of that wire.   

Hope I didn't confuse you too much 🙂  LOL!

It gets easier from there 😉

0 Kudos
Message 7 of 11
(3,085 Views)

Ok, here's where I'm at.  I have my vi working, mostly.  I would like to do the following and am a little stuck. When I hit "Configure", I would like it to zero out the text boxes.  So I moved the text boxes out of the case statement, thinking that would mean I could use them in all the cases.   Well that just means I have to wire up what happens to them for each case - I can't just let them alone for the other cases.  So how do I get that done?

The other thing I'm trying to do is write the values to a comma-seperated file when I hit "save".  I'm trying to build an array to save, but I can't grab the values out of the textboxes - something about the tunnels going the wrong way? 

I'm attaching my vi for clarity.

Also, if I'm doing anything bone-headed, I'd LOVE some suggestions on how to clean it up.

Thanks in advance!

Mike

0 Kudos
Message 8 of 11
(3,023 Views)

A couple things.

1.  Make sure you have all of your tunnels wired up and all the VI's and other functions have all of their required inputs wired up.  There are several errors on the broken Run error relating to this.

2.  Why are you converting an array to a matrix?

3.  As for backwards tunnels, it sounds like you are trying to go from the wires going to the indicators (which come from the case structure) and sending them back into the same case structure.  It can't be done.  You may either want to store the values of the indicators in a shift register, which would make them available on the next loop iteration.  Or use a local variable of the indicator to read the current value of the indicator inside the case structure.  This isn't usually a recommended practice, but can be done if you are careful about race conditions and the way you use the local variables.

Since it sounds like you are new to LabVIEW, I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 9 of 11
(2,990 Views)

Thanks for the reply. 

1. I do know that there are build errors, that's why I'm posting 🙂  I don't know how to accomplish what I'm trying to do!  I don't know how to wire up all the tunnels appropriately.

2. I'm doing that because that let me use the split signal object to get them back out.  I couldn't find a split array object that would give me more than one channel at a time.

3. So does that mean I need 16 shift registers?  Or should I do something like what I'm doing on the other case and put it in an array?  Should the indicators be inside the case structure?

I sort of have the same problem trying to wire up the save to disk - I need to get those 16 values back out when they hit "save".

Thanks,

Mike

0 Kudos
Message 10 of 11
(2,971 Views)