State-Space model of spring-mass system

In summary, Newton's law describes the motion of an object at rest or in motion with a force. The recoil force works in the direction towards the equilibrium point, and the dampening coefficient works against velocity.
  • #1
Number2Pencil
208
1

Homework Statement



Derive the state space model of a spring-mass-damper system. Neglect friction, wind resistance, etc. Neglect the force of gravity. Assume the spring's equilibrium point is at y=0 and there is an arbitrary

Homework Equations



[X'] = AX + BU
y = CX + DU

The Attempt at a Solution



Newton's law:
[tex]
F_{NET}=ma = m\ddot{y}
[/tex]

The sum is an arbitrary input force, u, the recoil force that works in the direction towards the spring's equilibrium point, and the dampening coefficient which works against velocity:
[tex]
u-c\dot{y}-ky=m\ddot{y}
[/tex]

Rearranging terms:
[tex]
\ddot{y} = \frac{1}{m}u - \frac{c}{m}\dot{y}-\frac{k}{m}y
[/tex]

Setting up state-space integral form:
[tex]
y = \int( -\frac{c}{m}y + \int (-\frac{k}{m}y + \frac{1}{m}u) dt) dt'
[/tex]I call the entire outer integral X1 and the inner integral X2, using this nomenclature:

[tex]
y = X_1
[/tex]

[tex]
\dot{X_1} = -\frac{c}{m}X_1 + X_2
[/tex]

[tex]
\dot{X_2} = -\frac{k}{m}X1 + \frac{1}{m}u
[/tex]

[tex]
\left[
\begin{array}{cc}
\dot{X1}\\
\dot{X2}\\
\end{array}
\right] = \left[
\begin{array}{cc}
-\frac{c}{m}&1\\
-\frac{k}{m}&0\\
\end{array}
\right]
\left[
\begin{array}{cc}
X1\\
X2\\
\end{array}
\right] +
\left[
\begin{array}{cc}
0\\
\frac{1}{m}
\end{array}
\right]u
[/tex][tex]
y =
\left[
\begin{array}{cc}
1&0
\end{array}
\right]\left[
\begin{array}{cc}
X1\\
X2\\
\end{array}
\right] + 0u
[/tex]So now I wanted to test it using a sine-wave input force to the system. Intuitively, I would expect a sine-wave output as the mass should be bobbing up and down on the spring. What I actually get is at the beginning, there is a much slower frequency component than my input sine-wave, as well as the input-frequency component, almost like the sum of two different sine waves. This slower-component then dies off and I am left with something that matches more closely to my input sine-wave. What is strange is that during that initial slow-frequency response, the amplitude gets quite large, much larger than when it is finally settled.

My question is: What is going on? Is my intuition just wrong and truly this mass has a large initial "push"? Is there an error in my state-space model? Or something I am forgetting to take into account. I tested that having a zero-force input, the spring remains at zero.

Edit: Also, my test constant values were m= 0.72kg, k = 0.5, c =1
 
Last edited:
Physics news on Phys.org
  • #2
Seems fine to me, you're solving it numerically I guess? MATLAB/Simulink?

Maybe you could post the code you're running etc.

I'm off to bed..
 
  • #3
Sure. Here is the MATLAB code I used to produce the time-domain plots. I had trouble with simulink...so I really can't verify if this is implementing state-space correctly.

Code:
%Physical Inputs
mass = 0.72;
springK = 1;
damperC = 0.5;

%Input Parameters
sineWaveAmp = 1;
sineWaveFreq = 0.5;

%Timing Parameters
timeStart=0;
timeStop=50;
dt = 0.001;

%Create State-Space Matrices
A=[-damperC/mass, 1; -springK/mass, 0];
B=[0; 1/mass];
C=[1,0];
D=[0];
stateSpace = [0;0];

%Loop Variables
numSamps = (timeStop-timeStart)/dt;
currTime = timeStart;

%Create Storage Elements
posVals(1:numSamps) = 0;
timeVals(1:numSamps) = 0;
u(1:numSamps) = 0;


%Step 1, create sine wave input values
sineWavePeriod = 1/sineWaveFreq;
for n=1:numSamps
	cycleTime = mod(currTime,sineWavePeriod);
	u(n) = sineWaveAmp*sin(2*pi*sineWaveFreq*cycleTime);
	currTime = currTime + dt;
end

%Step 2, simulate state space
currTime = timeStart;
for n = 1:numSamps

	% Y = Cx' + Du
	posVals(n) = (C*stateSpace)+(D*u(n));
	integratorInput = (A*stateSpace)+(B*u(n));
	
	%Integrate. x' = int(A*x + B*u)
	stateSpace = stateSpace+(integratorInput*dt);

	%Prepare next iteration
	timeVals(n) = currTime;
	currTime = currTime + dt;
end


%Step 3, plot
figure(1);
plot(timeVals,posVals);
title('Mass-Spring Position over time');
ylabel('Meters');
xlabel('Seconds');

figure(2);
plot(timeVals,u);
title('Mass-Spring External Input over time');
ylabel('N');
xlabel('Seconds');
 
  • #4
I did a quick comparison of your solution with that of the Dormand-Prince solver in the MATLAB Control Systems Toolbox and everything checks out, so good job :smile:

The transient you see at the start is the sum of the decaying natural response and the forced response.

Is there a reason for using that particular state vector? I'd have thought that [itex]\begin{bmatrix}y & \dot{y}\end{bmatrix}^T[/itex] would be more convenient.
 
  • #5
Alright, thanks miles. I guess my intuition was just off :p

For choosing that state vector, it's simply a product of me being very methodical on solving these kinds of things.

I'll check out this Dormand-Prince toolbox you mentioned, thank again
 

1. What is a state-space model of a spring-mass system?

A state-space model is a mathematical representation of a dynamic system, such as a spring-mass system, in which the behavior of the system is described by a set of state variables and a set of equations that govern how these variables change over time.

2. How is a spring-mass system represented in state-space form?

In a spring-mass system, the state variables typically include the position and velocity of the mass, while the equations describe how these variables change in response to forces acting on the system, such as the force of the spring and any external forces.

3. What is the advantage of using a state-space model for a spring-mass system?

State-space models provide a more comprehensive and flexible approach to modeling dynamic systems compared to traditional methods. They can capture nonlinearities, time-varying parameters, and external disturbances, making them useful for analyzing and controlling complex systems like a spring-mass system.

4. How can a state-space model be used to analyze a spring-mass system?

State-space models can be used to simulate the behavior of a spring-mass system over time and predict how it will respond to different inputs and forces. They can also be used to design control strategies for the system to achieve a desired behavior or performance.

5. Are there any limitations to using a state-space model for a spring-mass system?

State-space models require accurate initial conditions and parameter values to accurately represent the behavior of a spring-mass system. They can also be computationally intensive and may not be suitable for real-time control applications. Additionally, state-space models may not be able to capture all the complexities of a real-world system, so their predictions may not always match with actual observations.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
11
Views
1K
  • Advanced Physics Homework Help
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
460
  • Engineering and Comp Sci Homework Help
Replies
1
Views
926
  • Advanced Physics Homework Help
Replies
3
Views
253
  • Engineering and Comp Sci Homework Help
Replies
1
Views
854
  • Advanced Physics Homework Help
Replies
19
Views
794
  • Engineering and Comp Sci Homework Help
Replies
1
Views
790
Replies
11
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top