User:Brian P. Josey/Notebook/2010/08/24
|Project name||Main project page|
Previous entry Next entry
Slowly Getting Back Into It
I spent the first part of the morning slowly working through my old notes and the highlights at the end of each chapter in the LabVIEW manual. Since I was gone for over a week on vacation, and the start of the semester is as hectic as it always is, I have had very little time to practice what I've learned, and I'm feeling rusty. Reviewing has definitely helped though. For the second part of the morning, I ran through the last chapter I worked on before leaving to DC, which is on making decisions in VI's. This chapter highlights some important functions like the select function and case structure, both of which allow certain parts of the code to execute depending on conditions defined in the code, or by the user.
The select function is the most basic way to chose between two different possible outcomes. Essentially it is a switch that will allow one set of data to pass and ignore the other if the condition is true, or ignore the first and let the second pass if the condition is false. It requires three inputs: the data for a true value; the data for a false value; and a Boolean string that will select the two. The output from this function is simply whichever one of the two original data sets is selected by the Boolean value. An example of this is starting with temperature measured in °C, that travels in two branches. The first branch enters the select function without any modification, while the second is converted into °F. Then a switch on the front panel is wired to the Boolean input to specify which one is displayed as an output.
A case structure looks similar to a for loop or a while loop in that it encompasses a specific area of the block diagram, however it is different in that it can have multiple block diagrams within it. These are displayed depending on the cases that are being evaluated. The type, and number of cases are controlled by an input value that is wired to the case selector. This value can be Boolean, integer, string, enumerated, or error. For both Boolean and error, there are two possible cases: a true or false for Boolean, and an error or no error for error case structures. For the three other types, there can be up to 231-1 cases, and the user defines which cases are special. For the ones that are not defined by the user, there needs to be a default case that will execute for all other possible inputs.
One important aspect about case structures is how they handle inputs and outputs. Any number of wires can be wired as inputs into a case structure, but not all of them, or even any of them, have to be used in each case. This prevents unnecessary information from clogging up and getting into the code. However, the output tunnels in a case structure are different. Each output from a case structure has to be wired, and for each possible case. If not, the code will not work properly.
A formula node is a unique node in LabVIEW, it allows for simple text-based formulas to be integrated into the block diagram, and executed. They can be hooked up with MATLAB, which is very useful and powerful, however the authors did not state how. This is something that I will have to return to. To set up a formula node, you have to draw one to define a specific region, and then simply type into box what the formula looks like. There is a specific syntax to it that I will not write down, it's covered in LabVIEW's help section, but it is similar to MATLAB. Then the independent variables are coded into the node by right clicking and adding an input, and then named. The dependent variables are then wired in a similar manner to the output on the right side of the node. This can simplify the code by reducing a structure of nodes down to a few lines of code.