STATISTICAL ANALYSIS AND DESIGN OF A DATA - DRIVEN BASED CONTROLLER FOR A TEMPERATURE PROCESS STATION Thesis submitted to the SASTRA Deemed to be University in partial fulfillment of the requirements for the award of the degree of B. Tech. Electronics & Instrumentation Engineering Submitted by B.Aswin (Reg.No.: 120006005) R.Raghav Narayan (Reg.No.: 120006092) JULY 2020 SCHOOL OF ELECTRICAL & ELECTRONICS ENGINEERING THANJAVUR, TAMIL NADU, INDIA – 613 40 1 SCHOOL OF ELECTRICAL & ELECTRONICS ENGINEERING THANJAVUR – 613 401 Bonafide Certificate This is to certify that the report titled “ Statistical Analysis and Design of a Data - Driven based Controller for a Temperature Process Station ” submitted as a requirement for the course , B.Tech. Electronics & Instrumentation Engineering programme, is a bonafide record of the work done by Mr. B Aswin(Reg. No.120006005) and Mr. R Raghav Narayan(Reg. No.120006092) durin g the academic year 2019 - 20, in the School of ELECTRICAL & ELECTRONICS ENGINEERING, under my supervision. Signature of Project Supervisor : Name with Affiliation : Dr. K. Ramkumar, Professor, EIE, SEEE Date : Project VivaVoce held on ________________ Examiner 1 Examiner 2 SCHOOL OF ELECTRICAL & ELECTRONICS ENGINEERING THANJAVUR – 613 401 Declaration We declare that the thesis titled “ Statistical Analysis and Design of a Data - Driven based Controller for a Temperature Process Station ” submitted by us is an original work done by us under the guidance of Dr. K. Ramkumar , Professor , EIE, S EEE , SASTRA Deemed to be University during the final semester of the academic year 2019 - 20, in the School of Electrical and Electronics Engineering . The work is original and wherever w e have used materials from other sources, w e have given due credit and cited them in the text of the thes is . This thesis has not formed the basis for the award of any degree, diploma, associate - ship, fellowship or other similar title s to any candidate of any University. Signature of the candidate(s) : Name of the candidate(s) : Aswin B Ragh av Narayan R Date : iii A cknowledgement s First of all , we express our deepest gratitude to Prof. Dr. S. Vaidhyasubramaniam , Vice Chancellor, SASTRA Deemed to be University, who provided all the necessary facilities and encouragement during the course of our study. We also extend our sincere thanks to Prof. R. Chandra m ouli, Registrar, SASTRA Deemed to be University, for providing the opportunity to pursue this project. We dedicate our whole hearted thanks to Dr. K. Thenmozhi (Dean, SEEE) and Dr. A. Krishnamoorthy (Associate Dean, EIE) who motivated us during this project work. We owe a debt of deepest grat itude to our mentor Dr. K. Ramkumar , Professor, EIE, SEEE and Dr. S. Rakesh Kumar, AP - III, SEEE for their valuable inputs, guidance, encouragement, whole - hearted cooperation and constructive criticism throughout the duration of our project on the topic, ‘S tatistical Analysis and Design of a Data - Driven based Controller for a Temperature Process Station’. We take this opportunity to thank all our faculty who have directly or indirectly helped in our project. iv Abstract A laboratory level scaled down version of a Industrial temperature process station present at the process control laboratory . This project idea was formulated after it was observed that the equipment consists of conventional hardware components such as PC, and bulky wires and requires a separate set of hardware components which consequentially leaves a huge carbon footprint in the associated environment. This state of the system demanded a novel appro ach to utilize the usage of smart embedded controllers such as Arduino and related smart components to achieve the design of an embedded controller with reduced hardware requirements. This approach is taken into consideration with the aim of improving the experimental outcome of the process control laboratory through a simple controlling technique which helps people understand PID controlling in real time with a digital microcontroller . This project aims to design a data - driven based PID controller using Ar duino in replacement of the conventional PID controller. The design of the model is achieved by data - based modelling and statistic al tests are performed and the results are recorded. Specific Contribution: • Hardware Implementation of the model Specific Learning: • Working of hardware • PID Controller • Data driven Modelling Signature of the Guide Student Reg. No: 120006005 Name: Name: Dr. K. Ramkumar , Professor , EIE B Aswin v Abstract A laboratory level scaled down version of an Industrial temperature process station present at the process control laboratory. The laboratory level experiments comprised of the conventional hardware components such as process station, and bulky w ires to transmit the process variable specifically for a process station, thereby incurring increased hardware complexity. This project proposes a novel approach to utilize the usage of smart embedded controllers such as Arduino and related smart component s to achieve the design of an embedded controller with reduced hardware requirements. This approach can be considered to obtain a design more oriented towards Industry 4.0 such as employing the services of cloud architecture for storage of the sensor data, or using the high performance AI powered analytic tools to draw peculiar insights from the system data, etc. This project aims to design a data - driven based PID controller using Arduino in replacement of the conventional PID controller. Consequently perfo rming statistical analysis on the generated data can give various interpretations about the behaviour of data, relationship between the process variables, or to predict the future samples, feature extraction etc. Thus statistical tests can help in understa nding the data thus improving the accuracy of model selection specifically suited for the control system. Specific Contribution: • Software Implementation of the Model • Performing Statistical Analysis Specific Learning: • Reviewing the study of various data driven models • PID Controller • Statistical Tests Signature of the Guide Student Reg. No: 120006092 Name: Name: Dr. K.Ramkumar, Professor, EIE R Raghav Narayan vi Table o f Contents Title Page No. Bonafide Certificate i Declaration ii Acknowledgements iii Abstract iv List of Figures i x List of Tables x i i Abbreviations x i i i Notations xi v 1. Introduction 1 1.1 Introduction 1.2 Motivation 1 1 2 Objectives 2 3 Literature Review 3 3 .1 Basic Components of a Control System 3 3 .1.1 Measuring element/sensor 3 3 .1.2 Final Control element/actuator 3 3 .1.3 Controller 4 3 .1.4 Process 4 3 .2 Data - Driven Modeling 4 3 .2.1 Black - box Modeling 5 3 .2.2 Grey - box Modeling 7 3 .3 PID Controllers 8 3 .3.1 Proportional (P) 9 3 .3.2 Integral (I) 9 3 .3.3 Derivative (D) 10 3 .3.4 Effect of composite control action 1 1 3 .4 Ziegler Nicholas Tuning Method 1 2 vii 4 Hardware Specification 1 3 4 .1 Arduino 1 3 4 .1.1 Component Description 1 3 4 .2 K - Type Thermocouple 1 4 4 .3 MAX 6675 Module 1 4 4 .4 IRFZ44N MOSFET 1 5 4 .5 BC547 1 5 4 .6 Rotary Encoder 1 6 4 .7 I2C LCD 1 6 5 Hardware Setup 1 7 5 .1 Connection Schematic 1 7 5 .2 Working 1 7 6 Software Implementation 1 9 6 .1 General Procedure 1 9 6 .2 Matlab Implementation 1 9 6 .2.1 Data Preprocessing 1 9 6 .2.2 Finding the model structure 2 1 6 .2.3 Estimating the model 2 2 6 .2.4 Design of the PID Controller 2 3 7 Statistical Analysis 28 7 .1 Overview 28 7 .2 Python Implementation 28 7 .2.1 Initialization 28 7 .2.2 Null hypothesis testing 30 7 .2.3 Q - Q plot for testing normality 3 0 7 .2.4 KS test for normality 3 2 7 .2.5 Box Cox Transformation 3 3 7 .2.6 Linear Regression 3 4 7 .2.7 Distribution Visualization 3 5 7 .2.8 Prediction 3 6 viii 8. Results and Discussion 38 8.1 Data Driven Modelling 38 8.1.1 Response Comparison 38 8.1.2 Residual Analysis 40 8 .2 PID controller Design 41 8.3 Statistical Analysis 42 8.3. 1 Linear Regression 42 8.3.2 Box plot 43 8.3.3 Comparison of Kernel Density plots 44 9 Conclusion & Future Work 46 9 .1 Conclusion 4 6 9 .2 Conclusion 4 7 9 .3 Future Work 4 8 10 References 4 9 11 Appendix 50 11 .1 Similarity Check Report 5 8 ix List o f Figure s Figure No. Title Page No. 3 .1 Control System Block Diagram 3 3 .2 General - linear model Structure 5 3 .3 AR Model Structure 6 3 .4 ARX Model Structure 6 3 .5 ARMAX Model Structure 7 3 .6 BJ Model Structure 7 3 .7 Effect of gain on the closed - loop response of first - order system with integral mode 10 3 .8 Effect of gain on the closed - loop response of first - order system with PID control 1 1 3 .9 Block Diagram of PID Controller 1 1 4 .1 Arduino Uno 1 3 4 .2 MAX6675 Pin Configuration 1 4 4 .3 IRFZ44N Pinout 1 5 4 .4 BC547 Transistor Pinout 1 5 4 .5 Rotary Encoder 1 6 4 .6 16 X 2 LCD interfaced with I2C 1 6 5 .1 Schematic Diagram 1 7 5 .2 Block diagram of the Hardware setup 1 7 5 .3 PWM Response for varying duty cycle 1 8 6 .1 Code Snippet for preprocessing input 1 9 x 6 .2 Code Snippet for preprocessing output 19 6 .3 Smoothened Input Voltage 20 6 .4 Smoothened Output Temperature 20 6 .5 Code Snippet for estimating the input delay 2 1 6 .6 Estimated output delay 2 1 6 .7 Impulse Response 2 2 6 .8 Code Snippet for model estimation 2 2 6.9 Creating transfer function 2 3 6.10 Plotting the open loop response and finding Rise time and settling time 2 3 6.11 Bode plot and gain margins snippet 2 4 6.12 Bode plot 2 4 6.13 Ziegler Nichols method 2 5 6.14 Closed - loop system response 2 6 6.15 Code snippet of implementing ZN tuning values 2 7 6.16 Plotting the P, PI, PID controller response 2 7 7 .1 Importing the Libraries 28 7 .2 Calling describe() on the columns 29 7 .3 Scatter plot between the Voltage and Temperature 29 7 .4 Calling spearmanr() 3 0 7 .5 Q - Q plot for Voltage 3 1 7 .6 Q - Q plot for Temperature 3 1 7 .7 Q - Q plot for Voltage after log transform 3 2 xi 7 .8 Q - Q plot for Temperature after log transform 3 3 7 .9 Code snippet for boxcox transformation 3 3 7 .10 Probability plot before and after boxcox transformation 3 4 7 .11 Code Snippet for Linear Regression 3 4 7 .1 2 distplot() on Voltage 3 5 7 .1 3 distplot() on Temperature 3 6 7 .1 4 Code Snippet of Prediction 3 6 7. 1 5 Prediction Scatter plot 37 8.1 Simulated Response Comparisons 38 8.2 Residual Correlation Output 40 8.3 Response Curve of P,PI,PID controllers 41 8.4 Linear Regression Visualization 42 8.5 Box plot of Voltage 43 8.6 Box plot of Temperature 43 8.7 kdeplot() for error 44 8.8 kdeplot() for predicted temperature 44 xii List o f Tables Table No. T able name Page No. 6.1 Ziegler Nicholas Table 2 6 7 .1 KS Test Results Before Log transform 3 2 7 .2 KS Test Results After Log transform 3 3 8.1 Model Coefficients 39 8.2 Ziegler Nicholas Table with values calculated for this system 41 xiii ABBREVIATIONS PID Proportional Integral Derivative PC Personal Computer MOSFET Metal Oxide Semiconductor Field Effect Transistor AR Auto - Regressive ARX Auto - Regressive e x ogenous ARMAX Auto - Regressive Moving Average e x ogenous SISO Single Input Single Output MIMO Multiple Input Multiple Output MISO Multiple Input Single Output USB Universal Serial Bus GND Ground PWM Pulse Width Modulation AREF Analog Reference TX Transmitter RX Receiver SP Setpoint DC Direct Current LCD Liquid Crystal Display ZN Ziegler Nicholas IDE Integrated Development Environment LED Light Emitting Diode xiv NOTATIONS English Symbols e(t) - error with respect to time 𝐾 𝐶 - proportional gain 𝑝 𝑠 - controller’s bias r(t) - input with respect to time T i - load disturbance T R - set point T m - measured variable T – controlled variable 𝑇 𝐼 - integral time 𝑇 𝐷 – derivative time u(t) - controller output with respect to time y(t) - system output with respect to time Greek Symbols 𝛜 - erro r 1 CHAPTER 1 INTRODUCTION 1.1 INTRODUCTION Modern industries involving robotics, power plants , and sc ientific workstations have always utilized the de signs of the closed loop systems. The extensive use of control systems is visible in the temperature control of process stations, feed water regulation in steam boilers, movement control of the robotic parts , and countless more applications. One such popular impl ement ation is the PID algorithm . The ease of flexible implementation, it’s precise control decision and low cost of the controllers make it relatively popular compared to the other conventional controllers . The design of PID based control system of a specific process variab le necessitates a separate set of hardware components such as unique PC station for workspace, bulky wires for transmission , etc. This design principle can leave a huge carbon footprint on the associated environment and can also lead to additional costs co rresponding to the hardware complexity. 1.2 MOTIVATION This proje ct proposes a novel design approach emphasizing the usage of smart embedded microcontrollers such as Arduino and related components to achieve a smart control system with reduced hardware complexity. Such a type of design approach can aim to improve the in dustrial standards of the process control laboratory to Industry 4.0 and also improve the experimental learning outcom e of the laboratory. The data - driven modeling methods can be employed to develop models of the system which can offer the superior predict ion and accurate fit than that of the conventional design methods. 2 CHAPTER 2 OBJECTIVES The following are the process objectives to achieve the design of a data driven based controller for the temperature process: • Deploy a hardware implementation of the closed loop system for a temperature controlling process using the microcontroller and the associated electronic components. • Taking the experiment dataset into consideration, estimate various data driven polynomial models to represent a open loop plant. • Design a PID Controller for the obtained plant model • Perform statistical analysis to get bet ter insights about the behavior of data, and interpreting the relation between the process variables. 3 CHAPTER 3 LITERATURE REVIEW 3 .1 BASIC COMPONENTS OF A CONTROL SYSTEM Fig 3 1 Control System Block Diagram Where T i - load disturbance T R - set point T m - measured variable T – Controlled variable 3 .1.1 Measuring element/sensor As seen from fig 3 .1 , a s ensor detects the changes in any physical quantity of interest based on the response of an external stimulus and converts it to an electrical quantity for further processing. 3 .1.2 Final control element/actuator As seen from fig 3 .1 , a hardware control mechanism that implements a control action on the environment or the manipulated variable based on the command signa l received from the controller. 4 3 .1.3 Controller As seen from fig 3 .1 , the controller compares the feedback and the set point and produces the difference as error value to generate an actuating signal to drive the control mechanism. 3 .1.4 Process As seen from fig 3 .1 , the process is where t he actual reaction takes place designed with a list of control objectives. 3 .2 DATA - DRIVEN MODELING Chinesta Francisco, Gomez - B ombarelli, Kutz Nathan .J and Montans Francisco J ., (2019), “ Data - driven modeling and learning in science and engineering”, Data - Based Engineering Science and Technology, C. R. Mecanique 347 (2019) 845 – 855. This research paper reviews the applications of data driven modeling and procedur e s in various fields of techn ology. It emphasizes the abundance of data and its availability and how unbiased useful insights can be taken into the learning experience from the actual data observations in contrast to the classical scientific approach based on hypothesis testing and ex perimentation in a slow progressive manner with a limited amount of data. Rojas Fern andez, J.D. (2016), “ Data - D riven Control: a new important field in control theory ” This paper presents multiple various data - driven modeling methodologies to directly estim ate the system parameters purely from the data of the plant without the intermediate steps of the identification and simulating the test results. It explains the Iterative Feedback Tuning (ITF) technique to repeatedly minimize a control criterion and also the correlation based tuning to make the associated signals associated. Taking experimental data into consideration, the model and identification of the controller are performed using data - driven based modeling. The increasing rise of modern computers in recent years has led to huge advancements in machine learning techniques and statistical computations Due to technological advancements, the machines have now increase d computational capabilities, more data storage facility , etc. The model control design process initially requires the modeling of the plant, analyzing the results and developing a controller based on the model prediction, and consequently simulating the p lant and the controller as a part of closed loop system. This type of modeling architecture can help in the usage of first principle models, better identification of physical constraints , and capturing physical dynamics. These models can also provide direc t interp retation, critical insights. A suitable model structure needs to be chosen before its estimation which is based on th e understanding of the dynamics of the closed loop systems The commonly employed models for system identification includes the black box model ling , grey box model, and user - defined model. Systems are not defined for t he black - box model and all model paramet ers can be 5 considered adjustable without verifying the process dynamics. The parameters ca n be arbitrarily adjusted. The grey - box model makes an assumption that part of the information about the physical dynamics or some parameters are already known. The system parameters are assumed to possess partial constraints. 3.2.1 Black - box model An arsenal of parametric models describes the system in differential equa tions and transfer functions. The structures provide insights into the system dynamics and compact design. General – linear model A system can be defined by the following equation 𝑦 ( 𝑛 ) = 𝑞 − 𝑘 𝐺 ( 𝑞 − 1 , 𝜃 ) 𝑢 ( 𝑛 ) + 𝐻 ( 𝑞 − 1 , 𝜃 ) 𝑒 ( 𝑛 ) ( 3 .1) From fig 3 .2 we can see that t he general - linear model give s flexibi lity for both the system as well as the stochastic dynamics. This approach uses heavy computation with no confirmation of the global convergence and utilizes a non - linear optimization approach to compute the parameters. Fig 3 .2 General - linear model Structure Simplified models are derived from this structure By setting one or more coefficients as other models can be developed