dc motor control lab using xpc target on feedback modular servo system ms150_final

59
School of Electrical and Computer Engineering Control Group DC Motor Control Lab using xPC Target On Feedback Modular Servo System MS150 Manual Book RMIT University School of Electrical and Computer Engineering

Upload: harun-kaya

Post on 07-Apr-2015

813 views

Category:

Documents


19 download

TRANSCRIPT

Page 1: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

DC Motor Control Lab using xPC Target On Feedback Modular Servo System MS150

Manual Book

RMIT UniversitySchool of Electrical and Computer EngineeringControl Group @04.2010

Page 2: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Preface

NotePlease check the Feedback website for THE HEALTH AND SAFETY AT WORK ACT 1974, PRODUCT IMPROVEMENTS, COMPONENT REPLACEMENT, DECLARATION CONCERNING ELECTROMAGNETIC COMPATIBLITY and its COPYRIGHT NOTICE BEFORE starting the lab.

DeclarationThe first chapter is a brief introduction of the Modular Servo System MS150. The copyrights of the product, MS150 belong to Feedback Company. Please contact Feedback Company or check its official website to obtain the authorized manual book with detailed datasheets. The xPC Target System which is a Mathworks product, Mathworks holds the copyrights of it. The Second Chapter only refers a part of its content which will be used in the lab system.

Copyright NoticeRMIT University reserves all the copyrights of the lab design. 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 or otherwise, without the prior permission of RMIT University.

Page 3: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

ContentsChapter1. Introduction of the Feedback MS150 Sy1stem

1. Overview of Feedback Modular Servo System MS150…….22. Units Used in the DC Motor Speed Control Lab……………….3

Chapter2. Introduction of the XPC Target System1. Overview of XPC Target System……………………………………….52. National Instruments PCI Card………………………………………..63. Connection and Communication between the Host and

XPC Target…………………………………………………………………..….7Chapter3. DC Motor Speed Control Lab

1. Overview of the DC Motor Speed Control Lab……………….112. MS150 Setting for DC Motor Speed Control Lab…………...123. xPC Target System Configuration for Motor Speed Control

Lab…………………………………………………………………………………144. Lab Activities………………………………………………………………….215. Further Development………………………………………………….24

Reference…………………………………………………………………………………………….25Appendix……………………………………………………………………………………………..26

1RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 4: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter1. Introduction of the Feedback MS150 System

1.1 Overview of Feedback Modular Servo System MS150The Feedback Modular Servo System was designed to help students understand the principle of open or closed-loop control theory. Also, it is ideally suitable to be used in basic engineering training programs.

The system consists of a magnetic base platform and several units which can be attached onto the base with magnetic force. Each unit has its unique functions. For example, the Reduction Gear Tacho Unit GT150X is normally used to acquire the feedback in terms of the motor rotating speed. As the Fig.1.1 depicted, the units have diagrams on the surface indicating their inner connection and functions. These MS150 units are usually connected into either a DC system labeled as MS150, or an AC system labeled MS150A. In both systems, speed or position control may be implemented.

Figure1.1 Overview of MS150Other features of the system can be found on the Data Sheet of MS150 that can be downloaded from Feedback website, from which users of MS150 can have a more complete understanding.

In this manual, only the DC system MS150 will be introduced. In the DC Motor Control Lab, the following equipment in MS150 is required:The Power Supply Unit, PS150E;The Servo Amplifier Unit, SA150D;The DC Motor Unit, DCM150F;The Reduction Gear Tacho Unit, GT150X.

2RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 5: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter1. Introduction of the Feedback MS150 System1.2 Units Used in the DC Motor Speed Control LabGeneral functions of these units can be directly read from the surface of each unit, as the figures depicted below, where only some important features are specifically introduced. Please refer to Feedback official website to download more detailed data sheets.

Figure1.2 DC Motor Speed Control Lab Units

PS150EThe unit PS150E serves as the power supply of the system. Inputs are 120v~2A(T) and 230v~1A(T), 50/60Hz. The unit supplies +24v dc unregulated at 2A, +/-15v regulated at 0.5A, 18v ac at 1A, 9-0-9v at 10mA. The unit is usually connected to the Servo Amplifier Unit SA150D.

Chapter1. Introduction of the Feedback MS150 SystemSA150D

3RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 6: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

This unit is used to operate either the DC motor in the lab, or an AC motor system in MS150. There is a protection circuit built inside to avoid overload of the motor.

DCM150FThe motor in this unit is a permanent magnet DC motor, which has the limitation speed at 3000 radium/min. The torque is 2A for 0.1 Nm.

GT150XThe Reduction gear tacho unit installed a 30/1 reduction gear and a tacho-generator. The speed feedback of the motor can be read directly from the unit in terms of 2.75 volts/(1000r/min), or 5V/(1800r/min).

4RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 7: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target System2.1 Overview of XPC Target System“xPC is the solution for prototyping, testing and deploying real-time systems.”[4]

Fundamental Structure of the XPC Target System The XPC Target System consists of a host PC and one or several target PCs. In this environment, users can create Simulink models with blocks, or state-flow charts from the MATLAB libraries on the host PC. The models can be simulated or “built” in non-real time mode there. Subsequently, XPC target system incorporates a Real Time Workshop which allows the users to verify their models and generate executable program code using the embedded C/C++ compiler. When the executable code has been generated, XPC Target System downloads it from the host PC to the target PC through the Ethernet or RS232 connection. Finally, the XPC Target System runs the real-time applications on the separate target PC, and the users can change the parameters of the models on the host PC to prototype, test and deploy their systems in real-time.

Requirements of the XPC Target SystemHardware requirements: the system requires a PC to be the host PC, at least one target PC which must provide available I/O connection to the host PC (this can be Ethernet interface or RS232 interface) and the corresponding data cable to connect them. To run the real-time applications, including sending control signals and collecting feedback information back, a National Instruments PCI card should also be installed in the target PC. The PCI card should be connected to the control targets via break out board.

Software requirements: the MATLAB software and its Simulink and Real-Time Workshop, xPC target toolbox must be installed in the host PC. In addition, either a Microsoft Visual C/C++ compiler, or an Open Watcom C/C++ compiler should be prepared in the host PC in order to generate the executable code.

Features of the xPC Target System: please refer to the Mathworks website for this information of this part.

5RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 8: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target System2.2 National Instruments PCI CardFor data acquisition in the xPC Target System, a National Instruments PCI board and its suitable break out board are required. The PCI card is one of the most widely adopted internal buses for PCs. In our lab, NI PCI 6024E and the break board NI CB-68LP are employed.

To run the real-time applications, including sending control signals and collecting feedback information, a National Instruments PCI card should also be installed in the target PC. The PCI card should be connected to the control targets via its matched interface card.

Please check our appendix, or go to the National Instruments website to download the relative data sheets.

Fig2.1 PCI card and its installation

6RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 9: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target System2.3 Connection and Communication between the Host and XPC TargetPlease check the requirements of the XPC Target System first before starting the connection and communication between the host PC and Target PC

1) Physical ConnectionAs depicted in Fig2.2, XPC Target users should first set up the host PC and target PC. Remember Simulink models will be built and simulated on the host PC, and the real- time applications can be operated on the target PC. In Fig2.2, the laptop is used as the host PC with a Simulink model running on it, and the PC behind it is the target PC which is connected to the monitor. The monitor is used to observe signals from the xPC Target System. As the figure shows, there are two scopes on the screen corresponding to the two Target scopes in the Simulink model; the bar on the top describes the setting of the current system. Once it has been finished, users can connect the target pc to the host pc using available data cable. Ethernet cable is recommended for its stability and high data transmitting speed. Finally, the control target, namely in this lab, MS150 system shown as on the left hand side of the figure can be connected to the target pc through PCI and its interface card.

Caution: Do NOT turn on any control target power before a proper model has been downloaded to the target PC. Otherwise, target PC may send misleading control signal to the control target and cause damage.

Fig2.2 xPC Target System connection

7RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 10: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target System2) xPC Target Explorer SettingRun the Matlab on the host PC, and type in the command “xpcexplr” to run the xPC Target Explorer as shown below.

Fig2.3 xPC Target Explorer

Using the xPC Target Explorer, users need to complete the following operations:a) To start with, user should select the C/C++ compiler from “Compilers

Configuration”.

b) On the left window, under “Target PCx”, click on “communication”. Two options for host target communication are available to select on the right window where users can use their own customized settings. The selection should depend on the physical connection (TCP/IP is for Ethernet interface, and COM is for RS232 serial interface).

c) Change to “configuration” on the left window. Users should be able to see multiple approaches to boot the XPC Target System, including through CD boot, floppy boot and so forth. Create an image file of the boot disk and burn it to a CD for instance.

d) Insert the CD into the target PC, and boot its system directly from the CD drive. The target PC will log onto the xPC Target System.

8RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 11: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target Systeme) After completing the above three steps, do not change the communication

settings, right click on “TargetPCx” and select “connect”. The target PC will be connected to the host PC.

3) Simulink model settingNow users may create a fundamental Simulink I/O test model and set up the simulation parameters.

a) Type in command “simulink” and execute to open the Simulink Library Browser as the following figure shows.

Fig2.4 Simulink Library Browser

b) Create a simple I/O test model using the blocks from the library. xPC Target blocks library is located at the bottom of the entire library.

c) From the menu of the Simulink model, select “Simulation->Configuration Parameters”. In the configuration, it is inevitable to set solver options as well as the Real-Time Workshop options properly as the Fig2.5 indicated.

9RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 12: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter2. Introduction of the XPC Target System

Fig2.5 Simulation Configuration

d) Solver: normally set start time as 0s, and set stop time long enough for observation. In the lab environment, Fix-step type of solver is highly recommended. Fundamental sampling time should be faster than any of sample time setting of the blocks in the model.

e) Real-Time Workshop: select “System Target File” as “xPCtarget.tlc” for XPC Target System to generate C code.

f) After the above three steps have been finished, model can be downloaded by clicking on the “built” button.

g) Turn on the power of the control target and run the real-time application normally or externally.

10RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 13: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab3.1 Overview of the DC Motor Speed Control LabThe DC Motor Speed Control Lab is designed ideally for students to get familiar with the Advanced Control Theory including system identification and PID control. The lab will impress students by allowing them to build and simulate a model on an xPC Target real-time device, collect data and operate real-time parameter tuning.

In this chapter, the connection of the MS150 system and the set up of the xPC Target System for the DC Motor Speed Control Lab will be introduced in the first and second section. The following section explains how to precede system identification and PID control on this platform. The last section generalizes the possibilities for further development for this lab environment.

Features Graphical model design is intuitive for students to understand the control theory.

The signals can be directly observed on the target PC monitor.

Numerical data can be collected and exposed to Matlab platform for precise analysis.

With real-time parameter tuning on the model blocks or sub-system masks, the effects of proportional, integral and derivative controller can be observed directly.

MS150 system provides an easy-to-learn control target.

The lab can be easily extended using the potentio -meter unit of MS150, and professional programmers can design GUI interface for the lab with Microsoft Visual Basic Express or directly generate from Matlab.

11RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 14: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab3.2 MS150 Setting for DC Motor Speed Control Lab1) Physical Connection on MS150

a) MS150 DC Motor standard connection Supply power to unit PS150E and connect it to unit SA150D through the

port special for Servo Amplifier; Connect the Servo Amplifier to the DC motor unit DCM10F; Connect the DC motor unit DCM150F to the reduction gear unit GT150X

by using a 2.5mm Hex Key to tight their coupler.

b) Lab connectionPlease connect the wires to the ports on each unit according to the following figure.

Figure3.1 DC Motor Speed Control Lab Wire Connection

2) Connect to NI CB-68LP boardThe NI CB-68LP board is a “Low-cost termination accessories with 68 screw terminals for easy connection of field I/O signals to the counter/timer devices. The connector blocks include standoffs for use on a desktop or mounting in a custom panel. The CB-68LP has a vertically mounted 68-pin connector.”

As it shown in Fig3.1, the following terminals are employed in the DC Motor Speed Control Lab:22: DAC0OUT1, digital to analog output 1;55: AOGND, analog output ground;67: AIGND, analog input ground;68: ACH0, analog channel 0.

Chapter3. DC Motor Speed Control Lab12

RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 15: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

This pin assignment is specially used for NI PCI 6023E/6024E. Please check the appendix for the entire pin assignment table of NI PCI 6023E/6024E for further development in the future.

Fig3.2 NI CB-68LP

3) Trouble ShootingOnly the most frequently appeared problems and their possible solutions are listed below.

Feedback delay: if the feedback information is not reasonable and the response is too slow, please check the bearing of the unit GT150X. Make sure the bearing is stably fixed to the unit.

Motor noise: if the motor is too noisy even under low input gain situation, please check the coupling between the unit DCM150F and GT150X. Maybe, it was not tighten enough. Another possible problem could be the misalignment between the bearings of the two units.

No feedback on xPC Target monitor: if there is not any feedback depicted on xPC Target monitor, please first confirm whether there is reasonable feedback shown on the unit GT150X. If not, please check the physical connection according to the above two sections. Otherwise, please check the pin assignment table to see whether they match with the design of your model blocks.

Please Note: the channel number on the pin assignment table is indicated by that number plus one in the Simulink blocks.

13RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 16: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab3.3 xPC Target System Configuration for Motor Speed Control LabBefore configuring the xPC Target System, it is important to ensure the physical connections of the system correspond with the above chapters. Another important step that has to be completed is to burn a boot disk for xPC Target System and record its settings.

Subsequently, we can start configuring the xPC Target System according to the following steps. Please note: the following explanation is an example for the xPC Target System configuration. Users should learn the example and configure their system according to their customized settings.

1) xPC ExplorerStart Matlab and run xPC Target Explorer

Fig3.3 xPC Target Explorer

The xPC Target Explorer is the interface for the xPC Target System users to set up the configuration for the connection between the host PC and one or several target PCs. As the above figure shows, the xPC Target Hierarchy can be observed from the left hand side of the window. It shows the compilers configuration, the current directory to the .dlm files and all the Target PCs settings.

14RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 17: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control LabSet C/C++ program compiler

Fig3.4 C/C++ program compiler for xPC TargetUsers can select Watcom to use Open Watcom as a compiler or select VisualC as a compiler. However, both of them need to be matched with users’ current Matlab version. Please browse the Mathworks website to check the version matching table.

Set communication between the host and target PC

Fig3.5 Communication between host and target PC

Chapter3. DC Motor Speed Control Lab15

RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 18: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

As it shown in fig3.5, TCP/IP was selected, which means the host PC and the target PC should be connected through a Lan cable. Once it has been selected, all the TCP/IP options are activated. For example, users are allowed to set the target PC IP address. However, all the settings should correspond to the boot disk setting (Please check Chapter2 to learn how to create a boot disk). Another requirement is that the host pc IP should also be set properly. Please find the current Network Connection from Control Panel. Right click on the icon and select properties, and then select Internet Protocols (TCP/IP). Fill in the IP address, subnet mask and default gateway same as the boot disk setting and change the last digit of the IP address to a different number. Leave the DNS Server part blank. For example, if the IP address is set as below in the boot disk:IP Address: 192.168.0.2; Subnet: 255.255.255.0; Gateway: 192.168.0.254.The IP address of the host PC should be set as:IP Address: 192.168.0.1; Subnet: 255.255.255.0; Gateway: 192.168.0.254.

The other option for the host target connection is RS232, which stands for the communication through the serial port “COM”. For this option, users should ensure that the settings including the port number and the band rate match with the physical connection. Users may check the physical connection through device management on the host PC. If in case, the host PC did not recognize the connection, users may have to install a driver to the system. For example, if a laptop without serial port will be used as a host PC, a RS232 to USB converter cable can be used, but in this case, the driver for the connected USB should be installed.

16RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 19: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab2) Simulink model

Run Simulink and create a model

Fig3.6 create a Simulink model

Design an I/O test model using xPC Target blocksScroll down to the bottom of the library to find “xPC Target” type and find the blocks through the following path:xPC Target-> D/A ->National Instruments -> E-series -> PCI-6024E DA;xPC Target-> A/D->National Instruments -> E-series -> PCI-6024E AD;xPC Target-> Misc. -> Scope(xPC).Also, find a Pulse Generator in the Source library. Finally, connect them together as the following figure depicts.

Fig3.7 I/O test modelChapter3. DC Motor Speed Control Lab

17RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 20: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

3) Simulink Parameter Configurationa) Solver configuration:Start time-> 0; Stop time-> inf;Solver type-> Fixed Step;Fixed step size ->0.001;Select solver according to the expectations.

Fig3.8 Simulink Solver Configuration

The above configuration set the running time as from the very beginning to infinite. For the DC Motor Speed Control Lab, the solver type is expected to be fixed step. Since the lab is the real-time speed control of the dc motor, the other option, variable-step cannot be applied. It is impossible to estimate the solver step in real time.

18RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 21: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Labb) Real-Time Workshop ConfigurationSelect system target file as “xpctarget.tlc”

Fig3.9 Real-Time Workshop Configuration

The file “xpctarget.tlc” tells the Real-Time Workshop to generate the C program specifically for xPC Target System. The compiler selected in xPC Target Explorer setting is a general C program compiler. “xpctarget.tlc” is built on the basis of the general C program compiler, and specifically designed for xPC Target applications so that the Real-Time Workshop on Matlab can generate executable code according to the Simulink models that users created.

19RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 22: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab1) Run the model

Build the model, connect to target PC and run it in real time. Please check the following section for how to create, run and adjust a model properly. If there is any problem, please check the following session for trouble shooting.

2) Trouble ShootingOnly the most frequently appeared problems and their possible solutions are listed below.

Complier: if there is any warning about the complier, users should first confirm the complier is installed in the valid directory of Matlab; if there is still any problem, please browse the Mathworks website and ensure the version of the complier matches with that of the installed Matlab.

“Com” communication is not available: please ensure the driver of the serial port has been installed into the operation system. Also, please check the device management to make sure the setting of the port is matched.

Cannot find xPC Target library: please install the toolbox of xPC Target into your Matlab.

20RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 23: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control Lab3.4 Motor Speed Control Lab ActivitiesPID controller Simulink model example

Fig3.10 System Identification and PID control Simulink model

As an example, the above Simulink model employs the blocks from xPC Target Library and realizes the function of System Identification and PID control. The meaning for each part is explained as below.

Reference and Gain: these two blocks are used to set the reference point for the control target DC motor. The amplitude of the reference can be set in the parameter settings of the Reference block, or it can be changed directly on Gain even during the motor is running.

Constant input to pin 1 of the Switch 1: this is always set to be zero to eliminate the noise from pin 1 when it is not connected into the control loop.

PCI-6024E National Instr. Analog Input: this block is employed to collect feedback information from the MS150 system. Since in this lab, pin 68 was connected. According to the pin assignment table, it represents analog channel0. Therefore, in the Simulink model, the channel should be set as [1]. The channel number on I/O connector pin assignment table is always augmented by one when presented in Matlab.

Chapter3. DC Motor Speed Control Lab PCI-6024E National Instr. Analog Output: this block is applied to send control

21RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 24: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

signals out to the control target. The channel setting principle is the same with PCI-6024E National Instr. Analog Input block.

Switch 1&2: the switches are used to switch the operation mode. The system is in System Identification mode if both of switches 1 and 2 are connected to pin 1; if both of the switches are connected to pin 2, PID control will be employed.

Target Scope: these two blocks are found from the xPC Target Library, and are specifically designed to show control information on the monitor of the target PC. The data can be shown in several ways according to the settings of the block. For example, users can determine whether to show the data in graphical mode, or numerical mode.

PID Controller: the controller is actually a subsystem block. There are three parameters that can be adjusted on this block, kp, ki, and kd, which is corresponding to the gain of proportional, integral and derivative control, respectively. To discover the precise structure of the system, users can right click on the block and select “look under mask”. The inner structure will then appears in a separate window.

Fig3.11 PID Controller under mask

Out 1 & 2: these two blocks are crucial to collect numerical feedback information for precise analysis of the target system.

22RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 25: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Chapter3. DC Motor Speed Control LabFrom xPC Target Explorer, users are allowed to send their data collected from the above blocks to Workspace on Matlab. From the xPC Target Hierarchy, click on the model that is currently used as the figure below shows. Tick the time and output box, where you can change the data file name, and click on the “Send to Matlab Workspace” button. The data received from the two blocks will then be sent to the workspace.

Fig3.12 sending data from Simulink model to Matlab Workspace

Fig3.13 data on Workspace collected from Simulink portsAs the above figures shown, the data are sent to the Matlab Workspace. The two columns of “yout” correspond to the data from out1 and out2, respectively.

Chapter3. DC Motor Speed Control Lab23

RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 26: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

3.5 Further Expansion ProposalPosition Control: Feedback Servo System MS150 provides the potentio-meter unit OP150K and other units to collect positional feedback. Please check Feedback MS150 system manual book to find out the proper connection for DC Motor Position Control. In the xPC Target System design, please check the pin assignment table to find a proper channel for position feedback.

State-space Control: as long as the system has been identified in the way as section 3.4 described, State-space control can be employed in the system. The appendix at the end of the manual recommends the block diagram for State-space control.

AC Motor Control: the xPC Target System can also be deployed on AC motors. The system configuration part would be similar. However, it is necessary to design a suitable control model in Simulink for AC motors.

GUI Interface: a GUI interface for the Simulink models can be designed. The users who are good at Microsoft Visual Basic Express can use this program to design the GUI interface. The core for this way is to utilize xPC Target API and xPC Target API COM. Another approach is to complete the interface design in the Matlab environment and directly generate the GUI from Matlab. Please refer to Mathworks website for the concrete method.

Remote Control Lab: with a local router, the xPC target and its host and be connected to internet, which allows users could control it from distance. A specific IP is required for the system in this case.

24RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 27: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Reference

[1] Feedback Instruments Ltd, “Modular Servo Instructional Servo System, MS150” [Online] Available: http://www.fbk.com/files/MS150/Full%20MS150.pdf

[2] National Instruments, “Low-Cost E Series Multifunction DAQ –12 or 16-Bit, 200 kS/s, 16 Analog Inputs” (for NI PCI E-series) [Online] Available: http://www.ni.com/pdf/products/us/4daqsc202-204_ETC_212-213.pdf

[3] National Instruments, “Counter/Timer Accessories and Cables” (for NI CB-68LP) [Online] Available: http://www.ni.com/pdf/products/us/4daqsc390-392.pdf

[4] Mathworks Inc. “xPC Target Documents” http://www.mathworks.com/access/helpdesk/help/toolbox/xpc/?BB=1

[5] Wikipedia the free encyclopedia, “PID controller” http://en.wikipedia.org/wiki/PID_controller

25RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 28: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Appendix1. System Identification, PID Control and State-space Control diagrams 2. GUI Interface3. NI CB-68LP data sheet4. 68-Pin E Series Connector Pin Assignments

26RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 29: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Appendix1. PID Control and State-space Control diagrams1) System Identification

2) PID Control Design

3) State-space Control Design

27RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.

Page 30: DC Motor Control Lab Using XPC Target on FEEDBACK Modular Servo System MS150_final

School of Electrical and Computer EngineeringControl Group

Appendix2. GUI Interface

28RMIT UniversitySchool of Electrical and Computer EngineeringProf. Liuping Wang, Dr. N.V. Truong, Dae Yoo, Xuan Liu, Rex Lee.