MEEN 260-510 Tech Memo

11
LAB # 2: Intro to LABVIEW Texas A&M University MEEN 260-Section # 510 09/25/2014 "On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work." Name Benjamin Lohn Signature ______________________________________________ Name Pedro Martinez Signature ______________________________________________ Name Brian Quina Signature ______________________________________________

description

Technical Memorandum for a laboratory involving the use of LabView

Transcript of MEEN 260-510 Tech Memo

Page 1: MEEN 260-510 Tech Memo

LAB # 2: Intro to LABVIEW

Texas A&M University MEEN 260-Section # 510

09/25/2014

"On my honor, as an Aggie, I have neither given nor received unauthorized aid on

this academic work."

Name

Benjamin Lohn

Signature

______________________________________________

Name

Pedro Martinez

Signature

______________________________________________

Name

Brian Quina

Signature

______________________________________________

Page 2: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

1

Technical Memorandum

To: Professor Young-shin Kwon

From: B. Lohn, P. Martinez, B. Quina

Subject: LabView Programming

Summary

The purpose of the lab was to familiarize students with using the laboratory equipment, such as LabVIEW and the oscilloscope. This was accomplished by performing basic exercises in LabVIEW involving logic operations, loops, case structures, and data acquisition. First, several exercises were performed to familiarize users with the graphical interface. These exercises involved basic mathematical operations, a logic operation to select the greater numerical result, and a loop exercise. The next exercise involved gathering temperature readings at varying frequencies and then analyzing them. The final exercise involved the creation of a function generator that was used to create a variety of waveforms. The waves were then subjected to a noise generator and signal filtering. An oscilloscope was then used to display and analyze the waves. Screenshots were taken of all the virtual interfaces.

The lab exercises served to introduce students to the more basic elements of the LabVIEW program in preparation for future labs. The actual data gathered in the exercises was of no experimental value.

Introduction

The objective of this lab is purely educational, in order to prepare for future labs learning the ins

and outs of LabVIEW is vital. In order to explore the intricacies of LabVIEW some basic functional

knowledge is required. Before attempting this lab it is important to know how to perform a variety of

basic tasks such as displaying values, using basic functions, and discerning between different tools from

the Tool Palette. This lab also requires knowledge of loops, specifically the while loop, which performs

some kind of task within the loop until a specific logical condition is met [1]. In using the while loop, we

must also use the shift register which can be used to pass values from one loop iteration to the next.

After practicing these basic functions in LabVIEW we will use this information to first create a

thermometer that reads data inputted from a function generator and returns that data in the form of a

temperature while also recording the information on a graph. Finally, we will use out knowledge of

LabVIEW to create a function generator. This requires the use of a case structure which allows the

operator to create multiple programs within the case structure. The case structure analyzes the input

values and depending on the input runs one of the programs. In this section we will also experiment

with the effects of electrical noise, which is the random fluctuations in an electrical signal. In future Labs

we will be dealing with a variety of electrical equipment and electrical noise is a characteristic of all

electronic circuit. The degree to which noise is generated varies greatly but in many labs this will

produce significant error which must be addressed. Being able to identify and remove noise using a filter

in order to minimize error will be useful in labs to come. Although this lab is largely based on gaining

experience using LabVIEW some important conclusions about data acquisition and error will be made.

Page 3: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

2

Results

The first exercise served as a demonstration of ones understanding of LabVIEW. This was done by

recreating an example provided in the introduction of the laboratory. This example, shown in Fig. 1

below, involved accepting two inputs from the user and both adding the numbers and subtracting them.

It is important to note that there are two main windows involved when programming in LabVIEW, the

Front Panel and the Block Diagram. When a VI is first ran, the Front Panel is the window that opens and

on it the actual controls, indicators, and graphs that are in a program appear in this window. The second

window, the Block Diagram contains all the wires and instruments “that define how the controls and

indicators on the Front Panel are related.”[1] Data from the user is input into what are called control

terminals. These two terminals feed data to the adding and subtracting features of the program called

the nodes. The output of the nodes are wired to displays called indicator terminals.

Figure 1. Front panel (top) and block diagram (bottom) for exercise 1.

For exercise 3, the program from the first exercise was modified slightly to include a logical operator.

This logical operator was to determine which one of the two values in the indicator terminals is the

highest. In Fig. 2 shown below, you can see that in order to complete this request two nodes were

added. The first was the greater than sign, this node accepts the addition value and the subtraction

value and outputs a true or false statement. For example, if the addition value were a 14 and the

subtraction value were a 4, 14 is greater than 4 so the node would output a True. Also if the addition

value were a 4 and the subtraction value were a 14, 4 is not greater than 14 so the node would output a

false. This output was then wired to the “select” node along with the two values. If the greater than

node output a true, then the select node output the first value. If the greater than node output a false,

Page 4: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

3

then the select node output the second value. In this way, the number obtained by the addition

operation is not always the greatest.

Figure 2. Front panel (top) and block diagram (bottom) for exercise 3.

The next section involves the use of loops in the block diagram. Exercise 5 involved recreating the

example from figure 9 in the introduction of the laboratory in the lab. As seen in Fig. 3 below, this

program consists of a loop with a shift register. Inside the loop are an addition node that adds 1 to the

number of the last iteration and also a button to stop the loop. The rate at which this addition takes

place is set by the metronome. Also included in the program are the inside and outside loop indicators.

The difference between these is that the outside loop is wired to the right side of the shift register. This

means that in will accept the value that will be passed to the next iteration. The inside loop indicator is

wired directly to the addition node output and it will have actualized data of the running count.

Figure 3. Front panel (left) and block diagram (right) of exercise 5.

The reason the inside loop display and outside loop display are different when the program is running is

that while the inside loop display is wired directly to the output of the addition node. The outside loop is

Page 5: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

4

wired to the right register which takes its input from the addition node and routes around the loop to

the left shift register where it will again pass to the addition node to add 1 to the sum. The outside loop

never sees the running sum like the inside loop display does.

If the program were not turned off and the program was allowed to run the rest of the day, contrary to

intuition the display would not reach infinity. If the value is outside the desired range of the output type

integer wrapping occurs and the counting begins again. This happens because the indicator allows a

certain amount significant figures before it cannot handle more.

Exercise 6 involved the first use of LabVIEW’s data acquisition capabilities. A function generator was

used to provide a signal that mimics temperature changing in a probe. The function generator was

connected to the program through the use of the DAQ card and the DAQ assistant, as seen in Fig. 4

below. When the program was run you got a reading on the thermometer. If the run button was clicked

again, another temperature would appear on the thermometer, this was because the signal provided by

the function generator was a triangle wave and so the reading varied every second.

Figure 4. The front panel (left) and block diagram (right) for the basic thermometer exercise 6.

In order to continuously take readings a loop was added with a button to stop the collection of data. In

Fig. 5 below, the block diagram with these modifications is shown. It involved adding a while loop

around the existing diagram from Fig. 4. In addition, the stop button was added. This effectively allows

the program to constantly take readings until the stop button is pressed. Running this program, the level

on the thermometer fluctuates up and down constantly. If the frequency from the function generator is

lowered the fluctuations slow down. The same is true for the opposite, if the frequency from the

function generator is increased the fluctuations increase in speed.

Page 6: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

5

Figure 5. While loop placed around function generator program.

A waveform chart was added to the program in order to better illustrate the effects that changing the

frequency had on the response. In Fig. 6 shown below the waveform was added inside the loop and

connected to the Celsius output. At a frequency of 1 Hz the signal on the waveform chart was exactly as

that which the function generator had input to the program. The frequency was then increased to 10 Hz.

Now there seemed to be some interference in the waveform chart. This is attributed to aliasing. The

frequency is too high and it is not properly processed therefore the signal output to the waveform chart

is different than the signal received from the function generator. The frequency was further increased to

50 Hz. At this frequency the chart looked to return to normal but upon closer observation it was obvious

that the waveform was undergoing severe aliasing and the signal appeared to be a shape it was truly not

generated as. These can be seen in Fig. 7 below.

Figure 6. Waveform chart added to while loop.

Page 7: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

6

Figure 7. Waveform charts for (left to right) 1 Hz, 10 Hz, and 50 Hz signals.

In order to better understand the program, the highest value will be recorded in a new indicator

terminal. In order to record the highest temperature, logical operators much like the ones used in

exercise 3 from above will be employed to accept readings from the function generator continuously.

The highest number will be continuously updated and recorded. The block diagram showing how this is

accomplished can be seen in Fig. 8 below. The way this program differs from exercise 3 above is the use

of the DDT node to convert Dynamic Data from the function generator to Single Scalar. The logic nodes

can only handle one set of data at a time and this converter accomplishes that.

With this program it will be possible to tell temperature as a function of time. In the waveform graphs

from Fig. 7 above one can see the temperature in the y-axis is plotted against time in the x-axis. Some

problems that can be encountered with these output styles are that in some cases the data required to

output on a certain style may require digital data, and in others analog. It might be more beneficial to

Figure 8. Program that accepts Dynamic Data and coverts to Single Scalar.

Page 8: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

7

Exercise 8 was similar to the previous exercise in that a waveform chart was used to output a signal from

a function generator. Only in this example the function generator was created within LabVIEW. This

feature allows the user to select the type of waveform (i.e. sine wave, triangle wave, or square wave). In

addition the user is able to input the frequency and amplitude of the wave. This was done by loading a

template that contained a loop for a sine wave generator. In order to create the feature that allows one

to choose the type of wave, a case structure had to be wrapped around the signal generation block. This

essentially meant that what was inside is what would change when the different types of waves were

chosen in the ring. In order to add the ring a ring block was wired to the question mark in the loop of the

case structure. Having done this the ring block was updated to include the three wave types. In Fig. 9

below you can see the block diagram for the first part of this exercise.

Figure 9. Block diagram and front panel for signal case structure.

Experimenting with this resulted in that the resolution of the signal is important if one wants to prevent

aliasing. If the resolution is too high then the signal will be aliased because it is saturated with

information. With it too low there will not be enough data samples, which makes for a poor signal.

Noise was added to the signal by introducing the Uniform White Noise Waveform to the block diagram.

Output of this waveform was physically added to the original signal and this resulting signal was plotted.

In Fig. 10 below one can see the block diagram for this operation as well as the Front Panel showing the

waveform chart of the noise.

Figure 10. Noise being applied to the generated signal.

Page 9: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

8

In order to extract the original signal from the noisy signal a filter was applied to the program. A filter

“reduces the effect of portions of the signal above a specified frequency to remove the high frequency

noise.”[1] In Fig. 11 below, the filtered signal can be observed in the bottom right of the front panel.

Experimenting with the cutoff of the filter, a lower frequency seemed to cutoff most of the noise, but it

came with unwanted effects. In Fig. 11 below, you can see that the filtered signal is the inversion of the

original signal, shown in the top right graph.

Figure 11. Noise being filtered out of the signal.

Also discovered when experimenting with the program was that filters were more effective when the

noise amplitude was lower than amplitude of the original signal. This can be viewed in Fig. 12 below. The

first set of graphs is shows the triangle wave of 1 Hz and amplitude of 1. The noise amplitude applied is

of 1. We can see that this affects the first triangle wave the most since its amplitude is 1. The noise has

increasingly less effect on the rest of the graphs. In the last row of each of the sets of graphs is the

filtered signal. The cutoff was placed at 100 Hz and we can see that it was most effective in higher

frequencies.

Figure 12. Triangle graph of increasing frequency and amplitude.

Page 10: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

9

This is happens because the higher frequency of the original signal is closer to that of the cutoff,

maximizing the effect of the filter.

The last part of exercise 8 involved subtracting the original signal from the filtered signal. The subtracted

signal can be seen in the last row of Fig. 13 below. Ideally this would result in a straight line because

essentially the filtered signal was the original signal. This is not true in most cases because the filtered

signal is not filtered perfectly due to different factors, mainly the cutoff and the resolution not being

ideal.

Figure 13. Triangle waves shown with subtracted signal.

Additionally, the frequency cutoff can in some cases exclude data that was needed, leaving you with the

unclean look of the subtracted signal.

Varying the resolution, as it was stated above has its advantages and disadvantages. When a signal has a

low frequency, the resolution should not be too high as to saturate the signal. For higher frequencies, a

higher resolution is needed in order to keep pace with the higher frequency.

For the function generator produced in the program, the actual output was very close to what was input

in the front panel.

Filtering the noisy signal does not give you a perfect signal with no noise. This happens because the

noise added to the original signal is not uniform and cannot be filtered with one frequency. The original

signal is never recovered exactly as it was sent. For example, in telephone calls the voice you hear on the

phone does not sound exactly as it would if the person were standing in front of you. This is truer with

older technology, as modern filter technology has improved call quality, but nevertheless it is still not

perfect.

Page 11: MEEN 260-510 Tech Memo

MEEN 260-510 9/25/2014

10

Conclusion

A large portion of this lab is simply about learning and familiarizing ourselves with LabView but there are

still some important conclusions that can be drawn. In the thermometer exercise once we got to a high

enough frequency on our function generator the information was coming so quickly that LabView could

not keep up. By appearance the period actually got larger, and the data became unreliable. This is an

obstacle we must recognize and avoid in future labs, incorrect conclusions can be drawn if this is not

taken into account. In the final exercise we experimented with effects of Noise and filters on a function.

Although you can optimize the frequencies to reduce the error to a minimum there will usually be some

level of error whenever noise is introduced. This is an important conclusion to draw, as we move

forward with different Labs. We will be using imperfect equipment all of which will produce some level

of noise. In every lab we perform there will be a level of error, being able to identify that error, minimize

it, and then measure the remaining error in some sort of quantitative manor allows us to draw accurate

conclusions without being misled by incorrect or unreliable data.

References

[1] Department of Mechanical Engineering. “MEEN 260: Mechanical Measurements Laboratory

Manual.” Texas A&M University. College Station, TX. 2014.