IEEE ©2001 IEEE. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works must be obtained from the IEEE.

Return to Table of Contents

Developing Educational Software for Mechatronics Simulation

Takashi Kenjo, Member, IEEE, Tatsuya Kikuchi, Member, IEEE, and Masatoshi Kubo

Abstract - The need for a mechatronics simulation software is pointed out with special reference to engineering education, after which we present a convenient approach. Our basic algorithm computes the electro-mechanical behavior of electric motors combined with mechanical components like inertial/frictional/torsional loads, including such transmission elements as gears or lead screw/nuts. The simplicity and utility of our mathematical treatment are discussed in terms of its educational merits. The major theory is developed using a brush-type permanent DC motor, but brushless DC and stepping motors are discussed as well. We present three sample software. One is a simple program which demonstrates the computational principles for the electric current in an LRC circuit or the velocity of a suspended mass. The other two simulate the dynamic behavior of a slide table powered by a DC motor via gears and a lead screw. One is written in Microsoft Visual Basic code reflecting the physical meaning of mechanical components and the other is a Visual C++ version using the class library concept. The merits and demerits of these two approaches are discussed from the vantage point of undergraduate education and the retraining of technical instructors and working engineers.

I. Introduction

Today an astronomical number of small electric motors are being produced for use in many devices including automobiles, computer peripherals, household appliances, business machines, industrial robots, and medical instruments. These motors are electrically driven and, in many cases, electronically controlled. We have stressed the importance of efficient training of this subject and designed a teaching aid which we call MECHATRO LAB [1]. Using this machine, the instructor can demonstrate various types of motors and their control configurations, as a single motor or in combinations of two machines.

Meanwhile, in actual applications, the motor shaft carries a gearbox or a pulley; some motors have a hollow rotor construction to change its rotation to linear motion to drive the load, which often has a complex construction.

In the conventional curriculum of Japanese universities, perhaps in other countries as well, mechanical engineering students are only required to take a general electrical engineering course covering such topics as power transmission and alternating current theory. Meanwhile, electronic/electric engineering students need only enroll in an overview course on mechanical engineering. Clearly, this is not enough in terms of mechatronics or electro-mechanical education.

There are two approaches to the study of electromechanical systems. One is based on the analogy that holds between mechanical systems and electrical circuits (for instance between mass/inertia and inductance, or elasticity and capacitance); the other is the use of differential equations to compute physical quantities like position, angle, speed, and force.

Electrical engineering students are required to study the theory based on the analogy between electric circuits and dynamic systems, which provides a powerful analytical tool as seen in the work by Haskew and Schinstock [2]. To non-electrical engineering majors, however, viewing mechanical systems as an electrical circuit, sometimes with a voltage-supply and at others with a current-source, often causes confusion. Also, analogy is a convenient method for a system that can be represented as a combination of mass-spring-damper, but it is not almighty in practice.

Developing a simulation software that incorporates both methods - electromechanical analogy and numerical computation of differential equations - should provide a highly versatile and practical tool, being free from the limitations of either method used alone. Moreover, simulation programs may provide a better path into the electromechanical field for non-electrical students in particular, since almost all engineering students today receive some computer training and have access to PCs. Such simulation techniques will naturally be much more effective if it takes advantage of the PC's visual environment.

In order to create numerical computation software on a PC, one must be capable of synthesizing knowledge from various scientific and engineering disciplines. Ideally, those who have studied mathematics, physics, electronic circuitry, mechanisms and computer programming should be able to create their own computation software for their design purposes. This is unrealistic, at least in Japan, for several reasons. First, most electronic and mechanical engineering students are unable to acquire a sufficient proficiency in all these fields during their four-year undergraduate education; and many not even with the added two-three years of a Master's program. Furthermore, very few courses are offered in most universities that deal with the subject of synthesizing different areas of technology to predict the overall behavior of a mechatronics system. This situation can be considerably improved if there existed an educational simulation software, either as a "template" for program development or for effective instruction on the subject of mechatronics itself.

Consider now young engineers at corporate R&D labs, mostly engineering graduates including Master degree holders. They usually cannot afford the time to study such techniques on an individual basis. Meanwhile, they are given a relatively short time frame to design and develop products. Conventional design based on trial-and-error strategies is time-consuming, costly and inadequate for this task. Here too simulation techniques can prove to be powerful tools. Yet, to the authors' knowledge there are no effective software packages available.

Having recognized this situation, the authors have made some initial attempts over the past several years to meet our particular instructional needs. The resulting software is also being tested at a corporate R&D site. As its utility has come to be recognized, we have recently moved to a more systematic development of a simulation software for education and training purposes. This is the first report on its basic concepts and algorithm, including trainee reaction and discussions for future development. A few sample source-level programs are also presented.

II. Basic Approach

We shall first discuss whether a commercially-available circuit simulation software can be utilized for mechatronics purposes. This depends partly on the motor type. If the system includes a stepping motor or brushless DC motor, which are usually driven by electronic circuits, the problem lies in simulating the remaining mechanical portions in a manner compatible to the circuitry simulation. If a permanent-magnet DC motor simply driven by a DC voltage or current source is employed, the motor model may be replaced with a simple equivalent circuit, so the problem is whether the mechanical system can be treated by an electrical circuit model or if any additional considerations are needed. We begin our discussion with this problem.

A. Permanent-magnet DC Motor

We consider a permanent magnet DC motor using the model shown in Fig. 1. The idea of an equivalent circuit for the DC motor is discussed in reference [3]; here, we present a more expanded model. The key features here are:
1) Brushes are simulated by two diodes placed in reverse parallel (see Appendix A).
2) Winding inductance LA and resistance RA are represented in a straightforward manner.
3) Friction and hysteresis brake effects are represented by a current source denoted by iF and a special symbol resembling a resistor. We prefer to call this path a 'current sink' because a constant current Io is absorbed independent of the applied voltage. Note, however, that it reverses polarity when the rotational direction reverses (see Appendix B).
4) Eddy-current and viscous losses are represented by RE. In a typical motor, RE is larger than the armature resistance RA by a factor of 10~20. Weissmantel [4] presented many useful equations for computing a permanent-magnet DC motor, but he ignores the effect due to RE . While this is acceptable for  well-designed motors, this term is included in our scheme (see Appendix B).
5) The rotor inertia (rotor's moment of inertia) is represented by a capacitor CM.
6) Torque is given by KTi, where i is the current and KT the torque constant, which is also equal to the back-emf constant KE. The current in each parallel path represents the torque needed (or consumed) in it; for example, KT multiplied by iM (the current absorbed in the capacitor) is the torque used to accelerate the rotor (armature), and KTiF is the torque needed to overcome the mechanical friction and retarding torque caused by magnetic hysteresis in the motor's armature core.
7) The voltage v across each element represents the speed w as expressed by the simple equation:

The equations needed to describe the motor's behavior are as follows:
The electric relationship is governed by

V = input voltage
vB = brush-voltage drop
RA = winding resistance
LA = winding inductance, which is here assumed to be independent of rotor's angular position
iA = armature current which consists of iM, iE and iF:

e = back-emf, which is proportional to the motor's angular speed wM as expressed by

The torque TM generated by the motor is computed from the armature current by

The motor's dynamic equation is given by

Here, the three terms on the left-hand side correspond to the three terms on the right-hand side of (3) as follows:
1) Torque to accelerate the rotor:

where JM is the rotor's moment of inertia.
2) Retarding torque due to mechanical/electric viscosity:

Since the braking torque caused by eddy current is proportional to the speed, we let the viscous damping coefficient DM represent both mechanical and electric characteristics in this manner.
3) Friction torque as a function of wM

Instead of non-continuous characteristics we use for the frictional torque a monotonously-increasing continuous function given by

By letting wMo take on very small values, iF assumes step-like characteristics.
By substituting (4), (5) and (9) into (6), we get the following motor equation:

Meanwhile, the following relation applies to the circuit diagram of Fig.1(b):

By comparing these two equations, we can find expressions for the effective resistance RE and effective capacitance CM:

Thus, all components including mechanical elements are represented by electric terms. Hence, it is basically possible to analyze a DC motor's dynamic behavior using a circuit simulator. There are, however, at least two problems not normally encountered with electric circuits. One is the treatment for iF : it is necessary to use a rather complicated function in the simulation code to represent this term. The other is the cogging torque. As we have discussed elsewhere [5], cogging is not a simple phenomenon, having at least two components: one is related to the teeth-magnet interaction, which is deeply related to the magnetic circuit problem, and the other component arises from current commutation taking place in the brush-commutator mechanism. It is difficult to give an accurate description of cogging torque using either conventional circuit simulation software or our present method. A relatively simple treatment, possible with conventional simulator, is to treat KE as follows:

where KEO is the center value and KE the ripple amplitude of the back-emf coefficient.
The angular position M is the integration of motor speed:

z = typically twice the number of armature teeth [5]
= phase angle which depends on motor construction
This means that KE is actually not a constant but fluctuates as a function of the rotor's position.



Fig. 1.  (a) A DC motor and (b) Its equivalent-circuit model.

B. Direct Coupling with Inertial Load

We now discuss the case in which a load is directly coupled to the motor shaft, as modeled in Fig. 2(b). The torsion effect between the rotor and the load disk is represented by a coil, or inductance LS, and the mechanical loss occurring in the load disk is represented by another current sink  iF2 (= ±IoL) and another parallel resistor RE2.

Such systems are known to generate high-frequency mechanical oscillations due to the interaction between the torsion torque and inertia in both rotor and load. This oscillation is damped or suppressed by a damping mechanism, which dissipates kinetic energy in the form of heat; this can also be represented by a resistor RR and a current sink iFR in parallel with LS , as shown in Fig. 2(b). The resistor represents viscous damping and the current sink the frictional cause, whose mathematical treatment is given below.



Fig. 2.  (a) A DC motor with a directly coupled inertial load, and (b) Equivalent circuit expression.

C. Coupling via Gears

We next look at the case in which a load is coupled via a gearbox. Additional factors that must be taken into account are:
1) Speed/torque conversion effect. This can be represented by a transformer symbol, as shown in Fig. 3.
2) Transmission loss due to friction at the contacting surfaces.
3) Damper effect. Since collision and reflection between rack and pinion occurs in the simulation, this can disturb computation. It is necessary to incorporate some effects to absorb the kinetic energy and dampen this type of oscillation.

The mathematical treatment is as follows. First, the dynamic equations for the motor and load are written as:

Similar to the friction inside the motor, the load friction, which corresponds to iF2 in Figs. 2 and 3, is expressed using appropriate small values of wLo as follows:

Here, we interpret that TS is the torque used to drive the gear as seen from the motor, but the torque which is transmitted by the gear to drive the load is TS . If the gear's step-down ratio is q (<1), the torque ideally increases by the factor 1/q, but it is adjusted by the factor g(<1). The transmission efficiency  g is related to gear construction, the surface's materials, finish and lubrication conditions, and also differs for forward and backward conditions. As shown in Fig. 4(a), if the pinion is driving the rack, which is the normal condition, the efficiency is forward, but if the rack is driving the pinion, the efficiency is backward. As is well known, the forward efficiency is higher than the backward one.

Coefficients  and  depend on the motor's rotational direction and the contact conditions between the gear teeth. When the motor is driving the load, the forward efficiency gF is used, but when the load is driving the motor, as when the motor is in generator mode, the backward efficiency gB is used. This situation is rather complex and can be described as follows:


(This statement is not always necessary and can often be simplified depending on the model.)

It is known that for a worm gear or a lead screw, gF and gB are given by the following equations.
1) Forward.  When the worm (lead) is driving the rack (nut), the efficiency is:

Here, u is the coefficient of friction at the contacting surfaces, which is said to normally range from 0.05 to 0.15, and  is the lead, as explained in Fig. 5.
2) Backward.  When the rack (nut) is driving back the worm (lead screw), the efficiency is:

In normal cases, this is less than unity and in this case we treat it as 0.

Now, the major component of TS , which we note by TSA, is the torque generated by the torsion in the pinion and rack (or worm and rack), but the frictional and viscous torque caused by relative motion between these two parts is added to work as a damper effect. Using relative angle () and relative speed (qwM - wL), we put these as follows:


TSA is such as illustrated in Fig.4(b). When the backlash is very small, the model is effectively the same as in Fig. 2. The second and third terms in (24b) respectively correspond to the resistor and current sink in parallel with the spring symbol in  Fig.2, and the same functions are considered to be incorporated more effectively in the gears represented by transformer symbols in  Fig.3.  For  FR and DR , we select appropriate values as will be discussed in Section IV, and  we set a small value for wRo .

Fig. 3.  A DC motor carrying a load via a gearbox and lead screw.



Fig. 4.  (a) Rack and pinion coupling and (b) Torque vs. relative angle. h  is the backlash size, and the slope (kS) of the straight portions is the stiffness.

Fig. 5.  A worm gear model and definition of lead.

III. Computational Method

There are several numerical methods for solving ordinary differential equations. The method we employ in the sample program lacks mathematical rigor but is sufficiently accurate for most practical situations. This method is outlined below.

A. LRC Circuit and Mechanically Damped Oscillation

The most basic dynamic equation is

When this is applied to the mechanical spring model of  Fig. 6(a), where a body is suspended via a spring in a viscous liquid, the parameters have the following meanings:
v = body velocity
m = body mass
D = viscous coefficient
k = spring stiffness
f = gravitational force(mG) minus floating force, where G is the acceleration of gravity

The electric circuit equation for the LRC circuit in Fig. 7, which corresponds to this model, is

Most conventional numerical methods for such equations divide it into two first-order equations. Instead of dividing, we write as follows:

From this, we obtain the numerical computation formula:

Certain special cases point to some interesting features. When L is negligible, we let L = 0 to obtain:

This is the same as the normal Euler's forward method.

When the capacitance is infinite or 1/C=0 in (29), we obtain

which is the Euler backward solution for the LR circuit. Thus, (29) contains both the forward and backward methods.
Another feature surfaces when R = 0. The equation for this case is


It is known that the variable i or v displays an oscillation with a constant amplitude and constant frequency  .
If Euler's forward method is applied for this case, the computed oscillation will increase in amplitude with time; if the normal backward method is applied, the amplitude will be damped with time. The smaller step-size t is, the more gradual the increase or decrease rate.

When R = 0, equation (29) becomes:

In this method, the oscillation amplitude neither increases or decreases, i.e., stays constant as the analytic solution.

Our basic algorithm is based on the above theory, although we incorporated minor modifications when applying to our educational software. In Appendix C, we briefly discuss the numerical accuracy of (29).



Fig. 6.  (a) Mechanical spring model and (b) Its equivalent circuit expression.

Fig. 7.  LRC circuit.

B. Relation to the DC Motor's Equivalent Circuit

Here we add a supplementary explanation to the relationship between the DC motor's equivalent circuit, (26) and (27) and their circuits in Figs. 6(b) and 7. The pendulum can be represented by the parallel circuit shown in Fig.6(b). We assume that the force f applied to the pendulum is divided into three components and flow in the branches for the equivalent capacitor, resistor and inductor.

From the analogy to an electric circuit, we derive the following three relationships:

By substituting these into (35), we obtain (26). Here, note that the physical quantity across each element in Fig. 6(b) has the dimension of velocity but in the DC motor circuits (Figs. 1 and 2) it is voltage and corresponds to speed. In the DC motor circuit, the current is proportional to the torque. This fits with the idea that force is flowing in the branches in Fig. 6(b). Thus, the DC motor circuits of Fig. 1 through 3 can be regarded as a combination of a series electrical circuit of Fig. 7 and an equivalent parallel circuit for a mechanical system as in Fig.6(b). It is easy to see that motor's armature inductance LA and resistance RA can be represented respectively by the inductance L and resistance R in Fig. 7. Furthermore, the rotor inertia can be represented by a capacitance C. Note that in Fig. 6(b), the mass m is also represented by a capacitor. Just as the resistor written as 1/D is placed in parallel with the capacitor, resistor RE and a current sink element are placed in parallel with the capacitor in the DC motor circuit (see Fig. 1).

When the elastic element is fixed at one end, its equivalent element is in parallel with the capacitance in Fig. 6(b). On the other hand, if it exists between two inertial elements, its representation LS appears between the corresponding capacitors, as in Fig. 2.

As stated earlier, these analogies may at first confuse non-electrical majors. But once the basic concept is understood, they can prove highly useful when analyzing electro-mechanical systems.

C. Application to a Plain DC Motor

We now apply the above method to compute the motor's motional behavior. Equation (2) is rewritten as

Referring to the form of (29), the numerical equation for the n-th current In becomes

Note that wMn corresponds to the current summation term in (29).

For VBn, we derive from (A1)

It is often possible to ignore the motor's armature inductance LA because the delay of the current build-up due to this effect is very short as compared with the motional effect due to the rotor's inertia. Brush drop vB is as negligibly low as 0.1V or so in a small motor which uses metalized carbon brushes. In this case, (40) is simplified to:

When the power supply or the driving circuit has a current limiter, this function can be described as follows:

where ISETn is a set value.
The dynamic equation of (6) is rewritten as

The numerical value for IFn is derived from (10) as

From this, the numerical computation equation for wM is

where t is the step-size of time.
The rotor's angular position is computed simply as:

We then return to (39) to repeat the computation.

For a stepping motor, as well as a brushless DC motor, for which current must be computed for each phase winding, the back-emf in each phase is a function of angular position and the overall computation is rather complicated. See Appendices D and E for these motors.

IV. Sample Training Programs in VB and VC++

A. Three-Inertia Model with Backlash

It is not a difficult task to write a program for a system having more mechanical elements based on the above idea, as long as the number of inertial loads is kept relatively low.  We selected the slide table shown in Fig. 8(a) for producing  sample software. Assembling this machine was a project for one of the overseas instructors' refresher courses in our university. We decided to present to the trainees its simulation software.

Since trainees enrolled in our overseas instructorsí retraining course were assembling, the slide table is driven via a lead screw by a conventional brush DC motor with gearbox. The equivalent circuit representation for this model is shown in Fig. 8(b).

The key components and their parameters are presented below.
1) Motor
The drive motor is a brush-type DC motor with a gearbox with a reduction rate of 20. The estimated parameters are:

  • RA = 13 ohms
  • KE = KT = 0.08V s/rad or N m/A
  • VB = 0.2 volt
  • iB = 0.1 A
  • RE = 200 ohms
  • LA = 10 mH
  • JM = 0.0000018 kg m2

  • On the back-side shaft, a friction element is mounted to damp vibrations occurring inside the gearbox. With the friction element, the current sink is Io = 0.4 A. Without it, Io is reduced to 0.1 A.
    2) Lead screw
    The steel lead screw is driven by the motor at 1/20 of the motor speed. Although the gearbox has three stages, we assumed for our simulation the simplest model consisting of a pair of pinion and rack. Hence, our model is a three-inertia one consisting of motor, lead screw and table. Parameters are:
  • Size and moment of inertia: 0.3 m in length with 0.012 m diameter, the moment of inertia is estimated to be about JL = 0.0000045 kg m2
  • Lead pitch = 0.002 m
  • Motor-to-screw backlash = about 1.5 degree (about 0.027 radian)

  • 3) Table
    A workpiece rests on the table, which is supported by two rods and driven by a nut mechanism coupled with a lead screw. The combined weight of workpiece and table multiplied by the rod's friction coefficient is assumed to work as the frictional load.  There is a considerable backlash (about 0.3 mm). The effects that backlash and friction have on the overshoot can be demonstrated in this simulation.
    4) Viscous damping coefficients
    Although in the theory presented in Sections II and III, the viscous damping coefficients were important factors for computing an object's speed, they are rather small in reality and do not significantly affect computation results. In the sample programs below, we set as default values:
  • For computation of lead screw speed    DL = 0.0001 N m s/rad
  • For the computation of table speed   Dw = 0.001 Ns/m

  • 5) Friction in gearbox
    As we saw in Section II, the friction inside the motor is represented by a current sink; in the Microsoft Visual BASIC (VB) sample program below, its default value is set at 0.2 A. Friction torque is this multiplied by the back-emf constant. When KT is at the default value (0.1 Nm/A), the friction is 0.02 Nm. We set the friction for the bearings supporting the lead screw, represented by iFL in the equivalent circuit in Fig. 8(b), to 0.01 Nm.
    6) Parameters for viscous and friction damping due to relative motion
    These parameters for the gearbox affect oscillatory behavior when motion is just beginning. The following default values are set:
    DR = 0.001 Nms/rad,  FR= 0.001 Nm
    The sample program is able to demonstrate the influence of FR, as well.
    Meanwhile, the corresponding parameters for the lead screw and nut have very little effect because the nut is not allowed backward motion (see Section II on the criteria for  and  using  (20a) through (20d)). In any case, the following default values have been set:   DR2 = 0.001 Ns/m,  FR2 = 0.001 N
    7) Stiffness
    The stiffness between motor shaft and lead screw (in the gearbox) and that between lead screw and nut are important parameters. In the sample programs, we set them as follows:
  • For the gearbox:  KS = 2000 Nm/rad: Since accuracy of this value is not so important in this case, it is roughly estimated from the materials and constructions.
  • For the lead screw and nut:  KS2  = 1000000 N/m. Although a larger value is preferable, if this is too large, the resonant frequency becomes high, which would require a very small step-size.

  • (a)


    Fig. 8.  (a) Photograph of sliding table and (b) Its equivalent circuit representation.

    B. Expectations on the VB Version as a Teaching Material

    The trainees were expected to learn some analytical skills in mechanics and electronics. We felt, however, that a regular classroom lecture on theory would not interest them so much, and thought a simulation could serve as an effective learning tool in understanding the function of the components comprising the table-motor system. Our sample, shown in Fig. 9,  was as follows:
    The table is first set at the starting position and the motor is run at a supply voltage of 24V.
    When the table touches the limit switch placed at an appropriate position, the motor voltage turns to 0, and the table comes to a stop after a short time lag. The overshoot is observed. The parameters are then changed and the overshoot is checked again. The purpose of this exercise is to determine which factors are important (before any complicated feedback control is introduced).

    We wrote two program versions: one in VB and the other in Microsoft Visual C++ (VC++). The VB codes (sample program #2) were written following the flow of logic outlined above and referring to the equivalent circuit of Fig.8(b) so that students and instructors can actually "read" the physical or circuitry concepts within the program lists. Cogging is not dealt with in these samples.

    In the VB version, the following parameters can be set in the text boxes on the form and their default values near the quantities presented above.
    1) Common

  • Step-size t
  • Display time
  • Limit-switch position

  • 2) Power Supply
  • Applied voltage V
  • Maximum current IMAX

  • 3) Motor
  • Armature resistance RA
  • Effective resistance RE
  • Current sink   Io
  • Back-emf constant (=Torque constant) KE = KT
  • Inductance LA
  • Moment of inertia JM
  • Brush drop   VB

  • 4) Gear
  • Step-down ratio q
  • Transmission efficiency g (Default value is 0.8)
  • Motor-to-screw backlash h
  • Stiffness kS
  • Relative friction FR
  • Lead screw's moment of inertia JL

  • 5) Lead/Table
  • Friction coefficient for the rods  uw (Default value 0.1)
  • Friction coefficient for the lead screw  u (Default value is 0.05)
  • Table and work mass  m  (Default value is 0.5 kg)
  • Backlash h2
  • Stiffness   kS2

  • Fig. 9.  Window of VB version showing simulation results.

     C. Class Library Using VC++

    We felt the need to develop a more powerful tool for mechatronics computation. One solution is to use C++ and prepare a class library for mechatronics components. Rather than writing a program for each individual system (as in the above samples), it becomes possible to construct various systems from this library. These systems can then be simulated by inputting the appropriate data. We thus took the alternative approach of developing a C++ program based on the class-library concept (sample program #3).

    We believe that our basic algorithm for computing differential equations is suited to building an object-oriented software, where mathematical or algorithmic expressions can be manipulated as though they were "objects" (i.e., physical components). However, the object-oriented class library must be designed very carefully when authoring such software; that is, families and classes must be set up carefully. After analyzing the system of Fig. 8 and referring to some other systems, we decided temporarily on a basic structure for the class library (see Fig. 10). The classes we set are:
    1) Parts class (CParts). This is a superclass which has Drive class (CDriver) and Transfer class (CTransfer) as its subclasses. CDriver is defined as the class for something generating speed and position. CTransfer is defined as the class for something generating torque.
    2) Motor class (CMotor). This is under CDriver and only the permanent magnet brush-type motor is considered for now. Power-supply parameters are included in this. If we expand to include AC motors, it will be necessary to treat the power supply as a separate class.
    3) Gear class (CGear). This lies under CTransfer and includes step-down and step-up mechanisms together with a backlash. Under this class is Lead nut class (CLeadNut).
    4) Load class (CLoad). This is, under CDriver, for components having mass or inertia.
    5) Terminal class (CTerminal). This lies under CLoad. CTerminal indicates what comes after the last load; there may be nothing, it may be a spring with one end fixed to a stationary base or wall, or it could be assumed as a constant gravitational weight or torque.
    (Here class corresponds to the conventional concept of variable type.)
    The computation arrangement of objects within classes is shown in Fig. 10.  Each class contains objects (conventional variables), and is designed so that an object in a class can be connected to another object in a different class. Each object remembers its torque, speed and position and transmits them to the objects connected at left and right. The motor is at the far left, and is coupled with the first load via a gear. The first load is coupled with a second load (slide table in our sample), and between them is a gear (lead screw/nut in sample). We set down the general rule that a load is coupled with two transmission elements on each side. These elements usually consist of gears, but on the far right comes a terminal. The terminal for our slide table is an empty object.



    Fig. 10.  (a) Computation concept for the C++ version for the model shown in (b). Here, ALPHA and ALPHA2 correspond to coefficient   in (17) and the similar coefficient for the coupling between the lead screw and nut, respectively. VISC_FRICT 1 denotes the function of the second and third terms of the right-hand side of (24b). RATIO is the step-down ratio of the gearbox, and PITCH  the lead screw pitch per rotation.WM, WL and VW denote motor speed, lead screw speed and table speed, respectively. LANGL denotes the motor's angular postion, LANGL the lead screw angular postion, and WPOSITION the table position, respectively.

    D. Reaction of Trainees

    In our refresher course for technical instructors (five, from Malaysia, Mexico, Panama, Saudi Arabia and Tunisia), we first presented a BASIC simulation (sample program #1) which computes the current flowing in an LRC circuit, or the speed of a mass suspended in a viscous liquid by a spring. Its purpose was to review a simple, but important physical phenomenon common to electricity and dynamics, and to learn the computational principles of our algorithm. The simulation here is simply based on the analogy that holds between two separate systems, one mechanical and one electrical, and we are not yet considering an electromechanical system at this stage.  We found this simple example to be a necessary step before moving on to actual electromechanical systems. As expected, the theoretical explanation given in Sections II and III seemed very dry to the trainees, even though they were technical instructors.

    After this introductory example, we presented the two versions for the slide table. Fig. 9 shows computed samples for the VB version, and Fig. 11 a sample of the VC++ version. Both versions of visual software were very effective. The source files are given in Programs 2 and 3.

    We present the reactions of three trainees. The first trainee, who showed a great interest in all technical subjects, quickly understood the initial BASIC program for the LRC circuit, and remarked "We heard (in our C language course) that C is superior to BASIC, but there are too many things that must be learned before one can actually write programs using C." He asked a good question about the function of a brake, since he was taking one back to his country to install it in his machine. He planned to mount it onto a load that was geared down from the motor shaft. By slightly altering the sample software, we were able to demonstrate in class that a brake is more effective when mounted on the motor shaft than on the load side. We knew from experience that while feedback control is a popular electro-mechanical technique, it is not always an appropriate subject at the introductory level, and that examples showing the effects of fundamental components (such as brakes, reduction rate, various motor parameters) are much more important.

    Another trainee, who also showed interest in the BASIC program of the LRC circuit, was interested to see the source program for the VC++ version, but became discouraged when actually presented with it. The trainees were also enrolled in a course on C language, but the VC++ source program appeared to them as an entirely different language.

    The third trainee was very interested in seeing how changing parameters would affect the computational results. In her case, understanding the source code was not a high priority.

    Fig. 11. Windows of the C++ version.

    V. Discussion

    We discuss the utility and problems of our mechatronics simulation technique in the area of education, based on the authors' own experiences and the responses obtained from students, instructors and working R&D engineers.

    A. Algorithm

    First, we shall comment on our basic computation method. As we were aware of the accuracy limitation of the principle presented before, we also used a more accurate method in our research, but there were no significant differences as long as computation results did not diverge by setting a too large step-size t. For accurate computation of the influence of resonance, t must be set at a value smaller than 1/100 of the cycle of the highest natural frequency, but five times this value is sufficient for obtaining an overall profile. However, a step-size larger than this value may make the computation diverge. In the sample program, the minimum cycle-period of natural angular frequency is around 2ms. Hence, t required for accurate computation is 0.02ms, but for the profile computation, it can be 0.1ms.

    B. Note on Viscosity and KEKT/RE

    We shall comment on one matter about viscosity. This is about the viscosity which is inherently involved in the motor itself.  If LA and vB are negligible, we get  from (2) for iA:

    Therefore, (5) becomes as

    By substituting this into (17) we obtain

     It is seen in this expression that the armature resistance RA works effectively as viscosity in addition to DM, the component due to mechanical viscosity and magnetic hysteresis in the armature core. It is seen in (13) that DM is expressed as KEKT/RE.  Since in most motors RE is 10-20 times larger than RA, the inherent or effective viscosity due to the winding resistance is much greater than the mechanical and magnetic effect. However, when the motor is controlled in the current mode or the current limiter is working, the viscosity due to RA vanishes. For this reason, the undesirable oscillation that results from the interaction between the motor's inertia and shaft elasticity damps quickly in the voltage control mode, while it may not damp in the current controlled mode. In our slide-table example, this is evident if the maximum current is set, e.g,. at around 0.5A and the screw's moment of inertia is set at a value larger than the default value. It will be seen that the amplitude of this oscillation increases with the backlash in the gearbox.

    Although this damping mechanism is not apparent in (42), it is included in it implicitly, and its effect appears in the computation results. This may be a problem beyond the undergraduate level. However, the instructor shall be aware of this important technical matter and ready to answer questions if a student happens to notice this oscillation behavior.

    C. Students

    Undergraduates: Students in electrical/electronic engineering and mechanical engineering are the ones who have the opportunity to study mechatronics and then work in this area after they graduate. In Japan, most electrical/electronics students are required to take a course in general mechanical engineering, while mechanical engineering students must, in general, take a few subjects in electrical engineering, such as power generation, transmission or alternating current theory. Yet, this usually does not provide them with enough background knowledge to go on to further studies in mechatronics on their own. In particular, many students find it difficult to visualize how the electrical circuitry and mechanical components work together as a single system. It is in this area that we saw the need for an effective teaching aid. As a start, we chose the slide table simulation, thinking that it would serve as an effective visual demonstration which would arouse the interests of students studying mechatronics.

    What is the role of commercial software, such as PSpice or Matlab, in the context of mechatronics education? These are used by many researchers who take advantage of their advanced functions to conduct research. If they are to be used in undergraduate instruction, an introductory course should be provided where students can become proficient with their use. Purchasing such commercial software for undergraduate purposes can be very costly. Another problem with these simulation software is that many of the algorithms are treated as black boxes, making it difficult for instructors to give a clear explanation to their students. Thus, in undergraduate instruction, the authors believe that it is better to use an algorithm that can be seen and understood by students, and for which source code can be accessed and modified by instructors. Such an educational tool would effectively complement classroom lectures and laboratory workshops.

    Before establishing our simulation method in this fashion, we presented an early prototype to ten third-year students. In this class we explained the computation principle using the Euler forward method and gave them an assignment to simulate the square-wave oscillation produced in an astable multivibrator, which is composed of two transistors. DOS BASIC (BASIC) was used as the PC language.  This was a difficult assignment for them, and we felt that even though the computer language was the easiest available, dealing with several aspects (PC language, mathematical principle and electronic circuit) at the same time is very inefficient. Well-organized demonstrations are needed as a tool for undergraduates.

    Graduates: Our basic method combined with instructive sample programs should provide the graduate student in mechatronics with a solid background in simulation techniques, thus enabling him/her to move on to further advanced subjects and tools. For example, a Master's candidate at our university acquired a good understanding of simulation using our program, which he applied toward his thesis project. Knowledge of our software also helped him to effectively utilize Matlab to simulate more complicated systems. For relatively simple systems, i.e., those with up to three or four inertial elements, computational results agree well between our program and Matlab. (For a relatively large system of five inertial elements, for example, Matlab was often easier to use.) We found that special cases, such as the inclusion of cogging torque, could be incorporated into our program much easier because we were already familiar with its limits and possibilities.

    D. Instructors

    As stated before, we asked overseas technical instructors to give their reactions to demonstrations of the VB and VC++ version simulations of the slide table. The visual presentation was received very favorably. We also found that instructors generally preferred a sample program from which computational principles can be "read" and understood (in this case, the VB version), instead of one which merely provided a convenient black box tool. Some of them expressed interest in our simple computational algorithm for differential equations.

    Questionnaire results on familiar computer languages showed that most knew BASIC, while some were also familiar with C, Pascal or assembly. Since FORTRAN and BASIC were the major computer languages in the 1980s, most instructors who are now over the age of thirty received their computer training in these languages. Thus, this group of instructors responded more favorably to VB than VC++. Not being programming specialists, they were more at ease with the VB simulation.

    For technical instructors, it makes more sense to prepare sample software which can be modified to suit specific instructional situations. From the initial reactions obtained from our overseas instructors, however, it would seem that a simpler example may have worked better in inciting their motivation. For example, the following items may be mentioned:

  • Influence of current limiter (maximum current setting) on the overall function
  • Influence of  permanent magnet's strength on the overall performance  by increasing or decreasing KE = KT
  • Influence of inertia or mass of the three major components (motor, lead screw, and table) on the table speed
  • Influence of backlash size on positioning accuracy
  • Influence of the friction coefficient between the nut and lead screw on positioning accuracy
  • Step-size (t ) (see V. Discussion in Section A above.)
  • E. R&D Engineers

    Corporate R&D sections demand a simulation tool that can be used for practical design purposes. There are two types of design engineers working in the mechatronics field: the first views simulation software as a purely utilitarian tool, regarding it as a black box but demanding from it a high functionality; the second type is not satisfied until he or she can comprehend the "logic" of the simulation process. For the latter engineers, simulation software developed originally as instructional aids may prove useful at a practical as well as educational level.  The author's direct contact with some R&D engineers has shown that they see great value in Visual Basic as a tool for developing mechatronics software. The developed simulator, when combined with an interface to incorporate experimental data/design parameters, can be a highly effective design tool.

    Most working engineers are of the first type, more interested in tools that can be put to immediate practical use in their daily tasks; they normally do not have the luxury of expanding their knowledge outside their specialized fields. Thus, it would be unrealistic to expect mechanical engineers to spend much time studying electricity and electronics from their theoretical foundations. What is important is to provide an environment that would allow engineers to obtain relevant knowledge rather quickly through practical exercises, and for this, appropriate tools are needed. We believe that the development of a VC++ based simulation program, the initial form of which we have proposed in this paper, could provide one solution in this respect. A truly practical VC++ mechatronics simulation software will be realized only after further efforts are spent in a thorough component analysis, their integration into a coherent system, and actual program development.

    VI. Conclusions

    Noting the general need for mechatronics simulation software, we examined from various angles what this would entail in terms of the needs of students, educators, and R&D engineers, and presented an idea based on a fairly simple algorithm. The basic mathematical concept is to carry out direct numerical computation of electric and dynamic equations in a "half-forward, half-backward" method. In this method, the computational statements reflect physical meanings and so has a higher instructional value.

    We wrote a sample program using VB with plain animation, and another version in VC++ combining sophisticated three-dimensional (3-D) animation; the latter represents an initial step towards the object-oriented approach.

    The simulation programs were demonstrated to a class of overseas technical instructors, who showed a high enthusiasm toward their visual presentation. As educators themselves, they generally saw value in open software whose source codes can be directly accessed, while those in their thirties showed a higher interest in the VB version also for its familiarity and accessibility. Even so, the "virtual reality" effect produced by the 3-D animation in the VC++ version seemed to them a highly attractive feature.

    From the standpoint of future expandability, the authors feel that a program based on a C++ class-library is preferable; the sample program given here thus represents an initial attempt and we discussed issues related to its further development. Indeed, several problems must be addressed before a robust versatile package can be fully developed along this line.

    The general approach presented here should help students and educators alike in deepening their understanding of electro-mechanical science, as well as providing a practical design-and-analysis tool in the industrial R&D sector.

    Appendix A
    Mathematical Model for Brush Drop and Friction

    Fig. 12 shows the experimental results of brush-drop for a carbon-brush motor when it was run in both motoring and generating regions. This resembles the characteristics of two diodes placed in reverse parallel, and an approximation curve for the voltage vs. current relationship is given by

    with an appropriate iB (0.5A in this case) and a saturation value VB (1.5V here).  From various measurements, brush drop can also be approximated by an exponential curve, but we use the above approximation for its simplicity in algebraic treatment.

    Fig. 12.  Measurement of brush drop and approximation curve. 

    Appendix B
    Current Sink and RE

    Fig. 13 is a typical measurement of consumed current when a hysteresis brake is coupled to the shaft. The current is expressed by straight lines as a function of speed. The intercept of the vertical axis is the current sink Io and the slope is KE/RE. As shown here, the load's stationary characteristics can usually be treated with a current sink and an appropriate value for RE. When the load consists of a fan, the current becomes a nonlinear function of the current, in which case it is still possible to use our algorithm albeit with a small modification (although we omit the details here).

    Fig. 13.  If a hysteresis motor, which is a type of ac motor, is used for the load, the current consumed in the DC motor is expressed by a constant current corresponding to the hysteresis-brake effect, and a speed-dependent portion caused mainly by the eddy-current brake effect. The former is represented by Io and the latter by RE.

    Appendix C
    Computation Accuracy

    Here, we shall discuss the numerical accuracy of (29) briefly. The analytic expression for the periodic accuracy is (m/)sin(/m), where m is the number of divisions of one cycle. This means that this value approaches unity by increasing  m.  When m = 3, it is 3/ = 0.96, indicating that one simulated cycle has an error of 4%.  Fig. 14(a) shows this case. Fig. 14(b) is whent is slightly larger than , and the amplitude is larger than the analytic case by the  factor 1/cos(/m). Fig. 15(a) shows a non-oscillatory case where t is set at 0.628, which corresponds to 10 divisions of a cycle of the oscillatory case. The remaining two are for comparison for damped oscillation; the former is for 20 divisions and the latter 10 divisions. From these samples, we conclude that it is preferable for the step-size t to be smaller than 1/20 of a cycle. As pointed out in Section V, however, a much shorter step-size is required when the system has three bodies as in the sample program of the slide table.

    Fig. 14.  Accuracy of our computation method for non-damped oscillation for large t: (a)t=and (b)t= slightly larger than .

    Fig. 15.  Accuracy of our computation method for: (a)Non-oscillatory damping. (b) and (c) Damped oscillation. 

    Appendix D
    Stepping Motor

    The computation procedure for the current in a stepping motor varies depending on the motor's fundamental type and driving circuit topology. The circuit in Fig. 16(a) is a useful example, used frequently to drive a claw-pole type motor, as shown in Fig. 16(b).  When the transistor is turned off, the winding current will circulate through the external resistor RF and flyback diode, as shown in the Phase 3 portion.
    This motor is composed of two stator stacks, A and B, and each stack has two wires wound together in the so-called bifilar fashion [6]. This design is normally regarded as a two-phase motor, but may be interpreted as a four-phase motor because it possesses four windings.
    If the back-emf waveform is sinusoidal, the currents in phases 1 and 3 in stack A are governed by the following simultaneous equations:

    Similary for phases 2 and 4 in stack B:

  • L1~L4 = self-inductance of each winding, which ideally have the same value.
  • , mutual-inductance of each stack, which are also ideally identical to each other.
  • kA , kB = coupling coefficient(<1). The minus sign is due to the winding connections in each stack. The two wires in each stack are wound together in a ring coil, but they are separated at the terminals to be connected to the lead wires so that each winding generates opposite polarity when it is excited by turning the transistor (Tr1~Tr4) on.
  • R1~R4 = circuit resistance of each phase. When the transistor is ON, this is the winding resistance RW1~RW4, but when the transistor is OFF, the external resistance RF is added.
  • KES = back-emf constant, which is similar to the torque constant in a DC motor. This parameter may be slightly different between stacks A and B or between phases in each stack because of construction tolerance, but it is here assumed that each phase has the same value.
  • p = number of magnetic pole pairs in the cylindrical magnet rotor.
  • wM = motor's angular speed.
  • = angular position.
  • V1~V4 = voltage applied to each phase. This depends on the excitation method. For a typical two-phase-on operation, the following sequence (or its reverse) is repeated :

    TABLE I 
    A Typical Two-phase-on Operation
    Sequence V1 V2 V3

    where Vo is the power supply voltage and VD the flyback diode's forward voltage, which is normally about 0.6V.

    Torque TM is computed from:

    Here TCOG is the cogging torque, which is defined as the fluctuating torque that is generated not by the exciting current but by the interaction between tooth construction and the rotor's magnetization [5]. We assume from some experimental results that it is given by :

    where TG is an appropriate cogging amplitude, which may be negative. This simple expression is explained as follows. When the two stacks are symmetric with respect to the center and have the same conditions except for a quarter-pitch shift, the major cogging component occurs 4p cycles per revolution. This is normally very small, but if there is any imbalance between stacks, a considerable cogging torque of 2p cycles per revolution apperas; this is expressed by the above equation.

    The speed is computed in a manner similar to the case of a DC motor, i.e., from (6). The numerical computation is based on the form of (46).

    A major problem for beginners may be the algorithm for computing current from the basic  (D1) to (D4). There are several practical methods, but the following one follows the concept presented before. By eliminating i3 from (D1) and (D2), we get

    We obtain another equation

    Similar to (29), the numerical solution for i1 and i3 are :

    The function of the flyback diode can be incorporated in such a manner that if the computed value of  i1n or i3n becomes negative, then it is replaced by zero. Similar forms are derived for the currents i2 and i4 in the B stack.

    A source program produced on this concept will be obtained from our WEB site.



    Fig. 16.  (a) A driving circuit for a four-phase stepping motor and (b) A claw-tooth stepping motor. 

    Appendix E 
    Three-phase Brushless DC Motor

    We shall briefly describe the mathematical treatment for a three-phase brushless DC motor. If the motor is designed to generate sinusoidal back-emf, the electric equations for symmetrical three-phase windings (A, B, and C) are:

    where L is the self inductance of each phase, which is now assumed to be independent of angular position, R the winding resistance of each phase, M the mutual inductance between two phases, KEB the back-emf or torque constant similar to a normal DC motor, p the number of pole pairs, and an appropriate phase angle, which is normally zero.
    Here, we consider the fundamental relationship for a three-phase configuration:

    Using this, we can eliminate iB and iC from (E1) and obtain

    Similary, we obtain

    From (E5), we can derive the equations for numerical computation of iA like the case of a stepping motor, and also from (E6) for iB. However, note that for computing iC, we do not need to use a differential equation, but can simply use

    For a motor that has no teeth in the core, i.e., windings are placed in a homogeneous air gap, the torque is computed from

    For a motor whose back-emf wave form is trapezoidal, we add a fifth harmonic (typically 5% of the fundamental) component to the back-emf. So, we need only replace cos(p) with cos(p) - 0.05cos(5p) for phase A, and the like for the other phases, and also to the torque equation. For more accurate calculation, the seventh component is added as well.

    For accurate calculation of cogging torque, we must carry out direct computation of the total torque from magnetic circuit rules considering tooth construction, as shown in an example of a normal DC motor in Reference [5]. One type of brushless DC motor is dealt with in the Japanese paper [7], in which it is seen that though there are considerable phase differences between the magnetic circuit computation and that based on (E8), there are no big differences in the magnitude of total torque ripple as long as the fifth-harmonic  is appropriately included in the back-emf wave forms.

    Similar to a stepping motor, voltages VA , VB , VC are dependent on the drive circuit topology and use of position sensors, and a program must be produced for each scheme. The normal circuit is such as shown in Fig. 17. We will provide the source program from our WEB site for the 120-degree conduction mode, which is the most common method for driving memory disks in a computer.

    Fig. 17.  Bridge circuit for a three-phase brushless DC motor.


    The authors would like to thank R. Takeguchi, who kindly brushed up their English. 


    [1] T. Kikuchi and T. Kenjo, "A Unique Desk-top Electrical Machinery Laboratory for the Mechatronics Age," IEEE Trans. Educ., vol. 40,  no. 4, CD-ROM09, Nov. 1997.

    [2] T. A. Haskew and D. E. Schinstock, "Optimal Design of Electromechanical Actuators for Active Loads," IEEE/ASME Trans. Mechatronics, vol. 3, no. 2, pp. 129-137, June 1998.

    [3] T. Kenjo and S. Nagamori, Permanent-magnet and Brushless DC motors, U.K.: Oxford Univ. Press, 1985.

    [4] H. Weissmantel, "Einige Grundlagen zur Berechnung bei der Anwendung schnell hochlaufender, traegheitsarmer Gleichstromkleinst-motoren mit Glockenlaeufer," Feinwerktechnik & Messtechnik, vol. 84, pp. 165-174, Germany: Carl Hanser Verlag, 1976.

    [5] T. Kikuchi and T. Kenjo, "In-depth Learning of Cogging/Detenting Torque Through Experiments and Simulations," IEEE Trans. Educ., vol. 41, no. 4, CD-ROM12, Nov. 1998.

    [6] T. Kenjo and A. Sugawara, Stepping Motors and their Microprocessor Controls, 2nd ed., U.K.: Oxford Univ. Press, 1993.

    [7] T. Igarashi and T. Kenjo, "A Dynamic Simulation Method for Brushless DC Motor Considering Cogging Mechanism (In Japanese)," Proceedings of JIEE Rotary Machinery Symposium, RM-98-25, June 1998.

    Author Contact Information

    Takashi Kenjo
    Department of Electrical Engineering and Power Electronics
    Polytechnic University of Japan
    4-1-1, Hashimotodai, Sagamihara, Kanagawa 229-1196 JAPAN
    Phone: 81-42-763-9140
    Fax: 81-42-763-9150

    Tatsuya Kikuchi
    Department of Electrical and Electronic Engineering
    Tokyo Institute, Polytechnic University of Japan
    2-32-1, Ogawanishi, Kodaira, Tokyo 187-0035 JAPAN
    Phone: 81-42-346-7139
    Fax: 81-42-344-5609

    Masatoshi Kubo
    Department of Information Technology
    Kanagawa Prefectural Junior College for Industrial Technology of Japan
    2-4-1, Nakao, Asahi, Yokohama, Kanagawa 241-0815 JAPAN
    Phone: 81-45-363-1992
    Fax: 81-45-362-7141

    Author Biographies

    Takashi Kenjo (M'97) was born in Japan on February 2, 1940. He received the Masters Degree in 1964 and the Doctor-of-Engineering Degree in 1971 from Tohoku University, Sendai, Japan. His area of interest is in small precision motors and their controls, and he has written several monographs published by Oxford University Press. He has been with the Polytechnic University of Japan since 1965 and is currently a Professor in the Department of Electrical Engineering and Power Electronics.

    Tatsuya Kikuchi (M'95) received the B.S. (1984) and M.S. degrees (1997) in electronic engineering from the Polytechnic University, Kanagawa, Japan. From 1985 to 1992, he worked as a design engineer of servomotor controls. From 1992 to 1998, he was an Instructor in the Department of Electrical Engineering and Electronics at the Polytechnic Centers in Aichi, then Kanagawa prefectures. Since 1998, he has been working at the Tokyo Institute of the Polytechnic University of Japan. His interests include mechatronics and multimedia computing.

    Masatoshi Kubo received the B.S. degree in mathematics from Yokohama City University, Kanagawa, Japan in 1988. From 1988 to 1995, he was instructor at Fujisawa Vocational Training School in Kanagawa. Since 1995, he has been teaching in the Department of Information Technology at Kanagawa Prefectural Junior College of Industrial Technology. His main interests are computer graphics and programming languages.

    Return to Table of Contents