0% found this document useful (0 votes)
65 views

1 Labview

manula for vtu third sem students
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
65 views

1 Labview

manula for vtu third sem students
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
EXPERIMENT 7 SORTING EVEN NUMBERS USING WHILE LOOP IN AN ARRAY AIM: To sort even numbers using WHILE loop in an array. THEORY: Loops are used for controlling the iteration and execution flow of programs. Charts display the recent data and update periodically by maintaining a history of the past data While Loop While Loop executes a subdiagram until a condition is met. The While Loop executes the subdiagram until the conditional terminal, an input terminal, receives a specific Boolean value. The default behavior and appearance of the conditional terminal is Continue If True. When a conditional terminal is Continue If True, the While Loop executes its subdiagram until the conditional terminal receives a FALSE value. To change the behavior and appearance of the conditional terminal, right-click on the terminal and select Stop If True. When a conditional terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal receives a TRUE value. Because the VI checks the conditional terminal at the end of each iteration, the While Loop always executes at least one time. The VI is broken if the conditional terminal is not wired, Fig 7.1 shows example of while loop structure Basic error handling can be performed using the conditional terminal of a While Loop. When an crror cluster s wired to the conditional terminal, only the TRUE or FALSE value of the status parameter of the error cluster passes to the terminal. Also, the Stop If True and Continue If True shortcut menu items change to Stop If Error and Continue while Error. The iteration terminal (an output terminal) contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0. Fig.7.1. While Loop structure ‘© A While Loop executes a subdiagram until a condition is met. © The While Loop is like a Do Loop or a Repeat-Until Loop in text-based programming languages. ‘© The While Loop always executes at least once. © The For Loop differs from the While Loop in that the For Loop executes a set number of times. ‘© A While Loop stops executing the subdiagram, only if the expected value at the conditional terminal exists. © In LabVIEW, the WHILE Loop is located on the Functions » Programming » Structures palette. © You also can place a For Loop on the block diagcam, right-click the border of the For Loop, and select Replace with While Loop from the shortcut menu to change a For Loop to a While Loop. '* The While Loop contains two terminals, namely Conditional Terminal and Iteration Terminal. ‘© The Conditional Terminal is used to control the execution of the loop, whereas the Iteration Terminal is used to know the number of completed iterations. PROCEDURE: Step 1: Create blank VI Step 2: Right click on the Block diagram panel —structures— while loop Step 3: Right click on the Block diagram panel (inside while loop) — array—> index array Step 4: Right click on the index array (input side) —screate control Step 5: Right click on the Block diagram panel array —varray size Step 6: Right click on the Block diagram panel numeric Quotient & Remainder Step 7; Right click on the Block diagram pane! + Comparison Equal to 0? Step 8: Right click on the Block diagram panel numeric numeric constant Step 9: Right click on the Block diagram panel numeric— decrement Step 10: Right click on the Block diagram panel —-numeric— numeric constant Step 11: Right click on the Block diagram panel + Comparison Equal ? Step 12: Using wiring operations required connections are made as given in the block diagram inside loop. Step 13: Make a connection to while loop from index array Step 14: Right click step 13 connection (on loop) —>Tunnel mode—> Indexing Step 15: Right click step 14 connection (on loop) —>Tunnel mode—+Conditional Step 16: Right click on the Block diagram panel —array— sort 1D array Step 17: Right click on the sort 1D array (input side) —-create— control [Even array] Step 18: Right click on the sort 1D array (output side) —rereate— control [Sorted array] Step 19: Using wiring operations required connections are made as given in the block diagram outside loop. BLOCK DIAGRAM: Fig shows the block diagram of sorting even numbers using while loop. The array takes the input values. Using indexing values are accessed, and checked for even or not. To check for even number the element value is divided by two and resulting remainder if zero considered as even. This data is stored in output array. Using sort function, array is sorted. While Lo EVEN NUMBERS ARRAY ORIGINAL ARRAY iad Equal To 0? nae Quotient & Remainder Equal? |_p>—"" Sort 1D Array sorted array Array Size Fig Block diagram Sorting even Number in LabVIEW OUTPUT/ FRONT PANEL : nde ORIGINAL ARRAY EVEN NUMBERS AREY sores any Fig. Input and output of sorted even numbers RESUL' Fig shows the input array and sorted array. Even numbers are sorted using while loop in an EXPERIMENT 8 FINDING ARRAY MAXIMUM AND ARRAY MINIMUM AIM: To find t THEO! Arrays 1D Array Controls, In the maximum and minimum variable from an array. RY: A group of homogeneous elements of a specific data type is known as an array. Arrays hold a sequence of data elements.usually of the same size and same data type placed in contiguous memory locations. Individual elements are accessed by their position in the array. The position is given by an index, which is also called as subscript Some arrays are multi-dimensional, generally one -and two- dimensional arrays are the most common. You can build arrays of numeric, boolean, path, string and cluster data types. ‘You cannot create arrays of arrays ‘ators and Constants The index ranges from 0 to 3. The first clement in the array is at index 0, the second clement is at index 1, etc. Inan array the clement selected in the index display always refer to the clement shown in the upper left comer of the clement display. The element (9) at index 0 is not shown in the array, because index | is selected in the index display. Steps for creating an array constant Select an array constant from Functions » Programming » Arrays. Array shell appears with an index display on the left, an empty element display on the right. Place a constant in the array shell. The array shell automatically resizes to accommodate the object place in the array shell Alternative method is to copy an existing array on the front panel to the block diagram to create a constant of same data type lizing Arrays © When an array is initialized, define the number of elements in each dimension and contents of each element. An uninitialized array has a dimension but no elements. An uninitialized array control with all the elements are dimmed indicating that the array is uninitialized. Inserting Elements within Arrays = One can insert an element into a 1D array and a row or column into a 2D array. © Toaddan element 1D, right click the array on the front panel and select Dara Operation » Insert Element Before. © Toadda row orcolumn toa 2D array, right click the array on the front panel and select Data Operations » Insert Row Before or Insert Column Before. © One can insert elements, rows, column into arrays using the dnsert Into Array function. © Place an [asert Into Array function on the block diagram. © The index input specifies the element, row, column where to insert the element or array with 0 being the first. * Elements are added before the value wire to index. 2D Arrays © A 2D arrays stores clements in a grid, © Itrequires a column index and a row index to locate an element both of which are zero- based To create a 2D array on the front panel, right click the index display of the array and select Add Dimension from the shortcut menu. Deleting Elements within Arrays © One can delet an element within a 1D array and a row or column within a 2D. * Todelete an element ina 1D array, right-click the array element on the front panel and select Data Operations » Delete Element. © To delete a row or column in a 2D array, right-click the array row or column on the front panel and select Data Operations » Delete Row or Delete Column Can delete elements, rows, columns and pages within array using the Delete From Array funetion. Replacing Elements within Arrays © Place the Replace Array Subset function on the block diagram © Wire an array of any dimension to the n-dimension array input of the Replace © Array Subset function. © The function automatically resizes based on the dimensions of the array © The index input specifies which clement, row, column to replace © The new clement/subarray input specifies the value you want to replace an element. * Resize the Replace Array Subset function to replace another element, row, column within an array © Ron the VI Deleting Elements within Arrays ‘One can delete an element within a 1D array and a row or column within a 2D. To delete an clement in a 1D array, right-click the array element on the front panel and select Data Operations » Delete Element To delete a row or column in a 2D array, right-click the array row or column on the front panel and select Data Operations » Delete Row or Delete Column Can delete elements, rows, columns and pages within array using the Delete From Array function. PROCEDURE: Stop 1: Create blank VI. Step 2: Right click on the Block diagram panel —yarray— max & min. Step 3: Right click on the max & min (input side) create control. Step 4: Create four numeric indicators in the front pancl for maximum variable, index minimum variable, and index by right clicking on output side of max & min. Step S: Using wiring operations required connections are made as given in the block diageam. Step 6: Inputs are given in the front panel and the program is executed BLOCK DIAGRAM: Max element in_array arr Array Max & Min a mia index Min element in array Array Size size of array i= Fig Block diagram of erray maximum and minimum in LabVIEW OUTPUT /FRONT PANEL : Max element in_array max index ae 4673 if Min element in array min index Py 3 size of array 5 Fig Input and output of array maximum and minimum RESULT: Fig shows the maximum and minimum of given input array. The array maximum and minimum is determined using LabVIEW and also its index. EXPERIMENT BUILD A VIRTUAL INSTRUMENT THAT SIMULATES BASIC CALCULATOR USING FORMULA MODE AIM: To build a Virtual Instrument that simulates basic Calculator Using Formula Mode. THEORY: The Formula Node in LabVIEW software is a convenient, text-based node you can use to perform complicated mathematical operations ona block diagram using the C-syntax structure. It is most usefil for equations that have many variables or are otherwise complicated. The text= based code simplifies the block diagram and increases its readability. Furthermore, you can. copy and paste existing code directly into the Formula Node rather than recreating it graphically. The Formula Node is available in all development versions of LabVIEW and does not require an additional toolkit or add-on, PROCEDURE: The Formula Node in LabVIEW software is a convenient, text-based node you can use to perform complicated mathematical operations ona block diagram using the C- syntax structure. It is most useful for equations that have many variables or are otherwise complicated. The text-based code simplifies the block diagram and increases its readability. Furthermore, you can copy and paste existing code directly into the Formula Node rather than recreating it ‘graphically. The Formula Node is available in all development versions of LabVIEW and does not require an additional toolkit or add-on, his tutorial is useful for familiarizing yourself with the Formula Node. Follow the steps to create @ simple structure to compute different formulas depending on input values. Then, compare the simplicity of your block diagram using a formula node to its counterpart using graphical programming. The Formula Node is a tool that allows the benefits of text-based code within the easy-to-use graphical LabVIEW architecture. 1. Selecting FileNew VI to open a blank V1 2. Place a Formula Node on the block diagram. 1. Right-click on the diagram and navigate to Programming»Structures»Formula Node. 2. Lefi-click to select the Formula Node. 3. Place the Formula Node on the block diagram by left-clicking, dragging, and releasing the mouse. Right-click the border of the Formula Node and select Add Input from the shortcut menu. 4, Label the input variable x. Repeat steps 3 and 4 to add another input and label ity asin fig 10.1 Setpor Fig. 10.1 add input 5. Right-click the border of the Formula Node and select Add Output from the shorteut menu as in fig 10.2. Fig.10.2. add output 6. Label the output $1. 7. Repeat step 5 to create another output, and label this output DI Note: It is considered good programming practice to keep the inputs on the left border and the outputs on the right border of the Formula Node. This helps you follow the data flow in your ‘VL and keep your code organized. 8. Enter the expressions below in the Formula Node. + Make sure that you complete each command with a semicolon. Notice, however, that the if-statement does not require a semicolon on the first line. Right-click on each input and select Create»Control from the shortcut menu. Right-click on each output and select Create»Indicator from the shortcut menu. OUTPUT/FRONT PANEL: The front panel view is shown in following | RESULT: A virtual instrument that simulates a basic calculator is built. EXPERIMENT WATER LEVEL INDICATOR. AIM: To create and demonstrate water level indicator. De: cription: If No water is in tank then motor must be ON. If water level crosses 8 then Motor must be OFF. THEORY: The water level indicator circuits are used in factories, chemical plants, and electrical substations and in other liquid storage systems, There are many possible uses for this simple system, examples include ‘monitoringa sump pit (to control pump activation), rainfall detection, and leakage detection. Electronic water level eircuits have the capability of alerting if there is a water leak somewhere in the factory ‘When the water level is too high or too low or exceeds the higher limit, it can detect the water level easily by hearing an alarm sound or fiom different colors of a Tight bulb, We level in motor vehicles and the liquid level containers which are huge in the companies, also measure the fuel ‘The circuit is designed to indicate three levels of water stored in the tank: empty, half and full but not overflowing, When there is no water in the tank, all the LEDS are off'as an indication that the tank is completely empty. Then, manually control the knob to turn ON LED. Wh touches the maximum limit, the OFF LED will glow indicating that there is water within the tank. As the water level continues to rise and reaches half the tank, ON LED will still glow indicating tank is filling. n water level increases and The important LabVIEW components or tools, required to design a water level detector, list of these components below: + Tonk + Round Knob + Upper Level Indicator + Lower Level Indicator + Numerical Indicator + Graph to observe the results Vertical pointer is used to control the level of the water in the tank. Upper level indicator shows when the tank is about to completely fill. Lower level indicator shows indication by turning "ON" the LED when the level of the water in the tank is too low and we need to fill it. Graphs shows the graphical visualization as the vertical pointer moves up ow down, PROCEDURE: Step 1: Create blank V1 Step 2: Right click on the front panel snumerie— knob, Step 3: Right click om the knob —sPropertics— scale—> Sct maximum 10 and minimum 0 Step 4: Right click on the front pane] +Boolean— Round LED (Name it ON). Step 5: Right click on the front pane] —»Boolean—> Round LED (Name it OFF). Step 6: Right click on the front pane] —rnumerie—+ Numeric control Step 7: Right click on the front pane] —-numeric—+ Tank Step 8: Right click on the Block diagram panel +-comparison— greater or equal? Step 9: Right click on the Block diagram panel +comparison— less? Step 10: Rightclick on the Block diagram panel + numeric Numeric constant (set 8) [twice] Step 11: Using wiring operations required connections are made as given in the block diagram, Step 5: Execute- give inputs in the front panel by rotating knob and observe tank filling and switches ON & OFF. BLOCK DIAGRAM: Fig shows the block diagram water level indicator in LabVIEW. A round control knob is used to switch on the motor and off. Numeric indicator display water level in tank, a ane rorequsy Water level Mare Less oreqin ——-‘Matartealis ess & Fig. block diagram OUTPUT /FRONT PANEL = Water level is -as0a1t Water evel is More a ° . Water level is tess z ~ ° ‘0 RESULT: Fig. . (a),(b) and (c) shows Motor on with no water and filling and reached upper limit and off. A VI that indicates water level is built EXPERIMENT CALCULATION OF AREA AND PERIMETER OF CIRCLE AIM. To calculate area and perimeter of a circle Description: Arca of circle = =r? Porimeter/circumference of circle = 2r r= radius of cirele if 10 then indicate to reduce radius. THEORY: The area shows the space inside an object having two dimensions. Where as, circumference is the parameter which shows the boundary of the object. Ares is usually measured in m* and circumference is measured in m according to their System International (SI) units. [n this area and area and cireumference calculation of circle is achieved. In this LabVIEW program, which will take radius as an input and calculates the area and circumference of circle, You can also select the maximum limit of the radius. When the radius approaches its maximum limit an LED will glow showing the notification reduce the radi Step 1: Create blank VI Step 2: Right click on the front panel + numeric Numeric control Step 3: Right click on the front panel + numeric+ Numeric indicator [Name Area] Step 4: Right click on the front panel — numeric Numeric indicator [Name Circumference] Step 5: Right click on the front panel —+ Boolean—> Square LED Step 6: Right click on the Block diagram panel —>Numerie—> multiply (thrice) Step 7: Right click on the Block diagram panel —sstructures—> while loop Step 8: Right click on the Block diagram pane! numeric numeric constant [set value 10] Step 9: Right click on the Block diagram pane! —>numeric— numeric constant [set value 2] Step 10: Right click on the Block diagram panel —rnumeric— math constants—pi Step 11: Using wiring operations required connections are made as given in the block diagram BLOCK DIAGRAM: Fig shows the block diagram of area and circumference of circle in LabVIEW. Area and circumference is calculated using formulas, An upper limit to radius is also kept here enter the value of radius - r ‘Area of the circle ——fi ‘Square = Fig. block diurgram Perimeter OUTPUT /FRONT PANEL : enter the value of radius - r Area of the circle ga 50.2655 Perimeter 251327 RESULT:

You might also like