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

MEC8063 Tutorial 2 Labview Getting Started

Uploaded by

yulin lin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

MEC8063 Tutorial 2 Labview Getting Started

Uploaded by

yulin lin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

MEC8063 Introduction to Mechatronics Design

Tutorial 2 – Labview : Getting started

Objective: This tutorial is an introduction to the basics of Labview. It will teach you to write Labview programs
that perform basic input operations, simple calculations and output information in both numeric and graphical
form. By the end of this tutorial, you should be able to write Labview programs that contain program control
structures (For loops and Case stuctures), handle arrays of data and be able to load and save this data to files for
future use.

Reading: There is no specific reading for this tutorial.

1. Introduction

Labview is just a programming language however rather than writing code a series of symbols and connecting
wires are used. This ‘code’ can then be saved as a symbol and used as a routine in another program. The great
power of Labview comes from the simplicity of using prewritten routines, for input/output operations, for data
analysis, interfacing equipment and creating an interactive user display.

2. Programming basics in Labview

The PCs you are working on will have Labview installed. It is recommended that you create a folder on your disk
space, i.e. MyDocuments or OneDrive, to save your work to as you may be working on a different PC next week.
Another option is to get a student license and run the software on your own computer (for as long as you are a
student at Newcastle University), see https://services.ncl.ac.uk/itservice/core-services/softwaredeals/student/
for more details.

2.1. Opening Labview

To open Labview proceed as follows:

• Go to the Start menu


• Expand National Instruments
• Expand and open LabVIEW
• Open a Blank VI.

Note when you open Labview you may have 32 or 64 bit options. You may use either but you must be consistent as
programs working on one system will not work on the other one. For this course, I would recommend using the 32
bit version.

You will be presented with 2 windows: Front Panel and Block Diagram. If only one is showing, you can access the
other from Window – Show Block Diagram menu of the Front Panel or Window – Show Front Panel menu of the
Block Diagram. The Front Panel is the user interface and is what you use when the program is running. The Block
Diagram is where you write your program code (in icon form).

Other windows which you will find helpful through the exercises are:

• Context Help which is obtained from the Help menu bar. This gives you information about the currently
selected icon and is particularly useful for knowing what connections are needed.
• Controls / Functions (depending on which window is active) which are obtained by right clicking on the Front
Panel or Block Diagram. These contain your programming icons and you can drag and drop what you need to
use. If you cannot find a particular icon, use the search function of these windows.

John Hedley, School of Engineering, 2024. Page 1


MEC8063 Introduction to Mechatronics Design
2.2. Placing input and output boxes

From Controls (right click in the Front Panel window if this does not show) select each of the following and place
on the Front Panel:

• Express – Num Ctrls – Num Ctrl


• Express – Num Ctrls – Fill Slide
• Express – Num Inds – Num Ind
• Express – Num Inds – Meter

Firstly, we want to change the range of the Meter. Click on the number 10 in the Meter and change this value to
100. The Meter on the Front Panel should update accordingly. Double click on the text of Numeric of the input
box and retype as ‘Scaling Factor’. Similarly double click on Numeric 2 and retype as ‘Output’. Note that you can
do this as soon as the box is created. Rearrange any icon positions as you think suitable. You have now set up the
Front Panel for your monitor although at present it will not do much. As you have been creating this display
corresponding icons have appeared in the Block Diagram window. This is where you do the ‘programming’.

2.3. Programming

We are going to multiply our two inputs and display the output with an ‘optimum range’ indicator if our value is
between 40 and 60. Click on the Block Diagram and from the Functions window select Express – Arith & Com –
Numeric – Multiply and place it between the icons in the Block Diagram. You may wish to move some of the icons
in the Block Diagram so their placement makes more logical sense. If you move the cursor over the Multiply icon
its description will be given in the Context Help window – this currently shows there are two inputs x, y and an
output x*y (although this is fairly obvious at present when we come onto more complex icons this Context Help
will prove invaluable). Move the cursor over to the x-input of the Multiply icon in the Block Diagram window and
it should change into a reel of solder. Left click at this point and move it to the small output arrow of the Scaling
Factor icon. Left click again to finish the wire. If the wire is connected properly it should turn a thin orange colour.

You can left click several times to get bends in the wire thereby making your diagram look better (which becomes
important in complex programs). The thin orange line indicators a single double value (as shown by the Context
Help window). An integer would be a blue line while an array is a thick line (its colour depending on whether it is
double or int). A variety of lines colours and styles are available depending on the data being ‘sent’ along this line.
A dot on the line indicates wires are connected at this point (no dot and the wires are just lying over one
another).

Connect up the Slide to the other input of the Mulitply and the Mulitply’s output to the Meter. Connect a second
output line to the Output indicator (the second output connection can just be made directly from the wire). Your
diagram should now look something like figure 1. Save the program as Tutorial_2A.

John Hedley, School of Engineering, 2024. Page 2


MEC8063 Introduction to Mechatronics Design

Figure 1: The components in the Front Panel are ‘wired’ via the Block Diagram.

2.4. Running the program

We need to set some input values. Place the mouse pointer over the slider until it turns into a hand. Move the
slider to some level, say 5. Next either click in the Scaling Factor box to allow you to type a value or use the arrow
keys at the side. Set this value to 6. To run the program, click on the arrow icon just below the Edit menu. You
program gives a digital output and also a visual output in the form of the Meter.

Let us pretend we have made an error in the programming. Click on one of the input wires to the Multiply icon
and press delete. Either the line is complete deleted or parts of the line are left (shown as dashed with a cross).
This looks fairly obvious although in a larger program it may not be so obvious. Try running the program again,
you should notice the run arrow is now broken. On running you will get an error message. Click on one of the
error messages and it will highlight the part of the program that is causing the fault. Reconnect the wire (either
wire between the loose ends or press Ctrl-B to delete any broken wires and then rewire the connection). The
program should now run.

Faults are not always so obvious, for example it may be wired up but the wrong value is being sent. One way to
monitor this is to Highlight Execution (select the light bulb in the menu bar of the Block Diagram window so that it
becomes an ‘illuminated yellow’). Now run the program. You will see in the Block Diagram window the values
presented on each wire and the flow of the program. Again this can be very useful for debugging purposes
although it drastically slows down the program.

2.5. Finishing the monitor

We specified an ‘optimal range’ indicator in the original problem. Insert an LED into the Front Panel and label
appropriately. This will be dark green when off and light green when on (this can be changed by right clicking and
selecting Properties). The actual programming will require 2 Comparison and 1 Boolean operation from the Arith
& Com menu. Wire up the appropriate icons as shown in figure 2 and run the program. If the output is in the
range 40 to 60 the virtual LED should illuminate and stay dark otherwise.

John Hedley, School of Engineering, 2024. Page 3


MEC8063 Introduction to Mechatronics Design

Figure 2: Comparison operators can be used to control an LED.

2.6. Continuous operation

We are going to finish by putting the whole program in a continuous loop. From the Functions window, select
Express – Exec Control – While Loop and create the loop so it encloses the whole program, see figure 3. Note that
a Stop button has been automatically placed in the loop and variable i (which is the loop count) has been created.
Run the program (without Highlight Execution selected) and you will see how fast the program works. Try
adjusting the slider as the program runs. To stop the program either press your newly created STOP button or
select the stop icon (red circle) in the menu bar. Note that it is best to stop a program using the programmed
options (STOP button in this case) as this will end all operations appropriately (the program should close files,
disconnect equipment, etc, before exiting).

Figure 3: Incorporation of a While loop will allow the program to run continuously until activation of the STOP
button.

2.7. Exercise

We could say that we never want the value to go over 100, for example if it is being used to control the
percentage power of an engine. What if the output goes beyond 100 – the Meter will not show this. Try these
three options:

John Hedley, School of Engineering, 2024. Page 4


MEC8063 Introduction to Mechatronics Design

• Put a LED on the screen to indicate the Meter has overflowed (gone over 100).
• Rewire the While loop so that it will stop on this overflow, i.e. you will need an OR icon between the Stop
button and the red circle.
• Right click on the Scaling Factor box and from Properties, set the value to be limited from 0 to 10 (so this
overflow should never occur).

3. Displaying realtime data

For this exercise, we will create ‘artificial data’ for displaying. In future tutorials when we learn on how to stream
live data into the PC. Thus you will be able to use these techniques to display this live data.

3.1. Creating and displaying artificial data

Place a chart and three numerical inputs on the Front Panel using Express – Graph Indicator – Chart and Express –
Num Ctrls – Num Ctrl. Label one input as Frequency, one input as Amplitude and one as Noise Level. Enter values
of 10, 5 and 2 respectively in each of the inputs. In the main menu bar, select Edit – Make Current Values Default
(so these values appear whenever the program is reloaded) and then save the program as Tutorial_2B. In the
Block Diagram Window enclose all the icons with a For Loop using Programming (you may have to expand the
options in the window Functions window) – Structures – For Loop. Wire a Numeric Constant of 100 from the
outside of the loop to the N in the corner. This will cause the loop to repeat 100 times before exiting. Drag the i
(which is the loop count) to the top of the loop as in figure 4.

Figure 4: Using a For Loop for program control.

Create a numeric Constant of 2 (Express – Arith & Com – Numeric – Num Const) and also Pi (Express – Arith &
Com – Numeric – Math Constant – Pi). We can use several Multiply icons to multiply together 2, Pi, i and the
Frequency input however we will use the Express – Arith & Com – Numeric – Compound icon to multiply these 4
numbers together (use Context Help to see how to change the + to a ×). Feed the output from this multiplication
into a Sine icon (Express – Arith & Com – Math – Trigometric – Sine) and then multiply the output by the
Amplitude input. Finally wire the output into the Waveform Chart as shown in figure 5.

John Hedley, School of Engineering, 2024. Page 5


MEC8063 Introduction to Mechatronics Design

Figure 5: Using the trigonometric functions.

We have created 100 data points representing a sine wave, on running the program, these data points will be
displayed on the Chart as you create them. However when you run the program you will see that the output just
looks like noise and there is no evidence of a sine wave. This is because you are calculating multiples of 2π which
is just going to be 0 (within the numerical accuracy of the computer). Change the frequency to 0.1 and try running
it again, you should now see a series of sine waves. Run it several times and you will see that the time base keeps
increasing. To reset this to zero, right click on the Chart and then go to Data Operations – Clear Chart.

3.1.1. Adding noise

We have simulated some perfect data. We will now simulate some noise on this data to make it look more
realistic (purely for the purposes of this tutorial). Add a Random Number generator (Express – Arith & Com –
Numeric – Random Num) to the Block Diagram. You will see from the Help window that its output is between 0
and 1. Multiply this Random Number output by the Noise Level and then add this value to your sine wave. Run
the program and you will see a slightly noise sine wave produced.

3.1.2 Multiple inputs

It is sometimes useful to have more than one set of data being displayed on the same display (this makes it easier
to compare the data traces). For this exercise, we will have the Waveform Chart show the ‘clean’ and ‘noise’ sine
wave. We need to create a ‘Bundle’ of data to send to the Chart. Select Programming – Cluster – Bundle and place
it just before the Chart in the Block Diagram. In one input, wire the clean sine wave and to the other input the
noise sine wave, as shown in figure 6. The output from this Bundle icon can now go to the Waveform Chart. In the
Front Panel, expand the Plot 0 ‘sub window’ until Plot 0 and Plot 1 appears. Right click on Plot 1 and change the
Line Style to dotted. Try running the program and see what happens, your output should be similar to that shown
in figure 6.

There is one slight inaccuracy in this program – the noise is only added to the signal. If this was real noise, it would
have plus and minus components to it, i.e. the dotted line in your output should be scattered both above and
below the solid line, not just above it. Can you alter the program to obtain the ± scatter? The easiest way to do
this is to subtract 0.5 from the random number that is generated (the output will now range from -0.5 to +0.5 and
there give you this ± scatter).

John Hedley, School of Engineering, 2024. Page 6


MEC8063 Introduction to Mechatronics Design

Figure 6: Generating a ‘noisy’ data set.

3.2. Other display options

The Chart is useful when we have a stream of data that we wish to display as it is being recorded. Another option
is that we may have the complete data set that we want to display (all values rather than one at a time), for this
we can use Waveform Graph. Add a Waveform Graph to the Front Panel.

From the Help window, you will see this icon takes an array. To create a data array we need to send our created
values outside of the For loop, we do this by extending the wire to beyond this loop. Place the Waveform Graph
icon outside of the For Loop and wire in the noise sine data. You will see that as the wire leaves the loop, it turns
from a thin orange to a thick orange (denoting it is now an array of numbers). Try multiple plots in this Waveform
Graph (as you did for the Waveform Chart) using Build Array (Programming – Array – Build Array) for entry into
this icon.

4. File operations

It is important for programs to be able to load and save data. For this exercise, we will create some test data to
load up, modify and then save. Open Excel and type in the numbers shown in table 1, we shall refer to these
columns in this tutorial as x, y (= x2), B1 and B2.

0 0 0 0
10 1 1 0
20 4 1 1
30 9 0 1
40 16 1 1
50 25 1 0
60 36 0 0
70 49 0 1
80 64 1 1
90 81 1 0
100 100 1 1

Table 1: Simulated data to be used by Labview.

John Hedley, School of Engineering, 2024. Page 7


MEC8063 Introduction to Mechatronics Design
Save the data with filename ‘testdata1.txt’ as a tab delimited text file (if it is saved in Excel format the data will
not load into Labview, the easiest way to check this is to try opening the file in Notepad, if it is easily readable in
Notepad then it is saved correctly).

4.1. Loading the data into Labview and displaying

Open up a new (blank) Labview VI. Place a Waveform Graph (Express – Graph Indicator – Graph) on the Front
Panel. In the Block Diagram, place a Read From Spreadsheet icon (Programming – File I/O – Read Spreadsheet)
and set type from Double to Integer for this tutorial (as all our values are integers). You will see from the Help
window that there are a number of inputs and outputs to this icon. We shall only use two of these. As our data is
in columns we need to perform a transpose therefore wire a True constant to this input (i.e. place pointer over
connection, right click, select Create – Constant and then click on it to change from False to True). Figure 7 shows
the correct connections.

The data is presented on the ‘all rows’ wire (see Context Help for more details). This will be in the form of a matrix
(as indicated by the double line of the wire) as shown in our table 1. Once we have the data, we will plot it on the
Waveform Graph. Insert an Index Array icon (Programming – Array – Index Array) and wire the output from the
File read to the input of this Index Array (the Index Array should increase slightly in size as we have just wired a
matrix into it). Wire a constant of 1 on the Index 0 input (as shown on the Context Help) – this will select the
numbers in column 1 (column counting starts at 0 so column 1 numbers are 0,1,4,9,etc). We now have an array of
data values from column 1 (rather than our initial matrix). Wire the output into the Waveform Graph. Your
program should resemble that shown in figure 4.

Try running the program (if you have the debug light bulb illuminated whilst doing this, you will see the size of the
data arrays on each of the wires). You will be prompted for the filename, click on the file and select OK (note you
can wire the filename into the icon either directly or create a character input in your Front Panel and wire this
into the icon). You will see it has plotted the x2 column. However the x – scaling is incorrect.

Figure 7: Plotting data from a file.

John Hedley, School of Engineering, 2024. Page 8


MEC8063 Introduction to Mechatronics Design
4.1.1. Correcting the Waveform Graph

We can use the Waveform Graph in WDT mode, i.e. specify the x – scaling. For this, we need to enter values of x
initial value, x increment and the y data array and so we need to use values of x(0), x(1) – x(0) and y(0…..n).

Note: The Waveform Graph is best used when you only have x(0), dx and y data values – for example if you are
collecting data every 0.1s then start time x0 is 0, dt is 0.1 and y is the data you collect. For our exercise we have
our x and y data arrays and so it is easier to use an XY Graph (we will do this in a later tutorial). Of course you can
always switch between the 2 plots, either calculate x0 and dx from a x data array (which we will do here so you
are aware of how to manipulate data arrays) or alternative calculate a x data array from an x0 and dx value.

At present all the data is arranged in a 2D array so we will now attempt to get the bits of data we require.
Increase the size of the Index Array icon by dragging it downwards and you will get the option of indexing another
part of the data. This time wire a 0 constant to the index. You have the x – data array presented at the output.
You require x(0) and x(1). Place another Index Array icon on the Block Diagram and wire the x – data into the
input. Then index the values 0 and 1 by wiring these as constants to the index input. We now have the values we
require presented at the output. The input into the Waveform Graph requires x(0), dx and y. We will create a
bundle (Programming – Cluster – Bundle) with these values and the output can now be fed into the Waveform
Graph. Your program should look like figure 8. Try running the program, your x-scaling should be now correct.

Figure 8: Generating the correct x – axis scaling.

4.2. Saving the data

Saving the data is similar to loading the data. Although we already have our data stored in array format, we are
going to take the input to the graph and regenerate the data before saving to file – this seems a long way around
(why not just use our originally loaded data which is by far the easiest option) however the technique is being
used here for you to practice data manipulation (for example your data stream may consist of x0, dx and y and
you wish to save out x and y data arrays).

We wish to have a series of x and y values to save to an Excel sheet. We firstly need to unbundled the data.
Connect a wire from the pink line that is input into the graph into an Unbundle icon (Programming – Cluster –
Unbundle). You will see that the Unbundle icon automatically sizes itself once wired, it knows the input is a
{I64,I64,[]} format. The y values are already contained in an array. We need to generate the x values. We know
the starting point and the increment size so we just need to calculate x(0), x(0) + δx, x(0) + 2δx, x(0) + 3δx, etc.
How many of these values do we need to calculate? We need as many as there are y values so we need to

John Hedley, School of Engineering, 2024. Page 9


MEC8063 Introduction to Mechatronics Design
measure the size of the y array using the Array Size icon (Programming – Array – Array Size). We then use a For
Loop to calculate the x values and automatically generate the array (this is similar to what we did in section 3.1).
Figure 9 shows the required connections.

We can now build the matrix containing the x and y data (Programming – Array – Build Array) and save to the
Write Spreadsheet icon (Programming – File I/O – Write Spread) remembering to Transpose the data. The
program is shown in figure 9. Run the program. Load the resulting generated file into Excel (use tab delimited
when loading) and try plotting the data up in the Excel spreadsheet.

Figure 9: Generating and saving the required data.

4.2.1. A few final modifications

What if we wish to modify the data, say, find the square root of the y values. We do not need to wire up each y
value, we can just send the array into a Square Root icon (Express – Arith/Compare – Numeric – Square Root) and
the output array is the required calculated values.

To finish, we will give the user the option of either saving the original data or the square root or neither. For this
we need two switches on the Front Panel, a ‘Do you wish to find the square root?’ switch and a ‘Do you wish to
save the data?’ switch. Firstly place a Raised Box (Modern - Decorations – Raised Box) on the Front Panel. Note
that if this is placed over the Waveform Graph it will hide it as this was the last item to be placed, you will need to
select Send to Back to place this box behind everything. Insert a Label to let the user know what this is for
(Modern - Decorations – Label). Place two toggle switches (Modern - Boolean – Horizontal Toggle) on this Raised
Box and label accordingly.

We now need to wire up these options. Place a Case Structure (Express – Exec Control – Case Structure) around
the Square Root icon and the Write to Spreadsheet icon. Now wire the switch icons to the ? of the Case Structure.
Let us consider the save to file part. Click on the arrows at the top of this structure to toggle the True / False
options. You will see that if True then the data is saved, if False then nothing happens. This is what we want. For
the calculate root part, True calculates the root but False does nothing. We actually require the y data to pass this
Case Structure unaltered for the False condition. Therefore whilst on False, connect a wire between the input and
output side of this Case Structure. By toggling between True and False you can see the different paths the

John Hedley, School of Engineering, 2024. Page 10


MEC8063 Introduction to Mechatronics Design
program can take. The program should look similar to figure 10. Try running the program (select Highlight
Execution to get a clear indication of what is going on in the program).

Figure 10: Case Structures can be used to make decisions during program execution.

4.2.2. Exercise

As an exercise, try writing a Labview program to load the last two columns of data from your testdata1.txt file and
perform either an AND or OR operation on the first 4 pairs of data depending on the setting of a switch. Display
the output as a series of LEDs. Save the result to a file.

Note that number type is important, an LED will only have a Boolean as its input. There are a selection of
conversion icons (Programming – Numeric – Conversion) for example to convert Double to Int, Boolean to (0,1)
etc. An alternative way to get a Boolean value is to use a comparator (i.e. is x greater than 0.5).

5. Practical exercises

5.1. Introduction

When it comes to doing practical electronics, it is vital to have test equipment to diagnose performance and
potential problems in your circuits. This practical session will introduce you to using some of the basic lab
equipment needed when developing electronic based projects. Some of you may be familiar with a lot of today’s
material, for others this may be the first time you have used such equipment. The main aim of this exercise is to
familiarise yourself and be confident when working with electronics. Feel free to ask the supporting staff any
questions in you are having any difficult in performing the measurements.

5.2. Equipment

For this session, we will use a small USB oscilloscope (PicoScope). This is a very basic model of an oscilloscope but
does come with 2 input channels and a signal generator together with a host of useful functions available on the
corresponding PC software so provides a very useful option for learning about electronics test equipment.
Appendix 1 shows you the equipment available in the Electronics Lab in Merz Court which is typically what you
would use on projects needing better accuracy in the measurements.

John Hedley, School of Engineering, 2024. Page 11


MEC8063 Introduction to Mechatronics Design
5.3. Measuring an a.c. voltage

For this you will use the oscilloscope and signal generator part of the PicoScope. Plug the PicoScope into the PC
and open the PicoScope software. Using the probes, connect the output of the signal generator to channel A of
the oscilloscope (note that any oscilloscope channel will suffice). Do this by clipping the probes together (which is
your signal) and connecting the 2 black crocodile clips together (which is the earth connection). Note that the
probes have slider switches on the side, this is a scaling factor. For now push these sliders towards the tip (this
gives a scaling of 1 which is the default setting in the software).

Switch on the signal generator using the software. For the signal generator (clicking on the Signal Generator icon
will display an options screen), click on sine, set a voltage of 1V, offset of 0V and frequency of 1 kHz. Set channel A
of the oscilloscope to ±2V and the timebase (found in the Scope icon) to 1 ms/div. You should now clearly see
your waveform being displayed (as shown in figure 11). Adjust the vertical and horizontal scaling if you wish to
improve your viewing of the waveform being generated. Note that if the scope is set to running, you will
continually receive data, if set to stop (by clicking on the green Running icon) it will display the last trace.

Figure 11: Screenshot of the PicoScope software.

Now try the following:

a) The trigger is an important aspect of an oscilloscope, it determines where the trace starts. On this software,
you can set it from the Trigger menu or simply by moving the small yellow spot in the centre of the screen. To
demonstrate its function, move the yellow spot being displayed on the trace to a position higher than the sine
wave (whilst the scope is in running mode). You should see the trace appear to jump around (in the horizontal
direction). This is because it is randomly starting the data collection. Now set the yellow spot to within the
trace (ideally where there is a steep slope, i.e. near 0V). The trace will appear more stable as you have now
defined at what point in the trace the data collection should start. There are multiple options for this trigger
setting, for example change Direction in the Trigger menu to falling and the trace will go through the yellow
spot on a downward slope. The trigger can be very useful to collect data at a very specific instance in time (for
example do not record data until there is a sharp change in the measurement).

John Hedley, School of Engineering, 2024. Page 12


MEC8063 Introduction to Mechatronics Design
b) Take a look at the trace and see if you can measure the frequency and amplitude of it (you already know the
answer as it is set on the signal generator). There are 2 sliders on each axis (initially on top of each other). On
the vertical axis drag one slider to the bottom of the waveform and the other to the top. The values and
difference will be displayed in a table. You can do similar with the x-axis slides to give you the time difference
between points (from which you can work out the frequency) There is also a Measurement menu that will do
certain measurements automatically for you (for example try measuring the frequency). However if you are
using this option be sure you know what you are measuring – for example if you have two sine waves present,
which one are you measuring the frequency of or are you measuring the beat frequency?
c) Switch on channel 2 of the oscilloscope and you will see an additional trace (which is about 0 as there is not
signal going in this). If you wish you can switch off channel 1 from the menu. On these scopes you can have up
to 2 channels being presented (larger scopes have up to 4 channels). Having two signals being displayed at the
same time can be very useful (see for example tutorial 7 on measuring the encoder signals).
d) Get you waveform back on screen and we will now try adjusting the timebase allowing us to zoom in on parts
of the trace. Change the waveform generator Signal Type to Ramp Up and change the trigger to a direction of
Fallling. If you now change the timebase to, say, 2 µs/div you will get a lot clearer image on what is happening
at this falling edge part of the signal.
e) You can stop the trace at any time with the Running/Stopped button. Alternative you can set it up to just take
a single measurement by changing Trigger from Auto to Single. When you press run it will only capture one
trace and then stop.
f) Mode Coupling allows you to set it to a d.c. measurement or a.c. measurement. A d.c. measurement will
measure everything (d.c. and a.c.) whereas an a.c. measurement will only measure a.c. A quick demonstration
will highlight the importance of this. Try putting the signal generator on a small a.c. frequency output (say 0.1
V) but with a large d.c. offset (say 1V). On the oscilloscope it is difficult to expand the vertical scale as the trace
will go off the top of the screen (try changing the vertical scaling to ± 1V/div to see this effect). If you now set it
to a.c. coupling then only the 0.1 mV signal is shown which you can expand quite easily (try setting the vertical
scale to ±200 mV/div). Remember that there is still a d.c. component there but it is not being displayed. This
allows you to zoom in on very small a.c. signals. Remember to switch it back if you want to measure the d.c.
level also.
g) Finally try saving a single trace using the Save button. There are lots of options to save the data, try saving as
csv and import the data into Excel for plotting (and potentially future analysis). Note when doing any work (in
particular project work), it is good practise to save all of your raw data (be sure to label each file so you know
exactly what it is). That gives you the option of checking (or processing) it at a later date.

5.4. Exercise (note this may form part of the assignment so take a copy of the screenshot)

Change the trace to a square waveform of amplitude 2V and zoom in on the rising transition part (i.e. when the
trace goes from 0V to 2V). Although you would expect to see a sharp right angle at this transition point, in
practice this does not occur (you need to adjust the timebase accordingly to see this effect). Take a screenshot of
your screen (remember to show a list of all people in the group on the screen also). Can you explain why the
voltage trace looks like this?

6. Summary

You have now covered the basics of Labview programming. In this tutorial, you have seen how to include
structures in programs, use various display options and use file operations. This concludes the basic introduction
to programming in Labview. Future tutorials will focus on some of the more powerful features of Labview to
process data and make control decisions which will support the learning outcomes of the module.

John Hedley, School of Engineering, 2024. Page 13


MEC8063 Introduction to Mechatronics Design
Appendix 1: The electronic workbench setup in Merz Court

Figure A1: The electronics workbench in Merz Court. Similar equipment can be found in the new electronics
workshop in the Stephenson Building.

The 4 main items of equipment are shown in figure 1 and consist of:

DC power supply – this is a voltage (and current) source, these typically have either a set output voltage or can
have an output voltage that can be tuned to within a specific range.

DVM (digital voltmeter) – these can measure voltage and resistance (when connected in parallel) and current
(when connected in series). They are predominantly used for d.c. (or very slow changing) measurements but can
also be used to measure the amplitude of a.c. signals. In the lab, this is a benchtop piece of equipment but
typically these are handheld devices.

Signal generator – this is a voltage supply with the output being a specific waveform, for example a sinusoidal
(a.c.) voltage waveform, a square waveform, a ramp, etc. The frequency and amplitude of the output can be
controlled. There is also the option to have a d.c. offset on your signal.
Note: An a.c. signal will go from periodically change from, for example, -2.5V to +2.5V. If you add a d.c. offset of
2.5V, the output will then range from 0 to 5V.

Oscilloscope – this is a voltmeter that shows voltage as a function of time. This is displayed as a plot with time
along the x axis and voltage on the y axis. Depending on the settings when the trace reaches the end of the x-axis
it will:
1. STOP – when in single capture mode
2. START AGAIN – when in continuous mode
3. WAIT AND START AGAIN AT AN APPROPRIATE TIME – when in continuous mode and an appropriate
trigger level is set
The difference between points 2 and 3 above is that 3 will make the trace start at the same point in the waveform
each time (for example when it crosses zero with a positive slope) and thus it is easier to see the waveform.

For developing electronics, the oscilloscope is the most commonly used piece of test equipment. Analogue
oscilloscopes are generally the older type but will perform the job adequately. Digital scopes are the more
modern version and they differ to analogue scopes in two main ways:
• The signal collect is stored in memory which allows for saving and processing of the data.
• The buttons are soft keys (pressing a button runs a sub-program rather than creating an actual physical
connection). This gives the added functionality of having options such as Autoscale (automatically sets the
appropriate values such as voltage scale, time base and trigger level for you). It also means that switching
the oscilloscope off and back on again will reset the settings (which can be a good or bad thing).

John Hedley, School of Engineering, 2024. Page 14

You might also like