Contents

Modeling a DC Motor in Stateflow®

This example shows the model of a permanent magnet DC motor. The mode logic and dynamics of the DC motor are both modeled using Stateflow.

The DC motor state chart consists of two superstates: powerOn and powerOff. If the motor is powered on, it can be in one of two substates: up or down, signifying the direction of movement.

Note: This is a simplistic model of a DC motor. You can build more sophisticated DC motor models using Simscape™, which extends Simulink® with tools for modeling and simulating multidomain physical systems, such as those with mechanical, hydraulic, and electrical components.

The dynamics of the motor are defined directly in the state chart using graphical functions and change depending on the state of the motor. For example, when the motor is in the powerOff state, the voltage applied is equal to zero. When the motor is in the powerOn state, the voltage applied is either positive or negative, depending on the direction of the motor.

To review, the differential equations defining a permanent magnet DC motor are as follows:

$$di/dt = -R/L*i(t)-K_b/L*\omega(t)+1/L*v_{app}(t)$$

$$d\omega/dt = -1/J*K_f*\omega(t)+1/J*K_m*i(t)$$

where

$$i = \mbox{current}$$

$$R = \mbox{resistance}$$

$$L = \mbox{inductance}$$

$$K_b = \mbox{EMF constant}$$

$$\omega = \mbox{rotational speed of motor}$$

$$v_{app} = \mbox{applied voltage}$$

$$K_f = \mbox{damping constant}$$

$$K_m = \mbox{torque constant}$$

Was this topic helpful?