Example 2
Build a Simulink model that solves the following differential equation
2nd order mass-spring-damper 2nd-order mass spring damper system zero ICs input f(t) is a step with magnitude 3 parameters: m = 0.25, c = 0.5, k = 1
m x cx kx f (t )
Create the simulation diagram
On the following slides:
The simulation diagram for solving the ODE is created step p by y step. p After each step, elements are added to the Simulink model. model
Optional exercise: first, sketch the complete l t diagram di (5 min.) i )
m x cx kx f (t )
(continue)
First, solve for the term with highestorder derivative m x f (t ) cx kx Make the left-hand side of this equation the h output of f a summing i block bl k
m x
summing block
Drag a Sum block from the Math library
Double-click Double click to change the block parameters to rectangular and + - -
(continue)
Add a gain (multiplier) block to eliminate the coefficient and produce g alone the highest-derivative
m x
summing i block
1 m
Drag a Gain block from the Math library
The g gain is 4 since 1/m=4. /
Double-click Double click to change the block parameters. Add a title.
(continue)
Add integrators to obtain the desired output variable
m x
summing block
1 m
1 s
1 s
Drag Integrator blocks from the Continuous library
ICs on the integrators are zero.
Add a scope from the Sinks library. Connect output ports to input ports. Label the signals by double-clicking on the leader line line.
(continue)
Connect to the integrated signals with gain bl k to blocks t create t th the t terms on th the right-hand i ht h d side of the EOM
m x
summing bl k block
1 m
x cx
kx
1 s
c
1 s
Drag new Gain blocks from the Math library
To flip the gain block, select it and choose Flip Block in the Format pull-down menu.
Double-click Double click on gain blocks to set parameters Connect from the gain block input backwards up to the branch point. Re-title the gain blocks.
c=0.5
k=1.0
Complete the model
Bring all the signals and inputs to the summing i block. bl k Check signs on the summer.
+ -
f(t) input
m x 1 m
x cx kx
1 s
c
x x k
1 s
x(t) output
Double-click on Step block to set parameters. For a step t i input t of f magnitude it d 3 3, set Final value to 3
Final Simulink model
Run the simulation
Results
Underdamped response. response Overshoot of 0.5. Final value of 3. Is this expected?
Paper-and-pencil P d il analysis l i based on the equations of motion
Standard form k Natl freq. freq Damping ratio Static g gain
x m
1 c x x f (t ) k k
k n 2.0 m c 0.5 n k K
1 1 k 2
Check simulation results
Damping ratio of 0.5 is less than 1.
Expect the system to be underdamped. Expect p to see overshoot. Expect output magnitude to equal input magnitude. Input has magnitude 3, 3 so does output. output
Static gain is 1.
Simulation results conform to expectations.
End of tutorial