PREPARED BY:
CLIFF CHAN P.ENG, HIDAYAT SHAHID P.ENG
REVISED BY: MASOUD FARZAM AND LEON WU FALL 2016
I. INTRODUCTION
The laboratory manual has been written to help you to understand the operation of laboratory exercises
and what is expected from you as a student. You should read and comprehend this manual completely.
Laboratory sessions are designed to support and supplement engineering topics introduced in the course
and also to expose you to relevant engineering applications. You are expected to work in small groups in
order to get maximum benefit from performing the hands-on exercises. A total of 5 hands-on exercises
must be completed during the semester. In addition, you will learn and get familiar with FEAS Health and
Safety Policies, which are strictly enforced in all labs.
The hands-on exercises consist of dissection of engineered products and introduction to basic engineering
instrumentation. The lab exercises will help you to develop awareness of the design process for
engineering products. The lab exercises will also develop a foundation of basic engineering knowledge
and develop skills that will include but are not limited to:
In a laboratory setting, it is essential to keep track of what you have done; how you have done it, what
problems occurred, what went well and what went wrong. For this reason you are expected to prepare a
lab logbook. The logbook should be prepared in such a way that somebody else could make sense of it.
When writing a report or quiz on your work later, this lab book will be your main source of information.
It is therefore important to keep a complete record of your work in it. For example, you might not be able
to go back to the equipment later to re-sketch a component you may have forgotten to properly document
during your lab exercise. You should not expect your TA or Laboratory Coordinator to provide the
missing sketches. You should never use your friends logbook unless you have permission from the
Laboratory Coordinator or TA. Please note that Lab Coordinator will sign on your logbooks to ensure that
you are keeping proper records.
Ideally, the lab book is hardbound so that it survives the rough environment of the lab as well as frequent
use afterwards. If you use a collection of loose sheets, you are most likely going to lose the most
important page, or the pages get mixed up and you won't be able to put them back into order. Trying to
keep 'rough' notes on loose sheets of paper and transferring them into a 'neat' lab book afterwards, is a
waste of time and bad practice. Things to note in the lab book are:
The date and the title of the experiment and your objective.
A schematic sketch or drawing of the product used
List and sketches of components
Identification of each component including sensors
A record of what you are doing?
1
If working in groups, a list of your group members including their contact information.
Careful account of your Instructor or TAs presentation or lecture including a short description of
the product and analysis procedure.
Log of problems encountered, and notes
Short appraisal (conclusion/summary) of the lab exercise
Objective
Familiarize the programming environment of NI LabVIEW via constructing a simulation model
and a hardware-in-the-loop prototype with block diagrams and graphical user interface (GUI)
Background
National Instruments LabVIEW is a graphical programming and modeling IDE (Integrated
Development Environment) which allows scientists and engineers to perform system design and
modeling, data acquisition, systems control and monitoring, and systems testing and validation,
etc.
Unlike traditional programming environment where applications are created with a bunch of
command lines in a source code (Fig. 1), LabVIEW uses a programming method called Visual
Programming, which allows users to create applications by moving functions (either predefined
by National Instruments or user-defined functions), building blocks, or code nodes to create
flowcharts or structure diagrams (Fig. 2) that are then compiled and run.
LabVIEW contains a wide variety of toolkits to aid users in building their own models. Each one
of these toolkits has its own unique features or functions such as, programming structure,
instrumentation, signal processing analysis, data communication, controller design, vision and
motion control, etc., depending on the type of toolkits installed in the LabVIEW environment.
Some of these toolkits come as standard features while some others are offered as add-on
packages (you have to pay extra for them!).
The main model file created in LabVIEW is called Virtual Instrument file (file name ends with
.vi extension). A virtual instrument file contains two main bodies: Front Panel (Fig. 3) and Block
Diagram (Fig. 4). Front Panel is where you build your control interface in a graphical format
called GUI (Graphical User Interface) such as, buttons, dials, numeric or character inputs,
numeric or graphical indicators, charts and graphs, etc. Block Diagram is where you specify all
the functions that you want to govern your model such as, programming structures, I/O types,
math functions, control logics, and signal analysis methodologies, etc.
Upon completion of the virtual instrument file, the user can run the file to see if it contains any
errors. If the file is compiled successfully, the results will be displayed on the Front Panel (Fig.
5).
Apparatus
Procedure
Task 1: Create a virtual Function Generator (NI USB-6210 DAQ module is not
required for Task 1)
(Duration: 20 min)
1. Go to Windows Start menu bar and click on LabVIEW (32 bit) under All Programs |
National Instruments | LabVIEW 2011 (32 bit) to launch LabVIEW
2. Click on Blank VI (under NEW) from the Getting Started pop-up window
3. Two windows named Untitled 1 Front Panel and Untitled 1 Block Diagram are now
created for you
4. Go to either one of the windows and save it as Lab1a (make sure you keep the default
file type as VIs (*.vi))
5. In most cases when we create an application, we normally work with the Front Panel
first. As mentioned before, Front Panel is where you build your graphical user interface
(GUI).
6. As a general rule of thumb, you should specify the number and types of inputs and
outputs and identify functionalities of your model. In our case here, we have:
Input
Controls
Amplitude [V]
Frequency [Hz]
Input
Signal
Simulated
Voltage
Signal
Output
Waveform Waveform
in Chart
in Graph
Functions
1) Change amplitude of
input signal
2) Change frequency of
input signal
7. Go to Lab1a.vi Front Panel window and right click on your touch pad, a Controls
Palette will appear (Alternatively, you can also select Controls Palette from the top
toolbar under View). Controls Palette contains all sorts of control tools for you to design
and build your GUI on the Front Panel
8. On the Controls Palette, go to Express | Graph Indicators and click on Chart (Fig. 8)
9. Drag and drop the Chart onto the Front Panel open space. Repeat the same procedure for
Graph
10. On the Controls Palette, drag and drop the Knob and the Dial from Express | Num Ctrls
onto the Front Panel open space. Double click on the label of the Knob and rename it as
Amplitude [V]. Do the same for the Dial and rename it as Frequency [Hz]
11. Place the cursor on the Waveform Chart and right click on your mouse or touch pad,
select Properties. A Chart Properties window will pop up.
12. Type Voltage Signal in the Label box as shown in Fig. 9
10
13. Now try to disable the label of the Waveform Graph, what would you do?
14. Now your Front Panel should look like Fig. 10. Minimize the Front Panel and go to
Lab1a.vi Block Diagram, you should also see that the corresponding blocks of the
control tools can be found on the Block Diagram as shown in Fig. 11
Fig. 10
11
Fig. 11
15. You have just created the input controls and outputs on both windows, but you have not
specified the input signal and the functions you want your model to perform. So now you
have to drag and drop these items you have defined (refer to the table in Procedure #6)
onto the Block Diagram. The type of input signal we want here is called Simulate
Signal. The Simulate Signal block can be found when you right click the touchpad on
the Block Diagram and look into Express | Input. This particular function created by NI
already has the functionalities to change both the amplitude and frequency of the input
signal, so no more function blocks are required for our application here in this regard.
After you have inserted the Simulate Signal block onto the Block Diagram, your Block
Diagram should look like this (Fig. 12).
12
Fig. 12
16. Double click on the Simulate Signal block, a Configure Simulate Signal window will
be opened (Fig. 13). This is where you configure your input signal settings such as, signal
type (e.g. sine, square, triangle, sawtooth, DC), amplitude, frequency, offset, phase as
well as the sampling rate, etc.
Why do we need to create the knob and dial on the Front Panel if every setting can
be configured at the Configure Simulate Signal window?
13
True. In fact, not all settings or parameters can be configured outside of the
Configure Simulate Signal. For example, sampling rate is one of the settings that
cannot be configured elsewhere. However, using input controls on the Front Panel
offers a few advantages: 1) allows change-on-the-fly configurations; 2) better
visual aid and more user-friendly; and 3) allows settings to be overridden even the
values were pre-set initially at the Configure Simulate Signal window
Fig. 13
17. Now you have all the function blocks you need. It is time to wire them together and
complete the application. To so do, go to the Block Diagram and place the cursor on the
terminal of the (source) block that you want it to be connected to, the cursor will turn to a
roll of thread symbol. Click on the terminal and drag the roll of thread cursor towards
the terminal of another (destination) block that you want the source block to be connected
to. Then, click on the destination terminal. Now the two blocks should be connected by a
single wire. Repeat the same procedure for all other blocks on the Block Diagram. Make
sure you wire the correct terminals together. For example, terminal from the Amplitude
block should be connected to the Amplitude terminal of the Simulate Signal block (Fig.
14
14). Remember, each wire represents a single data source and your application may not
run successfully if there are broken wires on the Block Diagram
Fig. 14
18. Wire all the blocks together on your Block Diagram according to Fig. 15.
15
Fig. 15
19. Now you can place the cursor on the white arrow (Run) button and start the simulation.
What did you observe?
No, everything is fine except you ask your simulation to execute only once. That
is the reason why it stops right after you release the Run button. For continuous
running application in LabVIEW, you have to encapsulate all the blocks (blocks
you want to run continuously) inside an Execution Control called While Loop.
While Loop allows blocks to run infinite times until a stop criterion is reached or
the user halts the application to a stop via pressing the Stop button on the toolbar.
20. To allow continuous execution, right-click on the Block Diagram and bring up the
Functions Palette. Select While Loop under Express | Execution Control and insert it
16
to the Block Diagram. When you add the While Loop to the Block Diagram, you have to
drag it over all the blocks to be encapsulated in the loop. When all is done, your Block
Diagram should look like this (Fig. 16)
Fig. 16
21. Now run the simulation again and see what happen. What did you observe? Are the
results easy to read?
No, it is doing what you have asked for. However, the waveforms appear on the
chart and the graph are difficult to read because they are updated too quickly on
the plot. You may notice in the Configure Simulate Signal window in Fig. 13,
there are two radio buttons under Timing which allow the user to select either to
run the simulation with the Simulate acquisition timing or to Run (it) as fast as
possible. The former allows the application to run in synchronize (as much as
possible) with real time and the latter runs the application as fast as the internal
CPU clock permits. So to slow down the plotting rate on the chart/graph such that
the user can see the change of waveforms easily, one can simply select Simulate
acquisition timing. Simulate acquisition timing allows an application to work in
real time. This is especially useful because the user can get a feel of the true time
response of the system.
Is there any other way that you can slow down the chart/graph update? How about
changing the Samples per second (Hz) and Number of samples at the Configure
Simulate Signal window?
Well, before we answer this question, we should know what these settings mean.
Samples per second (Hz) defines how often a signal is sampled or generated
either by the hardware (e.g. DAQ module) or the computer (e.g. if it is a pure
simulation). Number of samples defines how often a signal is updated or plotted
on the display within one sampling cycle time. For example, if we define the
Samples per second (Hz) as 1 kHz (1000 Samples per second) and Number of
samples as 100, it simply implies that we will acquire or generate signal once
every 0.001 second and within this 0.001 second, 100 points will be plotted on the
display. In LabVIEW, there is a default (when the Automatic box is checked)
Sample per second to Number of samples ratio of 10:1 to ensure data points are
plotted smoothly on the chart/graph. So come back to the question, theoretically
speaking, you can just reduce the values of both settings in order to slow down the
updating rate of the display. However, since the CPU clock runs thousands of
times faster than the minimum time it takes for the naked eyes to catch a moving
dot, you will have a hard time reading the chart/graph even if you input the lowest
values to both settings. Therefore, choosing Simulate acquisition timing will be
a better option in this case.
22. Now make the changes and run the simulation again. What did you see this time?
18
23. Turn the Amplitude knob and frequency dial and see what happen to the chart and the
graph. Do you see any difference between the knob and the dial? What is the major
difference between a chart and a graph?
Task 2: Create a virtual Thermostat (NI USB-6210 DAQ module is not required for
Task 2)
(Duration: 20 min)
What is a Thermostat?
19
Fig. 17
7. Go to the Block Diagram, drag and drop the Subtract block from Express | Arithmetic
and Comparison | Express Numeric
8. Drag and drop the Less than 0? block from Express | Arithmetic and Comparison |
Express Comparison
9. Drag and drop the Greater than 0? block from Express | Arithmetic and Comparison |
Express Comparison
10. Now complete the wirings according to the Block Diagram shown in Fig. 18. Can you
complete the wirings successfully?
20
Fig. 18
What are the four funny little blocks in the middle of the Block Diagram used for?
Where can I find them?
These little blocks are Signal Manipulation blocks used for data type
conversions. Since the signal coming out from each block may have its own data
type (e.g. floating point, string, Boolean, scalar, waveform, 1-D array, 2-D
array..etc.), to allow the signal moving uniformly in between blocks, it is
necessary to use these signal manipulation blocks. Otherwise, the wires will not
be connected successfully. There are two types of data conversions we use here.
The ones on the left are called From DDT (Convert from Dynamic Data) while
the ones on the right are called To DDT (Convert to Dynamic Data). For our
task here, we use Boolean as the Scalar data type for both conversion blocks.
These conversion blocks can be found under Express | Signal Manipulation
21
11. Go back to the Front Panel and set the Temperature Setpoint to 25 C. Then, click Run
to start the simulation. Once the simulation is in progress, change the temperature value
on the fly with the Knob. What did you observe? Is your model working as you
expected?
12. Specify the inputs and outputs and identify the functionalities of this model. Fill out the
table below:
Input
Controls
Input
Signal
Output
Functions
What is hardware-in-the-loop?
1. Connect the NI USB-6210 DAQ module to the laptop and wait for driver initiation
2. A green light next to the USB port of the DAQ module should be flashing if the driver
initiation is completed successfully
3. Double click the NI MAX icon on your Desktop to launch Measurement and
Automation Explorer
4. Expand the Devices and Interfaces directory on the left panel, make sure NI USB-6210
Dev is declared without a red cross there. Congratulations if your Measurement and
Automation Explorer window looks like the one shown in Fig. 19. This means your DAQ
22
module is successfully connected to your laptop. Otherwise, unplug, reconnect the DAQ
module and reconfigure the driver
Fig. 19
5. Connect the 10-k potentiometer and the jumper wire as shown in Fig. 20
23
AI0 +
AI0
Fig. 20
8. Expand the Acquire Signals directory and select Voltage from Analog Input
9. Click on ai0 (analog Input Channel 0) and then click Finish
10. Enter 5 for the Max Input Signal Range (supply voltage of 5V) and 0 for the Min Input
Signal Range
11. Choose Continuous Samples for the Acquisition Mode
12. Reconnect all the wires in the Block Diagram. Your Block Diagram should look like the
one shown in Fig. 21 and your Front Panel should look like Fig. 22
Fig. 21
25
Fig. 22
13. Turn the potentiometer and observe the change of the thermometer reading as well as the
heater and A/C indicator lights. Does it work?
In Task 2, the knob that is used to simulate the temperature has a full range from 0
to 30 degrees Celsius. Now in Task 3, the 10-k potentiometer is used to
substitute the knob. The problem here is that the maximum (voltage) value the
analog channel gets is 5V (from the DAQ +5V supply). So in order to reach the
full range of the temperature reading, we have to multiple the analog input value
by 6.
26
14. Insert the Multiply block and the Numeric Constant block as shown in Fig. 23 to
complete the Block Diagram.
Fig. 23
15. Now try again and run the simulation. Can the model this time duplicate what the virtual
thermostat of Task 2 does? Do you see a problem of such control method for a thermostat
(you will know the answer after you completed Lab 2)?
Reference
[1]
https://en.wikipedia.org/wiki/Hardware-in-the-loop_simulation
27
Objective
Instrumentation of a Type-K thermocouple to be used for the design and fabrication of a
thermostat prototype
Background
Thermocouple is a complete circuit involving two dissimilar pure metal or alloy wires joined
together to form a loop [1, 2] as seen in Fig. 1. If a difference of temperature exists between both
ends, a difference in junction potential will occur resulting in a thermoelectric e.m.f.
(electromotive force) known as the Seebeck effect, which was discovered by Thomas Seebeck in
1821. If one junction is maintained at a constant and known temperature (the reference or cold
junction), and the characteristics of the thermocouple are known, the magnitude of the e.m.f.
generated will be a measure of the temperature of the other junction (hot junction). Depending on
the metals used and the temperatures of the junctions, the value of the potential difference
(usually measured in millivolts) varies. It is important to know that the e.m.f. generated for any
particular two metals at a given temperature will be the same, regardless of the size of the wires,
the areas in contact, and the method of joining them together [1].
Hot
Tref
Cold
Imagine if the circuit in Fig. 1 is broken at the center and only the left half of the circuit retains,
we now have constructed a simple thermocouple as illustrated in Fig. 2. The open circuit voltage,
the Seebeck voltage, is a function of the junction (thermocouple) temperature and the
composition of the two metals.
28
Metal A
T
Tref
+
eAB Seebeck voltage
Thermocouple
Metal B
Fig. 2 Simple thermocouple
What is Instrumentation?
Instrumentation is defined as the design, construction, and provision of
instruments for measurement, control, etc.; the state of being equipped with or
controlled by such instruments collectively [4].
For small changes in temperature, the change of Seebeck voltage is linearly proportional to the
change of the junction temperature given by:
(1)
= ()
(2)
29
Fig. 3 Seebeck Coefficient versus Temperature plot for various types of thermocouple [2]
As you can see from the plot in Fig. 3, Eq. (2) is a non-linear function. Hence, Eq. (1) is also a
non-linear function. Only for small temperature changes or within a linear region (as shown by
the shaded area in Fig. 3), can be taken as a constant. From the plot, we can see that the slope
of the Type-K (Nickel Chromium vs. Nickel Aluminum) thermocouple approaches a constant
over a temperature range from 0C to 1000C. However, for a wider temperature range,
nonlinearity has to be taken into account. Thus, Eq. (1) has to be expressed as a non-linear
function with a second-order polynomial approximation as:
= + 2 2
(3)
30
where is the generated e.m.f. in volts, T and Tref are the measured temperature and the
reference temperature in K respectively, and a and b are constants dependent on the
thermocouple material. Constants a and b have to be determined experimentally.
In theory, if we measure the Seebeck voltage (using a voltmeter or DAQ module) according
to the setup in Fig. 2, we can determine the temperature T at the measure point. In reality,
however, this is not as straight forward as you may think. By connecting the leads of the
thermocouple to the voltmeter or DAQ module (Fig. 4), two more metallic junctions J2 and J3
will be created and they will create additional e.m.f.s to the thermocouple circuit. The additional
e.m.f.s will affect the measured value of . Note that regardless if there is any external copper
wires connection, the terminals connecting the internal circuitry of the voltmeter or DAQ module
are most likely made of copper.
Metal A
Thermocouple
J1
T
Metal B
J2 Metal C
eAB
J3 Metal C
DAQ
Fig. 4 Thermocouple-DAQ circuit
If we convert Fig. 4 into its equivalent circuit diagram, it will look like the circuit depicted in
Fig. 5.
J2
Thermocouple
J1
T
Metal A
+
V1
Metal B
+ V2
Metal C
+
eAB
+ V3
Metal C
J3
Fig. 5 Thermocouple-DAQ equivalent circuit
31
Hence, the voltage V1 across the thermocouple J1 is going to be the sum of the voltages (V2 and
V3) measured across each junction plus measured by the DAQ module:
1 = 2 + 3 +
(4)
So, to determine the temperature T at J1 from the measured value of , Eq. (4) will have to be
rearranged to:
= 1 2 3 2 3
and thus,
(5)
+ 2 + 3
(6)
where 2 and 3 are temperatures at J2 and J3 respectively. According to Eq. (6), before we can
find out the temperature T, we have to know the temperatures 2 and 3 .
J2
Thermocouple
J1
T
Metal A
+
V1
Metal B
Tref
Isothermal
+ V2
+
eAB
+ V3
J3
Fig. 6 Thermocouple-DAQ equivalent circuit
To reduce the number of variants in the equation, we can connect J2 and J3 to an isothermal block
(Fig. 6). Isothermal block is an electrical insulator but a good heat conductor and it serves to hold
all three junctions at the same temperature. According to the Law of Intermediate Metals, which
states that a third metal inserted between the two dissimilar metals of a thermocouple junction
32
will have no effect upon the output voltage as long as the two junctions formed by the additional
metal are at the same temperature (Fig. 7) [2].
Metal
Metal
Metal
Isothermal
Metal
Metal
Isothermal
Therefore, by holding the junctions J2 and J3 to a constant reference temperature Tref, Metal C
(from Fig. 5) can be eliminated and Eq. (6) can be reduced to:
(7)
where the reference temperature can be measured by any device which has a characteristic
proportional to absolute temperature such as a thermistor, an RTD (Resistance Temperature
Detector), or an I.C. sensor (Integrated Circuit sensor). Thus, if we know the reference
temperature Tref and the measured value of , the thermocouple temperature T can be
33
determined. Note that Tref is NOT the initial temperature and it can change with respect to time
(time dependent). This is one of the disadvantages of using a non-calibrated thermocouple
because you always need to have a device to measure the reference temperature. It cannot
function alone (Thats another reason why it is call a couple?).
If a thermocouple is calibrated correctly, its output should be traceable according to standards
such as ASTM (American Society for Testing and Material) or NIST (National Institute of
Standards and Technology). For the thermocouple we use here, it was calibrated according to the
NIST standard, therefore, it should follow closely to the power series polynomial of Eq. (8):
= 0 + 1 + 2 2 + 3 3 + +
(8)
where n is the maximum order of the polynomial (up to n = 9), and a is the NIST Polynomial
Coefficients given in Table 1.
TYPE E
a0
a1
a2
a3
a4
a5
a6
a7
a8
a9
Nickel-10%
Chromium (+)
vs Constantan ()
-100C to
1000C
0.5C
9th order
0.104967248
17189.45282
-282639.0850
12695339.5
-448703084.6
1.10866E+10
-1.76807E+11
1.71842E+12
-9.19278E+12
2.06132E+13
TYPE J
TYPE K
TYPE R
TYPE S
Iron (+) vs
Constantan (-)
Nickel-10%
Chromium (+) vs
Nickel-5% (-)
Platinum-13%
Rhodium (+) vs
Platinum (-)
Platinum-10%
Rhodium (+)
vs Platinum (-)
0C to 1370C
0.7C
8th order
0.226584602
24152.10900
67233.4248
2210340.682
-860963914.9
4.83506E+10
-1.18452E+12
1.38690E+13
-6.33708E+13
0C to 1000C
0.5C
8th order
0.263632917
179075.491
-48840341.37
1.90002E+10
-4.82704E+12
7.62091E+14
-7.20026E+16
3.71496E+18
-8.03104E+19
0C to 1750C
1C
9th order
0.927763167
169526.5150
-31568363.94
8990730663
-1.63565E+12
1.88027E+14
-1.37241E+16
6.17501E+17
-1.56105E+19
1.69535E+20
0C to 760C
0.1C
5th order
-0.048868252
19873.14503
-218614.5353
11569199.78
-264917531.4
2018441314
Table 1
TYPE T
Copper (+) vs
Constantan (-)
-160C to
400C
0.5C
7th order
0.100860910
25727.94369
-767345.8295
78025595.81
-9247486589
6.97688E+11
-2.66192E+13
3.94078E+14
34
What is Temperature?
Apparatus
Thermocouple
bead
35
Procedure
Task 1:
Thermostat simulation with the use of LabVIEW build-in function for the
instrumentation of thermocouple
(Duration: 30 min)
1. Connect the NI USB-6210 DAQ module to the laptop and wait for driver initiation
2. A green light next to the USB port of the DAQ module should be flashing if the driver
initiation is completed successfully
3. Double click the NI MAX icon on your Desktop to launch Measurement and
Automation Explorer
4. Expand the Devices and Interfaces directory on the left panel, make sure NI USB-6210
Dev1 is declared without a red cross there.
5. Go to Windows Start menu bar and click on LabVIEW (32 bit) under All Programs |
National Instruments | LabVIEW 2011 (32 bit) to launch LabVIEW
6. Open and use Lab1c.vi from Lab 1
7. Save the file (select File | Save As) as Lab2a.vi
8. Go to the Front Panel of Lab2a.vi and construct a GUI according to Fig. 9
9. Rename the Waveform Chart to Temperature Plot and the horizontal (y) axis from
Amplitude to Temperature [Deg C]
10. Go to the Block Diagram, place the Temperature Plot block inside the While Loop
11. Now identify your input, output and functions of your model (Hint: Go back to Lab 1 if
you forget how to do this)
Input
Controls
Input
Signal
Output
Functions
12. Remove the Gain of the input (the little blue box connected to the Multiply block
downstream of the DAQ Assistant block) and the Multiply block. We are now working
with the thermocouple not the potentiometer in Lab 1, so we need a unity gain for the
direct read out value from the thermocouple to be used for the voltage to temperature
conversion
13. Bring up the Functions palette, insert the Merge Signals block from Express | Signal
Manipulation to the While Loop
14. Connect the DAQ Assistant output signal wire and the Temperature Setpoint signal
wire to the input signal ports of the Merge Signals block. Then, connect the combined
signal port of the Merge Signals block to the Temperature Plot
15. Connect another wire from the DAQ Assistant output port to the Thermometer
16. Remove the Simulate Signal (DC) block and its associated wires.
17. Double-click the DAQ Assistant block and remove Voltage from Channel Settings as
shown in Fig. 10
37
Fig. 10
38
Fig. 11
19. Select the appropriate Thermocouple Type and enter a value for the CJC Value (Cold
Junction Constant Value) (see Fig. 12). The CJC Value can be approximated by using a
physical temperature measuring device (e.g. thermometer) or the Device Properties |
Current Temperature value by launching the Measurement and Automation
Explorer as depicted in Fig. 13
39
Fig. 12
Fig. 13
40
20. Add a Dial on the Front Panel and name it as Temperature Offset [degC]. We use this
temperature offset to zero the residue voltages that exist at the various junctions of the
thermocouple circuit. We call this procedure as Software Compensation
21. Connect all the blocks together, your Block Diagram should look like the diagram
depicted in Fig. 14
Fig. 14
AI0 +
AI0
22. Now connect the thermocouple according to the photo and circuit diagram depicted in
Fig. 15
Fig. 15
Jumper wire
Thermocouple connection
23. Hold the thermocouple such that the tip (bead) is not touching anything except the air.
We can assume the junctions connected to the DAQ terminals (AI0+ and AI0-) and the
thermocouple all stay at the same reference temperature Tref. Now hit the white arrow
42
Run on the Front Panel and turn the Temperature Offset dial simultaneously such that
the temperature reading matches with the current temperature of the device as depicted in
Fig. 13. This will be your Tref. Can you read off the temperature value easily?
24. Your thermometer measurement probably has a lot of noise and is hard for the user to
read. One easy way to solve this problem is to utilize a filter that filters out the noise or to
smooth the signal plot. To do so, drag and drop a Filter block from Express | Signal
Analysis onto the block diagram. The Filter block should be inserted between the DAQ
Assistant block and the Add block
25. Select the Filtering Type and Filter Specifications according to Fig. 16
Fig. 16
What is a Filter?
26. The Half-width of moving average denotes how often you want to average the results.
For example, if the half-wide of moving average M is set to 100 sampling points, the total
sampling points N that are used to calculate the average value will be N = 2M + 1. In
other words, for a sampling rate of 1 kHz, a 100 samplings of the half-width of moving
average is equivalent to the duration of 201/1000 second, which is 0.201 second. So in
this case, the signal is averaged out for every 0.201 second. The higher the value of the
half-width of moving average, the smoother the plot but the slower the plot responds.
Thus, the value of the half-width of moving average should be chosen such that it
provides a smooth plot and yet the plot is fast enough to capture the dynamics of the
system
27. Input the value 200 for the half-width of moving average and press the white arrow Run
button on the Front Panel to run your model. Did you see any changes this time?
28. Now adjust the Temperature Setpoint (denoted by the red line in the Chart) and match
it with the reference temperature Tref plot
29. Put your finger tip close to the thermocouple (but do not touch the tip) or put the
thermocouple next to the CPU cooling fan of your laptop. See if you can raise the
temperature. As the temperature rises above or drops below the setpoint (red line), did
you see the Heater or the A/C indictors switch on and off? Is this what you have
expected? Do you see any problem with this type of control strategy?
30. If the measured temperature continuously fluctuates about the Temperature Setpoint, the
Heater and A/C will be turning on and off all the time. This is probably not what you
44
want as this not only wasting energy, it also reduces the life cycle of the Heater or the
A/C. One way to solve this problem is to insert a predefined nonlinearity called Schmitt
trigger into each temperature control device, one for the heater and one for the A/C.
Schmitt trigger (Fig. 17) allows the user to specify two threshold values instead of one
setpoint (Fig. 18). The two thresholds (upper and lower) are used for switching the
temperature control device either on or off while the region between the thresholds is
used to hold the temperature control device on or off for a certain time period. Fig. 19
shows a typical control strategy of a heater with a Schmitt trigger. For the case of the
A/C, the control (on/off) logic will be the opposite of the plot shown in Fig. 19.
Holding Time
Lower Threshold (i.e.
setpoint for Heater)
Schmitt trigger
Schmitt trigger is a device used for noise rejection and prevention of undesired
multiple triggering. When the input voltage is beyond an upper switching
threshold and giving a low output, the input voltage needs to fall below the lower
threshold before the output can switch to high. Conversely, when the input
voltage is below the lower switching threshold and giving a high, the input needs
to rise above the upper threshold before the output can switch to low. Such a
device can be used to sharpen slowly changing signals because when the signal
passes the switching threshold it becomes a sharply defined edge between two
well-defined logic levels [6].
45
Temperature
Hot
Cold
Setpoint
Time
Fig. 18
Heater OFF
Temperature
Hot
Upper Threshold
Heater On Hold
Cold
Heater Off Hold
Heater ON
Lower Threshold
Time
Fig. 19
46
31. To construct a Schmitt trigger, we can use a Comparison (In Range) block from
Express | Arithmetic and Comparison | Express Comparison and another
Comparison (Greater OR Equal) block connected in parallel to each other as illustrated
in Fig. 20. In the Configure Comparison (In Range) window, set the minimum value
to 0 and maximum value to 0.5. These two values represent the lower and upper
thresholds of the Schmitt trigger. Enter 0.5 in the Numeric Constant block next to the
Comparison (Greater OR Equal) block. This numeric constant is the ON trigger which
defines how high above the temperature setpoint the A/C starts to kick in. The triangular
block located downstream of the two Comparison blocks is called Select and you can get
it from the same Express Comparison directory. This completes the Schmitt trigger of
the A/C control. Now follow Step 32 to construct a Schmitt trigger for the heater control.
Fig. 20
32. To construct a Schmitt trigger for the heater control, simply copy and paste the subsystem structure you have created in Step 31. Double-click the Comparison (In Range)
block and change the minimum value to -0.5 and maximum value to 0. These two
values specify the lower and upper thresholds of the Schmitt trigger for the heater
control. Now replace the Comparison (Greater OR Equal) block with the Comparison
(Less OR Equal) block and change the value in the Numeric Constant block to -0.5.
This numeric constant is the ON trigger which defines how far below the temperature
setpoint the heater starts to kick in. Your Schmitt trigger of the heater control should look
like the one in Fig. 21.
Fig. 21
33. Now modify your LabVIEW block diagram to include the two Schmitt triggers you have
constructed in the previous steps. Your new block diagram should look like the one
depicted in Fig. 22.
Fig. 22
The four blue arrows sitting on the border of the while loop are called Shift Registers.
Shift registers are used to pass values from the previous iteration to the present iteration
in a looping structure. In other words, they occupy memory to pass previously stored data
48
to the present state. Shift Register comes in pairs: one for the incoming data and the other
for the outgoing data. To create a shift register, simply drag a wire to or create a wire
from the border of the While Loop, then, right-click on the little square box called Loop
Tunnel and select Replace with Shift Register as shown in Fig. 23.
Fig. 23
34. Now run your simulation model and observe the changes you have made. Is this control
strategy with the use of Schmitt triggers more reliable to use?
Task 2:
Thermostat simulation with the use of the NIST polynomial for the
instrumentation of thermocouple
(Duration: 30 min)
5. Construct a polynomial according to Eq. 8 with the NIST Polynomial Coefficients listed
in Table 1. Then, insert the polynomial into the While Loop of your model. (Hint: The
polynomial should be placed in between the DAQ Assistant block and the Filter block)
6. Now run your model and observe the differences between this new model and the one
you constructed earlier in Lab2a.vi
References
[1] Doyle, F. E. and Byrom, G. T. Instrumentation Temperature. Blackie & Son Limited,
London, England, 1970.
[2] Omega Temperature, Vol. 26, Omega Engineering Inc., Stamford, CT, USA, 1988.
[3] http://en.wikipedia.org/wiki/Temperature
[4] Oxford English Dictionary.
http://www.oed.com/view/Entry/97170?redirectedFrom=instrumentation#eid
[5] Rizzoni, Giorgio, Principles and Applications of Electrical Engineering (4th Edition). The
McGraw-Hill Companies, New York, 2004.
[6] Bolton, W, Mechatronics Electronic Control Systems in Mechanical and Electrical
Engineering (3rd Edition). Pearson Education Limited, Harlow, England, 2003.
50
Objective:
The purpose of this experimental exercise is to explore the mechanical dissection of a hand drill.
The exercise will help you to explore the design and construction of a common electromechanical system. You will disassemble and assemble a hand drill to:
Identify all components and their relationship to each other including how they are
assembled
Introduction:
The product dissection is the process of discovering the technological principles of a device,
object, or system through analysis of its structure, function and operation. It may involve taking a
mechanical or electrical device apart and analyze how it works in details.
In this dissection exercise you will take apart and reassemble a cordless Black & Decker 12 V
hand drill that is shown in Fig 1.
51
52
Procedure:
1. Discuss and define various roles for your team members
2. Document who is responsible for keeping track of all parts during the disassembly process.
Who is responsible for taking notes? It is extremely important to ensure that all parts are
tracked and proper notes and adequate sketches are taken in your logbooks. This information
will be vital during reassembly process and the following weeks lab session.
3. Please ensure to follow basic health and safety guidelines at all times. If you are unsure,
please contact your lab coordinator/instructor or supervisor!
Basic Safety Guidelines:
4. Carefully examine the exterior and shape of the hand drill. Identify all visible major
components and features. You should be able to at least observe eight major components
which are shown in Fig 2. With careful examination you should be able to identify
additional features.
53
Relationship
with other
components
How is it made or
manufactured?
6. Without disassembling the hand drill, are you able to imagine and comment on what
components you can find inside? Write down your ideas and thoughts.
7. Now you are ready to disassemble the hand drill to examine all internal components.
8. Remove the battery first! Why is it important to remove the power source? To remove the
battery, press the buttons on both sides as shown in Fig 3 and pull the battery out. Examine
the battery and identify its features without opening it. How does it work and transfer
electrical power to other components? How does it hold charge? Please ensure to keep track
of all components as you further disassemble the hand drill. You can easily do this by
creating a bill of materials (BOM). For example you can use the following format:
54
55
56
57
16. Examine the trigger switch and document how it is assembled with the housing. Remove the
direction switch and describe how it controls the motor direction.
17. Brainstorm how this power drill can be designed in different ways. What features will you
change to improve this drill? Document all of your thoughts in your logbook.
18. Now you can assemble the drill. You should follow the steps in reverse order of disassembly.
Please refer to your notes and step backward and ensure that hand drill is fully functional and
reusable.
19. After you have reassembled the hand drill, further analyze major components such as: motor,
chuck, battery, battery charger and gear transmission, etc. How these components work?
How these components are made? What other types of similar components have you found?
References
[1] Dissection figures provided by Mr. Leon Wu
[2] Black & Decker 12 V Hand Drill Owner Manual
58
Overview:
The purpose of this experimental exercise is to use hands-on dissection experience gained from
exercise 3 & 4 to dissect and analyze an engineering product. In this exercise a random
engineered product will be assigned to each group who will dissect and reassemble the product
and use analytical skills to:
Identify all components and their relationship to each other including how they are
assembled
Use presentation tools such as Microsoft PowerPoint to communicate the function of the
assigned product as well as its components
Procedure:
1. Discuss and define various roles for your team members
2. Document who is responsible for keeping track of all parts during the disassembly
process. Who is responsible for taking notes?
3. It is extremely important to ensure that all parts are tracked and proper notes and
adequate sketches are taken in your logbooks. This information will be vital during
reassembly process and the following weeks lab session as well as your class
presentation.
4. Please ensure to follow basic health and safety guidelines at all times. If you are unsure,
please contact your lab coordinator/instructor or supervisor!
Basic Safety Guidelines:
5. Carefully examine the exterior and shape of the assigned product. Identify all visible
major components and features. Sketch the product using hand sketching techniques and
identify all visible features. Discuss the functionality of each visible component within
your team. Record all identified components and their functionalities in your logbook.
Relationship
with other
components
How is it made or
manufactured?
6. Without disassembling the assigned product, are you able to imagine and comment on the
components you can find inside? Write down your ideas and thoughts.
7. Analyze the product within your team members and develop a plan to disassemble it.
Ensure to document all necessary steps to take it apart e.g., removal of fasteners, covers,
batteries, stickers etc. If you have any questions or concerns, contact your lab supervisor.
8. Take the product apart as much as possible.
9. Identify all components to explore and analyze their functionalities.
10. Prepare the bill of materials (BOM) and sketch all components. You can use the
following format for BOM.
60
61
Lab Exercise 5:
Objective
The objective of this laboratory exercise is to dissect a weight scale to explore its design and
functionality of its components.You will disassemble and assemble a weight scale to:
Identify all components and their relationship to each other including how they are
assembled
In addition, you will get familiar with MATLAB programming Graphical User Interface to
achieve the task of data acquisition using NI module
Background
Weight scale is a device used to measure the force exerted by the mass of an object under the
influence of gravity. A simple electronic weight scale (Fig. 1) normally consists of at least the
following components: load cell(s), a LCD (Liquid Crystal Display) panel, a base, a loading
platform, a switch, a power source, and a control unit (e.g. microcontroller) that converts the
electrical (e.g. voltage) signal from the load cell(s) to digits (weight) displayed on the LCD.
62
Loading
Mount
LCD Panel
Base
Cable
Conduit
Loading
Platform
(glass panel)
Unit Select
Switch
(kg/lb)
Control Unit
63
Fig. 2 Dissection view of an electronic weight scale (the base is not shown here)
64
Load cell (Fig. 3) is a transducer that is used to convert a force into an electrical signal. Two
common types of load cell that can be found in small-scale weight or force measuring devices,
such as the weight scale we use here, are: strain-gauge type and piezoelectric type. Strain-gauge
type load cell relies on a strain gauge that is made of metal wires, foils, or semiconductor
materials, which are attached to structural members. When the members are stretched under
tensile stress, the resistance of the metal or semiconductor element increases [1]. By measuring
65
the change in resistance value (i.e. via measuring the change in voltage across the strain gauge
when an electrical source is supplied to it), an estimate of the strain can be made, and thus, the
loading force (weight) can be determined. Piezoelectric type load cell relies on a piezoelectric
element which uses the piezoelectric effect to measure strain. Piezoelectric effect is the
generation of a potential difference (i.e. voltage) across the opposite faces of certain nonconducting crystals (piezoelectric crystals) as a result of the application of mechanical stress
between these faces [1]. By measuring the voltage across the piezoelectric element, the weight
acting on the load cell can be determined.
Our weight scale here uses four load cells simultaneously to measure the load on the loading
platform. The control unit (microcontroller) takes the signals from all four load cells and
calculate the average weight value. The advantage of using multiple load cells in parallel to
measure weight is that it can compensate for a load that is unintentionally placed off-center on
the loading platform.
To convert the electrical signal from a load cell, hardware components (e.g. potentiometer,
amplifier, capacitor, etc.) or software components (e.g. formulas for voltage to weight
conversion and noise filtering) or both is required. In order to determine the relationship between
the electrical signal and the measured weight value, a procedure called calibration is required.
Calibration is a comparison between measurements one of known magnitude or correctness
made or set with one device and another measurement made in as similar a way as possible with
a second device. There are many types of calibration methods and in LabVIEW, there are four
types: 1) Linear, which scales values by using the equation y = mx + b, where x is a prescaled
value and y is a scaled value; 2) Map Ranges, which scales values proportionally from a range
of prescaled values to a range of scaled values; 3) Polynomial, which scales values using an nth
66
order polynomial equation (e.g. NIST polynomial approximation used for the calibrated
thermocouple in Lab 2); and 4) Table (also called look-up table), which maps an array of
prescaled values to an array of corresponding scaled values, with all other values scaled
proportionally.
Apparatus
68
Fig. 7 Pliers
Procedure
Task 1: Dissection of an electronic weight scale
(Duration: 30 min)
1. Remove the battery and turn the weight scale upside down. Carefully remove the base by
loosening the four screws (circled in red) and gently shake the base loose (Fig. 10)
Fig. 10
70
2. Carefully take the load cell out from the support structure by gently press the top and
bottom clips outward (Fig. 11). Look at the design of the load cell. Can you tell how the
load cell is deformed when a load is applied to it? You can draw a Free Body Diagram to
illustrate.
Fig. 11
71
3. Remove the two screws on the circuit board (circled in red) and carefully take out the
LCD panel underneath (Fig. 12). Be careful not to damage the two plastic clips at the
bottom of the circuit board. Also, mark down the orientation of the LCD Panel. If you
flip it up-side-down when you put it back later, it will not work!
LCD Panel
Fig. 12
4. You have just dissected the weight scale. Now sketch out each component and describe
its functionality. Record all components and functionality in your logbook. You can use
the following format:
Component or
feature
Material
Function or potential
design intent
How is it made or
manufactured?
72
5. Now for each component, assign an Item Number, specify the Quantity, Description, and
the Materials used. Then tabulate them as a Bill of Materials (BOM) shown below:
Item
Number
001
Item
Quantity
Description/function/features Materials
Battery
Power source
Lithium
002
003
..
..
..
..
6. After you have completed the BOM, assemble all the components together and put the
battery back to the battery compartment.
7. Follow the instruction on the sticker of the weight scale to operate. Test and see if the
weight scale is still working. If not, find out the problem and fix it. Ask the instructor if
you have any questions.
Fig.13
3. Open NI MAX to rest the NI USB-6210 module by right clicking on the Reset as shown
below
Fig. 14
4. Open MATLAB environment in default setting which is the command interface, type
guide to invoke GUIDE. Select Blank GUI (Default), and then click OK.
Fig.15
5. An untitled GUI interface window will pop up. (hint: it might take a couple of seconds to
see the pop-up window, therefore please close all other applications and programs
because GUIDE will consume some resources from your laptop or PC)
Fig. 16
GUIDE environment
75
6. Hover over to left to select Static Text, Listbox, Push Button and Axes, then drag them
one at time to the grid.
Fig. 17
7. Save the untitled.fig to lab5.fig(Good habit to save the file every step)
Fig. 18
8. Right click on Push button and select Property Inspector. Go to the String field and edit it
to Plot Temperature
Fig. 19
9. Double click on the Static Text to open the Inspector Property window, and change the
string to Acquiring time
Fig. 20
77
10. Double click on Listbox to open the inspector window. Double click the icon beside
String as shown below, and then type 1,2,3,4,5 with return key after each number.
78
12. Right click on Plot Temperature, and select View Callbacks then select Callback
Fig. 23
13. Lab5.m text editor window will pop up with function pushbutton1 Callback(hObject,
eventdata,handles) highlighted automatically. Add the given code inside the function as
shown in the Fig. 24.
Fig. 24
15. Study the given code to understand the functionality of the code. Please note % at the
beginning of a line means commenting that line in MATLAB. Comments are ignored by
the compiler and interpreter. It is a good practice to provide the comments while writing
the source code. It would be extremely helpful for documentation purposes and future
integration with source code management for all users.
16. After inserting the code, hit the run button to start the program while you are turning the
potentiometer knob from one end to another end.
80
Fig. 25
For example, following line changes the String property of a static box control with a
tag name mybox to show the word hello on it:
Set(handles.mybox, String, hello)
References
[1] Oxford University Press. Concise Science Dictionary (New Edition). Oxford, England,
1992.
82