Vous êtes sur la page 1sur 42

Mechanical Engineering Department

Control Systems (1)

Applications of Matlab in Control Systems


By Eng. Yousef Sardahi

Finding Laplace Transform (1)


Find Laplace Transform of the Following Function

>>syms t; f=sym('-1.2*sin(5*t)+1.2*exp(-5*t)') >> laplace(f)

Finding Laplace Transform (2)


Find Laplace Transform of the Following Function

>> syms t a x >> f=exp(-a*t) >> TF=laplace(f,x) >>pretty(TF)

Finding Laplace Transform (3)


Find Laplace Transform of the Following Function

>> laplace(12*diff(sym('y(t)'),2))

>>laplace(12*diff(sym('y(t)'),2)+diff(sym('y(t)'),1)+5* sym('y(t)'))

Finding Inverse Laplace Transform (1)


Find Inverse Laplace Transform of the Following Function

>> syms s f=sym(4*s^2/(3*s+2)) >> ilaplace(f)

Finding Inverse Laplace Transform (2)


Find Inverse Laplace Transform of the Following Function

>> syms s f=sym(1/(s*(s^2+2*s+2))) >> ilaplace(f)

Simulink (1)

Build a Simulink model that solves the following differential equation


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 cx kx f (t ) x

Simulink (2)
First, solve for the term with highestorder derivative m f (t ) cx kx x Make the left-hand side of this equation the output of a summing block

m x
summing block

Simulink (3)
Drag a Sum block from the Math library

Double-click to change the block parameters to rectangular and + - -

(continue)

Add a gain (multiplier) block to eliminate the coefficient and produce the highestderivative alone
m x
1 m

summing block

Drag a Gain block from the Math library

The gain is 4 since 1/m=4.

Double-click to change the block parameters. Add a title.

(continue)

Add integrators to obtain the desired output variable


m x
1 m

1 s

1 s

summing block

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.

(continue)

Connect to the integrated signals with gain blocks to create the terms on the right-hand side of the EOM
m x
1 m

1 s
c

1 s

summing block

c x
kx

Drag new Gain blocks from the Math library


To flip the gain block, select it and choose Flip Block in the Format pulldown menu.

c=0.5 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. k=1.0

Complete the model


Bring all the signals and inputs to the summing block. Check signs on the summer.

f(t) input + m x

1 m

1 s
c

x x
k

1 s

x(t) output

c x
kx

Double-click on Step block to set parameters. For a step input of magnitude 3, set Final value to 3

Final Simulink model

Run the simulation

Results

Underdamped response. Overshoot of 0.5. Final value of 3. Is this expected?

Bus Suspension Modeling in Simulink


body mass (m1) = 2500 kg. suspension mass (m2) = 320 kg spring constant of suspension system(k1) = 80,000 N/m spring constant of wheel and tire(k2) = 500,000 N/m. damping constant of suspension system(b1) = 350 Ns/m. damping constant of wheel and tire(b2) = 15,020 Ns/m. control force (u) = force from the controller we are going to design. The road disturbance (W) in this problem will be simulated by a step input. This step could represent the bus coming out of a pothole

Building the Model


Open Simulink and open a new model window. First, we will model the integrals of the accelerations of the masses. Insert an Integrator block (from the Linear block library) and draw lines to and from its input and output terminals. Label the input line "a1" (for acceleration) and the output line "v1" (for velocity) . To add such a label, double click in the empty space just above the line. Insert another Integrator block connected to the output of the first. Draw a line from its output and label it "x1" (for position). Insert a second pair of Integrators below the first with lines labeled "a2", "v2", and "x2"

Continue ..

Continue ..
Next, we will start to model Newton's law. Newton's law for each of these masses can be expressed as:

Insert two Gain blocks, (from the Linear block library) one attached to the inputs of each of the integrator pairs. Edit the gain block corresponding to M1 by double-clicking it and changing its value to "1/m1". Change the label of this Gain block to "Mass 1" by clicking on the word "Gain" underneath the block. Similarly, edit the other Gain's value to "1/m2" and it's label to "Mass 2". (You may want to resize the gain blocks to view the contents. To do this, single click on the block to highlight it, and drag one of the corners to the desired size.)

Continue ..
There are three forces acting on M1 (one spring, one damper, and the input, u) and five forces acting on M2 (two springs, two dampers, and the input, u).

Insert two Sum blocks (from the Linear block library), one attached by a line to each of the Gain blocks. Edit the signs of the Sum block corresponding to M1 to "+--" to represent the three forces (two of which will be negative) Edit the signs of the other Sum block to "++-++" to represent the five forces, one of which will be negative.

Continue ..
Now, we will add in the forces acting on each mass. First, we will add in the force from Spring 1. This force is equal to a constant, k1 times the difference X1-X2. Insert a sum block after the upper pair of integrators. Edit its signs to "+-" and connect the "x1" signal to the positive input and the "x2" signal to the negative input. Draw a line leading from the output of the Sum block. Insert a Gain block above the "Mass1" block. Flip it left-to-right by single-clicking on it and selecting Flip Block from the Format menu (or hit Ctrl-F). Edit the value of this gain to "k1" and label the block "Spring 1". Tap a line off the output of the last Sum block and connect it to the input of this gain block. Connect the output of this gain block (the spring force) to the second input of the Mass 1 Sum block. This input should be negative since the Spring 1 pulls down on Mass 1 when X1 > X2. Tap a line off the spring force line and connect it to the second input of the Mass 2 Sum block. This input is positive since Spring 1 pulls up on Mass

Continue ..

Continue ..
Now, we will add in the force from Damper 1. This force is equal to b1 times V1-V2. Insert a sum block below the Mass 1's first integrator.Flip it left-to-right, and edit it's signs to "+-". Tap a line off the "v1" line and connect it to the positive input of this Sum block. Tap a line off the "v2" line and connect it to the negative input of this Sum block. Insert a Gain block to the left of this Sum block and flip it left-to-right. Edit it's value to "b1" and label it "Damper 1". Connect the output of the new Sum block to the input of this gain block. Connect the output of this gain block (the damper force) to the third input of the Mass 1 Sum block. This input is negative, similar to Spring 1's force on Mass 1. Tap a line off Damper 1's force line and connect it to the first input (which is positive) of Mass 2's Sum block.

Continue ..

Continue ..
Now we will add in the force from Spring 2. This force acts only on Mass 2, but depends on the ground profile, W. Spring 2's force is equal to X2-W. Insert a Step block in the lower left area of your model window. Label it "W". Edit it's Step Time to "0" and it's Final Value to "0". (We will assume a flat road surface for now). Insert a Sum block to the right of the W Step block and edit its signs to "-+". Connect the output of the Step block to the positive input of this Sum block. Tap a line off the "x2" signal and connect it to the negative input of the new Sum block. Insert a Gain block to the right of this Sum block and connect the Sum's output to the new Gain's input. Change the value of the gain to "k2" and label it "Spring 2". Connect the output of this block (Spring 2's force) to the fourth input of Mass 2's Sum block. This force adds in in the positive sense.

Continue ..

Continue ..
Next, we will add in the force from Damper 2. This force is equal to b2 times V2-d/dt(W). Since there is no existing signal representing the derivative of W we will need to generate this signal. Insert a Derivative block (from the Linear block library) to the right of the W step block. Tap a line of the Step's output and connect it to the input of the Derivative block. Insert a Sum block after the Derivative block and edit it's signs to "+-". Connect the Derivative's output to the positive input of the new Sum block. Tap a line off the "v2" line and connect it to the negative input of this Sum block. Connect the output of this Sum block (Damper 2's force) to the fifth input of Mass 2's Sum block. This force also adds in with positive sign

Continue ..

Continue ..
The last force in the input U acting between the two masses. Insert a Step block in the upper left of the model window. Connect it's output to the remaining input of Mass 1's Sum block (with positive sign). Tap a line off this signal and connect it to the remaining input of Mass 2's Sum block (with negative sign). Edit this Step block's Step Time to "0" and leave its Final Value "1". Label this Step block "U". Finally, to view the output (X1-X2) insert a Scope connected to the output of the rightmost Sum block.

Continue ..

Continue ..

Continue ..

Continue ..

Continue ..

Continue ..

Continue ..

Continue ..

Vous aimerez peut-être aussi