Data Acquisition in LabVIEW
Data Acquisition in LabVIEW
Minahil Shahzad
00000140764
Muhammad
Hasham Hussain 00000142771
Muhammad Bin
Javaid 00000132498
Nimra Farooq
00000120177
Page 1
Lab 04: Data Acquisition in LabVIEW using DC Motor
1. Objectives
Introduction to data acquisition
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.
Page 3
3. Introduction to the NI ELVIS DAQ device and QNET DC motor
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.
Page 4
3.1. Instructions to connect and power up the NI ELVIS
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.
Page 5
3.2. Schematic of DC motor signals and NI ELVIS channels
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.
Page 6
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
acquisition for the DC motor. However, the data acquisition for any device is similar in
LabVIEW especially if the DAQ is manufactured by National instruments (NI).
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
Page 7
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 channel 0. Select this channel from the drop down
menu of the Physical channel constant.
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
vii.
Page 8
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.
x. Now go to block diagram and connect the voltage input block to the data input
of the DAQmx Write.
Page 9
xi. The VI that we have created will only generate a single sample for the output
voltage. To continuously generate the sample we have to insert a simulation
loop. Insert a Control and Simulation loop outside the DAQ to execute the
simulation diagram until the Control & Simulation Loop reaches the simulation
final time by right-clicking on Block Diagram and using path shown in figure:
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:
Page 10
xiv. When setting the voltage with the slider input, we are not considering the gain of
the amplifier between AO#0 and the DC motor. To accommodate for this gain
we insert a reciprocal of this gain in our VI. In the block diagram, insert a gain
block by going to Functions Palette >> Control Design and Simulation >>
Simulation >> Signal Arithmetic >> Gain. Set the gain to 1/2.3 = 0.43
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.
Page 11
4.2. Acquiring for DC motor speed using analog input channel AI#4
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”
Page 12
ii. In the block diagram, connect the data output of the “DAQmx Write” to the
numeric indicator block
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. Paste the screenshot of Front panel and block diagram below and email this
document to [email protected]
Page 13
Page 14