LQR Controller Implementation

## Discrete state-space

To obtain a discrete model of the system, first I must find the state-space representation in continuous-time domain and then convert it to discrete domain using an appropriate sampling time. The conversion method I used is called zero-order hold. As for the sampling time it is a common practice to have 25\textasciitilde{}30 times of the bandwidth frequency of the closed-loop system but in my case I simply chose 0.02{[}s]. My biggest concern was the computation load I had to process without over-running the microcontroller's capability. Since I am using only an 8 bit microcontroller with 1KB of SRAM, it appears that the resources are limited. However if I had to decrease the sampling period, I could
have done it by reducing the period of sampling time right before the point of over-run.

The two linearized ordinary differential Equations were solved to represent my system in System Modeling and these representations can be put together in Simulink as shown below. Although having a non-linear system model for the simulation and using the linearized model for linear controller design is a recommended practice, time wasn't allowed for me to model a non-linear model within Simulink.

## Controllability

The design criteria for the system was simply to make it balance permanently. It seems that I forgot to mention about criteria for settling time, rise time, overshoot and steady-state error. This is because my preliminary goal had been reached only recently and I have yet come to an advanced stage in which to improve on those parts. The fact is I did not have a firm conviction given the unprofessional parts that it would do the work at all.

However, in theory, there is a way to gain assurance on whether a system is controllable or not. For the system to be completely state controllable, the controllability matrix must have the rank of n.
Consider the linear time invariant system given by

(1)
\begin{align} \dot{x}=Ax+Bu \end{align}

The controllability matrix of the above LTI system is defined by the pair (A,B) as follows

(2)
\begin{equation} C_{r}(A,B)=[B,AB,A^{2}B,A^{3}B] \end{equation}

The rank of the matrix is the number of independent rows. This gives 4. The system is controllable if and only if the controllability matrix $C_{r}(A,B)$ has the same rank as the state vector. This proves that
the current discrete system is completely state controllable.

## Digital LQR Full-State Feedback Controller design

The next step and the most critical step is to find the control matrix(K). Linear Quadratic Regulator method is used to find the control matrix. This method allows to find the optimal control matrix that results in some balance between system errors and control effort. To use LQR method, I need to find three parameters: Performance index matrix(R), state-cost matrix(Q), and weighting factors. For simplicity, I chose the performance index matrix equal to 1. The weighting factor was chosen by trial and error.

Unlike other design methods, the full-state feedback system does not compare the output to the reference; instead, it compares all states multiplied by the control matrix $Kx$ to the reference. Thus, I should not expect to see the output equal to the input. To obtain the desired output, It is necessary to scale the reference input so that the output equals the reference. This is done by introducing a feedforward scaling factor called Nbar.

Below is the response I get after tuning the state-cost matrix and Nbar values to achieve the most favorable response for a reference of 0.2[m].

The block diagram of the full-state feedback system is shown below. A periodic pulse disturbance was added to the theta derivative term and a step disturbance to the theta term. This was performed to observe the robustness of the system. In addition, a saturation block was added to simulate the non-linear factor in the motor dynamics. According to the response this system can reject theta offset and periodic angular velocity pulses and return to its reference position. Time allowing, I should check this out also by non-linear model for the robot.

page revision: 5, last edited: 18 Aug 2008 02:38