I have to solve an exercise for the Digital Control System course (using MATLAB software) which stands:
"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;
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?