Hardware Interface
Hardware Interface
Hardware Interface
Laboratory Experiments
ONLINEHARD 11/25/2014 14:19:47 Page 2
Lab
1. Write a LabVIEW program that executes an equivalent of the following C-like code,
where x is an input and y is an output (Formula Nodes are not allowed):
if(abs(x)< 0.1)
y = 1;
else
if(x>=0)
y = 0;
else
y = 2;
Run your program for the following inputs: x 0:05; 0:05; 1; 1.
2. Write a LabVIEW program that receives three colors representing a resistor’s value and
returns the numeric resistor value in ohms. Your interface should be similar to the one
shown in Figure P2.42. The third band should include silver and gold colors.
Run your program at least for the following inputs:
Red Red Black
Brown Black Orange
Orange White Gold
FIGURE P2.42
ONLINEHARD 11/25/2014 14:19:48 Page 3
Lab
1
1. It is well known that 1 x x2 x3 ∙ ∙ ∙ when j x j < 1:
1 x
Write a LabVIEW program that takes as an input a value for x, and a number of
iterations. The program will use a loop to calculate the sum of the geometric series for
the specified number of operations. It will also calculate the closed-form expression for
the series. The program will display the two results, and will also display the absolute
error of the difference.
Demonstrate your program with x = 0.5 and 3, 10, and 200 iterations.
2. Write a LabVIEW program that generates a 50% duty-cycle square-wave signal between
0 and Xmax volts, where X max < 10 V, with a nonzero variable frequency. The amplitude
and frequency will be inputs. Display the waveform on a waveform chart, which will
be an output. In this part you are not allowed to use the LabVIEW-provided function
generation blocks.
Demonstrate this program for amplitudes of 1, 5, and 10 V and for 1 Hz and 5 Hz.
ONLINEHARD 11/25/2014 14:19:48 Page 4
Prelab
Go to the website https://decibel.ni.com/content/docs/DOC-11624. Go over Unit 4—DAQ:
Lesson 1. Then go over the measuring voltage tutorial in http://zone.ni.com/devzone/cda/
epd/p/id/6436.
Lab
1. Write a battery-tester program using LabVIEW and myDAQ as an acquisition device.
The battery tester should work for three nominal values of batteries: 1.5 V, 6 V, and 9 V.
The batteries are considered dead for voltage values 20% or under the nominal. Between
20% and the nominal value the batteries are in a warning area, and for values above the
nominal the batteries are OK. Your interface should be similar to the one shown
Figure P2.43. A custom control accepting inputs from 0 to 120 has been created under
the name Battery Meter.ctl.
FIGURE P2.43
2. Use the LabVIEW program that you wrote in Experiment 2.5 to generate a 50% duty-
cycle square-wave signal. Output your signal through one of the myDAQ’s analog
channels and read the signal using the myDAQ oscilloscope function (available from
myDAQ file: NI ELVISmx Instrument Launcher) to verify the generated signal. Print
two examples using the scope’s automatic measurements.
ONLINEHARD 11/25/2014 14:19:48 Page 5
(b)
Note the value indicated by the blue arrow in Figure P4.28(b). In order to get a meaningful
reading for the speed of the motor, this value needs to be modified depending on the gear ratio
of your motor and the counts of your encoder. To understand how this value is calculated, note
that the DAQ Assistant block on top of the diagram reads the encoder input from the myDAQ.
One would reasonably assume that the frequency of this signal is proportional to the speed of
the motor, which is theoretically true. However, at very low speeds the DAQ assistant “times
out” and fails to provide a reading if frequency is measured directly. To avoid this problem, a
different method is used to calculate the signal frequency. The DAQ assistant measures the
rising edges of the encoder signal every 100 msec and subtracts that number from the ones
accumulated during the previous 100 msec period. The frequency of the encoder signal
(in edges/msec) is found by dividing the value of this subtraction by the period (100 msec).
See the Block Diagram to understand how this algorithm was implemented.
We use an example to illustrate the calculation of the constant pointed to with the red arrow.
If a 9.7:1 gear ratio is used with a 48 CPR encoder, with each revolution the encoder will
generate a total of 48 edges in each of the encoder channels. Using one channel only and
positive edges, there are 12 positive edges/rev of the motor shaft. The total number of counts
(positive edges) generated by each revolution of the external shaft is 9.7 × 12 = 116.4
positive edges/rev.
In order to find the rotational speed, the frequency (edges/msec) of the signal is divided by
the total number of counts generated by the external shaft, adjusting the units for time from
msec to sec: Rotational Speed (rps) = Freq × 1000/(9.7 × 12) = Freq × 8.591. This value has
to be set as illustrated in the Block Diagram.
The DAQ Assistant2 block transmits the voltage from the control slider to the myDAQ
and to the motor control chip. The DAQ Assistant3 block makes sure that the output to the
chip is zeroed when the VI terminates.
Hardware: Connect the myDAQ, the motor, and the motor controller as shown in
Figure P4.29.
Procedure:
1. Verify the operation of your circuit by running the VI and changing the position of the slider.
If everything is correct, the motor speed will vary as the slider’s position changes.
2. Verify that you are using the correct scaling factor for your motor by setting your motor
to rotate at 0.5 rps. Count the number of rotations in the shaft of the motor over 10 sec
using a stopwatch. Repeat by setting the rotational speed at 1 rps. Your measurements
must be consistent.
3. Perform the following measurements moving the slider:
a. Increase the voltage starting at zero and record the minimum voltage for the motor
to start rotating.
b. Starting the slider at a rotating speed, reduce the voltage until the motor stops. Record
this voltage.
Are these values equal? These values are important and will be used in future labs.
Keep them in a safe place so that you don’t have to repeat these measurements
again.
4. Make a graph where the x-axis is the input voltage, and the y-axis is the speed in rps.
Include the results in Part 3.
5. Draw a functional block diagram of the system (similar to Chapter 1), labeling each of
the components in the diagram.
ONLINEHARD 11/25/2014 14:19:48 Page 7
Motor
MyDAQ
white
BA6886N
1 2
3
4
5
6
7
10Ω
8
9 10
9V
6. The circuit and the VI above allow the motor to rotate in one direction only. Modify
the VI and the circuit so that the motor direction and speed can be controlled
from the VI.
Note that the reference input to the chip can only accept positive voltage values. The
motor control data sheet indicates that direction of rotation must be changed by flipping the
logical values of Pin 2 and Pin 10 on the motor control chip. However, a careful reading of
the data sheet indicates that there must be an instant of time (of unspecified duration) in
which both inputs must be False before switching direction. You may want to use a
LabVIEW ring to simulate a three-way switch. Use two of the selections of the ring to
control the motor’s rotation direction. The third selection in the ring should provide low
inputs to the motor controller logical inputs to be able to stop the motor before switching
direction.
1
MyDAQ right slot shown on left is taken from Multisim program module NI myDAQ design and also
reproduced in White-Paper 11423, Figure 2. Both Multisim and the White Paper are from National Instruments.
ONLINEHARD 11/25/2014 14:19:48 Page 8
Lab Connect the myDAQ, the motor, and the motor controller as shown in Figure P4.30.
This setup is identical to the one that was used initially in Experiment 4.5, except that we
Motor
MyDAQ
white
BA6886N
1 2
3
4
5
6
7
10Ω
8
9
9V
10
2
MyDAQ right slot shown on left is taken from Multisim program module NI myDAQ design and also reproduced
in White-Paper 11423, Figure 2. Both Multisim and the White Paper are from National Instruments.
ONLINEHARD 11/25/2014 14:19:48 Page 9
have connected the two analog input channels to the two analog output channels. This will
allow us to use the myDAQ oscilloscope for measurements. If you decide to use an external
oscilloscope, these connections are not necessary.
1. Open the Oscilloscope and Plant Identification 2.vi shown in Figures P4.31 and P4.32,
respectively. You can also choose to use an external oscilloscope. Use settings similar to
the ones shown in Figure P4.31.
2. In your Plant Identification 2.vi choose the value of amplitude and offset shown in
Figure P4.32. A LabView error will be generated if the square wave generates negative
values as these are not allowed as inputs to the chip. The value of the frequency is
irrelevant; you just have to make sure the input is slow enough so that the motor speed
reaches steady state as shown in Figure P4.32.
3. Run the Plant Identification 2.vi and the Oscilloscope. Press the Stop button on
the Oscilloscope as soon as it shows a full semi-cycle of positive speed, similar to
Figure P4.31.
4. Click on the Log button in the Oscilloscope, give the file a name, and save it to disk.
Open the file using a spreadsheet program.
5. Note that the response of the system in the Oscilloscope is in all likelihood that of a first-
order system, consistent with theoretical expectations. Thus, the transfer function will be
Ω
s K
of the form: .
E i
s sτ 1
K can readily be found from the Oscilloscope or the Plant Identification 2.vi. In the
9:71
example shown, K 1:079. We will use the spreadsheet data to find the time
9
constant, τ.
6. Use your spreadsheet data to find the time constant. For help on completing this task, go
to www.wiley.com/college/nise.
7. Repeat the experiment for input voltages of 2 V, 5 V, and 9 V.
Postlab
1. Is your system linear? How do you know?
2. If your system is linear for a range of inputs, find a judicious interpolation between the
three transfer functions you found in Part 7 of the lab. Write down your final transfer
function result and save it for use in subsequent experiments.
ONLINEHARD 11/25/2014 14:19:49 Page 11
R(s) + K C(s)
KP
sτ + 1
–
FIGURE P8.23
Lab
Software: The Speed P Control Incomplete.vi is provided and illustrated in Figure P8.24.
You need to modify it as follows before it becomes operational.
1. You need to change the constant on the left to fit your motor’s gear ratio and encoder
CPR (counts per revolution) as shown in Figure P8.24(b).
2. You need to write a SubVI for a P controller and place it where the arrow indicates
it in Figure P8.24(b). The function of a P controller is u K P e. Your SubVI has
two inputs, the system’s error e and the proportional constant K P . It will have one
output u.
3. Double-clicking on the Signal Conditioning (SubVI), Figure P8.24(b), you get
Figure P8.25. Modify the indicated constant to reflect the dead zone parameter of
your motor. This SubVI limits the input voltage to the motor controller and
eliminates the dead zone by offsetting the input to the motor controller.
Hardware: Figure P8.26 is the hardware diagram for speed control. The diagram is
identical to the one in Experiment 4.6, except that Pins 2 and 10 in the motor controller chip
connect to digital lines D2 and D3 in the myDAQ to allow changes in motor direction.
ONLINEHARD 11/25/2014 14:19:49 Page 12
Procedure:
1. Verify the operation of your closed-loop system.
2. Draw a functional block diagram (similar to the ones shown in control systems
textbooks) of the system. Do not include the signal conditioning functions, nor the
change-of-direction signals.
Motor
MyDAQ
5V
DGND
7
white
6
5
DIO 4
0–5V
3
2
1
0
1–
AI 1+
±10V 0–
0+
BA6886N
AGND
AO 1
1 2 3 4 5 6 7 8 9 10
0
AGND
–15V
+15V
AUDIO
OUT
10Ω
AUDIO
IN
9V
3. Using the transfer function you found in Experiment 4.6, draw the system’s root locus.
4. Find the theoretical range of K P in which the system is closed-loop stable.
5. Run your program and system to find experimentally the range of K P in which the system
is closed-loop stable.
6. Make a judicious choice of three different values of K P for experimentation.
7. Using the transfer function you found previously and the three judicious choices of
proportional gain, complete the following table using hand calculations only (calculators
OK, no computer simulations allowed). Show all your work.
KP
TP —Peak time
%OS—Percent overshoot
Ts—Settling time
Theoretical
8. For each one of the three values of K P , perform step-input experiments; use one single
value of step-input amplitude for the three values. Make sure that your oscilloscope
3
MyDAQ right slot shown on left is taken from Multisim program module NI myDAQ design and also reproduced
in White-Paper 11423, Figure 2. Both Multisim and the White Paper are from National Instruments.
ONLINEHARD 11/25/2014 14:19:50 Page 14
captures contain the system’s transient response in its entirety. Show measurements of all
the parameters in the table above and fill in the following table. Please note that T s , the
settling time, is hard to measure in the current setting because of the limited number
of analog channels present. Instead of measuring T s , mark in your oscilloscope its
theoretical value using the scope cursors.
KP
TP —Peak time
%OS—Percent overshoot
Experimental
R(s) + K C(s)
KP
s (sτ + 1)
–
FIGURE P8.27
3. Draw the unit-step response for the system marking the settling time, peak time, and
maximum output. Find all the possibilities: overdamped, critically damped, and
underdamped.
4. Find an expression for the steady-state error to a unit-step input for the system.
Lab
Software: The front panel and block diagram of the Position control.vi are shown in
Figure P8.28. Change the constants inside the Signal Conditioning SubVI to match your
dead zone parameters. The constant on the right of the diagram must be modified to match
your motor’s gear ratio.
Hardware: Make the following changes to the wiring diagram shown in Figure P8.26:
Move the connections from D1, D2, and D3 to D2, D3, and D4, respectively. All the other
connections remain the same.
Procedure:
1. Choose a small P gain. Verify the operation of your closed-loop system. The motor
should be able to move in both directions and through the full-scale range.
ONLINEHARD 11/25/2014 14:19:51 Page 16
2. Using the transfer function found in Experiment 4.6, calculate the motor’s transfer
Θ
s
function from armature voltage to angular position .
Ea
s
3. Draw a functional block diagram of the system. Do not include the signal conditioning
functions, nor the change-of-direction signals. Label all the pertinent signals.
Θ
s
4. Using the transfer function you just calculated, draw the system’s root locus.
E a
s
5. Find the theoretical range of K P for which the system is closed-loop stable.
6. Run your program and system to find experimentally the range of K P for which the
system is closed-loop stable.
7. Make a judicious choice of three different values of K P for experimentation.
ONLINEHARD 11/25/2014 14:19:52 Page 17
8. Using the transfer function you calculated above and the three judicious choices of
proportional gain, complete the following table using hand calculations only (calculators
OK, no computer simulations allowed). Show all your work.
KP
TP —Peak time
%OS—Percent overshoot
Ts—Settling time
Theoretical
9. For each one of the three values of K P , perform step-input experiments using one value
of step input for the three values. Make sure that your oscilloscope captures contain the
system’s transient response in its entirety. Show measurements of all the parameters in
the table above and fill in the following table. Please note that T s , the settling time, is hard
to measure in the current setting because of the limited number of analog channels
available. Instead of measuring T s , mark in your oscilloscope its theoretical value using
the scope cursors.
KP
TP —Peak time
%OS—Percent overshoot
Experimental
R(s) + KI K C (s)
s st + 1
–
FIGURE P9.14
For the system shown in Figure P9.14, do the following:
Lab
Software: Use the Speed PI Control.vi and change the constant on the left to fit your
motor’s gear ratio and encoder CPR as shown in Figure P9.15(b). Also change the
constants wired to the PI controller. These values should be the maximum motor voltage-
dead-zone constant. Change the dead-zone constants inside the signal conditioning block
just as you did in Experiment 8.4.
Procedure:
1. Make the P gain = 0, and choose a small I gain. Verify the operation of your closed-loop
system. In this experiment we will keep the P gain at 0.
2. Draw a functional block diagram (similar to that presented in Chapter 1) of the
system. Do not include the signal conditioning functions, nor the change-of-
direction signals.
3. Using the transfer function you found in Experiment 4.6, draw the system’s
root locus.
4. Find the theoretical range of KI in which the system is closed-loop stable.
5. Run your program and system to find experimentally the range of KI in which the
system is closed-loop stable.
6. Make a judicious choice of three different values of KI for experimentation.
7. Using the transfer function you found in Experiment 8.4 and the three judicious choices
of proportional gain, complete the following table using hand calculations only
(calculators OK, computer simulations are not acceptable). Show all your work.
KI
TP—Peak time
%OS—Percent overshoot
Ts—Settling time
Theoretical
8. For each one of the three values of KI, perform step-input experiments. Use a single
value of step input for the three values of KI. Make sure that your oscilloscope captures
ONLINEHARD 11/25/2014 14:19:54 Page 20
contain the system’s transient response in its entirety. Show measurements of all the
parameters in the Theoretical table above and fill in the following Experimental table.
Please note that Ts, the settling time, is hard to measure in the current setting because of
the limited number of analog channels available. Instead of measuring Ts, mark on
your oscilloscope the theoretical value using the scope cursors. (Important: In this
experiment stop the VI before restarting it every time you apply a step input. This
action will reset the integrator).
KI
Tp—Peak time
%OS—Percent overshoot
Experimental
Copyright 2015 John Wiley & Sons, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or
108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc. 222 Rosewood
Drive, Danvers, MA 01923, website www.copyright.com. Requests to the Publisher for permission should be addressed
to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, (201)748-6011,
fax (201)748-6008, website http://www.wiley.com/go/permissions.
Founded in 1807, John Wiley & Sons, Inc. has been a valued source of knowledge and understanding for more than
200 years, helping people around the world meet their needs and fulfill their aspirations. Our company is built on a
foundation of principles that include responsibility to the communities we serve and where we live and work. In 2008,
we launched a Corporate Citizenship Initiative, a global effort to address the environmental, social, economic, and
ethical challenges we face in our business. Among the issues we are addressing are carbon impact, paper specifications
and procurement, ethical conduct within our business and among our vendors, and community and charitable support.
For more information, please visit our website: www.wiley.com/go/citizenship.
The software programs and experiments available with this book have been included for their instructional value. They
have been tested with care but are not guaranteed for any particular purpose. The publisher and author do not offer any
warranties or restrictions, nor do they accept any liabilities with respect to the programs and experiments.
AMTRAK is a registered trademark of National Railroad Passenger Corporation. Adobe and Acrobat are trademarks
of Adobe Systems, Inc. which may be registered in some jurisdictions. FANUC is a registered trademark of FANUC,
Ltd. Microsoft, Visual Basic, and PowerPoint are registered trademarks of Microsoft Corporation. QuickBasic is a
trademark of Microsoft Corporation. MATLAB and SIMULINK are registered trademarks of The MathWorks, Inc.
The Control System Toolbox, LTI Viewer, Root Locus Design GUI, Symbolic Math Toolbox, Simulink Control
Design, and MathWorks are trademarks of The MathWorks, Inc. LabVIEW is a registered trademark of National
Instruments Corporation. Segway is a registered trademark of Segway, Inc. in the United States and/or other countries.
Chevrolet Volt is a trademark of General Motors LLC. Virtual plant simulations pictured and referred to herein are
trademarks or registered trademarks of Quanser Inc. and/or its affiliates. 2010 Quanser Inc. All rights reserved.
Quanser virtual plant simulations pictured and referred to herein may be subject to change without notice. ASIMO is a
registered trademark of Honda.
Evaluation copies are provided to qualified academics and professionals for review purposes only, for use in their
courses during the next academic year. These copies are licensed and may not be sold or transferred to a third party.
Upon completion of the review period, please return the evaluation copy to Wiley. Return instructions and a free of
charge return shipping label are available at www.wiley.com/go/returnlabel. Outside of the United States, please contact
your local representative.
Library of Congress Cataloging-in-Publication Data
Nise, Norman S.
Control systems engineering / Norman S. Nise, California State Polytechnic University, Pomona. — Seventh edition.
1 online resource.
Includes bibliographical references and index.
Description based on print version record and CIP data provided by publisher; resource not viewed.
ISBN 978-1-118-80082-9 (pdf) — ISBN 978-1-118-17051-9 (cloth : alk. paper)
1. Automatic control–Textbooks. 2. Systems engineering–Textbooks. I. Title.
TJ213
629.8–dc23
2014037468
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1