NI Tutorial 12944 En
-
Upload
hasrizam86 -
Category
Documents
-
view
5 -
download
1
description
Transcript of NI Tutorial 12944 En
-
1/6 www.ni.com
1.
Teach Tough Concepts: Closed-Loop Control with LabVIEW and a DC MotorPublish Date: Jul 22, 2015
Overview
The concepts of control are essential for understanding natural and man-made systems. Since control is a systems field, to get afull appreciation of control it is necessary to cover both theory and applications. The skill base required in control includesmodeling, control design, simulation, implementation, tuning, and operation of a control system. This tutorial shows how theseconcepts can be taught to students through use of a Quanser DC Motor plug-in board for the NI ELVIS, and LabVIEW ControlDesign and Simulation with LabVIEW MathScript RT. Traditionally, tuning a controller requires multiple iterations and trial anderror to perfect. However, LabVIEW allows you to tune your controller in real time and then move directly into verification with aseamless integration with hardware.
By the end of this tutorial you will be able to:Model a DC motorDesign a closed-loop PI controllerTune the controller in simulationImplement your controller with DC motor
Table of Contents
Solution Block Diagram VI Snippet
Download example programs and follow the tutorial below to recreate the lab demonstrated in the above video.Step 1 - Modeling
The first step to designing a closed-loop controller is to identify a mathematical representation of the plant, or create a model.Many types of systems can modeled, including mechanical systems, electronic circuits, analog and digital filters, and thermal andfluid systems. For this experiment, we are going to create a model for a DC motor.The DC motor can be best represented by a transfer function. A transfer function provides a mathematical description for how theinputs and outputs of a system are related. In our case, the input to the system is voltage (V ) and the output from the system ismangular velocity ( ). We can use the equation below to represent the model of our DC Motor where:m
km = Motor back-EMF constant (V/(rad/s))Rm = Motor armature resistance (Ohms)Jeq = Equivalent moment of inertia (kg*m2) (Assume that Jeq=Jm(Motor armature moment of inertia))
Figure 1. Mathematical Model or Transfer Function for a DC MotorThis model will be used to design a closed-loop controller, which can then be tested with the actual motor. We can represent thistransfer function in LabVIEW by using a MathScript Node which is part of the LabVIEW MathScript RT Module. The inputparameter values were obtained from the Quanser QNET DC Motor specifications sheet.
Figure 2. Model of the DC Motor represented in the LabVIEW MathScript NodeThe MathScript node can be found under the >> palette. Programming StructuresStep 2 - Control Design
The next step is to choose a control method and design a controller. When designing a controller it is best to fully understand theplant, in our case, the DC Motor. This understanding comes from analysis of specialized graphs, such as Bode, root-locus, andNyquist plot, which build intuition of how the plant will behave. Graphs in the time domain, such as the step response, provideimmediate feedback on the ideal behavior of the system, such as rise time, overshoot, settling time, and steady-state error.
-
2/6 www.ni.com
Figure 3: Schematic of a Closed-Loop Control SystemFor this experiment we will design a PI controller for our DC motor using the LabVIEW Control Design and Simulation module. TheSimulation Loop, which includes a built-in ODE solver for handling integrals and derivative terms, can be found in the Control
palette under . The Summation, Gain, Integrator and Transfer Function blocks can also beDesign and Simulation Simulationfound in the palette under and Control Design and Simulation Simulation >> Signal Arithmetic Simulation >> Continuous
. Linear Systems
Figure 4: Closed-Loop PI Controller in LabVIEW Control Design and Simulation Step 3 - Simulation
The next step is to simulate the response of the DC Motor when modifying the setpoint or desired speed input. This will allow us totune the controller parameters or gains to increase the robustness of our system. We will need to combine the Transfer Functionor model of the DC motor that we created in Step 1 with our closed-loop controller.
Figure 5: Closed-Loop PI Controller with DC Motor Transfer Function
-
3/6 www.ni.com
Step 4 - Tuning and Verification
Now that we can simulate both our controller and the response of the DC motor, we can follow an iterative process to optimize ourcontroller. We will tune the controller parameters from the LabVIEW front panel while verifying the system performance.
Figure 6: An Iterative Process for Optimizing the ControllerWe can use the following steps to tune our controller parameters:
Begin with gains set at: Kp = 1 and Ki = 0Increase Proportional Gain (Kp) to get desired rise timeIncrease Integral Gain (Ki) to reduce steady-state error if necessary
Once we run the program, we can see the desired motor speed and the estimated motor speed plotted on the Waveform chart.While the rise time looks good with our proportional gain, kp set to 1, the plot shows a small amount of stead-state error, which isrepresented by the gap between the desired speed data and the estimated speed data. We can reduce this steady-state error byincreasing our integral gain, ki.
Figure 7: Simulating the DC Motor Response with a Proportional (P) Controller If we increase the integral gain, ki, to 10, we have a much better system response.
-
4/6 www.ni.com
Figure 8: Simulating the DC Motor Response with a Proportional-Integral (PI) ControllerStep 5 - Implementation
Now that we've verified that our PI controller works with the simulated DC motor response, we can implement our finalized controlsystem and control the speed of our Quanser DC Motor plug-in board for NI ELVIS. The LabVIEW Control Design and SimulationModule can be used to control real life systems as well as simulated models. To migrate from simulated control to real life control,the plant model can be replaced with hardware input and output functions. In this case, we will replace the transfer functionrepresenting the DC motor with Data Acquisition (DAQ) input and output VIs that control the actual motor.
Figure 9: Migrate from Simulation to Real Hardware by Replacing Transfer Function with Hardware Input/Output Blocks
Timing is an important consideration when using the LabVIEW Control Design and Simulation Loop with real hardware. Since the
-
5/6 www.ni.com
Timing is an important consideration when using the LabVIEW Control Design and Simulation Loop with real hardware. Since theControl Design and Simulation Loop uses a built in ODE solver with time steps, it is important to set the Simulation Parametersand the Timing Parameters of the loop to have the same time step. Data acquisition tasks typically use timing parameters, so it isalso important to equate the Simulation loop timing with the data acquisition timing.We can now run the LabVIEW program and control the speed of the Quanser DC Motor from the LabVIEW front panel.
Figure 10: Response of the Actual Quanser DC Motor with our PI Closed-Loop Controller1. Solution Block Diagram VI Snippet
Right-click on the above VI Snippet and select Locate the file on your hard disk and click-and-drag the file iconSave Image As...onto your LabVIEW Block Diagram. LabVIEW will automatically generate the code form the VI Snippet. Click here for moreinformation on VI Snippets.Next Steps
Find free courseware for teaching controls, robotics, and mechatronicsSee recommended product bundles for teaching controls and mechatronicsDownload LabVIEW and LabVIEW Modules and Toolkits for control design and simulation
-
6/6 www.ni.com
Customer Reviews
2 Reviews | Submit your review