In this section, we alternatively show how to build the Train System from the Introduction: Simulink Modeling page using the physical modeling blocks of the Simscape extension to Simulink. The blocks in the Simscape library represent actual physical components; therefore, complex multi-domain models can be built without the need to build mathematical equations from physical principles as was done above by applying Newton's laws. Recall the following diagram of the train system:
As described in the previous page, the mass of the engine and the car are represented by M1 and M2, respectively. The engine and the car are connected by a coupling of stiffness k. The Force F represents the force generated between the engine wheel and the track and mu is the coefficient of rolling resistance.
The system parameters are as follows:
(M1) Engine Mass 1 kg
(M2) Car Mass 0.5 kg
(k) Spring Constant 1 N/m
(mu) Friction Coefficient 0.02
(F) Force 1 N
(g) Acceleration due to gravity 9.8 m/s^2
Open a new Simscape model by typing ssc_new in the MATLAB command window. A new model, as shown below, opens with a few commonly used blocks already in the model.
The elements of the model are:
The PS-Simulink and Simulink-PS blocks define the boundary between Simulink input/output models where the blocks are evaluated sequentially and Simscape models where the equations are evaluated simultaneously.
To create the model, a number of blocks need to be added.
Tips for adding blocks:
Add the following blocks:
Assign the parameter values listed at the beginning of this page to each of these blocks. In this case, we use the Translational Damper blocks to model the viscous friction in the system. Specifically, we assign the Damping coefficient of each block to be the friction coefficient multiplied by the normal force (mu*mass*g). If we desired a more sophisticated friction model, we could use Translational Friction blocks instead. Connect the blocks as shown to develop the model and rename the scope "Velocity".
Now add the following elements to the model:
In the Signal Generator block, choose the Waveform to be "square" with an Amplitude of "-1" and a Frequency of "0.001 Hz". To open the Configuration Parameters dialog, type CTRL-E. Then choose Type to be "Variable-step" and the Solver to be "auto". Also set the simulation Stop time to "1000". Connect the blocks as shown below to finish the model.
Run the simulation (type CTRL-T or press the green arrow run button) and open the Scope to examine the velocity output. The force input was a square wave with two steps, one positive and one negative. The Scope shows that the engine first went forward when the positive force was applied, then in the opposite direction some time after the negative force was applied. The velocity output identically matches the results of the Simulink model developed in the Introduction: Simulink Modeling page.
You can download the final Simscape model created here by right-clicking here and then selecting Save link as ....