Support Articles

Support Articles Modelling and Simulation Model Based Design Part 1: Executable Specifications from Models

Model Based Design Part 1: Executable Specifications from Models

This is the first of a four-part article in which we will demonstrate how Model-Based Design methodology can be applied to a practical design example; design of a robot arm controller. In Model-Based Design, a system model is at the centre of the development process—from requirements capture and design to implementation and test.

Each of the parts of this article will focus on one element of Model-Based Design:

  • Executable specifications from models
  • Design through simulation, reducing the number of prototypes required
  • Implementation via code generation, minimizing coding errors
  • Continuous test and verification throughout the design process

For more information on Model-Based Design, see the following link. http://www.mathworks.com/applications/controldesign/description/mbd.html

Contents

Written specifications often prove to be ambiguous and can be incomplete. Executable specifications are unambiguous because they can be simulated. Model elaboration gives us the ability to increase the complexity and fidelity of the model as we move through the design process. With an executable model, it is possible to link model blocks and test vectors to requirements. Supported document types include Microsoft Word, DOORS, etc. This is done with Simulink Verification and Validation (http://www.mathworks.com/products/featured/vv/)


Clicker for larger image.

Figure.1 Executable specification for robot arm system.

Let's now focus on modelling the elements in the plant which consists of the mechanical robot arm, electrical motors and position sensors.

Physical modelling of multi-domain plants

There are various first principals and data driven approaches to modelling systems in Simulink. Using physical modelling tools one can reduce the amount of domain knowledge and programming effort required in modelling multi-domain systems. Consider the robot arm plant in this case consisting of mechanical parts, the arm and couplings, and electromechanical elements, the motors. For modelling the mechanical components we will use SimMechanics, a tool for modelling three dimensional elements in Simulink. The model can be imported directly from a Solidworks or Pro Engineer CAD model using a CAD translator. In this article we will concentrate on modelling the electrical motors using the Simscape(tm) and SimElectronics(tm) physical modelling tools. The electrical motors are connected to the robot arm in the model using interface blocks from the SimScape and SimMechanics libraries. Figure.2 shows the model of the coupling between the robot forearm and hand with an electric motor actuator.

Click for larger image.

Figure.2 Robot arm plant model using physical modelling tools

Additional tools available for physical modelling within the Simulink environment are; SimMechanics, SimHydraulics, SimDriveline and SimPowerSystems.

Find out more about Simscape from http://www.mathworks.com/products/simscape/

Featured New Product: SimElectronics

SimElectronics extends the Simscape physical modelling environment with tools for modelling electrical and electromechanical systems. SimElectronics builds upon the Simscape Electrical Foundation Library and provides semiconductor, motor, drive, sensor, and actuator components, as well as building blocks that let you implement your own custom subsystems.

Since SimElectronics is built on Simscape technology you can interface your electronic and electromechanical elements with mechanical, hydraulic and thermal domains. Using the Simulink interface blocks you can develop plant models in the same environment that you use to develop and refine your control and signal processing algorithms.

SimElectronics libraries provide more than 55 models of electronic and electromechanical components, including models of motors and op-amps, which you can combine to represent commercially available components. The blocks in SimElectronics support two different work-flows - you can set the values of your parameters by pulling them directly from industry data sheets, or you can import SPICE circuits and device models directly into SimElectronics.

For more information on this product visit the SimElectronics product page at http://www.mathworks.com/products/simelectronics

Modelling of Electrical Motors

There are many different approaches for modelling a multi-domain system. The approach used depends on the complexity of the system and level of simulation fidelity required. If we consider a DC motor there are a few ways in which it could be modelled.

First principles model

Consider the two differential equations, which model the electrical and mechanical dynamics of the model respectively. Figure.3 represents a Simulink model of these differential equations.

Click for larger image.

Figure.3 DC motor model in Simulink

Physical Model Using Simscape

While this is a relatively simple system, additional mechanical and electrical complexity would make the system difficult to model from first principals. This motor could be equivalently modelled with physical elements from the Simscape library. Using the Simscape electrical and mechanical libraries one can model complex electromechanical systems easily.

Click for larger image.

Figure.4 DC motor model using Simscape foundation library blocks

SimElectronics provides additional electromechanical blocks which build on the Simscape foundation library blocks. These blocks provide an engineer with tools to develop and simulate complex electromechanical systems easily. The parameters of the blocks can be determined form industry data sheets. If we consider modelling the same electrical motor as previously we can now use the DC motor block provided in the Actuators & Drivers library from the SimElectronics blockset. The figure below shows the DC motor block and parameter dialog, note that the electrical parameters can be specified from equivalent circuit parameters, stall torque & no-load speed or rated power, rated & no-load speed.

Click for larger image.

Figure.5 SimElectronics DC motor model

Model Elaboration: Easier with Physical Modelling Tools

In the previous models we have been driving the model with an ideal voltage source. However with SimElectronics we can add fidelity to the model. We can now drive the motor with a PWM source and an H-Bridge. In the simulation in Figure.6 we are ramping the motor up to speed then applying a torque to the rotor at 4s. At this point the rotor slows down and the current increases. In this simulation he have used and averaged voltage from the PWM and H-Bridge, however, this can be set to PWM with the simulation results in Figure.7. This increases the fidelity in the simulation however at the cost of simulation speed.

Click for larger image

Figure.6 DC motor driven by H-bridge in average mode

Click for larger image

Figure.7 Simulation results of DC motor driven by H-bridge in PWM mode

Conclusion: Part 1

In this article we have focussed on using a software model as an executable specification of the design task. Using physical modelling tools, we showed how we can incrementally elaborate on our system model to increase the fidelity of that model.

In part 2 of the Model-Based Design series of articles, we will show how to design through simulation rather than using physical prototypes. By utilising our executable specification, we can rapidly optimise and simulate controller designs without having to build expensive physical prototypes of the plant or the controller at this early phase of development.