2. QNET-DCMCT Demo Guide
Table of Contents
1. INTRODUCTION..........................................................................................................................................1
2. DEMO OUTLINE........................................................................................................................................1
3. PREREQUISITES.........................................................................................................................................2
4. SETTING UP A QNET...............................................................................................................................2
5. DEMOS.....................................................................................................................................................3
5.1. Read Tachometer..............................................................................................................................3
5.1.1. Create Simulation Loop.........................................................................................................................3
5.1.2. Configure Simulation Parameters...........................................................................................................4
5.1.3. Setup to Read DC Motor Speed.............................................................................................................5
5.1.4. Read DC Motor Speed...........................................................................................................................6
5.2. Running DC Motor in Open-Loop....................................................................................................8
5.2.1. Feeding Voltage to Motor......................................................................................................................8
5.2.2. Run Open-Loop......................................................................................................................................9
5.3. Proportional Speed Control............................................................................................................10
5.3.1. Build Proportional Controller...............................................................................................................10
5.3.2. Running Proportional Speed Control...................................................................................................12
5.4. Proportional-Integral Speed Control...............................................................................................13
5.4.1. Build PI Control...................................................................................................................................13
5.4.2. Running PI Speed Control....................................................................................................................14
5.5. Using DAQmx Drivers...................................................................................................................15
5.5.1. Convert Analog Input Express VIs to DAQmx....................................................................................15
5.5.2. Convert Analog Output Express VIs to DAQmx.................................................................................17
5.5.3. DAQmx Configuration.........................................................................................................................19
Revision 1.1 ♦ Page i
3. QNET-DCMCT Demo Guide
1. Introduction
This manual outlines some procedures to demo the QNET DC Motor Control Trainer, shown in Figure
1, using LabVIEW. The DC Motor Control Trainer is used to teach motion control concepts such as
modeling and PID control.
Figure 1: QNET-DCMCT
2. Demo Outline
There are four demos:
● Demo 1: Read tachometer by moving around inertial wheel on DC motor.
● Demo 2: Run DC motor in open-loop, i.e. output voltage to motor and read speed from
tachometer.
● Demo 3: Build simple proportional compensator to control the motor speed.
● Demo 4: Build a proportional-integral compensator to control the motor speed.
● Demo 5 (optional): Convert Express VIs to DAQmx.
They introduce the following to the audience:
● Adding Simulation Loop.
● Configuring the simulation parameters.
● Basic Simulation Module blocks: Simulation Time Waveform, Summation, and Gain blocks.
● Express VI: These are used to output voltage to the amplifier and read from the tachometer
sensor.
Revision 1.1 ♦ Page 1
4. QNET-DCMCT Demo Guide
● LabVIEW front panel objects, e.g. knobs.
● Introduces DAQmx.
3. Prerequisites
In order to successfully carry out the demo you need the following equipment and software installed:
✔ PC equipped with an NI-ELVIS II
✔ QNET DC Motor Control Trainer
✔ LabVIEW 8.2.1, or later, with the following add-ons:
✔ DAQmx
✔ Express
✔ Control Design and Simulation Module
✔ ELVISmx
4. Setting up a QNET
One of the benefits of the QNET boards is its modularity. As depicted in Figure 2, any of these boards
can easily be connected to the NI ELVIS II system and give the student a new type of plant to work
with in minutes.
Figure 2: Modularity of QNETs.
Revision 1.1 ♦ Page 2
5. QNET-DCMCT Demo Guide
Follow these instructions to setup a QNET on an ELVIS II:
1. Make sure the NI ELVIS II is powered OFF.
2. Place the small opening on the front of the QNET over the mounting bracket on the front of the
NI ELVIS II workstation.
3. Slide the PCI connector of the QNET module end into the female connector on the NI ELVIS II.
Make sure it is connected properly.
4. Connect the ELVIS II power cable.
5. Connect the supplied QNET transformer to the bulk power jack on the QNET module.
Note: Not required for the QNET mechatronic sensors trainer.
6. Power the NI ELVIS II by turning ON the System Switch on the rear panel.
7. Turn ON the Prototyping Board Power switch.
CAUTION: Turn OFF the Prototyping Board Power switch if
(1) On the QNET-DCMCT, QNET-ROTPENT, or QNET-VTOL Trainer the DC motor
begins to turn, or
(2) On the QNET-HVACT the halogen light turns on brightly.
Take extra care when powering the QNET module to avoid causing any damage!
8. The Power and Ready LEDs of the NI ELVIS II unit should be lit.
9. Verify that the +15V,-15V, +5V, and +B LEDs on the QNET module are lit. They indicate that
the board has been properly connected to the ELVIS II unit.
Note: On the QNET Mechatronic Sensors and Myoelectric trainers, ensure the +15V,-15V, and
+5V LEDs are lit (no +B).
5. Demos
5.1. Read Tachometer
Demonstrates how to read from the tachometer by manually moving the inertial disc load mounted on
the QNET DC Motor.
5.1.1. Create Simulation Loop
The Simulation loop makes it easy to design and run simulations as well as control external hardware,
e.g. DC motor.
1. Open blank VI in LabVIEW.
2. Create a Simulation Loop in the block diagram, as shown in Figure 3.
Revision 1.1 ♦ Page 3
6. QNET-DCMCT Demo Guide
Figure 3: Simulation loop in block diagram.
5.1.2. Configure Simulation Parameters
We want to setup a simulation to run continuously at 100 Hz.
1. Access dialog box shown in Figure 4 by double-clicking the Input Node or by right-clicking the
border and selecting the Configure Simulation Parameters item from the shortcut menu.
Revision 1.1 ♦ Page 4
7. QNET-DCMCT Demo Guide
Figure 4: Configure simulation parameters.
2. Setup the Simulation Parameters as follows:
Final Time (s): Inf
ODE Solver: Runge-Kutta 1 (Euler)
Step Size (s): 0.01
3. Click on OK.
5.1.3. Setup to Read DC Motor Speed
Use the DAQ Assistant Express VI to read the QNET DC Motor tachometer. The tachometer is
connected to Analog Input Channel #4. Since we’re eventually doing control, we want to be reading
one sample of data for each Simulation loop iteration (i.e. On Demand).
Revision 1.1 ♦ Page 5
8. QNET-DCMCT Demo Guide
Remark: The QNET DC Motor has a digital tachometer. Its a on-board circuit that computes the
velocity from the encoder signals.
1. Go to Express Input category and add DAQ Assist to the block diagram.
2. Select Acquire Signal Analog Input Voltage.
3. Choose ELVIS II Device ai4.
4. As shown in Figure 5, setup with the following settings:
Acquisition Mode: 1 Sample (On Demand)
Figure 5: Configuring analog input channel in DAQ Assistant.
5.1.4. Read DC Motor Speed
Read the speed of the DC Motor in a chart.
1. Go to Graph Utilities and add a Simulation Time Waveform to the block diagram.
2. Connect output of DAQ Assistant to SimTime Waveform buffer, as shown in Figure 6.
Revision 1.1 ♦ Page 6
9. QNET-DCMCT Demo Guide
Figure 6: Add Simulation Time Waveform to block diagram.
3. Go to the front panel and show the Waveform Chart.
4. Change the time scale to [0,2].
5. Run the VI.
6. Move the inertial load back and forth. You should obtain a reading similarly as show in Figure
7.
Figure 7: Tachometer response when moving DC motor load back and forth.
Remark: This is the raw voltage from the tachometer. The voltage signal is proportional to the
speed of the motor shaft. To get the actual speed, use the calibration gain 2987 RPM/V.
Revision 1.1 ♦ Page 7
10. QNET-DCMCT Demo Guide
5.2. Running DC Motor in Open-Loop
Shows how to drive the motor while reading the corresponding motor speed.
5.2.1. Feeding Voltage to Motor
Using the DAQ Assistant Express VI to drive the QNET DC Motor. The motor is connected to Analog
Output Channel #0.
Add DAQ Assistant Express VI and setup with following settings:
1. Go to Express Input menu and add DAQ Assist to the block diagram.
2. Select Generate Signal Analog Input Voltage.
3. Choose ELVIS II Device ao0
4. As shown in Figure 8, configure the channel with the following:
Generation Mode: 1 Sample (On Demand)
Figure 8: Configuring analog output channel in DAQ Assistant.
Revision 1.1 ♦ Page 8
11. QNET-DCMCT Demo Guide
5.2.2. Run Open-Loop
Apply a voltage to the motor and observe the resulting speed response.
1. Add a Vertical Pointer Slide control called Input Voltage to the front panel and adjust its scale
from 0 to 2.
2. Wire the slider control to the data terminal of the DAQ Assistant block, as illustrated in Figure
9.
Figure 9: Block diagram setup for running DC motor in open-loop.
CAUTION: If you are using QNET-DCMCT rev 1, then add a -ve between the Input Voltage
control and the DAQ Assistant block. This ensures you read a positive speed when giving a
positive voltage.
3. Set the y-axis in the Waveform Chart to a fixed range of 0 to 0.5. Right-click on the y-axis of
the chart and ensure AutoScale Y is not selected.
4. Run the VI.
5. Adjust the slider control between 0 and 2 to vary the amount of voltage fed to the DC motor and
observe how the measured speed changes. A typical response is shown Figure 10.
CAUTION: Do not exceed +/-2V. This voltage is amplified by 2.3 V/V by the linear amplifier.
Remark: You need at least 1.0 V for the rotor to begin turning due to the friction from the
brushes. This demonstrates a common nonlinear phenomenon, i.e. deadband, that is seen in real
devices.
Revision 1.1 ♦ Page 9
12. QNET-DCMCT Demo Guide
Figure 10: Front panel when running DCMCT in open-loop.
6. Set the slider to 0 and stop the VI.
Remark: Make sure the input voltage is set to 0 before stopping the VI. Otherwise the DC
motor will continue spinning. The Express VI does not automatically reset the motor voltage to
zero when the VI terminates.
5.3. Proportional Speed Control
Design a simple proportional controller to regulate the speed of the DC motor.
5.3.1. Build Proportional Controller
Build the block diagram shown in Figure 12, as summarized by the steps below:
1. Add a Summation block from the Control Design and Simulation Simulation category.
2. Rename input voltage slider control to setpoint.
3. Connect the setpoint control to the +ve terminal of the Summation block.
4. Connect the tachometer signal to the –ve terminal of the Summation block. This is the
feedback signal.
5. Add a Gain block.
Hint: For faster access to the Gain block, right-click on the Summation block and go to the
Signal Arithmetic Palette item in the shortcut menu.
6. Double-click on the Gain block and set the Parameter source to Terminal, as pictured in Figure
11.
Revision 1.1 ♦ Page 10
13. QNET-DCMCT Demo Guide
Figure 11: Configure gain to be changed externally.
7. Right-click on the terminal input of Gain and create a Numeric Control called kp.
8. Wire output of Summation to Gain block.
9. Connect output of Gain block to DC motor output.
Figure 12: Block diagram to run DC motor proportional speed control.
Revision 1.1 ♦ Page 11
14. QNET-DCMCT Demo Guide
5.3.2. Running Proportional Speed Control
This shows basic speed control response. Since this is a Type 0 system, there is steady-state error.
Increasing the proportional gain improves the error but we need an integrator to solve the problem.
1. As shown in Figure 13, in the front panel add a digital display to the existing setpoint slider
control.
Hint: Right-click on the Vertical Pointer Slide control and select Digital Display under
Visible Items.
2. Set the scale of the setpoint pointer slide control from 0 to 4.
3. Change the y-scale of chart from 0 to 1.
4. Run VI.
5. Vary the setpoint control and examine how the speed changes.
6. Set the setpoint to 1 and slowly increase the proportional gain, kp, to 10. As illustrated in Figure
13, examine how the measured speed approaches 0.5 as the gain is increased. However, there is
still steady-state error.
Figure 13: DC motor speed control.
7. Set the setpoint control to 0 and stop the VI.
Revision 1.1 ♦ Page 12
15. QNET-DCMCT Demo Guide
5.4. Proportional-Integral Speed
Control
Design a proportional-integral (PI) compensator to remove the steady-state error.
5.4.1. Build PI Control
Build the block diagram shown in Figure 15, as summarized by the following steps:
1. Add another Gain block.
Hint: Click-and-drag the existing Gain block, hold the CTRL key, and drop the copied Gain
block.
2. Right-click on the terminal input of the new Gain and create a Numeric Control called ki. This
the integrator Gain block.
3. Connect the error to the input of the integrator Gain.
4. Add an Integrator block from the Control Design and Simulation Simulation Continuous
Linear Systems menu.
5. Wire the output of the integral Gain to the input of the Integrator block.
6. Add another Summation block.
Hint: Right-click on existing Summation block, hold the CTRL key, and drop the copied
Summation block.
7. Double-click on the Summation block that was just added and change the “-ve” sign to a “+ve”
sign, as shown in Figure 14.
Figure 14: Configure summation block.
8. Connect the output of both Gain blocks to the two +ve terminals of the Summation.
9. Wire output of Summation block to DC motor output.
Revision 1.1 ♦ Page 13
16. QNET-DCMCT Demo Guide
Figure 15: Block diagram to run the PI DC motor speed control.
5.4.2. Running PI Speed Control
See the effects of adding integral action to the control. This guarantees that the measure speed gets to
the desired setpoint, i.e. removes steady-state error that was observed when using the proportional
control.
1. Run VI.
2. Set the setpoint control to 0.5.
CAUTION: Make sure the setpoint does not surpass +/- 1.
3. Set the integral gain, ki, to 10. The measured speed should reach the setpoint of 0.5, as
illustrated in Figure 16.
Revision 1.1 ♦ Page 14
17. QNET-DCMCT Demo Guide
Figure 16: Running PI speed control.
4. Set the setpoint to 0.
5. When the motor stops spinning, stop the VI.
5.5. Using DAQmx Drivers
Introduce DAQmx by converting the Express VIs to DAQmx code.
5.5.1. Convert Analog Input Express VIs to DAQmx
Convert the Analog Input Express VI to an DAQmx based VIs.
1. Right-click on the analog input DAQ Assistant block and select Generate NI-DAQmx Code.
Revision 1.1 ♦ Page 15
18. QNET-DCMCT Demo Guide
Figure 17: Generating DAQmx code from an Express VI.
2. This will add a DAQmx Read VI and a sub-VI that configures the analog input channel, as
illustrated in Figure 18.
Figure 18: Generated analog input DAQmx code.
3. In the Simulation Loop, we only need to read a single point of data in each iteration. Set the
DAQmx Read VI to Analog Single Channel Single Sample DBL.
4. Place the configuration VI outside the Simulation loop, as shown in Figure 19.
Revision 1.1 ♦ Page 16
19. QNET-DCMCT Demo Guide
Figure 19: Setup AI DAQmx code.
5. Connect the task out of the configuration VI to the task/channels in of the DAQmx Read, as
shown in Figure 19.
6. Remove the data indicator and connect the data output terminal on the Analog DBL output to
the Waveform Chart, as illustrated in Figure 19 above.
7. Run the VI and the response should be similarly as shown in Figure 16, above.
5.5.2. Convert Analog Output Express VIs to DAQmx
Convert the Analog Output Express VI to DAQmx drivers.
1. Right-click on the analog output block, DAQ Assistant3, and select Generate NI DAQmx Code.
2. We don't need to use the special waveform timing. Click on OK on the message shown in
Figure 20.
Figure 20: Waveform Timing
3. This will add a DAQmx Write VI and a sub-VI that configures the analog output channel.
Revision 1.1 ♦ Page 17
20. QNET-DCMCT Demo Guide
Figure 21: Generated analog write DAQmx code.
4. In the Simulation Loop, we are only writing a single point of data in each iteration. Set the
DAQmx Write VI to Analog Single Channel Single Sample DBL.
5. Place the configuration VI outside the Simulation loop, as shown in Figure 22.
Figure 22: Block diagram of speed controller using DAQmx.
6. Remove the signal generator block (not needed because of Simulation loop).
Revision 1.1 ♦ Page 18
21. QNET-DCMCT Demo Guide
7. Clean up the excess wiring by pressing the CTRL-B.
8. Wire the output of the PI controller, i.e. the Summation block, to the data terminal on the
DAQmx Write VI.
9. Connect the task out terminal from the analog output configuration VI to the task/channels in
terminal of the DAQmx Write VI, as shown in Figure 22.
10. Run the VI and the response should be similarly as shown in Figure 16, above.
5.5.3. DAQmx Configuration
Introduce how to configure analog input and output channels using DAQmx.
1. The block diagram of the analog input sub-VI is pictured in Figure 23. It features all the settings
that were chosen when setting up the Express VI to read the tachometer.
Figure 23: Configuring QNET analog input channel.
2. Similarly for the analog output channel, shown in Figure 24.
Revision 1.1 ♦ Page 19