In that conversion, we'll assign the units. We need to convert this physical signal to a Simulink signal in order to view it on the scope. This physical signal can be used to implement simultaneous physical equations. The sensor block produces a physical signal. And we'll measure the motion of the shaft with respect to the housing. I'll right-click and add a motion sensor. If I want to view the results of this simulation on a Simulink scope, I can use sensor blocks. 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. And I can configure this parameter to be a runtime parameter, meaning that I can change this value without regenerating C code. Here, I can change it to a new numerical value, or I could assign a MATLAB variable. I can increase the distance that the motor shaft moves by resetting the stiffness of the spring. And we can see that it compressed to about 0.01 meters, or 1 centimeter. We can see how much the spring was compressed by selecting the x variable in the translational spring. Here I can see the speed of the shaft as it settles out to 0 radians per second.Īnd I can look at electrical quantities, such as the current through the resistor. We can explore the results of our simulation through this tree browser. Here we can see the Simscape Results Explorer. I'll right-click on the block and select Simscape, View Simulation Data, Simlog. And the spring will be connected to a point fixed in space. We want the motor to act against the spring. We'll do that using a wheel and axle block. We want to convert the rotational motion of the shaft to translational motion. We'll connect the damper to the housing of our motor. I will right-click and drag to create a branch, and then insert a damper block. We want to model the viscous friction in the bearing of our motor.
![dc motor matlab simulink model dc motor matlab simulink model](https://au.mathworks.com/help/examples/sps_product/win64/ee_motor_brushless_dc_01.png)
I'll click and drag to create a mechanical connection, and then insert an inertia to represent the inertia of the shaft. We'll insert a mechanical rotational reference block. We'll attach the housing of the motor to a point fixed in space. These two ports represent the mechanical connections of our motor. The next thing that we'll do is the mechanical portion of our model. To have access to some of those settings, we'll connect the solver configuration block. Simscape uses solver technology above and beyond what's available in normal Simulink. So I'll type in "electrical reference" and connect it here.
![dc motor matlab simulink model dc motor matlab simulink model](https://d2vlcm61l7u1fs.cloudfront.net/media%2F37a%2F37acad2d-67e2-4161-8925-b896a3dd619d%2FphpLoiWBJ.png)
Our electrical circuit will also need an inductor, which will then connect to the other side of our converter. I'll type in "electro" and then select the rotational electromechanical converter. We then need a block that will convert between electrical and mechanical energy. I'll click and drag to create an electrical connection and then type in "resistor," and then select the resistor component. The next thing that we'll need is a resistor. I'll click in the diagram and type in "DC voltage source," and then select the component from a list. To model our DC motor, the first thing that we'll need is a DC voltage source. It also adds a few of the blocks commonly used in Simscape. Using the command ssc_new opens up a Simulink model with the settings recommended for Simscape models. We'll use the MATLAB command ssc_new to open up a new Simulink model. And when we run the simulation, we will see how the motor reacts as it acts against a spring. We wish to model this system with electrical and mechanical effects. 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. In this demonstration, we're going to see how we can use Simscape to model a DC motor.