I have to solve an exercise for the Digital Control System course (using MATLAB software) which stands:

Problem diagram.

"A ball is suspended inside a vertical tube by airflow 'u' and connected via a spring of stiffness K to the bottom of the tube. The ball is subjected to gravity and a viscous friction with coefficient 'B'. The force 'F' exerted on the ball by the airflow is proportional to the airflow 'u' via the constant G; airflow can only be positive (entering the tube)."

I have also all the data needed to solve the problem numerically, but this is not important for the question. What I need to do is: "Write the system equations in state space form with airflow as input and the ball vertical position 'z' as output.Then, select a sampling time and design a digital control system that regulates the ball position by acting on the airflow to the following specifications:

  • Zero steady-state error (in response to the desired altitude step input).

  • Max overshoot: 30%;

  • Settling time at 5% less than 8 seconds."

After this, we have to compute the transfer function of the plant and put it in unitary feedback with the compensator.

I usually write first the system dynamics equations, then from these I choose a suitable set of state variables and I write the matrices A, B, C and D according to the state variables (I use the 'ss' function). The problem is that I don't know how to consider the gravity in this case because it comes in the system dynamics as a constant term (-g*m). For example by considering the state variables as [z' z] I obtained the following matrices:

A = [-B/m -K/m; 1 0];

B = [G/m; 0];

C = [0 1];

D = 0;

Simulink model.

I tried to design the compensator (a simple PID) without considering the gravity and by adding it later in the Simulink model used to test the system (after designing the compensator we have to build a Simulink model in which the discrete time compensator is tested with the transfer function of the continuous time system) but of course the system output is no more able to meet the requirements. For the gravity transfer function I considered to have the mass as input and the position as output

Am I wrong in not considering the gravity when designing the compensator? Or perhaps, if correctly implemented the gravity should not affect the system output?


2 Answers 2


Why don't you use pole placement method to meet your control objective. Since you already have a state space model it is much easier. You have to just check the controllability of your system and then based on control requirement decide on the poles. You can use cmu's Controll tutorial. http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&section=ControlStateSpace

At the same time it doesn't not make sense to me to model the whole system just to make a PID controller. With a good enough system model you can make better controllers such lqr etc.

However if you are hell bent on using a PID controller, you can still improve your PID controllers performance by making use of anti-windup and thereby making integral term much more aggressive which will increasing the response time. PID controllers don't require gravity compensators (PD controller does), but you can assist it by providing feed forward and you can always tune it to meet your requirement. At the same time you can use bode plot to check whether it is theoretically possible to attain such a bandwidth of the system without making it unstable.


The presence of gravity does impact on how fast you can achieve steady-state with zero error, because the integral part of your PID compensator needs to charge in order to counteract the term $mg$. As a result, you won't meet the requirement on the settling time, with the same setting of the gains.

It's still possible to follow your design steps if you consider adding eventually a feed-forward term $u_{ff}=mg/G$ to sum up at the output of your PID.

Therefore, $$ u=u_{PID}+u_{ff} $$

  • $\begingroup$ Thank you for the answer, but from a theoretical point of view what I did to consider the effect of the gravity on the system is correct? Because I also thought that I could simply compute the equilibrium point of the system (z0 by which we have Kz0 = mg) and then subtract that position from the system transfer function output, is it right? $\endgroup$
    – PaulRox
    Jan 18, 2017 at 9:28
  • $\begingroup$ Hi Paul, from a theoretical standpoint, gravity acts as a disturbance, thus you should study the sensitivity function that accounts for the effect of the disturbance on the output. Here some notes on that. $\endgroup$ Jan 18, 2017 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.