Você está na página 1de 12

ECET- 462

Application of Computers in Process Control


Purdue University, Calumet

Page 1 of 12

[LABORATORY 3]
Lab VIEW Basic programming Structures (Part b)

Page 2 of 12

Lab VIEW Basic programming Structures (Part b) LAB 3

Objectives: To learn how to work with Lab Views essential programming structures such as for-loops, while loops and formula nodes. Software required: Lab VIEW Programming: a) Formula Node: Step 1: Create a formula node in the block diagram.

Step 2: Create a program like below. To create input and output channels click on the left boundaries and rename them. Create control to both of them. Create output channels similarly and rename them. Write down the equations in the formula node. Run the program and change the values of input. Observe the output.

Page 3 of 12

Step 3: Complete the following steps to build a VI that uses the Formula Node to perform a complex mathematical operation and graphs the results. Step 4: Build the following block diagram.

Step 5: Place the Formula Node located on the FunctionsStructures palette. Step 6: Create the x input terminal by right-clicking the left border and selecting Add Input from the shortcut menu. Step 7: Create the y and output terminals by right-clicking the right border and selecting Add Output from the shortcut menu. You must create output terminals for temporary variables like a. When you create an input or output terminal, you must use a variable name that exactly matches the one in the equation. Variable names are case sensitive. Step 8: Type the following equations in the Formula Node, where ** is the exponentiation operator. Refer to the LabVIEW Help for more information about syntax for the Formula Node. a = tanh(x) + cos(x); y = a**3 + a; Step 9: Display the front panel and run the VI. The graph displays the plot of the equation During each iteration, theVI divides the iteration terminal value by 15.0. The quotient is wired to the Formula Node, which calculates the function value. The VI plots the array as a graph.

Page 4 of 12

Step 10: Write a small LabVIEW code that will calculate the roots of a quadratic functions. You must consider all cases; real and imaginary. Formulas:

p= x1,2 = x1,2 = if p 0 if p < 0

Use the VI you created to solve the following quadratic equation: x2 + 4x + 3 = 0 x2+2x + 2 = 0 Include screenshots for both the front panel and the block diagram and show the answer.

Sequence Structure: Two types of Sequence structures are discussed here: a) Flat Sequence b) Stack Sequence

a) Flat sequence: The Flat Sequence structure, shown as follows, displays all the frames at once and executes the frames from left to right and when all data values wired to a frame are available, until the last frame executes. The data values leave each frame as the frame finishes executing.

Page 5 of 12

Step1: Go to Function paletteProgrammingStructuresFlat Sequence. Drag and drop it in the Block Diagram, make a box like below:

Step 2: Now right click on the border and click on Add Frame After

Step 3: Create 3 more stack frame like below

Step 4: Now create a connection diagram as follows

Page 6 of 12

The Front Panel should look like this

Step 5: In the Block diagram click on the symbol below

Step 6: Hit the run button

Step 7: Take a look at the flow of the data in the block diagram.

Page 7 of 12

Step 8: Observe the output result in the front panel. Which output was supposed to come first? Which output display gives you the result at first? Explain why?

b) Stacked Sequence: The Stacked Sequence structure, shown as follows, stacks each frame so you see only one frame at a time and executes frame 0, then frame 1, and so on until the last frame executes.

Step1: Go to Function paletteProgrammingStructuresStacked Sequence. Drag and drop it in the Block Diagram, make a box like below:

Page 8 of 12

Step2: Right click on the boarder and click on Add frame after. Add two frames in this way.

Step3: The Stacked sequence frame looks like as below:

Step 4: Now Select 0 from selector label and make an addition program like below:

Page 9 of 12

Step 4: Now Select 1 from selector label and make another program like below:

Step 5: Select 2 from selector label and make a multiplication program like below:

Page 10 of 12

Step 6: Now go to the toolbar and click on Highlight Execution

Step 7: Select the selector label back to 0:

Step 8: Prepare the Front Panel like below:

Step 9: Run the program and observe the Data flow in the panels as well as the selector label.

Page 11 of 12

Step 10: What change do you see in the selector label during the execution of the program. Make a comment on that.

Page 12 of 12
Corresponding LabVIEW Function

Function/Syntax

Description

abs(x) acos(x) acosh(x) asin(x) asinh(x) atan(x) atan2(y,x) atanh(x) ceil(x) ci(x)

Returns the absolute value of x. Computes the inverse cosine of x in radians. Computes the inverse hyperbolic cosine of x. Computes the inverse sine of x in radians. Computes the inverse hyperbolic sine of x. Computes the inverse tangent of x in radians. Computes the arctangent of y/x in radians. Computes the inverse hyperbolic tangent of x. Rounds x to the next higher integer (smallest integer x). Evaluates the cosine integral for any real nonnegative number x. cos(x) Cosine Computes the cosine of x, where x is in radians. cosh(x) Hyperbolic Cosine Computes the hyperbolic cosine of x. cot(x) Cotangent Computes the cotangent of x (1/tan(x)), where x is in radians. csc(x) Cosecant Computes the cosecant of x (1/sin(x)), where x is in radians. exp(x) Exponential Computes the value of e raised to the x power. expm1(x) Exponential (Arg) 1 Computes one less than the value of e raised to the x power ((e^x) 1). floor(x) Round To Infinity Truncates x to the next lower integer (largest integer x). getexp(x) Mantissa & Exponent Returns the exponent of x. gamma(x) Gamma Evaluates the gamma function or incomplete gamma function for x. getman(x) Mantissa & Exponent Returns the mantissa of x. int(x) Round To Nearest Rounds x to the nearest integer. intrz(x) Rounds x to the nearest integer between x and zero. ln(x) Natural Logarithm Computes the natural logarithm of x (to the base of e). lnp1(x) Natural Logarithm (Arg +1) Computes the natural logarithm of (x + 1). log(x) Logarithm Base 10 Computes the logarithm of x (to the base of 10). log2(x) Logarithm Base 2 Computes the logarithm of x (to the base of 2). max(x,y) Max & Min Compares x and y and returns the larger value. min(x,y) Max & Min Compares x and y and returns the smaller value. mod(x,y) Quotient & Remainder Computes the remainder of x/y, when the quotient is rounded toward Infinity. pow(x,y) Power of X Computes x raised to the y power. rand( ) Random Number (0 1) Produces a floating-point number between 0 and 1 exclusively. rem(x,y) Quotient & Remainder Computes the remainder of x/y, when the quotient is rounded to the nearest integer. si(x) Sine Integral Evaluates the sine integral for any real number x. sec(x) Secant Computes the secant of x, where x is in radians (1/cos(x)). sign(x) Sign Returns 1 if x is greater than 0, returns 0 if x is equal to 0, and returns 1 if x is less than 0. sin(x) Sine Computes the sine of x, where x is in radians. sinc(x) Sinc Computes the sine of x divided by x (sin(x)/x), where x is in radians. sinh(x) Hyperbolic Sine Computes the hyperbolic sine of x. sizeOfDim(ary,di) Returns the size of the dimension di specified for the array ary. spike(x) Spike Generates the spike function for any real number x. sqrt(x) Square Root Computes the square root of x. step(x) Step Generates the step function for any real number x. tan(x) Tangent Computes the tangent of x, where x is in radians. tanh(x) Hyperbolic Tangent Computes the hyperbolic tangent of x.

Absolute Value Inverse Cosine Inverse Hyperbolic Cosine Inverse Sine Inverse Hyperbolic Sine Inverse Tangent Inverse Tangent (2 Input) Inverse Hyperbolic Tangent Round Toward +Infinity Cosine Integral

Você também pode gostar