Control Systems Lab 4
Control Systems Lab 4
Control Systems Lab 4
1. Objectives
• Introduction to data acquisition
Page 1
• Learn data acquisition in LabVIEW using NI ELVIS
2. Data Acquisition
Data acquisition is the process of sampling real world physical signals and converting them
into digital numeric values that can be manipulated by a computer.
For example, a physical signal is the humidity of a room as a function of time. Most of the
humidity sensors generate an analog voltage/current based on the current value of the
humidity. However, computers or microcontrollers cannot works with analog values. A
data acquisition system will sample this analog signal and convert each sample into a
digital numeric value. This would allow digital machines like a computer to analyze the
physical signal.
Some of the other physical signals are temperature, pressure, flow rate of a fluid in a pipe,
motor speed, pendulum angle, wind speed, etc.
Whenever we are working with physical systems or physical signals, without data acquisition
we would not be able to utilize the power of computers to analyze them.
Data acquisition systems (DAQs) typically have the following two components:
i. Sensors that convert physical signals to analog electrical signals
ii. Analog to digital converters, which convert conditioned sensor signals to digital
values.
Most data acquisition hardware that interface with computers are based on a PCI, USB, or
a similar interface. They are usually compatible with the popular engineering software
like MATLAB, LabVIEW, Simulink, etc. This allows us to easily interface real physical
signals in our simulations.
In our control laboratory we have a USB based data acquisition device called the NI
ELVIS. It is manufactured by a very famous company called National Instruments. It has
the functionality for all inputs/outputs i.e. analog I/O and digital I/O. This hardware is
compatible with the LabVIEW software. In this handout we will see how we can use this
hardware to interface with the DC motor and the inverted pendulum, which are physical
systems.
NI ELVIS board with a QNET DC motor installed on it is shown in the figure below. The
different components are listed in the table.
i. Without turning on the power adapters, connect the power adapter cables at point 5 and
point 9. See the figure and the table for details.
ii. Connect a USB cable at point 6 of the NI ELVIS board. Connect the other end to your
PC.
iii. Turn on the supply for power adapters. iv. Turn on the switch near point 5 of the NI
ELVIS. The switch is on the rear panel of the NI ELVIS.
v. Turn on the switch at point 2 of the NI ELVIS. If the DC motor starts running,
turn the board off and inform the lab staff.
vi. The power (point 3) and ready (point 4) LEDs of the NI ELVIS should be on
now. vii. The LEDs on the DC motor board at point 8 will also turn on.
viii. The NI ELVIS board and the DC motor are now ready to use.
The figure below shows which channels of the NI ELVIS board are used by the DC motor
and for what signal.
i. Analog output channel AO#0 is used to generate the voltage to be applied to the motor.
ii. Analog input channel AI#1 is used to acquire the armature current of the motor.
iii. Digital input channel DI#0 is connected to the encoder and used to determine the
position of the motor.
iv. Analog input channel AI#4 is used to acquire the speed of the motor.
With this handout you will also be provided another document “QNET User Manual.pdf”.
Read section 4 of this document to get more details of the DC motor.
4. Data Acquisition using LabVIEW
We have given a brief introduction to the NI ELVIS and QNET DC motor. Now we will see
how we can use LabVIEW for data acquisition. In this section we will only show the data
DAQmx is the LabVIEW driver for the programming of data acquisition hardware in
LabVIEW. It is a single programming interface for programming analog input, analog
output, digital I/O, & counters on hundreds of multifunction DAQ hardware devices. The
following are the steps for data Acquisition using DAQmx:
1. Create a virtual channel and task using the NI-DAQmx Create Virtual
Channel VI
2. Write or Read data using DAQmx Write or DAQmx Read VI respectively
4.1. Generating voltage for DC motor using analog output channel AO#0
iv. Right click on the physical channel input of “NI-DAQmx Create Virtual Channel VI”
and create constant. Here you will select the channel you want to use. According to the
schematic in QNET User Manual, the DC motor voltage is generated at analog output
v. According to the QNET User Manual, the output of the AO#0 is connected to an
amplifier with a gain of 2.3 and the maximum and minimum voltage for the DC motor
are +24 and -24, respectively. Therefore, we should set the output signal range from (-
24/2.3) to (24/2.3). However, to be on the safe side, we will keep the output signal
range from -8 to 8 volts.
vi. Create constants for maximum and minimum value and enter 8 and -8
respectively
ix. Now go to the front panel and insert a pointer slide from Numeric Control palette.
Name this input block as “voltage input”. Right click on the pointer slide and open its
properties. Go to scale tab and enter a range of -10 to 10.
xii. Insert the Control and Simulation loop outside the DAQmx Write
xiii. Double-click on top left of the loop. A pop-up window will appear. Configure
same simulation parameters and timing parameters as shown in the figure:
xv. This completes the voltage generation part of the VI. Run the VI and change the
slider to apply different voltages to the motor. The speed of the motor should
change.
i. Follow similar steps as for the voltage generate to configure the DAQ Assistant
for acquiring the motor speed. The differences are:
• Select analog input channel 4 instead of analog output channel 0 and use
DAQmx read instead of DAQmx write
• Set the signal input range from -10 to 10 volts
Now go to the front panel and insert a numeric indicator. Name this indicator as
“speed”
iii. Run the VI and apply some voltage to the motor. If the motor is moving you
should see some non-zero value in the numeric indicator for the speed.
iv. According to the QNET User Manual, the tachometer calibration is 2987
RPM/volts. There 2987 rotations in a minute, the tachometer generates 1 volt.
Since we are acquiring the voltage from the tachometer, we are not seeing the
speed of the motor in any standard units on our numeric indicator. To
accommodate for the calibration of the tachometer, we will multiply the acquired
voltage by a factor of 2987. This will give us the speed of the motor in RPM.
v. In the block diagram, insert a multiplier block to scale the acquired voltage.
Rename the numeric indicator as “Speed (RPM)”.
vii. Since in the earlier labs we derived the transfer function for motor speed in
rads/sec, we would also like to have the speed in these units. Insert another
numeric indicator in your VI and name it “Speed rads/sec”. Scale the speed in
RPM to find the speed in rads/sec. The formula is given below:
4.3. Acquiring for position of the DC motor speed using digital input
channel DI#0
iv. In the front panel, right click to open controls palette. Go to Modern >> I/O >>
DAQmx Name Controls >> Device. Place a device block in your VI and connect
the “device name” block to “dev” input of encoder config VI.
Another advantage of data acquisition is that we will be can implement the controller on
a computer and use it with the actual hardware. We will do this activity in later labs.
We have created a VI for data acquisition. However, we haven’t tested if the signals that
are being generated are of the correct value or not. Similarly, we haven’t tested if the
acquired signals are of the correct value or not.
90 Degrees:
180 degrees:
-90 degree:
OBSERVATION:
In our hardware setup, it is difficult to measure the applied voltage. So we will be unable
to verify the voltage generation part of the data acquisition directly. However, we can tell
you that the motor speed is approximately 158 rads/sec when a voltage of 5 volts is
applied. Apply 5 volts to the motor and verify if this really is the case.
The figure below shows which channels of the NI ELVIS board are used by the Inverted
Pendulum and for what signal.
i. Analog output channel AO#0 is used to generate the voltage to be applied to the
motor.
ii. Analog input channel AI#0 is used to acquire the armature current of the motor.
iii. Digital input channel DI#0 is connected to the Motor encoder 0 and used to
determine the position of the Motor Arm. iv. Digital input channel DI#1 is
connected to the encoder 1 and used to determine the position of the Pendulum
Link.
v. Analog input channel AI#4 is used to acquire the speed of the motor.
Note: You can use Pendulum_Position.vi present on the desktop of your computer
Connect Rotary Inverted Pendlum system to your PC using same procedure you used to
connect the DC Motor System and Create a VI which:
• Selects device number
• Applies Voltage to the Pendulum’s Motor
• Measures Arm Angle in Degree and rad/sec
• Measures Link Angle in Degree and rad/sec
• Measures Motor speed in RPM and rad/sec
Front Panel: