Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   How do i find a variable and use it on Labview (http://www.chiefdelphi.com/forums/showthread.php?t=72447)

Chris11246 19-01-2009 17:02

How do i find a variable and use it on Labview
 
Im trying to get a variable on Labview that has an input and an output but i cant find one. Ive found local and global variables but then how do i use them.

Booksy 19-01-2009 17:10

Re: How do i find a variable and use it on Labview
 
I seem to be in the same predicament as you... I get the variables, but wiring anything to them gives broken wires. I think I have only found input variables.

FYI, the variables that I am talking about are in the programming menu.

EDIT: http://zone.ni.com/devzone/cda/tut/p/id/7585 - Looks like "change to read" is what you (I) want.

Russ Beavis 19-01-2009 17:27

Re: How do i find a variable and use it on Labview
 
Chris,
After you create a control or indicator on the front panel (or right-click on a subVI or function and select "create control" or "create indicator" which does this for you automatically), you can create local variables for accessing it by right-clicking on its icon in the block diagram and selecting "create local variable". If you use the "finger" tool on a local variable, you can change what variable is attached by selecting from all variables in the VI.

Russ

Chris11246 19-01-2009 17:32

Re: How do i find a variable and use it on Labview
 
Thats just a local variable i know how to find them but how do i use one to input and output values.

Russ Beavis 19-01-2009 17:34

Re: How do i find a variable and use it on Labview
 
Do what Booksy says - right-click and "change to read" or "change to write" to set it to an indicator/control (aka output/input).

When in doubt, right-click. It unlocks "everything".

Russ

Chris11246 20-01-2009 15:20

Re: How do i find a variable and use it on Labview
 
Yes but i want something that doest both at once that just lets it either read or write. Is there some way to connect a read variable and a write variable

Booksy 20-01-2009 15:22

Re: How do i find a variable and use it on Labview
 
Quote:

Originally Posted by Chris11246 (Post 804494)
Yes but i want something that doest both at once that just lets it either read or write. Is there some way to connect a read variable and a write variable

why not make 2?

jmanela 20-01-2009 15:31

Re: How do i find a variable and use it on Labview
 
check whether the value is boolean or numeric, and make sure it wires to the corresponding input.

Chris11246 20-01-2009 15:31

Re: How do i find a variable and use it on Labview
 
Yes but will those be connected. I want one value that will be changed by the joystick value and then will change the motor speed not two values. (Im not using the Crio stuff for testing so i cant use get motor speed or set motor speed)

Russ Beavis 20-01-2009 15:58

Re: How do i find a variable and use it on Labview
 
1 Attachment(s)
Any wire in LabVIEW can be read from but can only be written to by a single output.

You can create as many local variables (either read or write variety) for the same "physical" variable. You can have many outputs "simultaneously" writing to the same "physical" variable via many local variables (see attached).

Russ

BLAQmx 20-01-2009 16:01

Re: How do i find a variable and use it on Labview
 
Be careful when you write to a variable. Its good practice to only write to a variable in one location, but you can read from the variable in many locations. If you write to a variable in multiple locations you are bound to run into race conditions.

Chris11246 20-01-2009 16:08

Re: How do i find a variable and use it on Labview
 
Ok but if i have multiple variables then how do i know which one is which read is connected to which write variable.

Russ Beavis 20-01-2009 16:20

Re: How do i find a variable and use it on Labview
 
That "example" that I published? FULL OF RACE CONDITIONS (intentionally). Good luck trying to figure out the order of precedence in that. I was simply trying to show that it's possible.

The OS/program will only store 1 "real" copy of the variable in a single memory location. Every function can simultaneously read/write to the single memory location from "anyplace". But as BLAQmx points out, be careful when you have multiple writes that are happening simultaneously.

You'll never know which "write" "wins". That's why I use sequences to force program flow where necessary. Being a very single-threaded engineer, I use a LOT of stacked sequences.

Russ

BLAQmx 20-01-2009 16:46

Re: How do i find a variable and use it on Labview
 
1 Attachment(s)
Every variable can be either read or written to.I n that sense there is only one variable but two states. This single variable may have multiple copies of readers and writers, but they are all reading and writing from the same place in memory.

Let me know if the screen shot I have attached helps at all.

Chris11246 20-01-2009 16:51

Re: How do i find a variable and use it on Labview
 
In your example you have variables with "X" and "Y" in them all i get are "?"s how did you rename the variable.
BLAQmx where do you find the boolean, string, and numeric all i can find are local, global, and shared and how do you name them.

Booksy 20-01-2009 17:15

Re: How do i find a variable and use it on Labview
 
Quote:

Originally Posted by BLAQmx (Post 804560)
Every variable can be either read or written to.I n that sense there is only one variable but two states. This single variable may have multiple copies of readers and writers, but they are all reading and writing from the same place in memory.

Let me know if the screen shot I have attached helps at all.

I think you made a typo in your comments. The one says it has one writer and multiple readers, but it actually has one reader, and multiple writers.

Greg McKaskle 20-01-2009 21:22

Re: How do i find a variable and use it on Labview
 
You click on the ???s and choose from the list of controls. If you rename a control, the variable also gets renamed.

Greg McKaskle

BLAQmx 20-01-2009 23:37

Re: How do i find a variable and use it on Labview
 
Quote:

I think you made a typo in your comments. The one says it has one writer and multiple readers, but it actually has one reader, and multiple writers
I'll double check and repost the screenshot. Thanks!

Quote:

In your example you have variables with "X" and "Y" in them all i get are "?"s how did you rename the variable.
BLAQmx where do you find the boolean, string, and numeric all i can find are local, global, and shared and how do you name them.
Tutorial: Local Variable, Global Variable, and Race Conditions
See the section Implementing a Global Variable

There is also a video of there tutorial here.

Alan Anderson 21-01-2009 00:51

Re: How do i find a variable and use it on Labview
 
I'm not really sure why you want to use variables. You might be thinking too much in terms of procedural programming (like C or even BASIC) instead of treating LabVIEW as a dataflow programming method -- which it is.

In LabVIEW programs, wires are essentially the variables. They're what "hold" values as they move from where they're produced to where they're used.

dgraves702 21-01-2009 01:17

Re: How do i find a variable and use it on Labview
 
Quote:

Originally Posted by Alan Anderson (Post 804992)
I'm not really sure why you want to use variables. You might be thinking too much in terms of procedural programming (like C or even BASIC) instead of treating LabVIEW as a dataflow programming method -- which it is.

In LabVIEW programs, wires are essentially the variables. They're what "hold" values as they move from where they're produced to where they're used.

Exactly. All you need to do is wire the output from your Get Axis VI from the Joystick Palette to the Set Speed VI (or equivalent if you are using your Drive motors) from the Motors Palette. You don't need to use variables at all.

Russ Beavis 21-01-2009 07:30

Re: How do i find a variable and use it on Labview
 
Excellent point, Alan! Maybe Chris was getting too hung up on that concept.

In general, you should be able to do all of your programming without using global or local variables. Wires can go "everywhere" by simply wiring "through" structure boundaries or exploiting shift registers or sequence locals (look 'em up). Variables are only really necessary when

A) You want to clean up your block diagram since having wires everywhere can get out of hand.

or

B) You've got a set of parallel processes that need to share data (although I believe there may be a few other more advanced options that could be used). Processes WILL NOT run in parallel when they are wired together (since a wire cannot be read from until it is written to whereas variables can be read from at any time).

Another suggestion - check out Highlight Execution mode. It can be really handy for helping understand program flow and debugging.

Russ

Chris11246 21-01-2009 10:50

Re: How do i find a variable and use it on Labview
 
I was just trying to make a test vi that doesnt use the Crio but i couldnt make a value that could be used as the motor value that could be changed but still give me a value(i wanted to make it accelerate or decelerate and show the value of the motor) I can get what i want using the Crio stuff but I was just trying to figure out how to test it.

Jon236 21-01-2009 10:58

Re: How do i find a variable and use it on Labview
 
Simply create a control on the front panel to input your value.....then place an indicator to the output of your coding to show the result. Make sure to create a While loop to let it run.

blackdeath 21-01-2009 17:50

Re: How do i find a variable and use it on Labview
 
Just take the axis from the unbundle by name and hook it to the tank drive/arcade drive.vi input


All times are GMT -5. The time now is 08:59.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi