Surname: Lab Group

Surname:
Lab Group Letter:
First Name:
Circle category that relates to you
MEng EEE / BEng EEE / CES / TBS / DMEM/
BTech ( Bell College)/ BTech EEE / (ERASMUS or Exchange
student)
Department of Electronic and Electrical Engineering
University of Strathclyde
19328/19218 Measurement and Control
Lab Worksheets: LabVIEW development
Dr R Katebi/Dr J Wilkie
GH7.52/GH7.53
Industrial Control Centre
Department of Electronic and Electrical Engineering
University of Strathclyde
JW:Labview_v3
1
The following Lab worksheets contain 5 sections:
1.
2.
3.
4.
5.
6.
Introduction to LabVIEW
Using LabVIEW to interface to a real system
Measurement of time constant and gain of d.c. servo
Using LabVIEW to send a signal to the dc servo
Connecting up a closed loop system
Testing the closed loop responses
1. Introduction to LabVIEW
Objective:
The objective of this lab is to learn how to develop a small program (or ‘VI’) in LabVIEW
and run the VI.
1.1 What is LabVIEW?
LabVIEW a program development application, much like various C or BASIC software
development tools. It is, however, different from those applications in one important respect.
LabVIEW uses a graphical language, G, to create programs in block diagram form while
other programming tools use text-based languages. LabVIEW includes libraries of functions
and development tools designed specifically for instrument control. It has application specific
libraries for data acquisition, serial instrument control, data analysis, data presentation and
data storage.
LabVIEW programs are called Virtual Instruments (VIs) because their appearance and
operation imitate actual instruments. VIs contain an interactive user interface, which is called
the front panel, because it simulates the panel of a physical instrument. The Front Panel can
contain knobs, push buttons, graphs, and other controls and indicators. The actual program is
included in the Block Diagram Window.
1.2 How to Start LabVIEW?
Either
Double-click on the LabVIEW icon.
Or go to
Start → Program→ LabVIEW →LabVIEW ( ignore , or cancel all registration information).
After a few moments, two blank, untitled windows appear. The first window with the gray
background is the Front Panel. The one with the white background is the Block Diagram
panel.
JW:Labview_v3
2
1.3 Running The Temperature Demo
Open the temperature System demo VI by following these steps:
a.
b.
c.
d.
e.
Select file open.
Double-click on examples.llb.
Double-click on apps.
Double-click on tempsys.llb.
Double-click on Temperature System Demo.vi.
After a few moments, the Temperature System Demo VI front panel appears. The front panel
contains several numeric controls, Boolean switches, slide control, knob controls, charts,
graphs, and a thermometer indicator.
JW:Labview_v3
3
The Temperature System Demo VI simulates a temperature monitoring application. The VI
takes temperature readings and displays them in the thermometer indicator and on the chart.
The Update Period Slide controls how fast the VI acquires the new temperature readings.
LabVIEW also plots high and low temperature limits on the chart, which you can change
using the Temperature Range knobs in the middle left border. If the current temperature
reading is out of the set range, LEDs light up next to the thermometer.
1.4 How to run VIs
Follow these steps to run the demo.
1. On the front panel toolbar, click
2. Click on the stop
3. Click on the continuous run
on to run button to start the demo.
button to stop the demo.
button to continuously run the demo.
4. Turn the data analysis on and off by clicking on the
5. You can also stop the demo by clicking on the
6. You can also the Pause/Continuous button to
button
Acquisition switch.
start and stop the program.
This is usually used for debugging the program.
When you use this button, the
Block Diagram Panel opens and you can see the block diagram of the Temperature demo.
7. On the Block Diagram Panel, click on File and click on Close to close this window.
1.5 How to Change Data
To change any of the operating data on the front panel, follow these steps:
1. Click on the Windows menu.
2. Click on the Show Tools Palette. The following Tools Window will appear.
You can move the tools Palette to a clear space by holding it with the mouse and move it
around.
Operating Tool
Positioning Tool
Wiring Tool
Break Point Tool
Coloring Tool
3.
4.
5.
6.
Labeling Tool
Pop-up Menu
Scrolling Tool
Color Copy Tool
Probe Tool
Click on the Label
button. This is called the Operating Tool.
Click on the value of
High Limits on the Temperature Panel..
Use backspace key to clear the old value.
Enter the new value.
JW:Labview_v3
4
7. Now, try to change the following settings:
i.
The upper limit of the temperature range to 87.0.
ii.
The upper limit of the Update Period slide (in system controls) to 2.0.
iii.
Try to change a few values of your own choice.
8. Close the Temperature Demo VI.
1.6 Creating a VI
VIs have three main parts: the Front panel, the Block Diagram panel, and the icon/connector.
The icon/connector will not be discussed in this tutorial.
1.6 1Front Panel
You build the front panel of a VI with a combination of controls and indicators. Controls are
your means of supplying data to your VI. Indicators display data that your VI generates.
There are many types of control and indicators. You add various controls and indicators to
the front panel from the various sub-palettes of the Control palette. Now, go to file menu and
open a new VI. If the Control palette is not visible,
Select Show Controls Palette from the Windows menu.
1.6.2 Numeric Controls and Indicators
The two most commonly used numeric objects are the digital control and digital indicator.
1. Click on the Numeric icon in the Controls Palette.
2. Click on the Digital Control.
3. Move the mouse to the front panel (hand symbol) and click. The Digital Controller
appears on the front panel.
4. Use the Operating tool to change the value by clicking on the increment buttons.
5. Click on your Digital Control with right-hand mouse button, click on Show, click on
Label, and use the keyboard to type ‘No.1’. This automatically goes in the box that
appears. A small box appears on the top of the digital control.
6. As in the diagram below, put another digital control on the front panel and call it No. 2.
JW:Labview_v3
5
7. Put another digital control on the front panel and call it No.1+No.2. Then, click on the
digital control with the right-hand mouse button; click on Change to indicator.
8. Put another digital control and call it No.1-No.2. Change to indicator. Your front panel
should look like this:
Note:
•= To edit text you must use the ‘A’ buttons from the Tools Palette.
•= To move a box you must use the pointer buttons from the Tools Palette.
1.7 Block Diagram
To open the block diagram, go to Window menu and click on Show diagram. The following
window will appear.
Input Terminals
Output Terminals
The block diagram is composed of nodes, terminals and wires.
Nodes are program execution elements. Nodes are analogous to statements, functions and
subroutines in text-programming languages. There are no nodes in the above diagram. You
will see nodes later.
JW:Labview_v3
6
Terminals are ports through which data passes between the block diagram and the front panel
and between nodes of the block diagram. There are two types of terminals, control/indicator
terminals and node terminals. Controls and indicators terminals belong to the front panel
controls and indicators. Control/indicator terminals are automatically created or deleted when
you create or delete a front panel control or indicator.
To include the functions for add and subtract, go to Windows menu (on Block Diagram
Panel) and click on Show Functions palette (If this not already active). This window appears.
Click on the Numeric button to invoke the following window:
JW:Labview_v3
7
Click on the add function and then click on the block diagram window at the point where you
want to place the add icon. Repeat for the subtract function. The window should look like
this:
You can use the Position tool (pointer) in the Tool Palette to move the icons around on the
block diagram window. Try to move the add and the subtract icons. (You should first choose
the Position tool in the Tool palette by clicking on it. Then click on the add icon, it starts
blinking. Now move the icon by holding it with mouse and move it around.)
1.8 Help
Click on Help menu and then Show Help. Now, move the cursor to the add icon, you will see
the following window. The function has two inputs and one output. You have to wire all the
inputs and outputs for the VI to run.
Nodes
1.9 Wiring
Wires are data paths between terminals. Data flows in only one direction, from a source
terminal to one or more destination terminals. To wire from one terminal to another, use the
Wiring Tool, which looks like a reel of wire in the Tools Palette. Click with the wiring tool
JW:Labview_v3
8
on the first terminal, moves the tool to the second terminal, and click on the second terminal.
You can start wiring at either terminal.
When the Wiring tool is over a terminal, the terminal area blinks, indicating that clicking
will connect the wire to that terminal. You need not hold down the mouse button while
moving the Wiring tool from one terminal to another. You can bend a wire by clicking the
mouse button to tack the wire down and moving the mouse in a perpendicular direction.
If you want to delete any wire, double-click the wire using the mouse pointer and then press
the Delete Key.
Your block diagram window should now look like this:
1.10 Running the VI
You can now go to the front panel and run your VI. Check the results for the following
numbers:
No.1 10
No.2 3
No.1 3
No.2 -5
1.11 Boolean Controls and Indicators
You use Boolean controls and indicators for entering and displaying Boolean (True-False)
values. Boolean objects simulate switches, buttons, and LEDs. The most common Boolean
objects are the vertical switch and the round LED.
Exercise 1: Compare the two numbers in your previous VI and turn on an LED if the
numbers are equal. Run your VI and confirm the result.
2. Using LabVIEW to interface to a real system
Objectives
1. learn how to use LabVIEW to read single analogue input values from a process
2. evaluate the gain in the hardware card interface box
3. learn how to construct a 'while' loop to perform continuous sampling
2.1 How to read single analogue input values from a process
We are going to input a voltage from the potentiometer on the dc motor equipment and
display the output on the Panel .
LabVIEW preparation
In the Panel window, look at
Windows→Show controls→Numeric→Choose a digital indicator
Call this digital indicator ‘Voltage 1’
Controls→String→Choose a String control
Label this 'Channel number for voltage 1'
Now change to the Diagram (Windows → Diagram) and RH click in free space to get
JW:Labview_v3
9
Functions Palette→ Select a VI
( a virtual instrument or existing module)
Ensure you are in the following directory;
c:/LabVIEW/19328
Choose the 'ReadChannel' vi module and place on the Diagram. A block appears entitled
'Read One Data'. With the wiring tool wire 'channel No.' to the input of the Read one data
block. Wire the output of the read one data block to the DBL (double precision number)representing the digital indicator on the Panel. Return to Panel.
Process input wiring preparation
Use the power supply PS150E to supply one of the potentiometers on the attenuator unit
AU150B, with -15 to +15V. The middle terminal connection represents the changing voltage.
Interface box
The interface box contains some electronics which scale the inputs and outputs of the
process. CONNECT THE ANALOGUE GROUND TO THE 0V ON THE POWER
SUPPLY. Connect 0V, -15 and +15V from the power supply to the Interface Box.
Note the 'DC servo' connections:
ACH0, ACH1, ACH2 and ACH3 are analogue to digital input channels 0, 1 2 and 3
DAC0 is a digital to analogue output channel ( number 0) .
DO NOT CONNECT THE DC SERVO INPUTS TO ANY OTHER CONNECTIONS
ON THE INTERFACE BOX.
Connect the output signal from the potentiometer to one of the input channels, for example,
ACH0, and note the channel number. Connect a voltmeter to read this input voltage.
Voltage input in LabVIEW
Enter the channel number on the Panel ( in the box next to ‘Channel number for voltage 1’.
Use the 'enter' key from the numeric keypad or click with the mouse button elsewhere in the
panel to enter the number. Run the VI and note the change shown in the digital indicator.
Check your readings against the voltmeter. Tabulate your results and use an average of your
results to suggest what the scaling of input signals might be.
JW:Labview_v3
10
Voltage at Multimeter
Voltage reading on Panel
Scaling
Average value of scaling factor:
We have taken single samples of the voltage. If we connected the voltage representing the
speed of the rotating shaft of the dc servo, we would still only get single samples of the
output, even though the speed may be varying. .We would really like to write a programme
that continuously samples the input, until told to stop. This is achieved by incorporating the
analogue input samples in a ‘while’ loop.
2.2 Use of a ‘while’ loop to continuously sample the input signal
We need to add a switch to enable us to start and stop the ‘while’ loop. Show the Panel, then
Windows→Show Controls→Boolean→Choose a switch
Label the switch (the label appears in the Diagram which helps you find the appropriate
Diagram symbol. )
Windows→Show Controls→Graph→Choose a waveform chart
This will allow you to see the continuous input signal.
Show the Diagram:
Wire the output of the ‘read one data’ to the input of the waveform chart.
To add the ‘while loop’
Windows→Show Functions→Structure→While loop
JW:Labview_v3
11
A small square appears on the screen. Move it to the top left hand corner of the diagram.
Hold down the LH mouse button and stretch the square so that it covers everything to be in
the while loop ( for us, that it everything in the Diagram), and then let go of the mouse
button. A symbol in the bottom RH corner provides the condition for the termination of the
while loop. Wire the output of the switch to the while loop terminator.
Run Continuously
Return to the Panel and run your VI. Note that you will have to set your switch on to allow
continuous sampling, otherwise you will only have single sample operation. The digital
indicator will scroll very quickly. The waveform chart also moves quickly.
2.3 Adding a sampling rate to your data acquisition VI
For control systems, we need to monitor input signals and output control signals at fixed
sample rates. This is achieved by a timing device.
On the Panel, add a control knob to allow you to choose the sampling period.
Windows→Show Controls→Numeric→Choose a control knob
Set the maximum indicator on the control knob to be 1000 ( that is, 1000 ms)
In the diagram, you need to add the timing device
Windows→Show Functions→Time and Dialog→Choose the metronome looking device
Ensure that this is placed inside your while loop. Wire the control knob for sampling to the
input of the timing device.
Return to the front Panel and run the programme, noting the difference you make when you
alter the sampling . (The sampling control knob provides multiples of ms).
Altering the scales on your chart
To help interpret the responses on your chart, we need to alter the scaling:
Change the sampling to 100ms.
RH click on graph →XScale→Formatting→
change dx to 1.00E-1
change Scale style to give greater resolution (more ticks on axis)
change Digits of precision: 0
3. Measurement of time constant and gain of dc servo.
The objective of this section is to measure the time constant and gain of the dc servo.
3.1 Start LabVIEW from PC with Windows 95
Start → Program→ LabVIEW →LabVIEW ( ignore , or cancel all registration information).
JW:Labview_v3
12
You will again see the two windows: the Front Panel ( or Panel window) and the Block
diagram ( or Diagram window). You can swap from one to the other by using the mouse
cursor on Windows→ show panel or show diagram. In the following , note that 'RH click'
means click on the right hand mouse button, usually with the mouse cursor placed on top of
the object or on a free space on the Panel or Diagram.
3.2 Connecting the dc servo
Ensure the power supply is initially switched off. We are going to connect the following
modules
MT150F
tachogenerator ( provides a voltage representation of angular velocity)
SA150
motor unit
PA150C
Pre-amp unit for servo
Connect 0V, -15, +15 V to the pre-amp unit, PA150C. Connect the outputs 3 and 4 of
PA150C to the inputs 1 and 2 on the SA150 , respectively. Connect the field windings on the
SA150 unit (3 wires).
The tachogenerator, MT150F has both the ‘common’ and connection ‘1’ linked to 0V.
Connection ‘2’ should be connected to the ‘compensation’ unit on the PA150C.
Input signal: Alter the potentiometer to have a voltage range of 0-15V. Connect the output
of the potentiometer to input ‘1’ on the pre-amp unit , PA150C.
Output signal: Connection ‘2’ on MT150F provides the voltage output which represents the
velocity. This should be connected to one of the input channels of the Interface Box.
Run the system. By altering the input voltage , you can see the change in the output of the
motor speed.
3.3 Calculation of time constant
We would like to find out the gain and time constant of the motor. The control block diagram
is given. The Tacho unit is a measurement device which produces a voltage signal that
represents the velocity of the faster motor shaft. Note that there is a gear ratio(30:1) between
the two turning shafts.
Velocity( rad/s)
Velocity( rad/s)
(Main shaft)
(Output shaft)
Input
Motor unit
Gear
ratio
voltage
Km
1
τ=s + 1
30
Output
Tacho Unit voltage
Kt
By putting a step change in input voltage, the output voltage will appear on the wave form
chart and you can calculate the time constant. Use the Zoom command; it looks like a
magnifying glass on the waveform palette.
JW:Labview_v3
13
Sketch of output response:
Calculation of times constant: Show clearly all your working.
How good is your step response? How could you improve it?
3.4 Calculation of system gain
We would like to monitor both the input and output signals of a system to be able to calculate
the system gain. To do this we need to add another waveform chart.
Copy and place another waveform chart and channel number input on the Panel. In the
diagram copy another ‘read-one’ data block’. Wire the channel number to the input of the
read-one-data block, and wire the output of this block to the new waveform chart.
What is the input signal? (and the units?)
What is the output signal? ( and the units?)
What ‘gain’ are you calculating?
JW:Labview_v3
14
Wire the dc servo input voltage from the potentiometer to one of the analogue input channels.
Check the channel numbers are correct on the Panel. Run the VI.
output
Calculate the gain = input from the control diagram.
Value of Gain =
Now clean up your diagram. You may wish to remove the digital indicator on the Panel. You
can remove the ‘palettes’ attached to each chart by using RH click on the chart : the Show
Palette indicator is a toggle switch.
4. Using LabVIEW to send a voltage signal to the dc servo.
Objective:
The objective of this section is to learn how to use the computer to send an analogue signal
to the dc motor.
4.1 Sending an output signal
You will need to add a control knob to the Panel to allow you to control the output voltage.
Windows→Show Controls→Numeric→Choose a control knob.
Set the upper and lower limits on the scale to +5 and -5 V.
On the Diagram, note the ‘DBL’ representing the control voltage. Ensure it lies within the
‘while loop’. Add an Analogue output block:
Windows→Show Functions→Data Acquisition→Analog IO→AO Update Channel.vi
This AO Update Channel block requires a device no. specific to the hardware card and a
channel number:
(device = 1) and ( channel number = 0, since only one output channel, DAC0, available)
Windows→Show Functions→Numeric→Numeric constant
Set to ‘1’ and wire to device number on AO block
Windows→Show Functions→String→String constant
Set to ‘0’ and wire to channel number on AO block.
Use wiring tool to wire the control knob for output voltage to the last input of the AO block.
JW:Labview_v3
15
DC servo connections
Connect multimeter to DAC0 output of Interface box. Run the VI and check your readings
against the multimeter. Tabulate your results and use an average of your results to suggest
what the scaling of output signals might be.
Voltage reading on Panel
Voltage at Multimeter
Scaling
Average value of output scaling factor:
4.2 Recalculation of time constant
Connect the DAC0 output to the input port ‘1’ on the pre-amp unit. (Remove the
potentiometer input.) Redo the step response of the dc servo. Re-calculate your time constant.
Sketch of output response:
JW:Labview_v3
16
Calculation of time constant: Show clearly all your working.
Comment on your result compared to the previous result.
4.3 Analysis
Sketch the connection diagram from the computer to the dc motor and vice versa. Note
which signals are analogue and which are digital.
Describe the purpose of the Interface Box.
JW:Labview_v3
17
5. Closed loop system
Objective
The objective of this section is to connect a position feedback loop to the dc servo.
5.1 Preliminary discussion
Set point
(degrees)
Set point
(Volts)
+
Input
Conversion
K1
Output
velocity
( rad/s)
Error
Position Gain
control
Kp
Interface
voltage
-
Motor unit
Km
τ=s + 1
Output
position
( degrees)
1 180
ns π
Box
Display
Tacho Unit
voltage
Kt
Channel 1
Measurement
Potentiometer
Channel 0
Ko
voltage
The right-hand side of the diagram shows the motor and the measurements of velocity ( via
the tacho unit) and position ( via the potentiometer). 'n' represents the gearbox ratio between
the rotating shaft and the output shaft. These measurements are passed through the interface
box into the computer. The left hand side of the diagram represents the controller. A
reference set point for the rotating shaft is entered ( in degrees) and this is converted to an
equivalent voltage. The error is calculated by subtracting the measured position from the
desired position. This error is multiplied by a constant gain, Kp, and passed back through the
interface box to control the motor.
is programmed in LabVIEW.
In the previous lab, we achieved the continuous sampling of the input signals and passed an
output to the dc servo. In this lab we aim to close the feedback loop in the diagram and
control the dc sercvo.
Values of constants already determined:
Km = 280 rad/s /Volt
Kt = -0.022 V/rads-1
Ko = 15/180=0.0833 Volts/degree:conversion from
(-180o to +180o)to(-15 to +15V)
K1 = 1/36 = 0.0278 V/degree :conversion from (-180o to +180o) to (-5 to +5V)
n = 30 : gearbox ratio
τm = 0.25 seconds
JW:Labview_v3
18
5.2 DC Servo connection: Revision of last lab
Connect the following
Interface Box: 0V, -15V, +15V. Connect analogue ground to 0V.
SA 150D: using three wires connect the field characterisitcs on the dc motor
PA150 C: Connect 0V, -15V + 15V. Connect outputs 3 and 4 to inputs 1 and 2 on SA150D,
respectively. Connect input '1' to DAC0. This is the voltage output from the computer.
MT150F: Connect 'common' to '1' and also to 0V. Connect '2' to the compensation unit on PA150C.
Connect '2' also to ACH1 on the interface box. This is the velocity measurement.
OP150K: Connect -15V, +15V to inputs 1 and 2 respectively. Connect '3' to ACH0 on interface box.
This is the position measurement.
Open the LabVIEW VI
c:\LabVIEW\19328\ 19328 dcservo level1
Look over the panel and diagram. Ensure that you recognise all the components. (They were all used
in the last lab).
Set the sampling time to 10 ms.
Enter the Channel numbers in the Panel.
Run the program.
Alter the 'preset' on PA150 to ensure that for 0V output, the motor shaft does not turn. Check
how the motor behaves when you enter small input voltages ( for example, 0.01V).
5.3 Position feedback loop
We are going to close the feedback loop. To do this, we need to provide a reference set point
and a constant position control gain, Kp. This will give
error = set point - measurement
control output = Kp * error
The measurement is in Volts. However, we would like to enter the setpoint in degrees and
have the LabVIEW programme convert this to volts that can be used to calculate the error
signal.
LabVIEW preparation
In Panel window,
Windows→Show controls→Numeric→Choose a Control knob
Label as position control gain and set max value on scale to 0.2. RH click on the control
knob and let the Format and precision be 3 decimal places.
Controls→Numeric→Choose a horizontal slider control
Label this 'Input position (degrees)'
Switch to the Diagram:
Windows→Show Functions→Numeric→Add a divide sign
Windows→Show Functions→Numeric→Add a numeric constant
JW:Labview_v3
19
Use these components ( with correct numeric constant value!) to convert the input in degrees
to a value in volts. Wire this up now.
Create the error by subtracting measurement from Channel 0 from this set point.
Windows→Show Functions→Numeric→Add a subtract sign
Wire the error connections up now.
To calculate the control output signal, we need to multiply the error signal by the position
control gain. Choose the appropriate components and wire this section up now.
Output of the control signal
In the previous lab we used a voltage output which we set manually. This is still in the
Diagram. We would like to retain this option but also have the option of using the automatic
control via the feedback loop. To achieve this quickly, we will let the output signal be the
sum of both signals; and let either the manual input voltage or automatic position control
gain be zero if we are not using this control method.
Delete the wiring connection from the Voltage output to the AO output.
Add a '+' component. Wire both the Voltage output and the output from the control gain
calculation to the inputs of this summation. Wire the output to the AO output block.
6. Closed loop responses
The objectives of this section are to
1. examine the effect of changing the position control gain on the output response of
the system
2. analyse the block diagram for the position control system
6.1 Experimental results
Run the VI: Tabulate your answers to the following:
Set the control gain Kp to 0.05, 0.1, 0.15, 0.2, 0.25. Describe the behaviour of the output
response in terms of percentage overshoot and settling time.
(Percentage overshoot =
overshoot-final value
x 100)
final value
(5% Settling time: Time taken for response to get within and stay within 5% of final value.)
JW:Labview_v3
20
Control Gain, Kp
Sketch of
behaviour
output %age overshoot
5% settling time
0.05
0.1
0.15
0.2
0.25
Comment on how changing the proportional gain changes the system response.
6.2 Block diagram calculation
(i)
For the general block diagram, calculate the closed loop transfer function from
setpoint to output position. Remember to include the gain from the interface box in
your calculations. If you are unsure of your final calculations, check with the lecturer
before performing the following analysis.
JW:Labview_v3
21
(ii) Evaluate the closed loop transfer function of the dc servo control system using the
parameter values listed and the 5 values of Kp which you used in the lab. What are the poles
for this range of values? Is the system stable for the values? Tabulate your answers.
JW:Labview_v3
22