Jump to content
Sign in to follow this  
lovemachinez

Does Labview can create variable like C language?

Recommended Posts

Does Labview can create variable like C language?

example int x,y,z;

char x,y,z;

I want to storage the number into variable to use in my next process. Does it have..?

Share this post


Link to post
Share on other sites

QUOTE (lovemachinez @ May 14 2009, 10:54 AM)

Does Labview can create variable like C language?

I want to storage the number into variable to use in my next process. Does it have..?

LabVIEW does not operate the way you are thinking. The data is contained "on the wire". I would recommend looking at shift registers for next-loop operations.

Tim

Share this post


Link to post
Share on other sites

QUOTE (lovemachinez @ May 14 2009, 10:54 AM)

Does Labview can create variable like C language?

example int x,y,z;

char x,y,z;

I want to storage the number into variable to use in my next process. Does it have..?

Yes and No. A LabVIEW variable can do similar things compared to a C variable, but it is more interesting and useful becasue it has a visual aspect

Tim S answer was just fine, but I will add a more.

Nobody ever writes all this down because most people learn it quickly by being shown by an experienced user. When learned this way the simplest things seem obvious.

But, if you have progammed a text based language and come to LabVIEW alone and with no guidance, then even these small things are difficult and NOT obvious. I hope the following information is helpful.

To make a "variable" right click over the Front Panel (FP) a pallette of menus will appear.

In the pallette select the Modern or Classic menu.

Then select the first menu item "Numeric."

The simplest "Numeric Control" looks like a number in a box with a small up/down button to the left. Pick that with the left mouse button and place the icon on the FP.

The front Panel is the Graphical User Interface that the program operator sees and interacts with when the program.

(Program = "Virtual Instrument" or VI in the LabVIEW development system)

This is a control "variable" that can be edited while the LabVIEW VI is running, or while you are in programming mode.

If you go to the Block Diagram (BD) (double-click on the control with the left mouse button OR press Ctrl-E on the keyboard to bring the BD into focus) you will see the Block Diagram representation of the control.

All the other selections in the Numeric menu, dials, sliders, and so on, are merely different visual forms of a numeric control - they alll have value, format, and representation (double, interger, etc.) just like the Numeric Control.

If you right-click on the BD representation of the Numeric Control a menu appears. Pick "Create," then "Indicator."

A new Icon appears and a wire connects the original control with the new "Indicator." If you look on the FP you willl see there is a representation of the Indicator.

The variable you have created is a Double Precision variable. In a sense the control, the wire, and the indicator are all the variable. The control is the varialbe in a form that is runtime editable, the wire is the means by which the value of the variable is present through out the program, and the indicator is a visual indication of the value of the variable.

If you wish to have an integer variable (int), right click on the control (at the FP or BD) and pick "Representation." You can "declare" whether the variable is an 8, 16, 32 or 64 bit integer, or one of the various unsigned integers, or one of the various precision or complex variables by picking from the Representation menu.

If you wish to have a string (like char) variable create a control but select the String & Path menu.

You can make Boolean (binary variables) with the items in the Boolean menu.

Changing the representation of the control will cause a mismatch with the indicator, the value will be coerced (forced) to the form of the data sink (indicator in this case) and the coersion will be represented by a very small triangle where the wire is attached to the indicator. If you change the Representation of the Indicator to match the Control the "coersion dot" will go away.

Good luck,

Mike

Share this post


Link to post
Share on other sites

Just to be clear - controls and indicators are NOT variables. They are points in the code which allow user interaction (or argument/result passing, in case of a subVI).

In LabVIEW, you're not supposed to care about variables, but about the data. Each node (VIs, controls, structures, etc.) has inputs and/or outputs and you should only care about the data that flows through those wires. If you have a wire coming into a case structure and connecting to an exit tunnel, the wire on the outside of that tunnel is NOT the same wire or "variable". It has data on it, which may or may not be the same data which went into the case structure and may or may not occupy the same area of memory, but you should only be interested in the value flowing through the wire and what it represents. In that sense, each wire is like a variable, but there's no real point in thinking about it that way.

Now, you can explicitly create variables, but because of the parallel nature of LabVIEW, you're risking creating race conditions and bugs:

Local variables are secondary access points to controls and indicators in a specific VI.

Global variables are for sharing data between VIs.

Shared variables are for sharing data between machines.

There are other ways to pass data around, most of which are better:

Shift registers, inputs and outputs on VIs, LV2-style globals, queues, notifiers and some others.

You should go through some tutorials for more.

Share this post


Link to post
Share on other sites

Yair,

Thanks for that bright and concise philosophical discussion. Not being a student of computer science I couldn't have begun to describe the distinction.

I know controls, wires and indicators are not variables in the C, Basic, Fortran sense, but I couldn't have begun to say how they differ.

I was taking the similarity more from the English/mathematical word (as apposed to Computer Science) "variable" - a thing that is quantitatively changeable - magnitude, direction. A wire IS variable since it can represent alterable quantity, or in the case of wire representing a string, changeable meaning. Likewise a control or an indicator fit this looser definition. The OED has nearly two full pages devoted to the definition of "Variable."

Mike

Share this post


Link to post
Share on other sites

It's important to make the distinction, because users which have a background in text-based languages often have difficulty in grasping the dataflow concepts of LabVIEW. I'm guessing that more often than not one of the first questions they ask is "how do I create variables?". If they're lucky, they someone to explain how LabVIEW doesn't need variables unless you have parallel code. If they're not, they stumble onto locals, globals or Value property nodes and think "what a crappy language, this is so inelegant". At least if they're reasonably smart. Otherwise, they just tend to use them badly.

Share this post


Link to post
Share on other sites

QUOTE (Yair @ May 17 2009, 01:31 PM)

It's important to make the distinction, because users which have a background in text-based languages often have difficulty in grasping the dataflow concepts of LabVIEW. I'm guessing that more often than not one of the first questions they ask is "how do I create variables?". If they're lucky, they someone to explain how LabVIEW doesn't need variables unless you have parallel code. If they're not, they stumble onto locals, globals or Value property nodes and think "what a crappy language, this is so inelegant". At least if they're reasonably smart. Otherwise, they just tend to use them badly.

This was exactly my first impression of LabVIEW. Well, I think my words were more like: "...what a sh#$% language, this is so fu!*#%CONTENT% hideous... Hey boss, please tell me again why you want me to start using this crap!...".

It wasn't until after someone like the two of you (Yair and MRoss) that this stuff started making sense to me. Thanks!!!

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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