CSE-471 Lab 03

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Kingdom of Saudi Arabia

‫اﻟﻤــﻤـــــــــﻠﻜــــﺔ اﻟﻌـﺮﺑﯿﺔ اﻟﺴــــــﻌﻮدﯾﺔ‬


Royal Commission at Yanbu
Colleges & Institutes Division ‫اﻟـــــــﮭـــــــــــﯿـــــﺌﺔ اﻟﻤﻠــــــﻜـــــــﯿﺔ ﺑــﯿﻨﺒﻊ‬
‫ﻗــــﻄـــﺎع اﻟـﻜــــــــــــﻠــﯿﺎت واﻟـﻤــﻌــﺎھـﺪ‬
Yanbu University College ‫ﻛـــــﻠﯿﺔ ﯾﻨﺒﻊ اﻟﺠــــــــــــــــﺎﻣـــــــــــﻌﯿﺔ‬
Computer Science & Engineering Dept. ‫ﻗﺴﻢ ﻋﻠﻮم وھﻨﺪﺳﺔ اﻟﺤﺎﺳﺐ اﻷﻟﻲ‬
Information & Computer Technology Dept. ‫ﻗﺴﻢ ﺗﻘﻨﯿﺔ اﻟﻤﻌﻠﻮﻣﺎت واﻟﺤﺎﺳﺐ اﻵﻟﻲ‬
LAB 3

ACADEMIC YEAR 1439/1440 H (2018/2019 G), SEMESTER II (182)

MICROCOMPUTER INTERFACING &


DATA ACQUISITION
CSE471
START TIME: 8:15 AM
DATE: Tuesday, 29 January, 2019
FINISH TIME: 10:05 AM

STUDENT NAME: _________________________________________________________

STUDENT ID: SECTION: 1

FOR INSTRUCTOR USE ONLY GENERAL INSTRUCTIONS

MAX MARKS
Q. No. CLOs
MARK OBTAINED

1
2
3
4
5
6
7

TOTAL MARKS

MARKED BY: Signature:

CHECKED BY: Signature:


LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

PROGRAMMING ITERATIONS AND CONDITIONS IN


LABVIEW

PERFORMANCE OBJECTIVES:
Upon completion of this laboratory exercise, the student technicians/engineers will be able to:
1. Create arrays in LABVIEW and perform data processing with them.
2. Create 3 x 3 matrices and perform mathematical calculations.
3. Understand clusters and their usage in LABVIEW programs.
4. Use data manipulation using bundle and unbundle functions.
EQUIPMENT:

1 LABVIEW equipped PC

DISCUSSION:
LABVIEW provides following ways to collect values:
1. Clusters
2. Arrays and matrices
CLUSTERS
A cluster is a fixed sized grouping of potentially different data types such as data and time data,
integer numeric data, image data, a Boolean value, and a string, hence cluster is similar to a
record or a structure in a text based programming language. It should be noted that cluster can
be either an indicator or a control but not a mixture of both.
ARRAYS AND MATRICES
An array, which consists of elements and dimensions, is either a control or an indicator.
Elements are the data or values contained in the array. A dimension is the length, height, or
depth of an array. Arrays are very helpful to handle a collection of similar data. They are also
used in storing a history of repetitive computations. Array elements are ordered. Each element
in an array has a corresponding index value, and you can use the array index to access a specific
element in that array. In LABVIEW, the array index is zero-based. This means that if a one-
dimensional (1D) array contains n elements, the index range is from 0 to n – 1, where index 0
points to the first element in the array and index n – 1 point to the last element in the array.
A matrix is a single control that holds a collection of values of the same data type. A
LABVIEW matrix is always 2D, although you can use a single column or row. A LABVIEW
matrix cannot have more than two dimensions. The first element of a matrix is element 0, not 1.
LABVIEW offers the following functions to handle the array and matrices.
• Array Max & Min
• Insert Into Array
• Array Size
• Replace Array Subset
• Array Subset
• Reshape Array
• Search 1D Array
• Transpose 2D Array
• Sort 1D Array
• Cluster To Array
• Split 1D Array
• Array To Cluster
• Reverse 1D Array
• Matrix to Array
• Rotate 1D Array
• Array to Matrix
• Delete From Array

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


1
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

TASK-1
PERFORMING BASIC ARRAY OPERATIONS IN LABVIEW
Write a VI that performs the following operations on the given arrays / matrix A, B and C.
1 8 7 3 5 4
𝐴 = �2 9 4 � , 𝐵 = �4 9 3 �
3 6 2 7 2 5
• Array addition A + B
• Multiplication of B by a given scalar (say 100)
• Element by element multiplication of arrays A and B
PROCEDURE:
1. In order to create an array of any dimension use following steps:
a. Create array controls on the front panel.
b. Place the array container on the front panel.
a. Controls Palette / Modern Group / Array, Matrix & Cluster Group / Array
c. Place one numeric control inside the array container.
a. Controls Palette / Modern Group / Numeric Group / Numeric Control
d. Add a dimension to create a 2D array. Right-click on the index and select Add
Dimension from the pop-up menu. Expand the size of the array. Drag the handles at
the sides of the array to change the number of displayed array elements
e. Enter values into the arrays. Once the right number of rows and columns are displayed,
double-click in each array element to enter the value for the element.
2. Repeat the above steps to create array B.
3. In function palette, find the respective operations and connect them appropriately to create
block diagram.
4. Run the simulation to obtain the results.
5. Front panel and block diagram are shown in following.

Figure 3.1 Task 1

YANBU UNIVERSITY COLLEGE


2
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

TASK-2
PERFORMING BASIC MATRIX OPERATIONS IN LABVIEW
Write a VI that performs the following operations on the given arrays / matrix A, B and C.

1 8 7 3 5 4
4 7 3
𝐴 = �2 9 4 � , 𝐵 = �4 9 3� 𝑎𝑛𝑑 𝐶 = � �
6 5 2
3 6 2 7 2 5

• Inverse of matrix B
• Multiplication of matrix A x B
• Determinant of matrix A
• Transpose of matrix C
• Condition number of matrix C
PROCEDURE:
In order to create a matrix use following steps:
1. On the control panel select real matrix control from Array, matrix and cluster control
of control palette.
2. Enter values into the matrix. Once the right number of rows and columns are displayed,
double-click in each array element to enter the value for the element.
3. Repeat the above steps to create matrices A, B and C.
4. In function palette (Use numeric and linear Algebra VIs) find the respective operations
and connect them appropriately to create block diagram.
5. Run the VI to obtain the results.
6. Possible layouts of Front panel and block diagram are shown in following.

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


3
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

Figure 3.2 Front Panel (top) and Block Diagram (bottom) Task 2

Observe the results of A x B of tasks 1 and 2 respectively and write down your
Q
observations.

YANBU UNIVERSITY COLLEGE


4
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

TASK-3
PLACING AND EXTRACTING DATA
One of the important operations on a given array is to insert data or extract data from it. The goal
of this task is to create sub-array(s) by extracting particular rows and columns of a given array.
Besides this how values can be inserted into particular row or column of an array.
PROCEDURE:
In LABVIEW, implement the block diagram shown in figure 3.4.

Figure 3.3 Screen Shot of Results of Task 3

Figure 3.4 Block Diagram of Task 3

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


5
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

TASK-4
CLUSTERS IN LABVIEW
Write a VI to create a cluster with following specifications:

• Cluster must contain numeric; two vertical toggle switches (Boolean 1 and Boolean 2) and
a horizontal slide fill control.
• The numeric indicator in the modified cluster shows value one more than numeric value of
first cluster. Boolean 1 in the modified cluster must be the inverted version of Boolean 1 of
cluster.
• The small cluster must contain a copy of Boolean 1 and must display the numeric value of
numeric input control.
• Additional numeric indicator to the display the value of horizontal slide control outside the
cluster and LED which is controlled by Boolean 2.
• All clusters must be contained in a while loop with wait until next ms function. The delay
must be of 100 ms.
• The front panel of the VI is shown in figure 8 as reference.
PROCEDURE:
1. Implement the front panel (figure 3.5) and block diagram as shown in figure 3.6 respectively.
2. Run the simulation to verify the specifications.

YANBU UNIVERSITY COLLEGE


6
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

Figure 3.5 Front Panel of Task 4

Figure 3.6 Block Diagram of Task 4

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


7
LAB MANUAL
LAB EXPERIMENT - 03: ARRAYS AND MATRICES IN LABVIEW

REVIEW QUESTIONS
1. Explain the working of the code (block diagram) of task 3.

Suppose we want to extract first six rows from “New Array” to form a new row sub-
2.
array. Suggest your changes in the code of task 3.

3. What changes should be done to insert data into row 6 of the Generated Data array.

FINAL CHECKLIST
All the students must make sure, before they leave the Lab:
1. Clean your equipment, materials, and work benches before you leave.
2. Return all equipment and materials to their proper storage area.
3. Submit your lab report and answers to the questions, together with your data,
calculations (if any) and results before the next laboratory sessions.

YANBU UNIVERSITY COLLEGE


8

You might also like