A model-based design approach greatly reduces the development time of motor control applications. By Arun Mulpur and Zijad Galijasevic.
Sophisticated motor controllers are being used
in an increasingly wide range of applications to provide more complex and accurate motion control, reduce energy consumption, and deliver many other benefits. These controllers are often based on 16- and 32-bit digital signal controllers (DSCs) that provide some application libraries but still require tools and methods for developing and implementing advanced motor and motion control algorithms and integrating various control functions and peripherals. Development time and expense is increased by the fact that errors in design and integration are usually not detected until code is runon actual hardware.Model-Based Design can address these challenges
by enabling a hierarchical design process in which the entire design is initially defined at a conceptual level and detail is added as necessary to deliver the needed functionality. The model is used to define specifications, evaluate design and system performance, automatically generate code, perform hardware-in-the-loop testing, and create a softwarebasedtest harness for testing production hardware.This approach can substantially reduce
development time by rapidly leading to complete and functional proof-of-concept designs and enabling rapid design iterations and parameter optimization through a unified design, simulation, and testenvironment.Build, check, modify
The use of Model-Based Design for motor control
applications has been aided by the introduction of blocksets that include preconfigured blocks to handle all elements of vector control systems, such as Park and Clarke transforms, PWMs, PI loops, speedestimators, flux estimators, and others.These new tools enable designers to quickly build
a graphical model using pre-built blocks representing primitives and advanced algorithms, incorporating their own C-code only when required. All of the integration between the various blocks and peripherals is carried out automatically. These new tools have received customer acceptance for critical engineeringprojects, as well as industry recognition.Model-Based Design enables engineers to build
scripts to depict typical operating scenarios that simulate the operation of the controller in software. Engineers can quickly modify the model and observe the performance change, enabling improved design performance through rapid iterations.The key element of this approach is flexibility
in evaluating a new design without having to make a major investment in hardware prototyping. For example, engineers can run the controller model on a simulated real-time platform, controlling a model that simulates the performance of the motor. Or, they can generate the code and run it on the actual hardware and use it to control a real motor or a realtime simulation of the motor.This makes it possible to evaluate the performance
of a wide range of designs in a very short period of time and at a very low cost in the early phases of the development. For example, the engineer might develop a simple software model of an electric motor and control it with the early iteration of the control system. He could easily quantify control system performance, e.g. the amount of time required to respond to a speed change command. The design could be quickly changed, by adjusting PID parameters, and the effect on performance observed immediately.Modeling in action
A simple DC motor control system design
was developed using Simulink, which is a platform from The MathWorks Inc. for multi-domain simulation and Model-BasedDesign.In the configuration (see diagram
above), a PID block controls the duty cycle of a PWM block, which in turn controls the voltage delivered to the motor. The quadrature-encoder-pulse (QEP) block accepts quadrature pulse output of an optical encoder connected to the motor armature. The QEP block then calculates the position of the armature and the speedof rotation.The output from the QEP is a digital
velocity signal that is utilized by the PID controller block to control the duty cycle of the PWM. It is important to note that the speed measurement, PID and several other blocks generate hand-written assembly code that is optimized for the TI DSP used in thisexample.The initial PID parameters generated a
set of results with output plots representing the desired speed, PWM duty cycle and actual speed. The plots show that the controller response is not optimized due to a large overshoot and prolonged oscillations. Through iterative modifications, the parameters of the PID block are adjustedto produce better response.Once the control system design behaves
properly in simulation, the engineer can automatically generate C-code and run the design on an embedded hardware system. This means that designers can evaluate their hardware prototype in real-time. In this example, the design was targeted to the Texas Instruments TMS320F2812 DSPand the Code Composer Studio IDE.Directly to implementation
Real-Time Workshop and Embedded
Target for TI C2000 DSP from The MathWorks provide fixed- and floating-point code generation from Simulink for TI C2000 DSPs. The generated source code is then automatically placed into a Code Composer Studio project. In addition to device drivers and control algorithm, generated code contains a real-timescheduler, linker-command file and project-settings.In this example, the target was connected
to a real motor, using an evaluation board. Link for Code Composer Studio was also used to transfer data between Simulink and Code Composer Studio. Link for Code Computer Studio extends MATLAB (a platform for technical computing) to provide project load, run, and stop management; debug points; data manipulation; the hardware-in-the-loop simulation system; co-simulation support; and support for RTDX (Real Time Data Exchange). This application takes control of Code Composer Studio during the testing and debugging process and allows for real-time exchangewhile the target application is running.One of the steps in targeting the TI DSP
is to change drivers to optimize the model for Texas Instruments’ Real Time Data Exchange , which provides bidirectional communications between the host-side client and target application. Link for Code Composer Studio is used to facilitate RTDX communication between MATLAB and applications running on the target. In addition, the same product creates the Code Composer Studio project, sets compilerand linker options, builds, loads and runs the application.On-target code verification
Performing the optimization tasks using a
traditional design process would require significant number of iterations, with each involving changing the control system algorithms and parameters, recompiling, and re-running the application. Model- Based Design makes it possible to perform design iterations in a matter of seconds on parameters that can be adjusted in realtime, and in minutes on other parameters.For example, engineers can view the
measurements of current and voltage on the real motor stator windings on the screen while at the same time looking at variables in the control systems, such as measurements of the same parameters. The ability to view and compare physical measurements with control system variables in real time provides insight into the design that can dramatically reducedevelopment time.Depicted are plots
showing data representing measured motor speed and duty-cycle of the generated PWM waveform. The data is brought back from the application running on the real hardware to MATLAB using RTDX. In this example, RTDX is also used for varying the desired speed of the motorin real-time.Adding advancedfeatures
Additional control systems
capabilities that might otherwise require weeks of coding can be added to thesystem design simply bydragging and dropping blocks from otherblock libraries. For example, designers ofdistributed control systems can add a blockto provide CAN networking capabilities tothe controller architecture.Just like the rest of the controller design,
the logic operations needed for processing the received CAN messages and generating the resulting control decisions can be prototyped, simulated, and implemented through automatic code generation The networking capabilities of the controller can also easily be simulated by using an add-on card that provides CAN support to the PC. And the same capability can be used for tuning model parameters and obtaining model data while the application representing the model is running on the actual DSP hardware.It all goes to show that Model-Based
Design can assist in the development of increasingly sophisticated embedded motor controllers by providing an environment where simulations can be used to quickly evaluate the performance of alternate design concepts. Models can be automatically converted into efficient Ccode for hardware-in-the-loop simulation. This approach makes it possible to deliver higher performance by evaluating a larger number of design alternatives while reducing engineering costs. CEADr Arun Malpur and Dr Zijad Galijasevic are both with The MathWorks Inc (www.mathworks.com), a global provider of technical computing software represented in Southeast Asia by TechSource Systems(www.techsource.com).
A model used for determining parameters and evaluating performance of a PID block
Initial and improved performance
















Free Magazine Subscription
Printer-friendly version
Email to a Friend



