State-Space model of spring-mass system

Click For Summary

Discussion Overview

The discussion revolves around deriving the state-space model of a spring-mass-damper system, specifically neglecting friction and gravity. Participants explore the mathematical formulation and numerical simulation of the system's response to a sine-wave input force.

Discussion Character

  • Technical explanation, Mathematical reasoning, Experimental/applied, Debate/contested

Main Points Raised

  • The initial post outlines the derivation of the state-space model using Newton's law and presents a mathematical formulation for the system.
  • The author describes unexpected behavior in the system's response to a sine-wave input, noting a slower frequency component at the beginning of the response.
  • Some participants suggest that the numerical implementation may be correct, while others inquire about the choice of state vector and its implications.
  • A later reply confirms that the transient response observed is a combination of the decaying natural response and the forced response.
  • Participants discuss the appropriateness of the chosen state vector and its impact on the analysis.

Areas of Agreement / Disagreement

There is no consensus on the interpretation of the initial transient response, with some participants agreeing on the nature of the response while others question the model's accuracy or the author's intuition.

Contextual Notes

Participants note that the numerical simulation may not fully verify the implementation of the state-space model, and there are discussions about the choice of state vector that could influence the analysis.

Who May Find This Useful

Readers interested in control systems, numerical simulations, and the dynamics of mechanical systems may find this discussion relevant.

Number2Pencil
Messages
204
Reaction score
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:
<br /> F_{NET}=ma = m\ddot{y}<br />

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:
<br /> u-c\dot{y}-ky=m\ddot{y}<br />

Rearranging terms:
<br /> \ddot{y} = \frac{1}{m}u - \frac{c}{m}\dot{y}-\frac{k}{m}y<br />

Setting up state-space integral form:
<br /> y = \int( -\frac{c}{m}y + \int (-\frac{k}{m}y + \frac{1}{m}u) dt) dt&#039;<br />I call the entire outer integral X1 and the inner integral X2, using this nomenclature:

<br /> y = X_1<br />

<br /> \dot{X_1} = -\frac{c}{m}X_1 + X_2<br />

<br /> \dot{X_2} = -\frac{k}{m}X1 + \frac{1}{m}u<br />

<br /> \left[<br /> \begin{array}{cc}<br /> \dot{X1}\\<br /> \dot{X2}\\<br /> \end{array}<br /> \right] = \left[<br /> \begin{array}{cc}<br /> -\frac{c}{m}&amp;1\\<br /> -\frac{k}{m}&amp;0\\<br /> \end{array}<br /> \right]<br /> \left[<br /> \begin{array}{cc}<br /> X1\\<br /> X2\\<br /> \end{array}<br /> \right] + <br /> \left[<br /> \begin{array}{cc}<br /> 0\\<br /> \frac{1}{m}<br /> \end{array}<br /> \right]u<br /><br /> y = <br /> \left[<br /> \begin{array}{cc}<br /> 1&amp;0<br /> \end{array}<br /> \right]\left[<br /> \begin{array}{cc}<br /> X1\\<br /> X2\\<br /> \end{array}<br /> \right] + 0u<br />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
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..
 
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');
 
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 \begin{bmatrix}y &amp; \dot{y}\end{bmatrix}^T would be more convenient.
 
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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
7
Views
3K
Replies
6
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K