Modeling a DC Motor

Modeling a DC Motor


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 will 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 a 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 elect and then select the rotational electro mechanical converter I’ll then connect this to our resistor Our electrical circuit we’ll also need an inductor which will then connect to the other side of our converter We will 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 will 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 will 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 will 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 a 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 zero 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 the spring now compresses two centimeters again because we’ve halved the stiffness of the spring If I want to view the results of the simulation on a Simulink scope, I can use sensor blocks I’ll right-click and add a motion sensor and we’ll connect will 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 a half degree 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 explore

5 thoughts on “Modeling a DC Motor

Leave a Reply

Your email address will not be published. Required fields are marked *