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



Sunday 26 February 2017

Week 4

This is the fourth lab week for Y2 project. With the first four weeks work, our group project have already achieved the prototype of the conveyor belt sensor by using two Arduino Uno chips. Below is the pictures of our first  temperature-temperature and temperature-speed circuit respectively.


Figure 1: prototype of the temperature-temperature circuit


Figure 2: prototype of the temperature-speed circuit

Below is the proposals of this week;
  1. Test the output Pin 9 of the Arduino UNO chip utilised in temperature-speed circuit;
  2. Draw the Arduino layout circuit by using software Fritzing;
  3. Start soldering the circuit according to the Arduino layout schematic;
  4. Test the electric fan working on the temperature-temperature circuit and try to combine these two functional circuit.
The output of Pin 9 from Arduino board in temperature-speed circuit is shown in figure 3(a) and (b):


Figure 3(a): Pin 9 output when the temperature is 42C


Figure 3(b): Pin 9 output when the temperature is 51C
It can be shown that in figure 3(a), the average output voltage is around 276mV and in 3(b) is 498mV. The comparison between different temperature conditions indicate that, for higher temperature, the duty time in PWM voltage output will also increase to drive the motor in a higher speed.
The layouts of the temperature-speed circuit and temperature-temperature circuit are shown in figure 4(a) and (b) respectively:
Figure 4(a): Arduino schematic for temperature-speed control circuit

Figure 4(b): Arduino schematic for temperature-temperature control circuit

Here in figure 4(b), an PMDC motor is replaced for the electric fan.
The rated voltage of the electric fan is approximately 5V. After adjusting and testing, a 6V battery is connected to the collector of the transistor and a $1000\Omega$
The last part of this post, I will show you a draft interpretation of our temperature-speed circuit roughly:



Wednesday 22 February 2017

Week 3

Summary of week three's activities:
The week was mainly focused on adding the object sensor function to the temperature-speed function that can detect the distance from the obstacle/object. Initially, our first attempt was to use an IR emitter and sensor pair to transduce the distance signal as this link (Arduino IR sensor tutorial) and another link show. The IR emitter will emit the IR light which will be further detected by the receiver. Once the light path is blocked, the voltage will be set high immediately. The fundamental circuit we used for IR distance detecting and converting is shown in figure 1 and figure 2 shows the corresponding actual circuit we built. However after test, the IR receiver that we ordered can only detect a discrete IR impulse as an IR remote does. In the end, it seems that this application cannot achieve the function as we expected initially. 

Figure 1: Arduino UNO connection for fundamental IR sensor with obstacle detecting


Figure 2: Actual connection circuit for IR obstacle detecting circuit


An alternative distance detecting is to use a Ultrasonic device which can automatically send out an Ultrasonic wave. The Ultrasonic wave will be reflected back to the kit so that the distance can be calculated through reflecting time. The Arduino schematic is shown in figure 3. It is a trick when programming the code for Ultrasonic detecting, however it would be much easier if a NewPin function/header file was installed firstly into the Arduino library. Figure 4 shows the working detail of this Ultrasonic distance detector by using Serial display function in Arduino code assembly. Consequently, our second  method which uses the Ultrasonic emitter and receiver pairs was proven to be working as intended with high accuracy on distance measurement.


Figure 3: Fundamental Arduino UNO schematic for Ultrasonic distance detector circuit



Figure 4: Working test for Ultrasonic distance sensor

After testing the Ultrasonic kit properly, we then added the device on the temperature-speed control circuit coherently and merged the code for distance detector within the primary code. In order to harmonise these two functions, here, we summarised the relationship involved for distance detecting. We assume that roughly, when the object (for example, cake) is transmitted approaching to the one end of the belt, a buzzer should be triggered to alert the costumers. The frequency of buzzer should be set to be inversely proportional to the distance which means that the narrower the distance is remaining, the shriller the sound will become. The frequency of the buzzer will be controlled automatically by the distance $x$ between 0 to 30$cm$:
$$f(Hz) = \left\{ \begin{array}{rcl}\frac{1}{2\times (x^2 + 25)}& \mbox{for}& 5 \leq x \leq 30 \\ 0 & \mbox{for} & x < 5\end{array}\right.$$
The second equation of the buzzer frequency indicates that if the distance between the obstacle and the margin is smaller than 5$cm$, the buzzer will be triggered until the distance being resettled. Besides, the motor speed under this circumstance should also be 0.


In order to control the frequency of the buzzer in this circuit, two delay functions are invoked as:
digitalWrite(13,HIGH);
      delay(buzzervalue*buzzervalue+25);  // adjust this value for your convenience
      digitalWrite(13,LOW);
      delay(buzzervalue*buzzervalue+25);  // adjust this value for your convenience
Since the period of buzzer is set to be $2 \times (x^2 + 25)$, so the high pulse and low pulse of the sound should be maintained by  $(x^2 + 25)$ seconds. Here, 13 represents for the Arduino Pin which connected to the positive Pin of the positive buzzer.
The whole circuit is shown in figure 5 below:


Figure 5: Actual Arduino connection circuit for temperature-speed function 
with the application of temperature sensing, 
speed control and distance control


Objectives for the upcoming week:
  • Finish implementing the ultra sonic sensor along with its code.
  • Start building the physical conveyor belt for demonstrating purposes.
  • designing the poster and what materials should be included in it.


Tuesday 14 February 2017

Week 2

Summary of the week activities:
The fundamental activities we achieved is to start programming the Arduino code for the speed controlling circuit. Since we have already test the validity of the PWM voltage control by simulation, we will not bother too much in the theorem scope in this week. The figure below shows the overall structure for the temperature sensing and speed controlling circuit:


We discussed on the speed and temperature ranges that can suit our conveyor belt requirements and consequentially vary the speed of the motor depending on the surroundings temperature changing. Here is the determined relationship between temperature and the speed of the motor. Assuming the working temperature $t$ of the conveyor belt is between 40 to  90$ C^{\circ}$ and the motor rotation speed n is settled into the range between 0 to 255 units which will be in turn linearly dependent on the temperature. Hence:
$$n=3.1t-24\qquad for \ 40≤t≤90$$
and,
$$n=0 \qquad for\ t≤40 \ or \ t≥90$$
This linear relationship can be easily achieved by using a map function in Arduino UNO standard programming. The format should look like below:

fanSpeed = map(temp, tempMin, tempMax, 100, 255); // the actual speed of fan

Besides, it is proper to include an indicator, for instance, an LED to represent the speed of motor on the main control panel. Here again assuming a linear relationship between LED light intensity (regarded as L from 0 to 255 units) and the temperature (regarded as T from 40 to 90$C^{\circ}$) detected, the function will become: 
$$n=5.1t-204\qquad for \ 40≤t≤90$$
and,
$$n=0 \qquad for\ t≤40 \ or \ t≥90$$
The achievement for coding is similar as the fan speed control shown above.
After testing the programme with all functions, we started to build the whole circuit as shown in figure 1. The basic idea for this motor speed control is that, the Arduino chip and relevant codes will transduce the temperature signal in a suitable PWM voltage signal to output. The PWM signal will intermittently open or shut the transistor so that the DC voltage supply will be compensated adding on the DC motor. In addition, we also changed the components a little to make the circuit suitable for the ordered components' specifications. For instance, the 12v DC voltage supply was replaced by 6v and the base resistor was dropped to ensure a sufficient base current that can flow into the NPN transistor. The following video is attached to show the draft functions of the temperature-speed circuit. 


This video above demonstrates that the change in temperature will contribute a relevant change in the motor speed. The LCD screen will display the current surrounding temperature and motor speed. The motor will not rotate until the temperature is higher than 40$C^{\circ}$ and after that the motor will speed up linearly with the temperature changing. Besides, it is convenient to indicate the working mode of the motor explicitly. As shown in the video, the light intensity of the LED will also be changed depending on the temperature varying which is synchronized with the motor speed.

Notes and plans for the next week:

  1. A further function was suggested to build is a sensor that could detect the distance of the obstacle and stop the circuit when the object on the conveyor belt closes to a certain point. This sensor can be built on a new chip or on the original temperature-speed circuit;
  2. Another circuit should be built to achieve the temperature adjusting function. This part is recommended to build in a new circuit that will not violate with the original one. The cooling system can be an electric fan or any other refrigeration devices. 



Wednesday 8 February 2017

Week 1


First week summary:

The first week objective focused on the sensor functions achieving, that is, searching for the theorem background to accomplish the conveyor belt functions. Then we simulated the behaviour of each circuit. And decided to use Arduino UNO chip as our functional devices to achieve each functions. In this case, we will not bother calculating the specific relationship between temperature and the consequential speed.
In order to change the speed of the motor depending on the temperature, we decided to use Pulse Width Modulation (PWM) voltage control method in this case.
Pulse width modulation (PWM) is a voltage regulating method that can generate a series of voltage pulses of different duty time so that a varying average voltage will be generated and the speed of the motor will be controlled. For a large duty circle (see right side of figure 1), a higher average voltage will be generated.


Figure 1: PWM control output with different duty time

Theoretically, a 555 timer can be used to generate a voltage pulses with different duty circles. The working time and free time of the outcome pulses can be easily controlled by a pair of parallel variable resistors and capacitor. The simulation result of 555 timer by using Multisim is shown in figure 2. Besides, the diodes shown below works as current rectifier to prevent inverse flowing. 


Figure 2: Multisim schematic and PWM simulation result of 555 timer

It can be shown that a Pulse with a specific duty time can be generated. The active and free time can be calculated as:
$$T_H=0.693(R_1+R_{x1})C$$ $$T_L=0.693(R_2+R_{x2})C$$ $$T=T_H+T_L=0.693(R_A+R_B)C$$
And the consequential voltage becomes:
$$V_{RMS}=V\sqrt{\frac{R_1+R_2}{R_A+R_B}}$$

For a protection circuit, when the temperature goes higher than some critical value, the buzzer should start ringing. In figure 3, the critical voltage for the buzzer is set to be $1.5V$. $R_1$ represents for the thermistor. When the surrounding temperature becomes appr. $50C^{\circ}$, the corresponding resistance becomes 350$\Omega$. In order to trigger the buzzer at this resistance value, the resistance of the constant resistor $R_3$ can be set to be $585\Omega$ and the consequential output voltage around the buzzer becomes $1.508V$.  
Figure 3: Multisim schematic circuit and simulation result for the buzzer alert part

Notes:


A few components were order in this lab session in order to accomplish more functions to the circuit such as alarm and temperature control.

Second weeks objectives:
  • Start using Arduino UNO board to achieve the simulation results above. This involves coding and connecting.
  • Approval of the component list from Dr.Raja.

Project Overview


This a 2nd year bachelor project in University of Liverpool. The aim of the Project is to build a conveyor belt sensor that can detect the temperature change and react correspondingly on the conveyor speed. Besides a cooling system and security alert system are also concerned in this project. Below are the overview of this project. One application for this circuit is an automated oven for cake baking.


People Involved in this Project:

  • Supervisor: Dr.Raja. Munira
  • Project members:
  1. Xu,   Wangkun
  2. Al Khatri, Hatem Salim Ali
  3. Alghamdi, Abdulla Ghazi O
  4. Dashti, Lojain A H  M J
  5. Sulaiman, Maryam Elubobie

Project Overview:

The conveyor belt sensor should accomplish the following functions:
  1. Varying the speed of the motor depending on the temperature. When temperature goes up, the consequential speed of the motor should also go high;
  2. Immediate shut the motor and alert for narrow distance;
  3. A screen displays the current surrounding temperature and motor speed;
  4. A cooling system that can refrigerate the belt when the temperature is higher than a manually set value;
  5. Operationally, some indicators to show the working status of the circuit.
The following parts show the components we ordered to achieve these functions:

Component Amounts
Arduino UNO board 2
Positive buzzer 1
LED Severl
Resistor in different resistances Several
10k Potentiometer 2
LM35 thermistor 2
NPN transistor BC547 2
6V DC voltage source 2
Hook up wires Several
Diode 1N4007 2
5v DC motor 2
5v DC electric fan 1
LCD screen 1
Ultrasonic distance detector 1
Belt and Tyres 1
USB2-102 Cable 1
Table: Component ordering list

Some of the fundamental components are also shown in the below pictures:
Figure: Thermister LM35 

Figure: LCD display suitable for Arduino UNO