Mass-Spring System Simulink

105 次查看(过去 30 天)
Jochem
Jochem 2023-3-23
编辑: Richard 2023-11-28
I have a mass (x gram) with the following attributes:
Displacement(0) = u, velocity(0) = v, acceleration(0) = a.
I need to make a Block Diagram which could calculate the frequency, stiffness.
I have done these calculations already on paper but I don't know how I would simulate this on Simulink
Does anybody have a clue where to start / how to start?
Thank you for your attention.

回答(2 个)

Pratheek
Pratheek 2023-3-28
Hi Jochem,
I assume you need to calculate the stiffness and frequency of a spring mass system.
To simulate the sysyem in simulink for that you can follow these basic steps:
  1. Create a new Simulink model and add a Mass block to the model. The Mass block represents the physical mass.
  2. Add two Integrator blocks to the model, and connect as sown in the fig.
  3. Add a Gain blocks to the model and set its gain to Damping coefficient and Spring coefficient.
  4. Add a Scope block to the model to visualize the displacement if necessary.
  5. To calculate the frequency and stiffness, you can add two more blocks: a Sine Wave block and a Transfer Function block. The Sine Wave block will generate a sinusoidal input signal with a specific frequency, and the Transfer Function block will calculate the system response.
  6. Configure the Transfer Function block to calculate the system response from the displacement to the input. You can use the transfer function of a spring-mass-damper system to calculate the frequency and stiffness.
m reprent Mass in the fig.
These steps should give you a basic idea of how to create a Simulink model that simulates a mass with given attributes and calculates the frequency and stiffness. You may need to adjust the parameters and configurations of the blocks to match your calculations on paper.
  2 个评论
Jochem
Jochem 2023-3-28
Thank you very much, I had no idea where to start, I'm gonna try this.
Sam Chak
Sam Chak 2023-3-28
Hi @Jochem, You will appreciate why the blocks are arranged at such if you first learn how to solve the ODE in MATLAB using the ode45() function.
help ode45
ODE45 Solve non-stiff differential equations, medium order method. [TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0) integrates the system of differential equations y' = f(t,y) from time TSPAN(1) to TSPAN(end) with initial conditions Y0. Each row in the solution array YOUT corresponds to a time in the column vector TOUT. * ODEFUN is a function handle. For a scalar T and a vector Y, ODEFUN(T,Y) must return a column vector corresponding to f(t,y). * TSPAN is a two-element vector [T0 TFINAL] or a vector with several time points [T0 T1 ... TFINAL]. If you specify more than two time points, ODE45 returns interpolated solutions at the requested times. * YO is a column vector of initial conditions, one for each equation. [TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) specifies integration option values in the fields of a structure, OPTIONS. Create the options structure with odeset. [TOUT,YOUT,TE,YE,IE] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) produces additional outputs for events. An event occurs when a specified function of T and Y is equal to zero. See ODE Event Location for details. SOL = ODE45(...) returns a solution structure instead of numeric vectors. Use SOL as an input to DEVAL to evaluate the solution at specific points. Use it as an input to ODEXTEND to extend the integration interval. ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is nonsingular. Use ODESET to set the 'Mass' property to a function handle or the value of the mass matrix. ODE15S and ODE23T can solve problems with singular mass matrices. ODE23, ODE45, ODE78, and ODE89 are all single-step solvers that use explicit Runge-Kutta formulas of different orders to estimate the error in each step. * ODE45 is for general use. * ODE23 is useful for moderately stiff problems. * ODE78 and ODE89 may be more efficient than ODE45 on non-stiff problems that are smooth except possibly for a few isolated discontinuities. * ODE89 may be more efficient than ODE78 on very smooth problems, when integrating over long time intervals, or when tolerances are tight. Example [t,y]=ode45(@vdp1,[0 20],[2 0]); plot(t,y(:,1)); solves the system y' = vdp1(t,y), using the default relative error tolerance 1e-3 and the default absolute tolerance of 1e-6 for each component, and plots the first component of the solution. Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y): float: double, single See also ODE23, ODE78, ODE89, ODE113, ODE15S, ODE23S, ODE23T, ODE23TB, ODE15I, ODESET, ODEPLOT, ODEPHAS2, ODEPHAS3, ODEPRINT, DEVAL, ODEEXAMPLES, FUNCTION_HANDLE. Documentation for ode45 doc ode45 Other uses of ode45 dlarray/ode45

请先登录,再进行评论。


Richard
Richard 2023-11-28
编辑:Richard 2023-11-28
Hello,
I think you should start by creating a new Simulink model. In Simulink, go to "File" and select "New" to create a new model.
Then, add blocks to the model:To simulate the mass, displacement, velocity, and acceleration, you will need to add appropriate blocks to the Simulink model. Here's a step-by-step guide:
a. Start by adding a "Constant" block from the Simulink Library Browser. Double-click on the block to open its parameters and set the value to the initial displacement "u" of the mass.
b. Add a "Derivative" block from the Simulink Library Browser. Connect the output of the "Constant" block to the input of the "Derivative" block. This block will calculate the velocity of the mass.
c. Similarly, add another "Derivative" block and connect it to the output of the first "Derivative" block. This will calculate the acceleration of the mass.
Next, calculate frequency and stiffness:To calculate the frequency and stiffness of the system, you will need to incorporate mathematical operations in your Simulink model. Here's how you can do it:
a. Add a "Gain" block from the Simulink Library Browser. Connect the output of the second "Derivative" block (acceleration) to the input of the "Gain" block.
b. Double-click on the "Gain" block to open its parameters. In the Gain Value field, enter the stiffness value you calculated on paper.
c. Add a "Transfer Fcn" block from the Simulink Library Browser. Connect the output of the "Gain" block to the input of the "Transfer Fcn" block.
d. Double-click on the "Transfer Fcn" block to open its parameters. In the "Transfer Fcn" tab, define the transfer function of your system using the appropriate coefficients and exponents.
e. Finally, add a "Frequency" block from the Simulink Library Browser. Connect the output of the "Transfer Fcn" block to the input of the "Frequency" block. This block will calculate the frequency of the system.
Finally, once you have completed the block diagram, save the model and run the simulation. Click on the "Run" button in the Simulink toolbar to start the simulation. You can observe the outputs and analyze the results.

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by