You are on page 1of 9

Design and Fuzzy Logic Control Implementation for Embedded Systems Using Microcontrollers.

Application for Drive two Electric Furnaces. H. FEKHAR and A. KHELASSI Laboratory of applied automation Faculty of hydrocarbons and chemistry Boumerdes University E-mail :hfekhar1952@yahoo.fr, madjidk@hotmail.com

Abstract : This article describes the application of the microcontroller by using fuzzy logic algorithm to drive two electric furnaces. The first part of the paper consists of presentation hardware device. We have five distinct sections. A Pic18f4620 microcontroller, keypad unit, electronic drivers and alphanumeric liquid crystal display(LCD). The keypad allows the user to input the required temperatures and controllers parameters. The LCD display allows a better user interface with text message, measurement of physical variables and display all controllers parameters. The external integrated circuit is used to drive a power amplifier (SSR) .The software was written in C language dedicated for microcontrollers. A fuzzy logic control approach has been proposed to control the temperature of furnaces. This algorithm is implemented to reduce the performance degradation due to parameters variations and disturbances. Keywords: Microcontroller, keypad, sensor, shift registers, implementation, fuzzy logic control 1.Introduction The use of microcontrollers with a closed loop control incorporating fuzzy logic has been developed for a class of industrial temperature control problem [1]. Fuzzy logic control(FLC) has been rapidly gaining popularity among practicing engineers. This increased popularity can be attributed to the fact that fuzzy logic provide a powerful vehicle that allows engineers to incorporate human reasoning in the control algorithm. The use of microcontrollers is in full expansion nowadays. This embedded system has been used in many industrial applications. Currently these devices with programmable memory and many ports with Alternate function pins facilitate the connection to external devices. This present paper consists to develop the embedded system using Microchip PIC18F4620 to control two electric furnaces. Fuzzy microcontroller PIC is used for the implementation. 2. Hardware description [2] In this part we present the system hardware. The system is composed of PIC board, integrated circuits, two electric furnaces, sensors and software package. The overall system hardware is shown in figure1.It consist of the following sub systems: -(1) is microcontroller pic 18F4620 with flash -(2) and ( 3) are the CMOS 4094 serial in parallel out shift register. This IC is used to control DAC0800[3]. Its inputs require three lines (pins rd0 , rd1 and rd2). (4) and (5) are the DAC0800(digital to analog converter). These circuits are used to drive power amplifiers. (6) and (7) represent the power source to heater actuated by a solid state relay(SSR) -(10), (11) and (12) are temperatures sensors(AD590 and Pt100) and measurement amplifiers. These devices produces 100 mv/C. -(14) and (15) represent the 16 buttons keypad and LCD display. These devices provide

an Interface between the user and the Microcontroller development system. The keyboard allows the user to input the required temperatures and other operating parameters as required by the application program. The LCD module displays all controllers parameters. 3.Design and implementation of fuzzy controller [4 ,5 ,6 ]. 3.1.Fuzzy controllers structure. Fuzzy logic has been found to be very suitable for embedded control application. The bloc diagram is presented in figure2. The three principal elements to a FLC are: - Fuzzification module Rule base and inference engine. Defuzzification module. A.Fuzzification . On of the key part in the design of FLC is choosing the number of fuzzy sets. The inputs are the errors (e1, e2) between the references (Rf1 , Rf2) and actual temperatures ( Tm1, Tm2) and the changes in errors ( Ce1 , Ce2). The variables can be expressed as fellows: e1(k) = Rf1(k) Tm1(k) (1) e2(k)= Rf2(k) Tm2(k) (2) Ce1(k)=e1(k)-e1(k-1) (3) Ce2(k)=e2(k)-e2(k-1) (4) Where (k) is the time index.

from -1 to 1. The changing of scaling factors , changes the normalized universes of discourse. These parameters are used for tuning the Fuzzy-Logic-Controllers (FLC1 and FLC2).The most popular choices for the shape are the membership functions (MF) include triangle-trapezoidal function. For symmetrical (MF) there are some optimal values for the cross-point level and ratio. Each two adjacent MF have a cross-point level 0.5, this provides for significantly less overshoot, faster rise-time and less undershoot. This MF are chosen owing to the simplicity. In this paper, for errors and change errors seven fuzzy levels are defined as: fellow(figure 3): NB(negative big) NM(negative medium) NS(negative small) ZE(zero equal) PS(positive small) PM(positive medium) PB(positive big). Each MF are labeled A1(e1n),B1(Ce1n)

A2(e2n) B2(Ce2n).
Where A1, A2, B1, B2 define MF errors and change errors respectively. B.Inference rule and defuzzification In the fuzzy logic control the most commonly used method for inferring the rule output is so-called Mamdanis method. For a Mamdani-type FLC fuzzy rules are in the form: Ri :if en is A1 and en is Bi then un is Ci where Ai and Bi are fuzzy subsets in their universe of discourse and Ci is a fuzzy singleton. In this paper each universe of discourse is divided into seven fuzzy subset (NB NM NS ZE PS PM PB).The

The representation of the variables in terms of per unit values permits flexibility in design and tuning of controller. The following normalized equations can be written e1n(k)=Ge1*e1(k) ( 5) e2n(k)=Ge2*e2(k) (6) Ce1n(k)=Gd1*Ce1(k) (7) Ce2n(k)=Gd2*Ce2(k)(8) Ge1, Ge2, Gd1 and Gd2 define the scaling factors respectively errors and change of errors. The universe of discourse for errors and the change errors may be normalized

inference result of each rule consist of two parts, the weighting factors (Wi) of the individual rule and degree of change in duty ratio (Ci) according to the rule. (Wi) is obtained by mean of product[6 7]. The expert experience (figure4) has been incorporate into a knowledge base with 7x7 rules. The inferred output of each rule are : Wi1 =A1(e1n)*B1(Ce1n) (8) Wi2=A2(e2n) * B2(Ce2n) (9) Zi1=Wi1 * Ci1 ( 10 ) Zi2 = Wi2 *Ci2 ( 11) Where Zi1, Zi2 denote the fuzzy representation of change in duty ratio inferred by the ith rule. Index 1 and 2 denote the furnace N1 and N2.The defuzzification operation is performed next to obtain a crisp result. Here the center of gravity (COG) method is preferred. u1n = / (12) u2n = (13) where u1n and u2n are the results of change in duty ratio. The outputs un is incremental command. It is apparent that FLC1 and FLC2 are integral-type fuzzy controllers and force the steady-state temperatures error to zero. Consequently we have; U1(k)=u1(k-1)+Gu1*u1(k) (14) U2(k)=u2(k-1)+Gu2*u2(k) (15) 3.2.Control Implementation The microcontroller Pic18f4620 is used for the experimental application [7,8]. Pic with this feature provide 10-bit conversion giving a resolution of 1 to 1024.This is good enough for all but the most demanding applications (Pic incorporates 13 multiplexed A/D channel and running

at 40 Mhz).The CPU is driven by the software instructions to perform specific tasks. The instructions are written in highlevel language C dedicated for microcontrollers. DACs gives outputs U1(k) and U2(k). In our case we adopted serial-in/parallel out technique by using CMOS4094 shift registers. The idea is to put the serial data on the input line, LSB first(pin rd0) and clock(pin rd1) the shift registers 16 times(for 2*8 bit registers), stop (pin rd2) and read the parallel data from the Q0 to Q15 outputs. After 16 clocks pulses all 16 serial data bits have shifted In their appropriate pin. After initialization of the software, the steps for temperature control can be summarized as fellows: -The user enters command/dat, set points (Rf1, Rf2) and parameters FLC1 and FLC2 (ge1, Ge2, gde1, gde2, Gu1 and Gu2).The pic has to scan the keys regularly and check the keypad. If the key is pressed, the routine under execution display its response on the LCD. -The program has measure the physical variables(temperature Tm1,Tm2) by using the feedback sensors via 10 bits multiplexed A/D converter. The time acquisition(clock-conversion) equal fosc/2. The system operates on the average temperature reading from three sensors to give a more accurate representation of the overall temperature in the enclosure. -if a particular key is pressed, the CPU calculates the outputs control U1 and U2 than send the command via CMOS4094DACS.The scaling factors and sample period Ts can be modified by using the

appropriate keys for tuning the FLC1 and FLC2. In our implementation the total length of the fuzzy algorithm code is 29 kb which is 54 % of the picc program memory. There still remain 35 kb of the Pic18f4620 program memory, that are available for others purposes. 4.Experimental results In this section, an experiment is set up to demonstrate the performances of the FLC. Execution of the software that we have developed and implemented allows us to plot the graphs in a digital scope. Figure(8) shows the experimental results of the proposed FLC. In this figure the temperature-response and output command of the furnace1 and Furnace2 are represented. The first test is related to starting the command. A time responses of about 760s(furnace1) and 275s(furnace2) Is observed during the starting period. The controllers tracks the commanded temperatures reasonably well with a small Steady-state errors. The second test examines the disturbance rejection capabilities of each controller between 370s and 470s.The FLC quickly return the Temperature to the set point within 10s . 5 Conlusion A Fuzzy Logic Control(FLC) approach has been proposed to control the temperature of electric furnaces. The microcontroller PIC18F4620 is used for the implementation. To test and demonstrate the effectiveness of the proposed control, a prototype experimental setup has been developed (figure 6 , and figure7).

Implementation of fuzzy logic control algorithm in embedded microcomputers for dedicated application has shown good control. References [1]G.S.Nhivekar ,S.S.Nirmal,R.R.Muldhoker International journal of engineering science and technology V3 N4 2011 pp276-283 [2] H.Fekhar Application of the Microcontrollers for embedded systems Using an anti-windup P.I controllers . The 6th international symposium on hydrocarbons & chemistry Algier oct 2012. [3] W.Kleitz Digital electronics.A practical approach .Prentice-hall sixth edition 2003 [4]R.R.Yager,D.P.Filev;Essential of fuzzy modeling and control .John wiley & sons 1994. [5] B.K.Bose,G.C.D.Souza;A fuzzy set theory based control of a phase-controlled converter D.C machine drive;IEEE trans on indust applic V30 N1 Jan/fev 1994 pp 34-44. [6] H.Buhler;Rglage par logique floue Presses polytechnique romandes 1994 [7] J.Parab, S.A.Shinde,Practical aspect of embedded systems design using microcontrollers ,Springer Science 2008. [8]A.V.Deshmukh .Microcontrollers theory and applications.Tata McGraw-hill NewDelhi 2005. [9]A.M.Ibrahim ;Fuzzy logic for embedded systems applications Elsevier Science 2004 (u.s.a)

(1) PB P I C 1 8 rd0 F rd1 4 rd2 6 2 0 pc ra0 ra1

(13)

LCD Display (6) (8) (10)

4094 (2)

DAC1 (4)

4094 (3)

DAC2 (5) (11) (7) (12) (9)

Keyboard (14)

(13)

Rf(k) 6 2 microcontroller Pic18f4620 en Ge1,2

Figure 1. Schematic diagram

Uout FLC1 And FLC2 un(k) un(k) Gu 1/Z

1/z Gde1, 2

Cen

P L A N T

-Tm(k)

ADC

Signal conditionning

sensors

Figure 2. Block diagram fuzzy logic controllers ( FLC1 and FLC2)

Figure 3. Membership function error (e1n,e2n) and change error (Ce1n,Ce2n)

Figure 5 Membership functions Outputs u1n(k) and u2n(k)

Figure4. Rule base for (u1n) and (u2n)

Figure 6. Furnace N1 Sensors PIC18F4620 Conditionning circuit Lcd display Electronics drivers (CMOS4094-DAC ) Keypad Furnace N2

Figure 7. Fuzzy Microcontroller Board

(a) Starting periode

(b)

Disturbance rejection

Output control-temperature,Temperature response, Disturbance, Output control Rf1=75 C ,Rf2=50C, Ge1=Ge2=0.01, Gde1=Gde2=0.01,Gu1=Gu2=150,

Figure 8. Graphs control-Temperatures

You might also like