Video length is 4:30

Modeling a DC Motor

Simscape™ is used to model a DC motor. The model is created by assembling a physical network of Simscape components, including electrical resistors, shaft inertias, and friction. The simulation results are evaluated in the Simscape Results Explorer. The physical connections used in the model make it easy to understand, modify, and maintain, and make it possible to quickly build up models spanning multiple physical domains.

Recorded: 25 May 2016

In this demonstration, we're going to see how we can use Simscape to model a DC motor. The system we wish to model looks like this-- a DC motor that has two electrical connections and two mechanical connections, including one connection that can translate along an axis.

We wish to model this system with electrical and mechanical effects. We will use Simscape to model it. The model we build will look like this. And when we run the simulation, we will see how the motor reacts as it acts against a spring.

We'll use the MATLAB command ssc_new to open up a new Simulink model. Using the command ssc_new opens up a Simulink model with the settings recommended for Simscape models. It also adds a few of the blocks commonly used in Simscape.

To model our DC motor, the first thing that we'll need is a DC voltage source. I'll click in the diagram and type in "DC voltage source," and then select the component from a list. I'll set the voltage to 5 volts.

The next thing that we'll need is a resistor. I'll click and drag to create an electrical connection and then type in "resistor," and then select the resistor component.

We then need a block that will convert between electrical and mechanical energy. I'll type in "electro" and then select the rotational electromechanical converter. I'll then connect this to our resistor.

Our electrical circuit will also need an inductor, which will then connect to the other side of our converter. We'll also need a ground block. So I'll type in "electrical reference" and connect it here.

Simscape uses solver technology above and beyond what's available in normal Simulink. To have access to some of those settings, we'll connect the solver configuration block.

The next thing that we'll do is the mechanical portion of our model. These two ports represent the mechanical connections of our motor. We'll attach the housing of the motor to a point fixed in space. We'll insert a mechanical rotational reference block.

This connection represents the shaft. I'll click and drag to create a mechanical connection, and then insert an inertia to represent the inertia of the shaft.

We want to model the viscous friction in the bearing of our motor. I will right-click and drag to create a branch, and then insert a damper block. We'll connect the damper to the housing of our motor.

We want to convert the rotational motion of the shaft to translational motion. We'll do that using a wheel and axle block.

We want the motor to act against the spring. So we'll insert a spring. And the spring will be connected to a point fixed in space.

With this, our model is complete. We can run the simulation. I'll right-click on the block and select Simscape, View Simulation Data, Simlog.

Here we can see the Simscape Results Explorer. We can explore the results of our simulation through this tree browser. Here I can see the speed of the shaft as it settles out to 0 radians per second.

And I can look at electrical quantities, such as the current through the resistor. We can see how much the spring was compressed by selecting the x variable in the translational spring. And we can see that it compressed to about 0.01 meters, or 1 centimeter.

I can increase the distance that the motor shaft moves by resetting the stiffness of the spring. Here, I can change it to a new numerical value, or I could assign a MATLAB variable. I can also adjust the units. And I can configure this parameter to be a runtime parameter, meaning that I can change this value without regenerating C code.

I'll rerun the simulation, reload the simulation results, and we'll see that this spring now compresses 2 centimeters-- again, because we've halved the stiffness of the spring.

If I want to view the results of this simulation on a Simulink scope, I can use sensor blocks. I'll right-click and add a motion sensor. And we'll measure the motion of the shaft with respect to the housing.

The sensor block produces a physical signal. This physical signal can be used to implement simultaneous physical equations. We need to convert this physical signal to a Simulink signal in order to view it on the scope.

In that conversion, we'll assign the units. So we'll assign it units of degrees. Now when we run the simulation, we can see how much the shaft turns on a Simulink scope. And we can see that it settles at about 22 and 1/2 degrees.

In this demonstration, we have seen how we can model a DC motor using foundation library components in Simscape and analyze the results in the Simscape Results Explorer.