Control of a ball-and-plate system using a State-feedback controller Control de un sistema bola-placa utilizando un controlador por realimentación de estados

A ball-and-plate platform is a common example of the dynamical system used to apply modeling and control concepts studied in some engineering courses. In this kind of systems, a spherical body is positioned on a mobile plate with two degrees of freedom. The system is operated by two servo motors that cause displacement of the sphere in the x and y axis in the plane of the platform. It is known that such a system is highly unstable and non-linear. Initially, from a phenomenological analysis we obtained a state-space representation of the system. Then, a state feedback controller using the pole assignment method was designed to maintain a desired position of the sphere over the plane. A computer vision technique allowed us measuring the two-dimensional position of the sphere over the plane in real time. Model of the plant under study and controller design for sphere positioning were experimentally validated considering different set-points. Obtained results let us know that our plant-controller is stable and responds satisfactorily to position disturbances around a reference point.


RESUMEN
Una plataforma bola-placa es un ejemplo común de sistema dinámico utilizado para aplicar los conceptos de modelado y control estudiados en algunos cursos de ingeniería. En este tipo de sistemas, un cuerpo esférico se coloca sobre una placa móvil con dos grados de libertad. El sistema es accionado por dos servomotores que provocan el desplazamiento de la esfera en los ejes x e y en el plano de la plataforma. Se sabe que dicho sistema es altamente inestable y no lineal. Inicialmente, a partir de un análisis fenomenológico se obtuvo una representación del sistema en el espacio de estado. A continuación, un controlador de realimentación de estado basado en el método de asignación de polos fue diseñado para mantener una posición deseada de la esfera sobre el plano. Una técnica de visión por computador fue usada para medir la posición bidimensional de la esfera sobre el plano en tiempo real. El modelado de la planta en estudio y el diseño del controlador para el posicionamiento de la esfera se validaron experimentalmente considerando diferentes puntos de ajuste. Los resultados obtenidos mostraron que el controlador diseñado es estable y responde satisfactoriamente a las perturbaciones de posición de la esfera alrededor del punto de referencia.

INTRODUCTION
The Ball-and-Plate (BaP) system, like the Balland-Beam and the magnetic levitator systems, have arisen a special interest in teaching engineering and research due to its complex dynamics based on an inherent instability and nonlinearity. The main advantages of this type of systems are its low cost, easy implementation and the opportunity that it offers to make experimental validation of theoretical knowledge in modeling, controling and other disciplines of engineering like the computer vision and robotics.
Several works are reported by specialized literature. In [1] a BaP system is constructed with two magnetic suspension actuators for two degrees of freedom. For this system, a ball position controller using the Liapunov function was designed. A visual servo control for a BaP system using a LQR control approach is presented by Cheng et al. in [2]. The control of a BaP system using a friction compensation scheme, PD position controller and PD angular controller is discussed in [3]. In [4], a basketball robot project in which six degrees of freedom manipulator makes a balancing control of a ball on a plate based only on haptic information is presented. In [5] balancing a ball on a plate is achieved using low cost phototransistor sensors. Two independent PID control algorithm, one for each motor, are programmed in an AVR ATMega16 microcontroller. In [6], a normal proportionalderivative (PD) control is modified to a new dual form for controlling a BaP system. This variant corresponds to an asymptotic stable dual PD control with a nonlinear compensation. A novel mechatronic design of a BaP system is presented in [7], and two control strategies for ball position are discussed: 1) a PID controller with supervisory fuzzy control and 2) a sliding control. Finally, in [8,9,10,11,12] the modeling, construction and control of Balland-Beam systems, the one-dimensional version of BaP systems, are discussed.
In [13] four control methods are compared: PID controller, sliding mode controller, fuzzy controller and LQR controller; all applied to a ball and plate system. The results of this work relate the responses of the four controllers graphically and with values associated with establishment time, over-impulse and steady-state error. The author concludes -based on his graphical and numerical answers-that the controller with the best performance is the Sliding Mode control to solve the problem of static and dynamic tracking for nonlinear systems with high complexity as it overcomes modeling imprecisions and parameter variations.
In this paper, four stages of engineering analysis and design are addressed. The first stage corresponds to the phenomenological analysis of the movement of ball on plate, from which its representation in space state is obtained. In a second stage, with the previous results, a state feedback controller using the pole assignment method is developed and the establishment time and percentage overshoot as the main design parameters are considered. In third stage, simulations are performed in Simulink ® in order to verify the fulfillment of the desired parameters. Finally, our BaP-controller system implementation is experimentally validated.

Modeling
From the phenomenological analysis, it is possible to observe the forces acting in the BaP system. It should be mentioned that in the modeling of the system, only the dynamic of the Ball-on-the Plate is taken into account. The forces acting on the system with an angle β of one of its axes are defined in the free-body diagram shown in Figure 1. According with the free-body diagram and applying the second Newton's law, we have: In the equation (1), the first term defines the force component as a function of the inclination angle β, and the second term corresponds to the frictional force between the plate and the contact point of the ball. Given the dynamic of the BaP system, two movements are identified: translation and rotation. The latter is produced by the torque due to the contact point of the ball with the plate and its distance to mass center. It is described by: In equation (2), τ is the torque, f s is the frictional force and R is the ball ratio. Applying Newton's second law for rotational movement, caused by the torque, we have: Where in equation (3) α are the angular acceleration and the I cm is the inertial of mass center, given by the expression of equation (4).
From equations (1) and (4) the following differential equation is obtained: Now, (5) it is a nonlinear differential equation because it has a sinusoidal component. The development of a controller for this system is highly complex due to the nonlinear quantity. Nevertheless, this task becomes simpler if the nonlinear equation is converted into a linear equation. As shown in Figure 2, the sine function could be considered linear around its zero crossing. This could be used for the equation linearization but incorporates an operational restriction of the plate inclination in the range [-π/6, π/6]. Considering the above, we obtain the linear equation given in (6).
Since for this system a state feedback controller will be designed, it is necessary to go from the differential equation to a state space representation, and make the following substitutions: We can obtain the lineal model described by equations (7) and (8).
The matrix form of equations (7) and (8) are given in equations (9) and (10) This representation is valid for both, x and y axes.

Controller Design
Before starting to design the state feedback controller, it is necessary to demonstrate that the system is both, observable and controllable [14]. To do so, we must prove that: Figure 2. Linear zone of the sine function.
Where A, B and C, are the matrices included in equations (9) and (10). When equations (11) and (12) are evaluated according to the values of A, B and C matrices, we can obtain the following two results: This proves that the system studied is controllable and observable. When designing the space state controller, the pole assignment method was used.
In this method the closed loop system poles are placed on the complex plane S, to obtain the desired dynamic behavior, as shown in Figure 3. The characteristic equation of the system is changed into a desired characteristic equation by considering the next two design parameters: Where t sd is the establishment time and M pd is the percentage of over-impulse. From this, the damping coefficient ξ and the natural frequency ω n are calculated using the expressions (13) and (14).
These values are put into a second-order characteristic equation of the form: To obtain: To determine the feedback gains we can use Ackermann's formula, which is given by: Where K is the gain vector and Φ(A) can be calculated by using the expression: Φ A ( ) = A n +α 1 A n−1 +α 2 A n−2 …α n−1 A +α n l α 1 and α 2 values are taken from (16). After solving and simplifying we obtain: Where K is the feedback gain vector. The response of this controller retains a steady-state error, but the BaP system has an integrator in its dynamics, therefore it is recommended to use servo system type 1 [14], like the one shown in Figure 4. For equation (17), K1 corresponds to the first element of K and Km is a modified version of K, where the first element is replaced by zero. This can be observed in equations (18) and (19).
This controller is applied for positioning on both axes, x and y.

SIMULATION
At this point, with a dynamic system model and a state feedback controller design, it is necessary to observe the stability and dynamic behavior of the plant-controller system. For doing so, the program Simulink ® of Matlab ® will be used.
In Figure 5 it should be noted that the position of the ball in the x and y axes corresponds to the outputs of the BaP system, while the step signals correspond to the inputs. The obtained response is shown in Figure 6, the straight lines correspond to the speed of the ball, and the curve lines are the x-y ball position.
According to Figure 4 and equations (18) and (19), the simulation diagram of Figure 7 allowed us to obtain the BaP-controller system response shown in Figure 8. Note that each coordinate position has a different set-point, x = 0.5 and y = 0.75.
At this point, we can see that the controller forces the system to accomplish the design requirements of tsd=1s and Mpd = 2% for both, x and y position.

SYSTEM IMPLEMENTATION
The Ball-and-Plate system was built with two acrylic pieces of 0.35 m 2 each one. The first one corresponds to the 10 mm width base, and the second, to the 3mm width plate. Between them, the following pieces were placed: Central Piece allows the two degrees of freedom of the BaP system, the plate rests over it, which is made of polytetrafluoroethylene. Its operating range is [-15º, 15º] as it is shown in Figure 9.

Axes
were made of stainless steel. At one of its ends there is a small piece that allows the plate to be tilted. Axes are properly threaded to provide the possibility of adjustment of the platform with respect to the servomotors, as shown in Figure 10. Axes are responsible for converting the rotation movement of the servo motors into the linear motion required to incline the plate. Figure 10. An axis piece of the BaP system.

Servomotor
provides the torque and displacement to tilt the plate. Two servo motors are required for our two degrees of freedom of the BaP system (see Figure 11). Figure 12 shows integration of all of the pieces. The final aspect of our BaP system can be seen in Figure 13.

EXPERIMENTAL VALIDATION
For the BaP system under consideration we have an input and an output per axis. Therefore, it is necessary to incorporate a state observer to estimate the internal states of the real system, required to produce the control law. Figure 14 shows the system configuration after incorporating the state observer. Figure 14. Control loop using a state observer.
It should be noted that the observer only needs the input and output for each coordinate (x, y). The A, B and C matrices are known (see equations (9) and (10)) but the L matrix needs to be calculated.
The observer response must be faster than the control response [14], therefore the establishment time for the observer (t so ) must be less than the establishment time for the controller (t sd ).
The observer's characteristic equation is defined the same way that in (16), and making the proper operations we obtain the following: To calculate the L matrix we can use Ackermann's formula Where Φ A ( ) = A n +α 1 A n−1 +α 2 A n−2 …α n−1 A +α n I And n = 2,α 1 = 16 ∧α 2 = 105.06 Replacing and solving the matrix that makes the observer response faster than the controller's, we obtain: It should be mentioned that the configuration shown in Figure 14 will be applied to two servomotors, one for each x and y position of the ball on plate. As shown in Figure 15, there are two input references to the controller s.p x and s.p y , and two control actions U x (t) and U y (t) are generated, one for each servo motor. The interface between the BaP system and a PC is implemented through an Arduino UNO and a webcam. The microcontroller module receives the control signals generated by the control algorithm that runs on the PC and generates PWM signals to drive the servo motors. This causes the plate tilt to maintain the x-y reference position of the ball. Figure 16 shows the complete experimental setup.
A webcam is used as the position sensor of the ball on the 2D plate. Both, the video processing algorithm to determine the position of the ball and the control algorithm were implemented with Labview.
Video processing algorithm consists of the following stages: 1) Image Mask, for dimension reduction, 2) Measure, for corner detection, 3) Color Threshold to take into account only orange (ball) and black (platform), 4) Binary Image Inversion, to take into account the dynamics of the ball, not the platform, 5) Advance Morphology, to remove sections of the image that could be mistaken for the sphere and 6) Particle Analysis where the ball center coordinates are taken.
In Figure 17, the control algorithm in Labview can be seen. The configuration shown in Figure 14 is used to control each servo motor. Here we can see a SubVI corresponding to the observer; this algorithm is shown in Figure 18.
The parameters of the controller and the observer, used in the experimental validation phase, can be seen in Tables 1 and 2.       According to the results obtained from the experiment, Table 3 lists the values corresponding to the desired response parameters and steady-state error (Ess).
Compared to [14], the controller used in this work outperforms the PID controller, the fuzzy controller and the LQR controller as well, but it is not better than the sliding mode controller.
This work stands out for the simplicity of the modeling taking into account only the dynamics of the ball on the plate, unlike the works mentioned here, where the servomotors and the sensor element are also included, which makes the mathematical treatment difficult.
The implementation of the system is robust enough to be used as a laboratory experiment to advance experimental validations with different control alternatives, thus achieving a contribution to the training of professionals in this area of engineering, due to the fact that it is a complex system presenting a high degree of alignment and instability.

CONCLUSIONS
By linearizing the system, the operating range of the platform is restricted, a situation that is convenient because the mechanical constraints with which the central ball joint (central piece) was designed only allows inclinations of ± 15º in the x-y plane. This results in the convenient operation of the BaP system in the linear zone.
Since no sensors are available to detect BaP system states, it was necessary to include a full-order observer with establishment time twice as fast as the controller. In this way it was possible for the observer to estimate the states of the system before the controller stabilizes them.
The fact of taking into account the states of the system -in this case the position and speed-allowed the controller to generate a suitable control signal, achieving a correct response of the system to the disturbances, and allowing to locate the sphere around the desired set-point.
The servo-system type 1 is ideal to control processes whose dynamic behavior incorporates an integrator. This configuration is useful for eliminating the steady-state error in the system response when the states are fed back. Additional advantages of the servo-systems type 1 are that they avoid the need of a different gain for each reference position and avoid the need of making additional calculations in cases where it is required to add an integrator.
Due to the high speed of the system's response, it was necessary to calculate a controller whose desired poles provided an establishment time of 1 second. During the experimental stage, it was observed that by increasing this value, the servomotors presented a small oscillatory movement until the sphere was located at the desired point, which allowed to clearly identify the desired conditions of the controller, which were presented in Table 1.
The results of this work can be consulted in the link below: https://www.youtube.com/ watch?v=cgi5SiukWcY