# Design and Implementation of Fuzzy Approximation PI Controller for Automatic Cruise Control System

Authors: Pallab Maji; Sarat Kumar Patra; Kamalakanta Mahapatra
Journal: Advances in Artificial Intelligence
 (2015)

---

## Abstract

Fuzzy logic systems have been widely used for controlling nonlinear and complex dynamic systems by programming heuristic knowledge. But these systems are computationally complex and resource intensive. This paper presents a technique of development and porting of a fuzzy logic approximation PID controller (FLAC) in an automatic cruise control (ACC) system. ACC is a highly nonlinear process and its control is trivial due to the large change in parameters. Therefore, a suitable controller based on heuristic knowledge will be easy to develop and provide an effective solution. But the major problem with employing fuzzy logic controller (FLC) is its complexity. Moreover, the designing of Rulebase requires efficient heuristic knowledge about the system which is rarely found. Therefore, in this paper, a novel rule extraction process is used to derive a FLAC. This controller is then ported on a C6748 DSP hardware with timing and memory optimization. Later, it is seamlessly connected to a network to support remote reconfigurability. A performance analysis is drawn based on processor-in loop test with Simulink model of a cruise control system for vehicle.


---

## Body

## 1. Introduction

Fuzzy logic controllers (FLC) have gained high appreciation in nonlinear control [1, 2] although Proportional-Integral-Derivative (PID) controllers and model predictive controllers (MPC) are widely used in industrial processes [3–5]. This is mainly due to its aptitude which can counter nonlinear control problems by programming heuristic knowledge. These heuristics are derived from expert human knowledge and the input and output relationship of the process. However, it is vital that the heuristic knowledge is derived from plant experts. But it has been observed that skilled and expert operator for a process plant is a scarce resource. It is also a proven fact that human knowledge is often prone to error. Therefore, it becomes critical that correct system heuristics are used to derive the fuzzy control parameters. Many designs in the literature have used evolutionary techniques for fuzzy parameter (FCP) extraction [6–8]. However, these methods eliminate the human knowledge from these controllers, which is so imperative. This paper introduces a generic fuzzy logic controller system (G-FLCS) which extracts FCP from an input-output relationship of a plant using genetic algorithm and provides a web based user interface (WebUI) for users to tweak these parameters for fine tuning of the fuzzy control system. This system provides a remote accessibility and control over systems. Internet-of-things (IOT) has already been a revolution in the automation industry. Fuzzy logic has been extensively used in ACC and collision avoidance system over the years [9–11]. However, this paper presents a system that controls an automatic cruise control (ACC) unit of a vehicle using fuzzy logic and connects it seamlessly to the Internet which will allow technical support engineers to remotely configure if it malfunctions. ACC has been used in this paper as an example subsystem of a vehicle, but this feature of remote reconfigurability can be extended to other modules of vehicle automation and advance driver assistance systems (ADAS). Figure 1 graphically describes the control strategy employed for the ACC.Figure 1
Block diagram of automatic cruise control system.This paper is organized as follows. In Section2, mathematical modeling of ACC is described and is simulated in Section 3 for data collection. Fuzzy logic approximation control is explained in Section 4 and the proposed hardware G-FLCS is implemented in Section 5. Performance analysis of this controller with reference to PID controller and model predictive controller is drawn in Section 6. The paper is finally concluded in Section 7 and followed by the references used during this research work.


## 2. Mathematical Modeling Automatic Cruise Control System [12]

Consider a vehicle of massm moving at a velocity v. A force F is generated from the engine while a disturbance force Fd is resisting motion of the vehicle [12, 13]. Therefore, the equation of motion of the vehicle is given by(1)mdvdt=F-FD.The vehicle engine generates force F which is proportional to the rate of injected fuel in the engine. This phenomenon in turn controls the throttle of the vehicle. Torque produced T at engine speed ω can be mathematically represented as(2)Tω=Tm1-βωωm-12,where Tm is the maximum torque generated by the engine at full throttle to attain ωm and the maximum engine speed with torque coefficient β. For a gear ratio n and wheel radius r, current velocity can be related to the engine speed by the following equation:(3)ω=nrv=αnv.Therefore, the driving force can be computed as(4)F=nurTω=αnuTαnv.Basically, there are three major disturbance forces working on the vehicle, namely, gravitational force (FG), rolling friction of the road and vehicle tires (FR), and aerodynamic drag due to the body of the vehicle (FA)(5)FD=FG+FR+FA.The gravitational force acting on the vehicle can be modeled based on the slope of the roads(6)FG=mgsin⁡θ,(7)FR=mgCrsgn⁡v,(8)FA=12ρCdAv2.Combining (5) and (6), (1) becomes(9)mdvdt=αnuTαnv-mgsin⁡θ-mgCrsgn⁡v-12ρCdAv2.


## 3. Simulation of Automatic Cruise Control System

The mathematical model of an ACC presented in Section2 is simulated in MATLAB/Simulink with a PID controller. The Simulink model as presented in Figure 2 is simulated and the system response is observed and recorded. This recorded dataset is further used to extract fuzzy control parameter (FCP) which drives the G-FLCS. This method is carried out using PID control algorithm and, therefore, the G-FLCS eventually approximates the system response of the PID controller. However, since the control algorithm uses fuzzy logic in its core, a fast and easy tracking is observed.Figure 2
Simulink model of automatic cruise control.


### 3.1. Control Algorithms

There are various control algorithms in literature that have been effective in automatic cruise control systems [8, 9, 14, 15]. However, these control algorithms do not provide a system which can be remotely controlled. The system responses cannot be fine-tuned on-field. Moreover, control algorithms like model predictive control (MPC) and PID control are generally sluggish in their approach. In this paper, the system response with proposed G-FLCS control algorithm is compared to system responses with MPC and PID control as presented in Figure 3.Figure 3
Simulink model of automatic cruise control system with MPC, PID, and proposed G-FLCS on C6748 DSP hardware.


### 3.2. Data Collection for Proposed Controller Design

A system response with maximum of four inputs and one output is recorded. Once the dataset is derived, it is passed on to the system for FCP extraction. The proposed method for FCP extraction is based on genetic algorithm. In this algorithm, there are 40 system parameters that are varied according to genetic algorithm to achieve two objectives, namely,(i)
quick settling,(ii)
tracking reference.The Simulink model with initial FCP is used as an objective function which returns the transient and settling time. The coordinates of the membership functions are nonlinear inequality constraints. Thus, varying these FCP will provide an absolute tracking of reference (the codes can be downloaded from https://goo.gl/Zb17fZ).Throughout this implementation process, data synchronization and communication between user and the hardware G-FLCS are critical as it can be observed in Figure5. This figure depicts how data communication can be achieved with the help of various control signals between client-server and server-hardware G-FLCS. A web application provides a systematic user interface which collects data from authenticated users. The application waits for a new connection request on startup. On successful login, a user is presented with a web page containing four different tab-windows, each for basic parameters and information about inputs, outputs, and Rulebase. These windows will be preloaded with extracted parameters as shown in Figure 4 and can provide a way for fine-tuning the control parameters by an operator. In Figure 5, operations like connections, login, parameter collection, and communication with H-FLC through a server program are performed by the web application and are shaded inLight Grey. When a user provides the fuzzy control parameters (FCP) data, the web application validates the entered data based on the following protocols.(i)
All MFs have properly defined coordinates within specified range of operation.(ii)
Number of inputs and outputs is correctly defined.(iii)
Rules are validated according to Mamdani model.After validation of new parameters, the server application connects serially to the hardware G-FLCS. Serial communication protocol is used in this paper for the ease of implementation. This data communication can be easily extended to industry standard controller area network (CAN) protocol. G-FLCS completes current execution and generates control signal to the system. Thereafter, it acknowledges any incoming serial communication request and starts receiving and storing fuzzy parameters in the data memory. Sys/BIOS is a widely used real time operating system for TI DSPs and has been used in this work to take care of the multitasking of fuzzy processes.Figure 4
Fuzzy control parameter (FCP) extraction using genetic algorithm.Figure 5
Dataflow of the proposed G-FLCS system.


## 3.1. Control Algorithms

There are various control algorithms in literature that have been effective in automatic cruise control systems [8, 9, 14, 15]. However, these control algorithms do not provide a system which can be remotely controlled. The system responses cannot be fine-tuned on-field. Moreover, control algorithms like model predictive control (MPC) and PID control are generally sluggish in their approach. In this paper, the system response with proposed G-FLCS control algorithm is compared to system responses with MPC and PID control as presented in Figure 3.Figure 3
Simulink model of automatic cruise control system with MPC, PID, and proposed G-FLCS on C6748 DSP hardware.


## 3.2. Data Collection for Proposed Controller Design

A system response with maximum of four inputs and one output is recorded. Once the dataset is derived, it is passed on to the system for FCP extraction. The proposed method for FCP extraction is based on genetic algorithm. In this algorithm, there are 40 system parameters that are varied according to genetic algorithm to achieve two objectives, namely,(i)
quick settling,(ii)
tracking reference.The Simulink model with initial FCP is used as an objective function which returns the transient and settling time. The coordinates of the membership functions are nonlinear inequality constraints. Thus, varying these FCP will provide an absolute tracking of reference (the codes can be downloaded from https://goo.gl/Zb17fZ).Throughout this implementation process, data synchronization and communication between user and the hardware G-FLCS are critical as it can be observed in Figure5. This figure depicts how data communication can be achieved with the help of various control signals between client-server and server-hardware G-FLCS. A web application provides a systematic user interface which collects data from authenticated users. The application waits for a new connection request on startup. On successful login, a user is presented with a web page containing four different tab-windows, each for basic parameters and information about inputs, outputs, and Rulebase. These windows will be preloaded with extracted parameters as shown in Figure 4 and can provide a way for fine-tuning the control parameters by an operator. In Figure 5, operations like connections, login, parameter collection, and communication with H-FLC through a server program are performed by the web application and are shaded inLight Grey. When a user provides the fuzzy control parameters (FCP) data, the web application validates the entered data based on the following protocols.(i)
All MFs have properly defined coordinates within specified range of operation.(ii)
Number of inputs and outputs is correctly defined.(iii)
Rules are validated according to Mamdani model.After validation of new parameters, the server application connects serially to the hardware G-FLCS. Serial communication protocol is used in this paper for the ease of implementation. This data communication can be easily extended to industry standard controller area network (CAN) protocol. G-FLCS completes current execution and generates control signal to the system. Thereafter, it acknowledges any incoming serial communication request and starts receiving and storing fuzzy parameters in the data memory. Sys/BIOS is a widely used real time operating system for TI DSPs and has been used in this work to take care of the multitasking of fuzzy processes.Figure 4
Fuzzy control parameter (FCP) extraction using genetic algorithm.Figure 5
Dataflow of the proposed G-FLCS system.


## 4. Fuzzy Logic Approximation Control (FLAC)

The proposed system architecture involves hardware-software codesign to present a complete reconfigurable G-FLC as shown in Figures6(a) and 6(b). The WebUI in client-server model represents the software and the driver layer to interface the H-FLC through serial port. The DSP hardware receives FCP data serially and stores them. These parameters are segregated into two categories, namely,Setup andRulebase data. The driver layer in the hardware G-FLCS receives and acknowledges the data transmission.Figure 6
Proposed M-FRHC based H-FLC design architecture.
(a)
System architecture
(b)
Hardware design


## 5. Hardware Realization on TI C6748 DSP

### 5.1. Code Optimization

Code written in assembly (ASM) is processor-specific C code that can readily be ported from one platform to another. However, optimized ASM code runs faster than C and requires less memory space. Before optimizing, make sure that the code is functional and yields correct results. After optimizing, the code can be so reorganized and resequenced that the optimization process makes it difficult to follow. One needs to realize that if a C-coded algorithm is functional and its execution speed is satisfactory, there is no need to optimize further. But this motivates us to stretch the optimization such that we can extract the best possible efficiency from the system [16].Step 1.
G-FLC is programmed in C language without using any compiler optimization levels.Step 2.
Intrinsic functions are used along with various optimization levels. Functions like minimum (min), maximum (max), product (prod), and division (div) are written as intrinsic functions and called necessary by the modules and submodules of G-FLCS.Step 3.
Thereafter, the profiler is used to determine and identify the functions and submodules that may need further optimization. Later, these functions are converted to linear ASM.The compiler can insert calls to special functions in the run-time support library (RTS) to support operations that are not natively supported by the ISA. For example, the compiler calls__c6xabi_divi() (_divi() in COFF) function to perform 32-bit integer divide operation. Such functions are called compiler helper functions and result in a function call within the loop body. For example, in G-FLC, the compiler accomplishes the division operation by calling the compiler helper function “_divi” in fuzzification and defuzzification modules [16–18].


### 5.2. Code Implementation

Code Composer Studio (CCS) is a proprietary integrated development environment developed by TI for programming DSP and ARM processors. The design is programmed in C language and optimized as described in Section5. Thereafter, it is cross compiled using CCS v5.5 compiler and implemented on TMS320C6748 as a target DSP processor. This system represents the hardware G-FLCS as discussed previously. G-FLCS is connected to a server PC using on-board UART and provides a platform which is capable of accepting FCP file to operate as a standalone tunable G-FLCS. Detailed memory utilization of the built code is shown in Figure 7. It can be observed that the code size without optimization acquires 66% of the SHRAM and has a code size of 88 K in comparison to 61% of the SHRAM and code size of 80 K with code optimization technique described in Section 5.1.Figure 7
Memory utilization of proposed system realized in TI C6748 DSP.
(a)
Without optimization
(b)
Optimization


## 5.1. Code Optimization

Code written in assembly (ASM) is processor-specific C code that can readily be ported from one platform to another. However, optimized ASM code runs faster than C and requires less memory space. Before optimizing, make sure that the code is functional and yields correct results. After optimizing, the code can be so reorganized and resequenced that the optimization process makes it difficult to follow. One needs to realize that if a C-coded algorithm is functional and its execution speed is satisfactory, there is no need to optimize further. But this motivates us to stretch the optimization such that we can extract the best possible efficiency from the system [16].Step 1.
G-FLC is programmed in C language without using any compiler optimization levels.Step 2.
Intrinsic functions are used along with various optimization levels. Functions like minimum (min), maximum (max), product (prod), and division (div) are written as intrinsic functions and called necessary by the modules and submodules of G-FLCS.Step 3.
Thereafter, the profiler is used to determine and identify the functions and submodules that may need further optimization. Later, these functions are converted to linear ASM.The compiler can insert calls to special functions in the run-time support library (RTS) to support operations that are not natively supported by the ISA. For example, the compiler calls__c6xabi_divi() (_divi() in COFF) function to perform 32-bit integer divide operation. Such functions are called compiler helper functions and result in a function call within the loop body. For example, in G-FLC, the compiler accomplishes the division operation by calling the compiler helper function “_divi” in fuzzification and defuzzification modules [16–18].


## 5.2. Code Implementation

Code Composer Studio (CCS) is a proprietary integrated development environment developed by TI for programming DSP and ARM processors. The design is programmed in C language and optimized as described in Section5. Thereafter, it is cross compiled using CCS v5.5 compiler and implemented on TMS320C6748 as a target DSP processor. This system represents the hardware G-FLCS as discussed previously. G-FLCS is connected to a server PC using on-board UART and provides a platform which is capable of accepting FCP file to operate as a standalone tunable G-FLCS. Detailed memory utilization of the built code is shown in Figure 7. It can be observed that the code size without optimization acquires 66% of the SHRAM and has a code size of 88 K in comparison to 61% of the SHRAM and code size of 80 K with code optimization technique described in Section 5.1.Figure 7
Memory utilization of proposed system realized in TI C6748 DSP.
(a)
Without optimization
(b)
Optimization


## 6. Performance Analysis

A performance analysis between MPC, PID, and proposed hardware G-FLCS is drawn after a hardware-in-loop simulation of Simulink model presented in Figure3 is completed. The ACC system response under the influence of individual controllers is plotted in Figure 8(a). It is evident from comparing responses of these controllers that the fuzzy approximated PI controller has a very less settling time and a fast transient response. However, the fuzzy controller structure provides an option to fine-tune the control parameters on run-time. Moreover, mathematical model of the ACC plant was also not in the vicinity while formulation of fuzzy parameters was undertaken and Figure 4 abundantly explains this, hereby reducing the computational complexity which exponentially increases with the increase in input variables. The control output from the proposed hardware G-FLCS closely matches the control output from the Fuzzy Toolbox of MATLAB. A mean square error of 0.13 was recorded. Figure 8(b) shows the control output of the two fuzzy logic controllers when operated on the ACC plant model.Figure 8
(a) Response of ACC under influence of various controllers, (b) control output of hardware G-FLCS and MATLAB Fuzzy Toolbox with same FCP.
(a)
System response
(b)
Control output


## 7. Conclusion

It is evident from the responses of the three controllers presented in Figure8(a) that proposed FLAC has a very less settling time and a fast transient response compared to others. Mathematical model of the plant was not in the vicinity while formulation of fuzzy parameters was undertaken. A parameter extraction technique inspired with genetic algorithm is implemented on an ACC process to provide the applicability of the proposed idea. The resultant hardware FLAC is found to have a low computational complexity and high code density and connects seamlessly to the local area network (LAN).



---

*Source: 624638-2015-11-15.xml*