System Modeling White Paper System Modeling: An Introduction Scott Cooper Mentor Graphics REF: MWP2650 www.mentor.com/systemvision INTRODUCTION testing allows the impact of component tolerances on This paper introduces a systematic process for overall system performance to be analyzed, which is developing and analyzing system models for the impractical to do with physical prototypes. purpose of computer simulation. This process is demonstrated using the Digitally-Controlled When employed during the beginning of the design Positioning System (referred to as “Position process, simulation technologies create an environment Controller”) shown in Figure 1. in which a system can be tuned, optimized, and critical insights can be gained – before any hardware is built. WHAT IS COMPUTER SIMULATION? During the verification phase of the design, simulation The general concept of “computer simulation” technologies can again be employed to verify intended (referred to simply as “simulation” in this paper) is to system operation. use a computer to predict the behavior of a system that is to be developed. To achieve this, a “system model” It is a common mistake to completely design a system of the real system is created. This system model is then and then attempt to use simulation to verify whether or used to predict actual system performance and to help not it will work correctly. Simulation should be make design decisions. considered an integral part of the entire design phase, and continue well into the manufacturing phase. Simulation typically involves using specialized computer algorithms to analyze, or “solve”, the system SYSTEM OVERVIEW model over some period of time (time-domain The Position Controller is composed of two sections, as simulation) or over some range of frequencies indicated by the dotted line dividing the system shown (frequency-domain simulation). in Figure 1. These sections are referred to as the Digital Command and Servo subsystems. These subsystems WHYSIMULATE? will be developed individually, and then combined to Simulation is useful for many reasons. Perhaps the form the overall Position Controller system. most obvious use of simulation is to reduce the risk of unintended system behaviors, or even outright failures. The Position Controller works as follows: ADigital This risk is reduced through “virtual testing” using Command subsystem is used to generate a series of simulation technologies. Virtual testing is typically user-programmable “position profile” commands, used in conjunction with physical testing (on a physical which the motor/load are expected to precisely track. prototype). The problem with relying solely on physical The digitally-generated command drives a digital-to- testing is that it is often too expensive, too time- analog (D/A) converter which produces an analog consuming, and occurs too late in the design process to representation of the digital command. allow for optimal design changes to be implemented. DDiiggiittaall SSeerrvvoo CCoommmmaanndd Virtual testing, on the other hand, allows a system to be tested as it is being designed, before actual hardware is DDiiggiittaall SSeerrvvoo// DD built. It also allows access to the innermost workings of CCoommmmaanndd 22 MMoottoorr// AA LLooaadd a system, which can be difficult or even impossible to observe with physical prototypes. Additionally, virtual Figure 1 – Position Controller System Modeling: An Introduction 1 The D/Aoutput is then filtered, and used to command The focus of the Develop System Modeling Analysis an analog servo loop, the purpose of which is to Strategy phase will be to mathematically describe the precisely control the position of an inertial load various analog components in the Servo subsystem, connected to the shaft of a motor. Each of these blocks and to consider the modeling process in general. will be explored in detail in this paper. In the Develop Conceptual Servo Design phase the analog Servo subsystem components are implemented This type of servo positioning system is commonly using the analog behavioral modeling features of the employed in various applications in the automotive, VHDL-AMS language. industrial controls, and robotics industries, among others. Although this paper focuses on this single The Develop Detailed Servo Design phase deals with system, the process used to develop the Position system implementation issues, which often entails Controller may be applied to a great number of other upgrading “high-level” models to be more consistent systems as well. with the intended physical implementation of the system. SPICE and VHDL-AMS models are combined MODELING THE SYSTEM to achieve this goal for the Position Controller system. Before setting out to model this system the following assumptions will be made: The Integrate Digital Command and Servo Subsystems phase discusses how to implement the Digital • The Digital Command subsystem will be Command subsystem components using the mixed implemented by another designer analog/digital features of the VHDL-AMS modeling • The specification for the Digital Command language. Once the Digital Command subsystem is subsystem requires that it will generate a new implemented, the entire Position Controller system will 10 bit digital word every 2 ms be simulated. The Digital Command and Servo subsystems will be All design development and simulation in this paper is developed individually. Since the Servo subsystem is performed with the SystemVision™ System Modeling this designer’s primary design responsibility, special Solution from Mentor Graphics Corporation. consideration will be given to modeling this subsystem. This approach of breaking a larger system down into DEVELOPSYSTEM MODELING manageable subsystem (or smaller) blocks is often ANALYSIS STRATEGY helpful during the early phases of a design. Once This first phase of a system design deals with many individual subsystems are working properly, they can of the decisions that need to be made when starting then be integrated into the full design. development of a new system. Attention is also given to defining mathematical descriptions for the various The Position Controller will be developed in four analog components in the Servo subsystem, and how phases as follows: to systematically approach the modeling process • Develop System Modeling Analysis Strategy in general. • Develop Conceptual Servo Design • Develop Detailed Servo Design SERVO SUBSYSTEM • Integrate Digital Command and Servo Subsystems Since the majority of the modeling tasks exist in the 2 System Modeling: An Introduction Servo subsystem, the first three phases of the design 2. Load position accuracy process will focus on this subsystem. The Digital 3. Stability margins Command subsystem will be developed in the fourth 4. Noise rejection phase of the process. 5. Robustness to parameter variations It is important to consider what specific information is The purpose of the Servo subsystem is to precisely desired from a simulation, as it helps to focus the control the position of a motor-driven load in response modeling efforts. For this paper, speed and accuracy to an analog command. Since the motor/load must be are of main concern. The primary components that may precisely controlled, it suggests that a feedback control affect the speed and accuracy of the Servo subsystem loop will need to be employed. are the low-pass filter, the motor, and the load (power considerations will be deferred until the “Develop Since it is ultimately the position of the load that needs Detailed Servo Subsystem” phase of the process). to be controlled, a position feedback loop will be used By focusing on these critical components, the (which means that the load position must somehow be fidelity requirements on other component models measured, and fed back to close the control loop). can be relaxed. Experience with such systems has shown that both the response and the stability of position control loops can COMPONENT MODELS be enhanced by including some velocity feedback in In order to create a system model, each component in the loop in addition to position feedback. An initial the real system will need to have a corresponding design of the Servo subsystem is shown in Figure 2. “component model” (although it is often possible to combine the function of multiple components into a single component model). These component models are then connected together (as would be their physical counterparts), to create the overall system model. What lies at the heart of any computer simulation, therefore, are the component models. The “art” of Figure 2 - Servo Subsystem creating the models themselves, and sometimes more The Servo subsystem consists of a low-pass filter importantly, of knowing exactly what to model and (to filter out quantization noise from the D/A why, are the primary keys to successful simulation. converter), followed by a position control loop with velocity feedback. Position feedback is provided by a MODELING DECISIONS potentiometer attached to the motor shaft, and velocity When setting out to obtain the models necessary for feedback is provided by a tachometer attached to the a system design, the following questions should shaft as well. The motor itself is driven by a be considered: power amplifier. 1. Which characteristics need to be modeled, and The following aspects of the Servo subsystem are of which can be ignored without affecting the results? interest from a system design standpoint: 2. Does a model already exist? 3. Can an existing model be modified to work in 1. Load positioning speed this application? System Modeling: An Introduction 3 4. What are the options for creating a new model? application, op amp characteristics such as input 5. What component data is available? current, input offset voltage and output resistance may prove entirely negligible. So is it always necessary to These questions will be discussed in turn. use an op amp model that includes these characteristics? Maybe all that is needed is a high gain Which characteristics need to be modeled, and which block that can be used in a negative feedback can be ignored without affecting the results? configuration. In this case, is it even necessary to While it is important to identify component include power supply effects in the model? characteristics that should be modeled, it is equally important to determine what characteristics do not need By answering these types of questions, the level of to be modeled. By simplifying the model requirements, complexity required for any component model can be the task of modeling will be simplified as well. determined, as well as the corresponding development time that will be needed to create and test it. The designer’s first inclination is typically to wish for (Of course, if the goal is to create a re-usable library of a model that includes every possible component component models, then more device characteristics characteristic. However, most situations require only would typically be included in order to make the a certain subset of component characteristics. Beyond models as useful as possible to a wide audience this subset, the inclusion of additional characteristics is of users). not only unnecessary, but may increase model development time as well as the time required to run Does a model already exist? a given simulation session. In a perfect world, all component vendors would produce models of any components they manufacture, For example, suppose a design uses a 10 kΩ resistor. in all modeling formats. This is not the case in the real To simulate this design, a resistor model is needed. world. But even though all of the required models may But from the perspective of the design in question, not be available, a good number of them very well may what exactly is a resistor? Is a resistor a device that be. Whenever possible, designers should make the most simply obeys Ohms law, and nothing more? Or does its from model re-use. resistance value vary as a function of temperature? If so, will this temperature dependence be static for a In order to determine the availability of existing given simulation run, or should it change dynamically models, designers must understand what modeling as the simulation progresses? formats are supported by their simulation tools. One such format, the VHDL-AMS hardware description What about resistor tolerance? Is it acceptable to language, is used in depth in subsequent phases of assume that the resistor is exactly 10 kΩ? What if the this design. actual resistor component supplied by the manufacturer turns out to be closer to 9.9 kΩ, or 10.1 kΩ Can an existing model be modified? (for a +/- 1% resistor)? If the tolerance is important, If an exact model is not already available, it is also does the model itself need to account for this tolerance, possible that a similar model can be found, and re- or is this accounted for by the simulator? parameterized or functionally modified in order to serve the design. Before proceeding further, however, a Take an op amp as another example. Depending on the distinction should be made between re-parameterizing a 4 System Modeling: An Introduction model, and changing the model functionality. the design will need to be created (although the opposite is actually true – all of the models that Re-parameterizing a model simply means passing in comprise the Position Controller system were actually new values, or parameters, which are used by the available in a library supplied with SystemVision, and model equations. The model equations themselves would possibly be available from other VHDL-AMS don’t change, just the data passed into them. For simulator vendors as well). example, a resistor model may be passed in the value of 10 kΩ or 20 kΩ. The underlying model doesn’t What component data is available? change, just the value of the resistance. Consideration must also be given to what component data is available in the first place. The capabilities In many cases, by contrast, it is necessary to change the of a model may need to be restricted based on the underlying model description itself. Although not as amount (and quality) of data the component’s easy as re-parameterizing an existing model, this manufacturer provides. approach is often faster than creating a new model. SERVO SUBSYSTEM COMPONENT What are the options for creating a new model? MODEL DEVELOPMENT So how does one actually go about the process of The behavior for each of the analog components creating simulation models? There are two general required by the Servo subsystem shown in Figure 2 “styles” that dominate the modeling landscape today – will be considered next. The D/Aconverter consists each with its strengths and weaknesses. of mixed analog/digital functionality, and will be discussed in the Integrate Digital Command and Servo The first modeling style uses hardware description Subsystems phase of the design process. languages (HDLs) that have been specifically developed for the purpose of creating models. Creating Very simple models will be developed first, followed models with HDLs is often referred to as “behavioral by models of moderate sophistication. These behavioral modeling”, but this is a bit misleading as models can descriptions are actually implemented as component be developed in this manner to any desired degree of models in the next phase of the design process. fidelity. Behavioral modeling is discussed extensively in this paper. Power Amplifier The “big picture” functionality of the system is of The second modeling style is one in which a “building primary interest in the initial phase of the design. It has block” approach is used to create new models by also already been determined that the power amplifier connecting existing models together in new is not a critical component with respect to Servo configurations. This approach is often referred to as subsystem speed and accuracy. Therefore, the power “macro-modeling” or “block-diagram modeling” and amplifier can be initially modeled as a simple gain is popular with both SPICE-type and control block with unlimited voltage and current drive capacity. systems simulators. In reality, this system will likely employ a switching Since one of the purposes of this paper is to instruct amplifier topology to drive the motor. Why then start off the reader in model development, the assumption will with such a simplified model of the power amplifier? be made that all models required for the first phases of Aside from the obvious answer that the time required System Modeling: An Introduction 55 to develop simple models is less than the time required to develop complicated models, there are two primary reasons why this approach should be considered. First, a switching power amplifier model will typically be driven by a pulse-width modulator (PWM). This device is inherently mixed-signal (i.e. it consists of both analog and digital behaviors). As a result, it will be difficult to perform frequency-domain analysis on a system using such a component. However, frequency domain analysis will prove useful as the control loop is Figure 3 - Example switching waveform stabilized and the system bandwidth is determined. As shown in the figure, it takes quite a few time steps to construct a single pulse in such a system. A20 KHz Second, think about the analog simulation process: a switching amplifier could easily require more than simulator “constructs” the time-domain response for 1,000,000 time steps for a 1 second simulation! a system model from a collection of system solution points. Each of these solution points represents a This is one of the reasons that a simplified model is corresponding point in time. The time between each desired. The important question is: “Can reasonable of these solutions is called a “time step.” simulation results be achieved with a simple gain block approach?” The short answer is yes. Even if the actual For each one of these time steps, the simulator must power amplifier in the system is going to be solve the entire system model. Further, the solving implemented as a switching amplifier, the gain block of each time step is in itself an iterative process, representation is acceptable given the following often requiring several passes to get a single time two assumptions: step solution. • The frequency of the switching amplifier is much greater than the bandwidth of the control loop (true Whenever waveforms change as the system model is in the vast majority of designs) simulated, time steps are generated. The more the • Power consumption is not of great concern in this waveforms change, the greater the number of time phase of the design process steps required to account for the changes. Systems that include switching electronics have rapidly-changing For the purposes of this paper, these are perfectly waveforms by design. As a result, these types of reasonable assumptions in the early phases of the systems can require large amounts of simulation time. overall design. Ultimately, the actual behavior of the switching amplifier will be accounted for, at which Aportion of such a waveform is given in Figure 3. time the simple gain block model will be replaced by a For this waveform, each super-imposed “X” switching amplifier model. represents an actual simulation time step. Now that the scope of the initial power amplifier model has been determined, the next step is to identify a mathematical description that defines the behavior to 6 System Modeling: An Introduction be implemented. The functionality of each component of the Position Controller system is described in v = K*angle (3) out in numerous text books, technical papers, and data sheets. In the case of simple models such as a gain block, the Tachometer mathematical description is fairly intuitive, as shown in Atachometer is a component that generates a voltage Equation (1). level that represents a rotational velocity. Physical tachometers are basically smaller motors whose shafts vout = K*vin (1) are directly coupled onto the main drive motor’s shaft. As the main motor spins, the smaller motor generates At a high, abstract level, a power amplifier just a back-EMF voltage that is proportional to the amplifies an input signal and presents it at the output. shaft speed. Parameter K represents the gain factor. Since the tachometer is not a “critical” component Summing Junction in this phase of the design, only the behavior of the Amathematical description of an ideal summing tachometer needs to be accounted for, not its physical junction is also fairly intuitive. This behavior can be implementation. The tachometer therefore does not described as shown in Equation (2). need to actually be modeled as a motor at this time. v = K *v +K *v (2) Tachometer behavior can be approximated by out 1 in1 2 in2 differentiating the motor shaft position. This will Note that optional gain factors (K1 and K2) have been generate the shaft velocity. The equation describing included in the model equation. This allows either input this behavior is given in Equation (4). to be optionally scaled, and also allows the model to be changed from a summing junction (e.g. +K1 and +K2), d(angle ) v = K* in (4) to a differencing junction (e.g. +K1 and –K2). out dt The addition of optional gain coefficients is a recurring Low-Pass Filter theme in many of the models presented in this paper. As with the other components of this design, the This is not by accident. Generally speaking, models physical implementation of the low-pass filter is not should be developed so that they are re-usable. important at this time, but its behavior is. This behavior By simply adding user-adjustable gain coefficients at can be realized in several ways. To illustrate this point, strategic locations in a model, the model becomes the low-pass filter will be described using three useful to a wider audience at negligible cost in terms techniques: Laplace transfer function, differential of model development time. equation, and discrete RC (resistor/capacitor) components. Potentiometer Apotentiometer is a device that generates a voltage Low-pass filteras transferfunction level in proportion to a rotational angle. (For greater Filter behavior is often described using Laplace precision, optical encoders are often employed for transfer functions. The description of the low-pass this purpose). The behavior of a potentiometer can be filter behavior using a Laplace transfer function is expressed as shown in Equation (3). given in Equation (5). System Modeling: An Introduction 7 used in practice. The filter behavior can also be described using discrete RC (resistor/capacitor) ω v =v * p (5) components. The relationship between the time out in s+ω p constant and RC component values is shown in Equation (8). Whered ω is the cutoff frequency in radians per p second (rad/s). τ = RC (8) p Equation (5) represents a low-pass filter as a Laplace The RC implementation of the low-pass filter is transfer function with the DC gain normalized to 1. illustrated in Figure 4. In this configuration, the low- Laplace transfer function descriptions are extremely pass filter is realized by a frequency-dependent voltage useful for device behaviors that are described by 2nd divider due to changing capacitor impedance. As or higher-order differential equations. Asingle pole frequency goes up, capacitor impedance goes down, low-pass filter is a marginal case that is as easily and the output voltage amplitude drops. expressed as a differential equation as it is expressed as a Laplace transfer function. This is illustrated next. Low-pass filteras differential equation By re-arranging Equation (5) and replacing the Laplace operator s with the differential operator d/dt, the low-pass filter action can also be realized in terms Figure 4 - RC Low-pass Filter of a differential equation1 , as shown in Equation (6). The filter can be modeled using any of these approaches, all of which can be simulated in either the dv v =v +τ * out (6) time or frequency domains. in out p dt Load (Inertia) To implement a model in this manner, the frequency The load is a fairly critical system component since it must be converted into a time constant. This conversion will likely represent one of the largest time constants in is shown in Equation (7). the entire system. This will directly influence the speed of the system. For this design, the load will be 1 τ = represented as an inertia, the behavior of which is (7) p ω described in Equation (9). p Where τ is the time constant in seconds. dω p torq = j* (9) dt Low-pass filteras RC components In essence, this equation defines how much torque Both the differential equation and Laplace transfer will be required as the load is accelerated (acceleration function approaches for describing the low-pass filter is calculated as the derivative of the load angular behavior are relatively straightforward and commonly velocity). Equation (9) depicts load torque as a function of (shaft) velocityd(ω). The load torque 1For additional methods to implement the low-pass filter, as well as expanded coverage on the derivations shown here, please refer to can also be calculated as a function of (shaft) Chapter 13 of [1]. θ position ( ). 8 System Modeling: An Introduction This formulation is given in Equation (10). representing it as a resistor in series with an inductor. This includes the electrical dynamics of the winding – d2θ torq = j* (10) i.e. the winding resistance and inductance, as shown in dt2 Figure 6. This second formulation is used in the Servo subsystem illustrated in Figure 2. Actuator (Motor) The motor representation must be carefully considered. As a primary focus of the design, the motor in large part determines the overall value of the system model developed in the early design phases. The system model is valuable only to the extent that it can produce useful information that can further guide the system design process. Useful information can only be Figure 6 - Motoras resistive/inductive load produced if the motor model is reasonably accurate. Although this is an improvement on the previous motor model, the dynamics of the motor are still not Motoras resistive load represented. For example, there is no accounting for So how might the motor be represented? One approach back-EMF, so it will appear that there is more voltage would be to model it as a pure resistive load, as shown available to drive the motor than there will be in the in Figure 5. If the resistance value is chosen to match actual system (since back-EMF will be subtracted from the winding losses in the motor, then some static or the drive voltage in a real system). Areal motor will steady-state analyses may be performed. This type of initially draw a good deal of current from the power motor model may prove useful for sizing the amplifier as it tries to overcome the motor shaft inertia, power amplifier. but will then draw less current as the shaft picks up speed. The resistor/inductor model cannot account for this effect because the mechanical inertia of the motor and load are not represented. This model would not provide any real dynamic information – and it is exactly this dynamic information that is needed to verify the overall system topology. Figure 5 - Motoras resistive load Dynamic motorequations The drawback to this model, of course, is that it doesn’t Asuperior approach to modeling the motor is to obtain take any motor dynamics into account. In addition, this the fundamental equations which govern motor simplistic approach doesn’t even completely model the behavior (widely available from numerous sources), electrical portion of the motor, which includes winding and implement these equations in the model. inductance as well as winding resistance. Using this approach, the dynamic behavior on the electrical side of a DC motor can be described with Motoras resistive/inductive load Equation (11). The resistive load motor model can be improved by System Modeling: An Introduction 9