Sunday 5 March 2017

Week 5

The outline of the fifth week's proposal is to theoretically test the Proportional, Integral and Differential (PID) control method by researching and simulating using MATLAB. Hence in week 4, a temperature controlled circuit is decided to build to primarily cool down the conveyor belt using PID control correspondingly with the acceleration process. It is proper to introduce a stability test for this feedback control as well as PID turning test to find the most suitable constant gains for this control system.  Besides, it is time to start soldering the circuit on board for a flexible display purpose. The overall plans for the last week covers:
  1. Using Root Locus test to obtain the stability range of  Proportional gain in P-only system in MATLAB;
  2. Testing the turning responses for different gains combinations in MATLAB Simulink block;
  3. Apply the simulations above with a proper combination of Proportional, Integral and Differential gains inside the Arduino codes;
  4. Start soldering the board with tiny electronic components;

PID controller theorem:

A Proportional, Integral and Differential (PID) Control method is a closed loop control approach that can effectively compensate the system noises and accurately control the state of the control signal to the plant. This controller continuously test the error  e(t) as the difference between the desired Setpoint (SP) and the current state Process Variable (PV), and applies a compensation on the control signal u(t) on the Plant. Figure 1 shows a full PID control loop: 
Figure 1: Full PID control loop

Processing voltage signal (PV) represents for the current state of the independent variable which will feedback to the controller through the first summing junction. Set point (SP) or the reference signal is the standard of the whole system which will be subtracted by PV as the actuating signal which will trigger the controller. In this case, unless the error between the reference and PV is zero, the PID loop will force the Process signal approach to the reference point progressively. The last component is the Control signal .  represents the same value of the current independent state, but can also be regarded as the output of the PID loop to control the outer device which has the ability to drive the feedback loop stable at the set point. The formula behind PID loop can be summarized as:
$$e(t)=SP(t)-PV(t)$$
and,
$$u(t)=K_pe(t)+K_i\int^t_0{e(\tau)d\tau+K_d\frac{d}{dt}e(t)}$$
Here,  represents for the error between reference signal and current state signal and  represent for the $K_p, K_i, K_d $ voltage amplifier constant of proportional error, integrational error and differential error respectively. These three parameters measure the dependences of the system on the current, past and anticipated future conditions individually and can be determined by experimenting. Basically, parameter  $P_d$  will be settled as 0 in regular applications.
By using PID control method, control signal will drive the external component which in turn changes the Process voltage approaching to Reference signal step by step. The variation range between each step will be reduced so that the circuit performs more efficiently. In contrast, an open loop control circuit will change the output depending on the input immediately. Besides, the triggering signal is the subtraction between SP and PV which will control the plant more accurately.  

At the very beginning, the experimental groups aimed to build a closed loop control circuit in both temperature-speed and temperature-temperature circuit. However, without the sufficient knowledge and apparatus, it is hard to convert and encode the speed signal back to the reference signal in closed loop. Since the reference signal is belt temperature and the current state is the speed of the motor, the relationship between these two variables is required.


Locus root test of the P-only control method for the conveyor belt.

Firstly we will do Root Lotus Analysis to find the theoretical range of the Proportional gain in P-only control. Then we will test this range using MATLAB simulation function.
Assuming the Process Gain of the temperature-temperature system is 0.1 and the time constant is 50 seconds. Besides, assuming a long time delay to compensate the complexity of the connection, for example, 30 seconds. So that the overall transfer function (TF) will become:
$$TF=\frac{0.1e^{-30s}}{50s+1}$$
Here, in order to find the range of the Proportional Gain, firstly assume this is a P-only control system so that the simplified control system will become the loop shown in figure 2:
Figure 2: Simplified P-only controller

Since MATLAB cannot functionalize the exponential time delay $ e^{-30s}$ inside the simulation process, here we’ll use Padé Approximation on this exponential term. Generally, Padé Approximation transform the exponential term into a rational number with both numerator and dominator are power series:
$$e^x=\frac{1+(1/2)x+(1/9)x^2+(1/72)x^3+(1/1008)x^4+(1/30240)x^4}{1-(1/2)x+(1/9)x^2-(1/72)x^3+(1/1008)x^4-(1/30240)x^4}$$
Applying this approximation into our equation using first order terms only, will give:
$$e^{-\theta_ps}=\frac{1-(\frac{\theta_p}{2})s}{1+(\frac{\theta_p}{2})s}$$
where $\theta_p$ represents for time delay 30s. Below is the MATLAB comparison results among transfer function, transfer function with exponential delay and transfer function with Padé Approximation:
Figure 3: Padé Approximation comparison among TF, TF with delay and TF with approximation

Below shows the Root Locus output. The left side of the  dashed line represents for the Proportional gains that output a stable response whereas the pure real poles on the x-axis indicate for a condition with non-oscillating. So in this case, the range of the P-gain should not be bigger than 43. 
Figure 4: Locus root test for stability of P-only system

MATLAB simulink for stability and turning

In order to test the stability in a more real condition, it is proper to go through a rough simulation of this response system. Besides, a series of tuning test can also be introduced based on this simulation block. Figure 5 represents for a MATLAB simulink block for this PID full response system. 
Figure 5: MATLAB simulink block for a full PID control system adjusted for the temperature-temperature circuit

Figures below show varied $K_p, K_i, K_d $ combinations for this temperature-temperature response circuit. 

Condition 1: Output response with a step input with $K_p=45, K_i=0, K_d=0 $


It can be concluded that in this condition, the response is unstable which is resemble with the Locus Roots test. 

Condition 2: Output response with a step input with $K_p=40, K_i=0, K_d=0 $

The output response is still unstable, but the oscillating extent seems to shrink compared with condition 1. The system is still unstable which is conflicted with the Locus Roots test can be explained as the deficiency of  Padé Approximation. We reduce the Proportional gain for a little big step to see the stability.

Condition 3: Output response with a step input with $K_p=40, K_i=0, K_d=0 $

It seems that the system is under a approximate no-damping conditions at this moment which can be regarded as the critical boundary of the stability. If $K_p$is smaller than 35 further, the system can be concerned as stable.

Condition 4: Output response with a step input with $K_p=30, K_i=0, K_d=0 $

As we assumed in this case, the output response will become stable after a long time.

Condition 5(a): Output response with a step input with $K_p=15, K_i=0, K_d=0 $

Here, we will test the stability at $K_p=15$ to see if it is suitable for our temperature-temperature circuit. 
The system will remain stable with an unavoidable offset of the input step response.

Condition 5(b): Control signal on the plant with $K_p=15, K_i=0, K_d=0 $

Condition 6(a): Output response with a step input with $K_p=15, K_i=15/50, K_d=0 $

Here, in order to eliminate the offset effect of the P-only controller, the Integral gain $K_i$ must be included. Since the integration manipulate the area of the error passed over time, it will extend the response signal over the input step so that the offset will be eliminated. Also, the integral gain will also deteriorate the overshoot condition in turn. 
As analysed above, the offset has been successfully eliminated while a overshoot condition occurs instead. 50 seconds in the denominator of  Integral gain is chosen as the time constant. 

Condition 6(b): Control signal on the plant with $K_p=15, K_i=15/50, K_d=0 $

Condition 7(a): Output response with a step input with $K_p=15, K_i=15/50, K_d=65 $

The only reason for applying the third Differential gain is to reduce the percentage overshoot caused by Integral gain. However, it can be demonstrated that this effect is insignificant with a drawback of reduce the response speed. Since the overshoot effect will have little harm on Arduino circuit, in temperature-temperature PID circuit, we will only use the first two parameters.

Condition 7(b): Control signal on the plant with $K_p=15, K_i=15/50, K_d=65 $

Ideally, the control output on the plant is insignificant except with several kick-outs. This pulse effect is mainly caused by the intermediate change of the error value in a quasi-zero time interval.
For a short conclusion, the constant gain values will be set suitably as $K_p=15, K_i=15/50, K_d=0 $ as discussed for the Arduino UNO code. 

Setting the Arduino UNO code for PID temperature controller

For the temperature control circuit, three contributions of the PID equation were converted to represent the relative speed of the electric fan. So PV here is a transduced speed value relative to the current temperature. SP is the reference fan speed converted from the variable resistance (voltage). The difference between these speed parameters will trigger the control circuit which will work as the triggering error and produce the control signal to drive the electric fan (as plant) and cool down the circuit. In order to test the functions of different voltage gains, experimenters are allowed to change these three values in the serial monitor display. Besides, the constant gain values will be set suitably as $K_p=15, K_i=15/50, K_d=0 $ as simulated for the Arduino UNO code. 
Figure 6: Serial display for temperature-temperature circuit with default Gains



Figure 7: Serial display for temperature-temperature circuit with user set Gains

Soldering the board for tiny components

The overall prototype of this temperature controlled conveyor belt with both speed controlled and temperature maintain is shown in figure 6.


Figure 8: Prototype of the  temperature controlled conveyor belt with both speed controlled and temperature maintain applications

The test video is attached below:

The figures below shows a 3D housing design for the circuit. figure 9 shows the front and left view which contain LCD screen hole with two circular holes for the two potentiometer. figure 10 is a left and back view the two squared holes should be to help cable management and the two cylindrical poles should a stand for the fan and ultrasonic sensor. figure 11 shows a back-right view a circular holes, it can also be seen on figure 10, which is where the two motors will be staying at. figure 12 shows a top view which where the circuit will be located.

Figure 9: front and left view
Figure 10: back and left view

Figure 11: back and right view

Figure 12: top view



No comments:

Post a Comment