135
DESIGN OF FUZZY LOGE CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND PIPELINES A Thesis Presented to The Facuiw of Graduate Studies of The University of Guelph ki partial fuIfUment of requirments for the degree of Master of Science August, 1999

DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

DESIGN OF FUZZY L O G E CONTROLLER FOR THE

CATHODIC PROTECTION OF UNDERGROUND

PIPELINES

A Thesis

Presented to

The Facuiw of Graduate Studies

of

The University of Guelph

ki partial fuIfUment of requirments

for the degree of

Master of Science

August, 1999

Page 2: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

National Library Biblbthèque nationale du Canada

Acquisitions and Acquisiflions et Bibliographie Sivices serVrCes bibliographiques 395 Weiirngton Street 395. me Wdiington Ottawa ON Ki A ON4 OttawaON K l A W Canada Canada

The author has granted a non- exclusive licence allowhg the National LLbrary of Canada to reproduce, ban, distribute or sell copies of this thesis in microform, paper or electronic formats.

The author retains ownership of the copyright in this thesis. Neither the thesis nor substantial extracts from it may be printed or otherwise reproduced without the author's permission.

L'auteur a accordé une licence non exclusive permettant a la Bibliothèque nationale du Canada de reproduire, prêter, distribuer ou vendre des copies de cette thèse sous la forme de microfiche/nlm, de reproduction sur papier ou sur format électronique.

L'auteur conserve la propriété du droit d'auteur qui protège cette thèse. Ni la thèse ni des extraits substantiels de celle-ci ne doivent être imprimés ou autrement reproduits sans son autorisation,

Page 3: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

ABSTRACT

DESIGN OF FUZZY LOGIC CONTROLLER FOR

THE CATHODIC PROTECTION OF

UNDERGROUND PIPELINES

Xohamed S h Almardy

University of GueIph, 1999

Advisoc

Professor Gordon Hayward

Corrosion is one of the most serious problems that faces ail metals exposed to soil

and/or water. It becomes more serious in very large pipeline networks, where Failures

can have severe consequences, both environmentdy and economicallyY Therefore, it is

very important to study corrosion prevention for burïed pipelines. This work describes

the fuzzy control of a pipeline corrosion by using impressed current cathodic protection.

The purpose of this system is to maintain the distributed voltage of a steel pipeline at

the set point (850mV with respect to copper/copper sulfate reference electrodes) . The

fuzzy con t rok is applied to the system to improve the performance of the cathodic

protection, and to reduce power cost. The performance of the f u z y control system

depends on the control parameters, membership functions, control niles: and scalùig

factors. The fuzzy controller is constnicted of Enguistic contzol des. In this study the

control rules have been derived by modelling the cathodic protection of a buried

pipeline. The simulateci pipeline was divided of several points and by measuring the

voltage at each point, the right current required to inhibit corrosion was determined.

When controlling a single anode system with three measuring electrodes, a controiler

Page 4: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

determining corrections to the current output was shown to work weIl in simulation-

This controller was tuned by vaqbg the choice of the output rnembership functions.

The controller was extendeci to a two anode system by adding more des. Again the

controuer performed well in simulation. The simulation was then verified by operating

the controller on a physical çystem consisting of two anodes protecting a steel rod

buried in damp sand. The pdormance after retuning was very similar to that of the

simulation. Further tests where the anode size and location were changed gave expected

results-

Page 5: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1 am deeply obliged to my advisor Prof- G. L. Hayward for his guidance, continuous

support, helphil suggestiom and comments- His livehess was in.uabIe as a source of

encourgement in the preparation of this dissertation.

The valuable suggestion and opinions of Prof- 0. A. Basir were very much appreciated

by the author. Thaxiks is also extended to my fdow graduate students who offered'

encouragement and support.

This thesis is dedicated to my parents in my home country, and to my famiIy.

Page 6: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND
Page 7: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

4-2 Multi anode control design . - . . . . . . . . . - . - - - - - . . - - . - - 48

5 Experimental results 63

5.1 Results with different mernbership hinctions . . . . . - - - - . . . - - - - 65

5.2 Renits with different position and size of anodes . . - - . - - - - - - - . 72

6 Conclusions and Recommendations

A Simulation code of single anode system

B fuzzy logic control code for multiple anode system

Page 8: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND
Page 9: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

The hzzy cont101 simulation action with Big change M.5 and S m d

change fO.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

The f k z y controI simulation action with Big change I1.5 and Small

change fO.1 - . . . . . . . . . . . . . . . . - . . . . . . . . . . . . . . - . 56

The fuzzy control simulation action with different d e s and Big chang

fl.OandSmalLchangef0.1.. . . . . . . . . . . . . - . . . . . . . . . . 58

The fuzzy control simulation action with different rules and Big change

M.5andSmallchangekO.l.. . . . . . . . . . . . . . . . . . . . . . . - 60

The fuzzy control simulation action with Big change f0.8 and Sm&

change fO.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

The configuration of a real system . . . . . . . . . . . . . . . . . . . . . . 64

The h z y control performance with Big chartge f 1.0 and S m d change f0.1 66

The configuration of the anodes and reference dectrode positions fiom the

pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - 67

The fuzzy control performance with Big change I1.0 and Small change

AO.01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

The hzy control performance with Big change f0.5 and S m d change

1î0.01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - . . . . - - - 70

The fuzzy control performance with Big change f 0.5 and Small change f 0.1 71

The fuzy control performance with Big change f 0.2 and Small change f0.1 73

The hzy control performance with Big change f 0.2 and Small change

*0.01 . . . . . . . . . . . . . . . . - . . - - . . * . . . - - . . * . . - - - 74

The different size and position of the anodes . . . . . . . . . . . . - . . . 75

5.10 The h z y control pdormance with large anode sizes at P2 and P3 . . . 77

5.11 The fuzzy control performance with smd anode size at P2 and P3 . . . . 78

5.12 The fuzzy control petformance with s m d s&e anodes at positions Pl and

P4 . . . . . . . . . . . . . . . . . . . . . . . . . . - * . . . . . . . . - . . 79

Page 10: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

5.13 The h z y contIol performance with d size anodes at positions at P5

andP8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Page 11: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

List of Tables

4.1 The output regession in Iow sand conductivity . . . . . . . . . . . . . . 18

4.2 The output regression Ur high conducti-vi~ sand . . . . . . . . . . . . . 4 3

vii

Page 12: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 1

Introduction

- Corrosion is one of the most serious problems that faces a l l met& exposed to soils andior

water. It becomes more serious in very large pipeline networks that transport oil and

gas. Corrosion is the deterioration of a metal by chernical or electrochemical reaction

with its environment, and the corrosion of a piece of metal may be sumrnarized as the

change fkom the metal to metal ion [47]. Corrosion is caused by a flow of electricity from

one metal to another or fkom one part to another, an electrolyte is needed for this flow

[46]. The ions usually detach in solution or as a precipitate weakening the pipeline. The

process can be written electrically as :

M-, Mnf + ne-

Metal Positively charged metal ion + Negatively charged electron

To stop the corrosion, the protected pipeline requires a variable current. This cur-

rent is determined by the metal and the area of the pipeline, as welI as the surrounding

electroIyte. The major difliculty is that the soil resistiviw varies with climatic condi-

tions. Since soi1 resistance is a part of the system circuit, for a constant DC voltage the

DC current will vary as climatic conditions change. According to [[4 31, conventional

cathodic protection systems resolve this problem by manual adjustment of the DC volt-

age periodically to obtain constant current. Automaticdy regulated systems have been

Page 13: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

developed [12,18]. These systems sense the variations of sur~ounding medium resistivity

and the measured data concerning the cathodic protection and adjust the DC voltage of

the system.

According to [SI], the efIiciency of cathodic protection can be avoided if the potentials

of cathodic protection do not exceed the threshold values ( -0.55V to -0.85V ) relative

to the standard hydrogen eledrode.

This work describes the design of a fuzzy controller of a pipehe corrosion by using

impresed current cathodic protection The purpose of this system is t o maintain the

distributeci voltage of a steel pipeline at the set point (850mV with respect to the copper

/ copper sulfate reference electrodes). Fùzzy control is applied to the system to improve

the performance of the cathodic protection, and to d u c e power cost.

The performance of the fuzzy control system depends on the control parameters,

membership fimctions, control des, and scaling factors. The fwzy controuer is con-

stnicted by linguistic control rules, which are composed of the fuzzy variables and the

hizzy sets. In this study, the funy control rules have been derived by modeling the ca-

thodic protection of buried pipeline. The simulated pipeline is divided at several points

and by measuring the voltage at each point the right amount of current given the number

and location of each anode is determinecl-

Mamdani's fuzzy inference method was used to process the control system for cathodic

protection. In this study Mamdani2s method was among the first control systemç b d t

using fuzzy set theow E t was proposed in 1975 by Ebrahim Mamdani [29] as an attempt

to control a steam engine and boiler combination by synthesbing a set of linguistic control

rules. The inference method used here differs somewhat fkom the methods described in

the original papes [38], however the basic idea is much the same.

The Fuzzy controller (FC) in this study contains an integral action ( the summation

of the changing current ) which eliminates the o s e t and it derives its control action from

a d e base containing linguistic rules which have the form:

Page 14: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

(CONDITIONS ARE SATISFIED) T m N (CONSEQUENCES MAYBE INFERRED) .

This kind of knowkdge-based control becomes very usefd when the processes of

cathodic protection to protect the long pipeline in cliffixent soi1 resistivitsf are too com-

plex for analysis using conventional control algorïthms and the construction of a precise

mathematical mode1 is too difEicult. An inteIligent controller of this type has si@cant

commercial benefits. Eliminating the rigorous mathematics in implementing a control

system will make the technology adable.

1.1 Thesis objectives

The primary objective of the fuzzy control is the development of an independent con-

trol system capable of giving optimal control of an impressed current system to protect

pipelines. Two objectives have been identifid

4 Developing a fuzzy controller for single and multiple anode systems.

+ Testing the controller on both simulated and physical pipeline models.

Page 15: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 2

Background

2.1 Corrosion

There are three important objectives of corrosion studies: economic, which is the reduc-

tîon of material losses; improvement in the safev, operating equipment may fail with

catastrophic consequences, and the conservation of metallic resources [4].

Around 1815, Wollaston regarded corrosion by acids to be an electrochemical process.

In 1824, Davy showed that when two dissimilm met* are imrnersed in water, one of

the met& is corroded and the other received a degree of protection, later this work was

followed by the investigations of Faraday into the correlation of electrical and chemical

phenornena, and from these he was able to derive his laws of electrochemical action which

give the relationship between the current and the associated rate of corrosion [35].

Since metallie corrosion is an electrochemical process, it is very important to under-

stand the basic nature of electrochemical reactions- There are two basic requirements:

anodes where corrosion occurs and current Ieaves the metal and enters the electrolyte.

and cathodes where no corrosion occurs and the current enters the metal from the solution

[13]. Electrochemical reaction means the simultmeous occurrence of chemical changes

and exchange of electrïcal energy, which means whenever corrosion takes place there is a

flow of electric current hom corroding areas of the metal into the electrolyte.

Page 16: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

This electric m e n t flowing korn the metal c e with it metal ions. As the metallie

ions dissolve in the eIectrolyte, they display hydrogen ions which flow to the cathode and

deposit as hydrogen gas. For instance, the corrosion of a piece of iron, the metallie iron

is converted to an iron ion by giving up two dectrons (oxidation) which replace hydrogen

ions. These move to the cathode where they are reduced to fonn hydrogen gas [47]-

The corrosiveness of a soil environment is imidy a h c t i o n of the electrical resistivity

of the soil; therefore, soils of low electrical resistivity tend to be corrosive, while soils of

high electrical resistivity tend to be l es cormsive [BI. Failures in pipeLines can have swere consequences, both environmentally and ec*

nomically. Therefore, it is very important to study corrosion prevention for buried pipes.

Many systems have been proposed to decrease the rate of corrosion of buried pipelines-

The most widely used, is protection by an impressed current. In this system, the anodes

are inert electrodes that are connected to a power supply to force the reaction to the le&,

that is to prevent ion formation. To solve the problem, Grst knowing the reason or the

cause of this problem, and then try to find the ided solution for it.

2.2 Cause of corrosion

For the causes of corrosion, there are five major causes of corrosion; galvanic effect

which caused by both, the differential electrolyte conditions (the same metal is placed in

two different electrolyt~), dissimilar metals, stray current, direct chernical attack, and

rnicrobiological attadc.

Page 17: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Corrosion occurs when dissimilar eIectroIyte allow current to flow fkom one part

of a metal s&e to another for various reasons such as different ~ r p g of soil in contact

with a continuous length of a pipe, variation in the adability of oxygen, and difference

in moisture content of electroIytes. Additional variations can be of chernical nature, such

as PH and chemical constituents-

Accordkg to [17], when a pipeline traverses dissidar soilç, the pipeline in a pârticular

soil electrolyte will often assume a galvanic potential that is somewhat dif%rent fkom the

potential of portions of the same pipehe traversing dissimilar soils elsewhere along the

route. Soils that have varying levels of oxyge~ concentration will be subject to corrosion

where the part of the pipe in the lowest oxygen concentration is fixing corrosion-

Corrosion can occur when two dissimilai- metals are immersed in a corrosive or con-

ductive solution, as a resuit of the diffaence in potential existbg between the materials.

When different met& (different corrosion potential) are comected without insdation

between them, a standard galvanic corrosion c d is obtained [13, 461.

Buried pipelines can suffer fiom an additional source of corrosion: stray currents

originate at railways, tramways or industrial installations, where currents flow in the soi1

coming fkom these resources. This kind of current causes corrosion at areas where the

currents leave the structure to enter the soi1 [50, 481. If the electrical resistance of the

buried pipelines k lower than the retum path through the soil, then the stray currents

wiii prefer returning through the pipelines to close th& electncal circuit [42, 131.

Stray-curent eEects usually occur when the direct currents associated with a foreign

metallic system (one not directly associated with the pipeline of concem) use the pipeline

as a preferential conductor in retuming to their source and, when this occurs, the currents

will couple to the pipeline fiom the soil and flow longitudinally along the pipe tc a location

where they discharge fiom the pipe to the soils in order to complete their circuit [17].

Direct chemical attack is another cause of corrosion and occurs in the processing

industries where such acids as çuifuric, hydrochloric, and acetic are used. Although the

uniform attack and the reaction of gases with met& are occurring by electrochemical

Page 18: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

proceses at a mic~oscopic or atomic scde, however they are included in the general

classification of chemical corrosion [8].

Mïcrobiological corrosion r d t s in differential dectrolyte conditions and is often clas

sified as bacteriologid corrosion. Mïcrobiological action produces many physical and

chernical changes in the soil and hence results in local changes in soil conditions. As

a result, active galvanic cells are produced, caused either by local variations in oxygen

content (differential aeration) or by consumption of the hydrogen film on the cathodes

(depolarking action). The bacteria which causes the greater part of ail corrosion at-

tributed to bacterid action are the anaerobic types which exkt in the absence of oxygen-

Microorganisms existing in a pipeline trench can affect the control of corrosion either

directly or indirectly [li']. The &ts of corrosion on pipelines can take many forms, and

identifyuig these forms can help in understanding the corrosion process.

2.3 Forrns of corrosion

It is convenient to classify corrosion by the appeanrnce of the corrodeci metal- Fontana

[31] pointed out that fdures of metals are not recognized as corrosion failures unless the

corrosion forms are Imown. Some of the corrosion classifications are unique, but ail of

them are more or less interrelated.

Unifonn or general corrosion is the simplest and most common form of corrosion- It

takes place d o d y over the pipeline surface by meam of a chemical or electrochemical

reaction. Pipeling resist corrosion by forming a film on the d a c e after metal exposure

to the air for a period of time, which protects the base metal. Combination with oxygen

to form metallic oxides, or scale, results in the loss of the material in its useful engineering

form, which dtimately flakes off to return to nature [47, 461.

Galvanic corrosion is another form and happens when two different met& are electri-

c d y connected and placed in a conductive solution. An electrical potential will ex& and

corrosion occurs as a r d t of the potentid Merence between the materials. Corrosion

Page 19: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

of the less resistant metal inaeases and the sdace becomes anodic, while corrosion of

the more resistant metal deaeases and the d a c e becomes cathodic [l?].

The direction ofelectron's flow, and the galvanic behaviour depends on which metal is

more active, the more active metal becomes anodic, and the more noble metd becomes

cathodic [47]. The drîvïng force for galvanic corrosion is the difference in potential

between the component met&- The galvanic series,the further apazt two met& are

fkom each other on the electropotential series, the greater îs the rate of corrosion.

When the corrosion attacks those sites whre individual grains with a rneta.Uk ma-

terial tou& each other, it is cded intergrmular corrosion. Intergrmular corrosion is

the selective attack of the grain boundary or an adjacent zone, the grains themselves

sufEer relatively litt1e corrosion- This attack occurs because of the corrosion potential

that develops between a thin grain boundary zone and the buk of the imediately adja-

cent grains [47]. Because of this characteristic, intergrandar and galvanic corrosion are

related,

The presence of narrow openings or gaps between metal to metal may give rise to

localized corrosion at these sites [17]- This kind of corrosion is called crevice corrosion

and it is believed to start as the result of the differential aeration mechanism. The oxygen

content of the liquid at the mouth of the crevice which is exposeci to air is greater, so

a local cell deveiops in which the anode or area being attadced is the surface in contact

"th the oxygen depleted liquid [l]. Crevice corrosion is usually associated with small

volumes of stagnant solution caused by holes, gasket surfaces, lap joints, and surface

deposits [7].

It is often difEcult to detect pits because of their s m d size and these pits are often

covered with corrosion products- This kind of corrasion is called pitting corrosion and is

one of the most insidious forms of corrosion. Real pitting starts as a localized fdure of a

protective film on the metal, this fdure may occur at a defect or impwity on the metal

surface, or at a scratch, or occur because of a momentary change in solution concentration-

Normally, failure is followed by rapid film repair, but if the damage continues long enough

Page 20: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

the film may not be able to repair itseIf and a pit is initiated [8]. Pitting and crevice

corrosion are related-

Because of the relative movement between a cornosive fluïd and a metal suffie,

especidy when the metal passes under water, the metal will face a combination of

mechanical action and cbemicd or electro-chernical reaction- &osion-corrosion is the

acceleration or increasing of the deterioration or attack on a metd because of relative

movement between corrosive fluid and the metd sdace. This movement is quite rapid

and metal is rernoved from the sudace as dissolved ions, or it forms solid corrosion

products that are mechanicdy swept fiom the metal surface [7, 31, 17, 81.

Corrosion may take another form ( stress corrosion cracking ) as a resdt of the

combination of the simultaneous presence of tende stress and a specific corrosive medium-

This kind of corrosion occurs at points of stress [46]. The rate of crack propagation

can vary greatly and is affecteci by stress levels, temperature, and concentration of the

corrodent [47].

The possibility of bacterial action is an important consideration in assessing the

chance of corrosion, particularly of buried steel pipelines and structures. A wide va-

riety of bacteria, dgae, and h g i have been identified as causing problems. In addition,

most bacteria need oxygen for metabolic processes, although some types are anaerobic

which mean they grow only in the absence of mrygen. SypicaUy, they grow best in tem-

perate cha tes and fairly neutral pK dues, even though some mes thrive at pH values

as low as zero and temperature from (-10 to 9g°C) [8]. Buried pipelines might s d e r due

to the met abolic activities of micreorganisms residing in the soi1 [l?] . Ih fact , microbb

logically infiuenced corrosion is quite cornmon for buried pipelines. As mentioned early,

a l l of these types of corrosion are interrelated.

Page 21: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

2.4 Corrosion prevention

The breaking d o m of met& through the e1ectrochemica.l process of corrosion is related to

the &dation of the metd In order to stop corrosion, the ultimate goal is the elimination

of the pipehe midation reaction. Since the problem of corrosion has been recognized,

several prevention techniques have been and still developed for corrosion prevention:

cathodic protection is one of the most widely used techniques.

2.4.1 Cathodic protection

Cathodic protection is the reduction or eIimination of corrosion by making the metd a

cathode by means of an impressed current or by attachment to sacrificial anode (magne-

sium, aliiminum or zinc). The steel pipeline is cathodicalIy protected by its connection

to a sacrificial anode buried in the same s d -

According to [31,46,35, 171, cathodic protection was first suggested by Sir Humphrey

Davy in the 1820s as a means of controlhg corrosion on British navel ships. It becarne

common in the 1930s on the Gulf Coast of the United States, where it was used to control

the corrosion of pipelines carrying naturd gas and petroleum products. Corbett and

Morgan [Il, 351 pointed out that the corrosion of underground pipelines, and associated

cathodic protection systems can be modeled as electical networks. Therefore, the basic

electrical laws can be applied and electrical models can be developed.

There are two major techniques for the implementation of cathodic protection: by a

galvanic anode which can be described as a metd which will have a voltage difference

with respect to the corroding structure and will discharge current that will flow through

the environment to the structure. To do this, the anode must be electrically connected to

the pipeline to be protected and also must be in contact ~ 5 t h the conducting environment

containing that pipeline [31, 35].Sacrificial anodes are used where current requirements

are relatively low, electrical power is not available and short term protection is needed.

For impsessed current systems,a rectifier converts high-voltage AC current to a low-

Page 22: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

voltage DC cment. The negative terminal of the DC power supply is connected to an

underground pipelinet and the positive to an inert anode which allows electric m e n t

to flow in the soü fkom the buried anode to the underground pipeline to be protected.

Typical material used for this anode is graphite [351. With ùnpressed current systems,

it is possible to impose whatever potential is necessary to obtain the current densitly

requïred.

2.5 Optimization of the impressed current method

hpressed cathodic protection systems are often employed to prevent corrosion. Io such

cases the net of the buried pipelines to be protected rnay have a very complex layout.

Consequent1~ the theoretical prediction for the potential distributions will &O-be com-

plex. ( The cathodic protection of burïed pipelines has some particular characteristics

that necessitate and justify the use of simulations ).

For providing an adequate level of cathodic protection , corrosion monitoring becomes

more and more necessary for underground metal structures (pipelines). According to

Marshakov and Petrov -1, th&. sensors were intended for use in monitoring corrosion

of underground pipelines. The sensors make î t possible to measure the soi1 corrosivity

and the effectiveness of electrochemical protection, including the &ect of stray current

fields. The sensors signal the appearance of a hydrogen flow into pipe steel caused by

eIectrochemical over protection.

In the case of several conductors forming complex and extended networks, the predic-

tion of the potential distribution consequent to the cathodic protection current injection

may be a hard task. Tosato and Quaia [14] pointed out that their design method was

based on the electrical linear net equations, and the approach to the problem based on a

passive twc+port model for each individual branch of the network. Using this approach

the overall net can be represented as a computational model of linear conductors.

The method has been tested in several situations and a cornparison between potential

Page 23: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

field measurements and theoretfd d u e s has been made. There Is a knitatioxx a linear

relation between m e n t and voltage is required to formulate the linear net node qua-

tions. This approach, however, is an approximation; it is only fully linear for the ohmic

fraction of the potential, but it is not for the polarization fiaction. On the other hand,

the major advantage is the possibüity to face the problem by means of fxaditional linear

electrical network equations and so the relevant calculations can be easily performed on

a cornputer. The writing of the conductance matrix even in the case of complex net-

works is easy, updating of the conductance matrix is simple, and the potential along each

individual branch can be imtiestigated and detected practically.

NurnerÏcal techniques are accepted widely in general corrosion engineering and Ca-

thodic protection calculations. Some similari@ e t s between corrosion in underwater

and underground circrrmstances. The structures play the roles of electrodes Mmersible

in a huge electrolyte (sea or soil). The major clifFerence between ofhhore platforms and

buried pipelines is the dimension. While floating structures are on a very small scale,

underground pipeline applications are on a scale of kilometers and these lengths intro-

duce nomegligible pipe resistance that influences potential and current distributions in

the soil and along the pipe.

According to KenneUey [9], the OKAPPI model (underground cathodic protection

pipehe) coupled the boundary element method (BEM) and the finite element method

(FEM) for the cathodic protection of buried pipes. The major innovation in this sim-

ulation was the inclusion of nonnegligible ohrnic voltage drops in the pipelines. The

model was three dimensional and minimized discretization- The basic idea of the model

proposed was to link an extenial with an intemal formulation, the extenial equation

(BEM) modeled the phenornena occunkg in the soil while an additional interna1 equa-

tion (FEM) was introduced to model the potential problem in the rneta.Uk part of the pipe

caused by the nonnegeligible ohmic resistance of large underground pipe structures which

contradicted the assumption of equipotential base met&. The method gave promising

results for the modehg of large cathodicaUy protected buried pipe networks, and al l the

Page 24: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

experhents gave excellent r d b .

The OKAPPI modd was extendeci [IO, 131, to calculate sihations where stray CU-

rents dishirb the system burÏed in the soil. OKAPPI can model problems involving

multiple cathodic protection systems accurately, and it has b e n proven that the devel-

oped model was powerfid and flexible.

A boundary element technique coupled with Newton-Raphson iteration was used to

solve the govemïng equations for two and three-dimensional models, which is run on a

personal computer [401. These models were developed to estimate current and potential

distributions on an underground pipeline when anodes are placed nearby or when dis

crete coating holes expose bare steel. The 2-D and 3-D boundary element mathematical

models provided the flexibilim to model the perfomiance of cathodic protection designs

for a wrietq of pardel anode configurations. The model offered a convenient tool to

quanti& the performance of cathodic protection system and dowed users to determine

the influence of relevant parameters ( soil resisTtiviw, coating damage, and anode type

and spacing ).

According to ûrazem [41], the case studies demonstrated the utility of the boundw

element terthnique to calculate the current density and the potential distribution in the

presence of discrete holes on a coated pipeline and the flexib'iii~ of these models to model

the performance of cathodic protection design. The model calcdations can be used to

optimize the pipeline anode configuration for a gïven set of operating parameters but the

computer programs require accurate input parameters to provide reasonable predictiom.

Emenike [39] pointed out that polarization is a major design philosophy of cathodic

protection systems. A polarïzed structure draws minimum current fkom the system. The

Emenike model was used to address the important issue of optimum design. The change

of current density with time for a cathodically protected structure was presented by a

difFerent ial equat ion.

Aoki and Amaya [5] presented a boundary element application to determine the OP-

timum locations of anodes and the optimum impressed current to ea.ch anode. The

Page 25: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

problem was reduced to minimiae the power supply under the protection condition by

assuming some assumptiom. They divided their work into two parts: first, the anodes

were located directly on the waIl of the structure; second, the anodes were located in

the electrolyte. An dective sensitivity analysis method for three-dimensional problems

was presented to reduce computational time, and a genetic algorithm combined with a

clustering technique and a gradient method was applied to cope with the multipeaked

cost functioa The authors mentioned that in r d structures an optimization problem is

sometimes accompanied by inverse problem-

According to Cao and Song [16], fuzzy clusterhg andysis was applied to condation of

soi1 corrosiveness for the first time and to underground corrosion systems. It was proven

that the h z y technique codd succeed in evaluating soi1 corrosiveness.

Zarmani, Chuang, and Porter [54] derived a mathematical formulation for the cathodic

protection system employed for corrosion prevention of structures in infinite electrolytes.

The developed mathematicai mode1 was discretized by the boundary element technique

which was solved iterativdy by the Newton-Raphson method. The formulation was based

on two fundamental arguments: that the potential at inlinity was unknown and the total

charge on the boundary is conserved- The major feature of the formulation was that an

infinite domain does not have to be approximated by a finite one, such approximation

introduces mors and reduces the &ciency of the boundary element method.

Hou and Sun [24], presented a simple formula for the h e a r model and gradient

algorithms for the nonlinear model to finci the location and the curent densisr on the

anodes. Boundary element methods were employed for the numerical caIculation. A

multi-anode system is considered. Two types of controi problems considered: the 1inea.r

control problem where the current density was the only control and the location of the

anodes was fixed, the 0 t h was the nonlinear optimal control problems which had both

the cment density and location of anodes as control variables.

A cment density control problem with 1inea.r constraint equations and k e d anode

location was considered by Zamani and Chuang [15], Lagrange multiplier techniques were

Page 26: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

used to derive an optimal system ofequations which was roughly twice the size of the con-

straint equations. The techniques dealt with single anode system- The numerical results

demonstrateci the effectiveness of optimal control techniques in cathodic protection.

Sun [52], used Gauss-Newton algorithm for solving the nonlineaz model. Bomda.ry

element methods are employed for the numerical caldations. his optimal control model

was developed to protect both cathode and painted surfaces of a ship by adjusting the

current density on the anodes to achieve optimal protection. Mathematically this can

be formulated as an optimal control problem. Lagrange multiplier techniques had been

used to derive an optimal system which only deals with single-anode system.

A problem arises in cathodic protection systems is defining the optimal positioning

of the anodes. Hou and Sun [25] looked at these problems as an optimal control problem -

where the main goal was to obtain a desired potential distribution on the cathode that will

prevent or reduce cathodic corrosion- The differentiabilily of the functional minimized

was justified and the equations satisfied by the derivative were established. For cornputing

the optimal position of anodes a numerical algorithm was proposed, and by implementing

the numerical algorithm with a boundary element method some numerical results were

obt ained.

Linear models work, but are based on approximation Mathematical models are

complex and require accurate inputs. To increase practicality, a les rigorous approach

based on fuzzy logic appearç usefd-

2.6 Review of Ebzy Techniques

Fuzzy logic approach iç one of the intelligent control modes, and as used in control engi-

neering offérs new approachg to controUer design. These approaches are more intuitive;

they do not require sophisticated rnathematics. The fuzzy control approach has been

studied extensively over the la& decade and many important theoretical, as weIl as prac-

tical results have been reportecl. Fuzzy logic was first introduced by Zadeh in 1965, and

Page 27: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

the fkst practical h m y logic controller was implemented by Mamdani in 1974. Today,

fuzzy control applications cover a &ety of practid systems, such as t rain operation,

robots, heat exchmgers and in many other systems, such as vide0 cameras, aeLTospace,

etc.

The specid feature of h z y logic is the capabiliw of handling linguistic dues and

imprecise data based on possibility distribution, such as " if the temperature is high

then increase coohg ". Ebzy control is convenient for compIex and nonlinear systenis

since its algorith does not require exact mathematical modehg of the systems. In

fuzzy control the main advitntage of using fimgr set theory is to apply h z y logic for

evaluating £iwy des, whereas in conventional control strategies arïthmetîc is used to

calculate the controlIer output. It is tempting to combine the advantages of fuzzy logic

with the flexibility of arithmetic operations (211.

A fuzzy controller operates in its unique domain where the nùg of the fuzzy mem-

bership hinctions are defined by an application expert. These membership functions

represent the possibiliw distributiom based on the vagueness of the variables- The d e s

and membership functions play important roles in fuzzy calculations. In such a controller,

the variables are related to non-fuzzy &verses giving the passible range of measurement

or action magnitudes [43]. These Mnables take on linguistic values which are expressed

as fuzzy subsets of the UIilverses.

A fuzzy subset M of a universe of discourse H = {x) is defined as a mapping p&) :

H -, [O, 11 by which x is assigned a number h m O to 1 indicating the extent to which

x has the attribute M. For instance, if x is the degree of the room temperature, then

"cold" may be considered as a particular h z y value of the variable temperature and

each temperature is assigned a niImber pCOId(x) E [O? 11 which indicates the extent to

which that temperature is considered to be cold. The set theoretic operations of union,

intersection and complement for b z y sets are defined via their membership fuaction~

[19, 261-

Page 28: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

The union S U R, defined by

where u stands for m;ucimum, and the union corresponds to the connective O R

The intersection S Ti R, defined by

where n stands for minimumf and the intersection corresponds to comective AND.

The complement s of S, defined by

where the complementation corresponds to negation ( NOT ).

If S and R are linguistic values fiom two dissimilar universes of support [28], Say,

H = {x) and G = {y), respectively, a h z y relation 31 from H to G is a fuzzy set on

the Cartesian product H * G, characterized by a function ~ ( x , y), by each pair (x, y) is

assignecl a nuniber in [O, 11 indicating the extent to which the relation 92 is true for (x, y).

This is represented by the h c t i o n

Therefore, by knowing the relation 92 between S and R and the value S ( the an-

tecedent ), one can infer the consequent R from S and 91. The compositional d e of

inference used to relate p~ to ps and ps is

The basic idea in fuzzy logic is to ex& a gradua1 transition [37, 43, 21 fiom one

Page 29: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

consequent to the next. The general operations can be ~~~ll~~la;rized as, the input mem-

bership functions fuzpfy the crisp input (process variable) into fuuy domain, then the

rules evaiuate the fuzzy value and give the result. FinaIly, the output membership h c -

tions defuzzify the results fiom f u z q domain badc to crisp domain. The fuzzy controller

involves four basic operations, the hizzification, the d e base, inference engine, and the

difuzpfication. A simpIified block diagram of a fuzzy Iogic controUer is shown in Figure

Rule base inference

Fuzzification inference

Figure 2.1: Block diagram of hizzy logic controller (FLC)

i

Decision- @ maong logîc ,

Fuzzv

Page 30: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

The procedure of fuzzification consists of finding appropriate membership functions to

describe crisp data Simply, many of the quantities considered to be crisp and determinis- * -

tic in reality are not deterrmnistic at ail. They csrry considerable uncertainty- If the form

of uncertainty happens because ofimprecision or vagueness, then the variable is probably

fuzzy and can be represented by membership function [44- The membership hctions

for the fuzzy variables may have several shapes. For instance, let the temperature of

the room be a linguistic vazîable- Then the set temperature could be T(temperature) =

(cold, warm, hot). The scale from O to 40, cold temperature may be up to 15, warm

could be fkom 10 to 25, and hot temperature codd be h m 20 to 40.

Fuzzification involves the following functions [26] :

- Measures the values of input variables.

- Performs a scale mapping that can transfer the range of values of inpct variables

into corresponding universes of discourse.

- Performs the function of fiizz'ication that converts input data into suitable Linguistic

values-

2.6.2 Rule base and inference engine

The rule base is the heart of a fuzzy controller, since the control strategy used to control

any system is stored as a collection of control d e s . For instance, a controller with three

inputs ml, m*, and m3 and output u. Then a control nile has the form [37].

If ml is A, 7n2 is B, and m3 is C then u is D, where A, B, C, and D are linguistic

t erms . The form of the des is co~ll~~lonly referred to as the IF-THEN de-based. It typically

expresses an Xkrence such that if we know a fact ( antecedent ) , then we can infer another

fact cded a conclusion ( consequent ) [43].

The inference engine is a program which uses the d e base and the input data of the

controller to draw the conclusion. The conclusion of the inference engine is the h z y

Page 31: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

output of the controuer which becornes the input of the defuzzificatio~i,

2.6.3 Defuzzification

Defuzzification is the conversion of a h z y quantity to a precise quantiq, just as a

fuzzification is the conversion of a precise quanti@ to a h z y quantiW. The output of

a fuzzy process can be the union of taro or more fuzzy membershïp functions defined

on the universe of discourse of the output variable [43]. There are several methods for

defuzPSring fuzzy output membmhip hctions, the method of defuzpfication ofken used

in h z y controllers is the center of gravity method [2]. The center of gravity is given by

the algebraic expression

According to Chuen [26], defimidication performs the followïng functions:

- a scale mapping which converts the range of values of output variables into corre-

sponding universes discourse.

- defuzzification which yields a nonfuzzy control action fiom an inferred h z y control

action.

The difference between conventional control and h z y control is that the decision

made by a conventional controIler are stiff 'true' or 'false'; fuzzy control uses fuzzy logic

which is closer in spirit of human thinking and natural language. Tang and hIÜIhoUand

[36] presented an udied approach for comparing the perfiormance of fuzzy and ciassical

controller designs. The relationships have been established between the gain parameters

for the two classes of controller designs. The methods applied equally well to proportional-

integral linear multiband, and multilevel relay controllers. The resuit can be viewed as a

simple tool that was designed to help solving the tuning problem for fuzzy controUers.

A lot of fuzzy applications show that the hizzy logic contr011er produces superior

results

Page 32: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

to those obtained by conventional control algorithms, especially in systems that are

too cornplex, or m systems under uncertain and Inexact environments [44& Lee [26] p r e

sented comprehenslve review of the classicd design and implementation of the hmy logic

controlkr. A survey of the FLC was presented; a generd methodology for constructing

a FLC and assgsing Ïts performance was dgcribed.

Two developed extension designs of the basic f i i zq logic control ( FLC ) ( including

the FLC with dual control laws, PI and PD forms; and threepiece FLC ) were presented

by Chen and Kuo [23] to enhance the control performance of the basic F'LC. The simula-

tion resdts showed that these modifications can provide semxontrol r d t s superïor to

those of the basic E'LC design as well as those of conventional threemode PID controllers.

Huang and Nelson [44, 271 have been demonstratecl that a fuzzy logic contro11e.r can

perfonn much better than a conventional control, such as a PID controller, if the FLC

has been well constructed. The general method for designing a FLC is to use trial and

observation. They presented the experhental results of a debaseci fuzzy logic controller

used to control heating, ventilating, and air conditioning system ( HVAC ).

Kandel, Zhang, and Henne [22] discussed the methodology of using fuzzy logic tech-

niqües to improve the performance of an operating system. Through the analysis, they

found that many elements of an operatîng system, process, storage, file management, and

distributed system management can be fuzzified so as to tackle the problem with fiizzv information and to d o w users to use the cornputer systems conveniently and &ciently-

The simulation r d t s showed that these methods are relatively &cient to enhance the

operating systern-

Yuasa, Mitsuo and Gunji [53] dgcribed the fuzzy control of a s m d automatic guided

vehicle (AGV) system to maintain a constant distance between a forward and following

vehicle by proposing a new dpamic tuning method of a scaling factor to improve the

performance of the (AGV) system. It was found that the new dpamic tuning rnethod of

scaling factors was very useful, and the new fuzzy control method had a better response

than conventional fuzzy control and the P D control method.

Page 33: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Deepak and Kuldip [45] used a furzy controller for controIling the pitch axk of the

unmanned research vehicle o. They found the b z y controller gave better r d t s

than those obtained fiom the eJristing analog controIler.

Digital fuzzy logic controllers are so far the most commerciaUy successful impIementa-

tions of fuzzy logk circuits. Various aspects of digital k z y logic controUer design and im-

plementation are dlscussed by Marek, Janos and Kirby [30]. Classic and improved models

of the single-input singleoutput, multi-input singleoutput, and multi-input multi-output

FLC's are analyzed in terms of haxdwa.re cost and performance Findy, a direct data

Stream architecture for complete digital fuzzy controller was shown as an improved solu-

tion for high-speed, cost, and real-time control applications.

Mauer [32] used a fuzzy logic controller for anti-locking braking system (ABS). A

digital controller design was chosen to combine a fuzzy Io& element and a decision logic

network. The simulation results showed that a fuzzy controller in combination with

a decision logic for estimation of the road condition was rapid and effective means to

provide braking torque control over operating condition raaging fiom pavement to black

ice. The controller was found quite robust-

A continuous speech recognition system knowledge engineering techniques and fuzzy

concepts has been discussed by Yu, Oh, Yamashita and Mizoguchi [20]. The main goals

are to provide the most effective way ofextracting the knowledge of human experts and to

achieve a recognition performance as high as that of human experts. The system provided

the user with a graphical and natural interface by means of the state description and

linguistic variables. It was shown that using fuzzy membership improved the recognition

performance, and the recognition unit was quite effective.

The fuzzy logic toolbox is a collection of functions built on Matlab. It provides tools

for the user to create and dit fuzzy inference systems within the fiamework of Matlab.

There are two types of h z y inference systems that can be implemented in the hizzy

logic toolbox: Mamdani-type and Sugenetype.

The fuzq logic controllers designed this study are based on the fuzzy logic Tool

Page 34: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Box, a collection of functions built for the Matlab [38] system. This Tool Box relies

heavily on a Graphical User Interface ( GUI ) and provides a number of interactive took

to d o w the user access many of the functions. This provides an enviro111nent for h z y

system design and analysis. For the on-line controller, the fuzy control program was

written in Pascal. Here, control functions for analog input and output were induded-

Page 35: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 3

Single Anode System

In this section, a simple fuzzy control system which has one controIIed variable will be

developed. The current for one anode will be determineci horn three potentid mea-

surements. The controller will be tested on a simulation of the pipeline, however to

provide the basis for this simulation, the relationship between cment and potential was

de termined experiment dy.

3.1 Determination of current /potential relat ionship

Figure 3.1 shows a configuration of the system to be controlled. This was constructeci in

the laboratory using a small box of sand ( 114n x 76cm ). The pipeline was modeiled

by a 0 . 7 5 n diameter steel rod buriecl in the sand. The anode was a rectangular piece

of graphite ( 5 n x Icm x 0.5m ) placed equidistant fiom each end of the rod.

The potentials were measured using the copper/copper sulfate reference electrode

generally used to monitor cathodic protection in the field. These were constructeci in

the laboratory. The copper sulfate electrode is the half-cell generally used for cathodic

protection in the field. The half-cell which used in the lab measurements shown in figure

3.2 consists of a piece of copper, surrounded by a saturated solution of copper sulfate.

The porous plug is porcelain clay placed in the tip of the disposable pipet and fired

Page 36: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

in a propane flame. A mbber plug is pIaced on the top of the pipet. This type of half-

ce11 is in universal use for the rneasufemmt of struchne/eIectrolyte potentials on burÎed

structures, its main advantages are that it is cheap, simple to coIlStNct, and has a low

impedance.

Figure 3.1: Cathodic protection system with one graphite anode.

Materials are used in this experiment; a small box fUed with sand, graphite anode,

a power supply and müliammeter to impress current, the pipeline, and PH meter as a

high impedance voltmeter to measure the voltage at each point through copper copper

sulfate reference electrodes-

The negative tenninal of the power supply is connectecl to the pipeline, and the

positive to an inert graphite anode. This p d t s m e n t to fiow £kom anode, through

the electrolyte ( sand ), to the pipeline- Because the resistivity of the soi1 will determine

Page 37: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Rubber plug

Disposable pipette -

Porous ceramic

Copper wire

CuSo4 solution

C u S d crystd

Figure 3.2: Copper-copper sulfate reference elctrode (CuSo4).

Page 38: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

the required applied voltage, the measurements for both, high and low conductivity have

been taken-

The corrosion potential is measured by detaminuig the voltage difE'erence between

the pipeline immersed in a soil and the copper/copper sulfate reference dectrode, using

a PH meter. In this experîment the pipeline was dïvided into three points ( VI, V2, and

V3 ), where the corrosion potential is mea~ufed. This is the voltage ciifference between

the pipeline and the particular reference electrode.

The r d t s obtained are shown in Figure 3.3 and Figure 3.4. In Figure 3.3 the sand

was quite dry, therefore the r e s i s t ~ t y was hi& a&es adding some water to simulate

rainfd, the low resistivity gave the data in Figure 3.4. In both cases the relationship

was linear, therefore the interpolation equation was developed to simulate this system.

To test t h controller, a simulation was developed to act as the process in the system.

This simulation was developed to be easily repiaced with the real measurements for

physical testing, however simulation provides for rapid testing- The simulation was based

on equations derived from measurements taken fkom a real system as shown in Figure

3.1-

The experiment started by setting the cment in the power supply at zero and take the

voltage reading between the structure and reference electrodes in three diifferent locations

on the pipe by using pH meter ( connect one end of the pH rneter to the underground

pipeline and the other end with the reference electrodes ). For each test nin, the current

is changed and the potential is taken at each point on the pipe. The data which are

taken clarify the diffe~ent voltage values at three dlfferent locations on the pipe, whether

this potential data is underprotection or overprotection. These data points are taken for

dry and wet soil.

These data were used to determine estimate values that were not part of the original

sets of data by using linear interpolation. Linear interpolation is performed by the

bUTLAB interpolation functions [6].

Page 39: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 3.3: Linear estimate voltage dues VI, V2, and V3 with high resistivity 28

Page 40: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 3.4: Linear estimate voltage dues V1, V2, and V3 with low resistivity 29

Page 41: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

3.2 Fuzzy control design

A controller consists of three main parts: fuzzifkation, table of control d e s and

defuzzification. Fuzdication is done by using membership functions which form the heart

of any fuzzy controller. These bct ions determine the assignments of the certain values

of the inputs, and the degree of the assignments are quantifiecl as the membership values.

These membership values of the inputs detennine which control d e s can be applied.

PI ( proportional, integral ) is the most commonly used system because of its advan-

tages of qpick response and the dimiTintion of ofket [49]. In digital form this controuer

is given as:

Subtracting these two equations, the velocity form becomes;

Here the integral action is moved to the sllmmation of the correction Anznto get the

calculate manipulateci value. The velocity form can be written as:

Even though, there is an integral part in the fuzzy control that is used, it is not a PI

fuzzy controler. It is a variant

Fuzzy infaence is the process of mapping fiom a given input to an output using

fuzzy logic. In the fuzzy logic toolbm, there are five parts of b z y inference proces:

fuzzification of the input variables, the fuzy operators ( AND or OR ), implication

fkom the antecedent to the consequent, aggregation of the consequents across the rules,

and defuzzification. The model was built by using the gaphical user interface ( GUI )

Page 42: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

took provided by the h z y logïc toolbcac The controUer is designed to model a human

operator's actions and accept iingUiStic inputs and return a 'crisp' or d-ed output

by using the centroid rnethod ( center of gravity ) which used to controI the system.

Timothy [43] pointed out the steps in dsigning the fuzy logic control system are:

- Identify the Vanab1es ( inputs, States, and outpu& ).

- Partition the universe of discourse or the interval spanned by each variable into a

number of fuzv subsets, assignhg a linguistic label.

- Determine a membership function for each fuzzy subset.

- Forming the de-base-

- Choose appropriate scaling factors for the input and output Vanables.

- F ' u z e the inputs to the contr011er.

- Aggregate the h z y outputs recommended by each rule.

- Apply defuzzification to form a crisp output.

As the cathodic protection system has a linear characteristic for variations of the

voltage on the pipeline and the impressed current that used to protect the pipe, the

cathodic protection has to vary its pedormance according to these Miiations. In order

to calculate the confxolled variable, in this case the impressed current, the Mamdani's

h z y inference method is the most comonly used f u z q methodology

The single anode model is buirt of 27 de s , and each of the d e s depends on resolving

the inputs into a number of different fuzzy Linguistic sets; voltage is low (L), voltage is

ok (Ok), and voltage is high (H). The inputs were fuz&ed a g a k t these linguistic sets.

The £ive output membership hctions range fkom big decrease (bzgdec), decrease (dec),

(nochange), increase (inc) up to big increase (biginc). The hizzy logic basic structure

of the model and the membership functions are shown in Figure 3.5 and Figure 3.6

resp ectively.

Each trianguiar membership function can be described by the location of the vertices

A, B, and C as in the Figure 3.6-

Page 43: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Max Output

Figure 3.5: The hizzy logic basic structure of the mode1

Page 44: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1 hput voltages VI, ~ î , ~3 mV 1

1 OUTPUT i

Output anode curreat I imA 1

Figure 3.6: Fuzzy control of pipeline corrosion.

Page 45: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

3.3 F h z y simulation results

Several runs were done to observe the a f k t of membership function width, then trial

was made with fewer functions. FinaUy a tnal was made with singleton membership

functions rather than triangular membership hctions. The controller was tested by

having it control the simulation of the pipeline system. This allowed rapid tuning and

optïmization of the controUer- The parameter to be optimized

Here the cumulative s q u d deviation fiom the setpoint is

is the ISE cc& function:

(3-5)

used. A minimum in this

value indicates an optimum control tuning. Several experiments are done and some of

them are shown in Figure 3.7 to Figure 3.12.

There are 27 rules employed in the single anode controuer Each rule is a h z y relation

between the voltage measurements VI, V2, V3, and the action of the anode current 1.

The d e s are based on the result of simulations and an understanding of the cathodic

protection. In this model, the hizzy controlIer has ihree inputs and one output.

Triangulax membership function types were used for the inputs and output. The

range korn O to 170hV represents the input voltages between the reference electrodes

and the pipeline where Low voltage kom -850 to 850mV, OK voltage fiom O to 1700

and High voltage iÏom 850 to 2550mV. The range of the output of the anode current

was fkom -1 to 1mA to cover the output range. The simulation reSuIts by the fuzzy

control are show in Figures 3.7 to 3.9.

In Figure 3.7 by changing the output range and the five output membership functions

with the following settings:

Page 46: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1400/ Drysoil wet soii soi1

Figure 3.7: The fuzzy performance with Big change k3.0 and S m d change f 1.0 35

Page 47: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1 Kind of membership 1 A ( B ( C (

1 Dec

where the numbers are currents in mA-

The results in Figure 3.7 were obtained. The set point was 850mV so it is apparent

that the integral action did remove o&t. The r d t s were oscillatory for dry soil where

s m d change in current &es a large voltage change. Thus the process gain is high. With

wet soil the gain decreased to give a smooth response. Obviously, the proces can be

divided into two stages. At the first stage, there is strong oscillation with a high soil

resistivity, and at the second stage, there is a smooth response with a low soil resistiviw.

To evaluate the results of the fuzzy control, we introduce the ISE performance index

calculated by the equation: ISE = x(V - setpoint) * In Figure 3.7 the calculateci ISE performance is:

1 Selected performance index 1 Refi 1 Ref 2 1 Ref3 1 1 ISE 1 2.61~ 106 1 2.61~ 106 1 2 . 4 2 ~ 106 (

So the inauence of the output gain should be considered with the change of the

activated d e s and the parameter of the membership functions. In Figure 3.8 the results

obtained by changing the control settings to those shown in Table below:

Page 48: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 3.8: The flmy control pdormance with Big change H . 0 and S m d change M.5 37

Page 49: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1 BigDec

1 Dec 1 -0.5 1 -0.5 1 -0.5 1

show that using the singleton membership hctions reduced the controlier gain, this

reduced the extent of oscillation. In the wet soil the controller gave a smooth response

where the gain decreased. It can be seen that the performance of the control system

has been improved, but a s m d oscillation still exists and there is a little overshoot

indicated in the beginning where the soil resistivity is high. For the data in Figure 3.8,

the calculated ISE is:

1 Selected performance index 1 Refi 1 Refi 1 Ref3 1 1 ISE 1 7.82~ 105 1 7 . 5 0 ~ IO5 1 7.27~ IO5 1 In Figure 3.9, the number of the output membership functions changed fkom five to

three triangular membership functions with the following settings:

Kind of membership 1 A 1 B 1 C

The characteristic response of the contïol action is very smooth, no oscillation, also

no overshoot, but it takes long time for the system to respond, and it does not meet the

set point of the system which is 850mV, especially with wet soil where the resistivity is

Page 50: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1400 Dry soiT Wet soit

Figure 3.9: The fuzzy control action with Big change k2.0 and Small change f 1.0 39

Page 51: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

very low. The caldatecl ISE performance index is:

ISE 19.16 x 105 19.34 x 105 19-75 x 1051

The best smulation results for the h q r control and the behavior of the ideal con-

trouers to respond to a set point are shown in Figure 3.10- The results that are shown

in Figure 3.10, where the output trianguiar membership functions setting as:

1 Kind of mernbership 1 A 1 B ( C 1

show that nmowing the intervals reduced the controller gain, this reduced the extent

of oscillation. Also we can see that the rise time is very smd, invariably the peak

value of the overshoot inmeases and so does the settluig tirne, particularly where the soi1

resistivity is very high. The ISE is:

1 Selected performance index 1 Refi 1 Ref2 Ref3 1 1 ISE 1 3.78 x 105 1 3.75~ 105 ( 3.64~ 105 1 In Figure 3.11 the same form and placement of membership functions as in Figure

3.10 have been used for the output of the controlIer except the functions bigdec and biginc

which have trapezoidal form, where the parameters of these two membership functions

respectively setting as:

Page 52: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1409 I

Dry soi1 Wetsoil Dry soi1

Time,:

Time,

Figure 3-10: The fuzzy control with Big change f 1.5 and Small change f0.5 41

Page 53: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 3.11 shows the same chasacteristic respome of the control action as shown in

Figure 3.10. and the calculated ISE performance is:

In Figure 3.12 the results were obtained by changing the control settings to:

Selected performance index

ISE

Those results show that by nmowing the intervals, the response of the control system

is very smooth with wet and dry soi1 by decreasing the gain. But in the wet soil it takes

a long time for the control system to respond, &O the ISE was:

Refi

3-81 x 105

The best setting tunned were those for Figure 3.10. The table below showed the

Selected performance index

ISE

cornparison of the simulation results by the fuzzy controuer with different membership

Rd2

3.79 x 105

range: It is clear that inueasing the range of the output membership functions gives high

Ref3 3-66 x 105

Refl

5.25 x lo5

Re&

5.21 x 105

ISE value. On the other hand, more decreasing the range increases the ISE value again.

m 3

5-04 x lo5

Number of Rules

27

Membership Range and Nurnber

-3.0 -1.0 O f1.0 +3.0 (5)

ISE

2.61~10~

I

Expriment Duration

3lsec

Page 54: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Ti me,:

Figure 3.11: The fuzzy control performance with trapezoidal function in Big change and S m d Change 43

Page 55: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

1400 Dry soi1 Wetsoil j DrysoiI

Figure 3.12: The fuzzy control action with Big change f 0.75 and Small change f0.25 44

Page 56: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

In each fuzzy control action used the same d e s and the same method of diEudication

(centroid). They difkr only in the set of parameters of the membership hctions, and all

simulations started at zero anode current. It is dear that the performance of the fimy

control system depends on the control parameters, membership hctions, control d e s ,

and other factors included in the system.

Page 57: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 4

Dual anode system

-

In t h section, the model is extendecl to control multiple anodes ( multi input and

mdti output MIMO ). Figure 4.1 shows the block diagram of the lab experiment setup . Materials used in this experiment were the same as those used with single anode systern,

instead of one graphite anode, there are two graphite anodes sïrdar in size to used in

the single anode system ( 5cm x lcm x 0.5cm ). Five copper /copper sulfate reference

electrodes were used to measure the potential along the pipeline model-

4.1 Met hod and experimental results

In general, the method used was the same as the one used with single anode system, but

in this case the scenario was slightly different. Copper sulfate electrodes (half cell) were

placed at five points to measure the voltage between the structure and the copper sulfate

electrode,

The experiment started by setting the current in both power supply voltages at zero

current and take the reading voltage between the structure and reference electrodes in

five different locations on the pipe using the pH meter. For each test run, the current is

changed and the potential is taken at each point on the pipe. The collective data which

are taken cl- the different voltage values at five ciiffixent locations on the pipe, and

Page 58: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 4.1: Block diagram of cathodic protection system with two graphite anodes-

Page 59: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

whether this potentid data is mderprotection or overprotection. These data points are

taken with dry and wet soil.

The set of data that were collectecl confirm the potential on the pipe at VI, V2, V3,

V4, and V5 is hearly rdated to the cment that in anode1 (II) and anode2 (1~)- This

data developed a set of equations that allow the simdation of the control system The

estimation values were represented by equations of the form:

Hae Il, I2 stand for the m e n t in anode and anode, XI, X2 are the coefficients,

and C is a constant, Table 4.1 , and Table 4.2 respectively show the output regression.

Which , the same as in the single anode case gave good correlation ( R2 ) d u e s -

[ Reference electrode 1 Xi 1 X2 1 C 1 RZ 1

Table 4.1: The output regression in low sand conductivity

1 Reference electrode 1 XI I X, 1 C 1 R2 1

Table 4.2: The output regression in high conductivity sand

4.2 Multi anode control design

The fuzzy control structure for the cathodic protection srçtem is shown in figure 4.2.

The inputs to the controuer are the MLUg of the voltages. Three membership functions

Page 60: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

are defined for each input; low (L), ok (Ok) and high (H). The fiinctions Low and High

are trapezoidal, on the other hand, the Ok function is triangle. On a scale from O to

1700mV, low voltage up to 850mV, Ok voltage h m O to 1700mV, and high voltage fkom

850 to 170bV- The outputs of the controller are the values of the ment s . The five

singleton membership functions which range fiom bigderrease ( BigDec ) to bigincrease

( BigInc ) are d&ed for ea& output. The reasone of using singleton membership was

the simplicity for counting by the cornputer. The range of the inputs of the voltages and

the output of the anode ment the same as obtained in the single anode systern-

For the mode1 ixnplementation, production d e s operating on five sets of the input

variables and two sets of the output variables. The dynamic behavior of our h z y system

is charscterized by a set of linguistic description nùes based on expert knowledge. See

Appendix B. The fuzzy control d e s of the mode1 have the fom:

RI: If ( V1 is Low ) and ( V2 is Low ) and ( V3 is Low ) then Big hcrease ( Il)

R2: If ( Vl is Ok ) and ( V2 is Ok ) and ( V3 is Ok ) then No Change

&: If ( VI is High ) and ( V2 is High ) and ( V3 is High ) then Big Decrease ( Il)

%: If ( VI is Low ) and ( V2 is Ok ) and ( V3 is High ) then Increase ( Il)

R5: If ( VI is Low ) and ( V2 is Low ) and ( V3 is Ok ) then Big Increase ( 11)

&: If ( VI is Low ) and ( V2 is Low ) and ( V3 is High ) then Big Increase (Il)

R7: If ( V1 is Ok ) and ( Vz is Ok ) and ( V3 is LOW ) then Increase ( Il)

&: If ( VI is Ok ) and ( V2 is Ok ) and ( V3 is High ) then Decrease ( 4)

&: If ( VI is High ) and ( V2 is High ) and ( V3 is Low ) then Increase ( Il)

RIO: If ( V1 is High ) and ( V2 is High ) and ( V3 is Ok ) then Big Decrease ( Il)

When the voltage at VI, V2, and V3 is low then try a big increase in the current

anodel ( Rule-& If the voltage is ok at the same points then no change in the current

( Rub) . If the voltage at the same previous points is high then a big decrease in the

Page 61: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

If Vl is low and V2 is low and V3 is low Then big increase current by anode1 ïfV3 is low and V4 is low and VS is iow Then big increase cunent by anode2

Figure 4.2: hizzy controuer for dual anode system

Page 62: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

current anode ( R*). If one of the point is high,the 0th- is low and the third is ok

then just increase the current in the anode ( RI.&$- If the voltage at two points is Iow

and the other one is ok or high then a big incxease in the m e n t anodq ( RI&- and

R*). If the voltage at two points is ok and the other one is low then increase in the

current anode ( Rule7). If the voltage at two points is ok and the other is high then

demease in the m e n t anode ( Ruh) . If the m e n t at two points is high and the other

is low then increase in the m e n t anode ( Rd%).However, if the current at two points

is high and the other one is ok then a bigdecrease in the m e n t anodei ( Rulqo).

This selection of d e s change as the voltage changes. The same steps will happen

with V3, V4 and V5 which affecteci by changing the m e n t in anode2.The total number

of rules is 108. The centroid method ( center of area, center of gravity ) is used for

defuzdication. By this method, the value of fuzzy output which has the maximum

possibility distribution, is used as control output. Figure 4-3 shows the proceses that

have been followed to build the control system of our modd

Where A I is a correction fiom the fuzy controller. This summation of A values

is an integration which will serve to elimuiate ofket. The FLC was programmed in the

Pascal language. The controiler was tested tkough computer simulations for more than

tfiirteen case studies.

Some of those runs and their results are shown in the figures below. In Figure 4.4

the results obtained with The initial d e set in this fuzy control action contauied 108

des , based on the result of the simulations and also an intuitive understanding of the

cathodic protection processing and by changing the control setting to:

where the numbers are current changes in mA,

The results shown in Figure 4.4 were obtained. l e set point was 850mV so it is

Page 63: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

11I2- VLV2V3V4V5

5 New Old

New V1 V2 V3 V4 V5 -1 Rocess + - 11=11+u1

r2=I2tm

Figure 4.3: The simulation of the pipeline

Page 64: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

apparent that the integral action did remove offset. The results were osdatory for high

resistivity soil where s m d change in cunent gave large voltage changes, therefore the

process gain is high. mth wet soi1 ( Iow resistivity ) the process gain decreased to give

a smooth response.

The ISE performance with range fiom -1 to 1mA and 108 d e s was:

Selected index / Ref'

Where Ref is the abbreviation of the refkrence electrode.

In Figure 4.5 with the same set of d e s , the result obtained by changing the control

Refi

ISE

setting to:

l Ref3 Refs I 4.83 x 105

show that nanowing the inteTvalS reduced the gain, this reduced gain in wet and dry

soil gave a smooth response with very short rise time and no overshoot. In Figure 4.5 for

the response of the system to a change fkom high soil resistivity to Iow resistivitsf. In a

high soil resistivity, the s m d change in curent can give large change in voltage. Where

in wet soil, the large changes in current gives a large change in voltage. The response of

the controller was very smooth, and this smooth response &ected the ISE performance

which was:

2.85 x lo5 1 3.28 x los 1 2.75 x 105 1 3.04 x lo5

BigInc

In Figure 4.6 the results obtained by changing the control setting to:

Inc BigDec

ISE

T

Dec

1.20 x 106

BigDec 1 Dec I

NoChange

1.08 x 106

Nochange

1.17 x log 1 9.84 x lo5 1 8.44 x 10' 1

Inc Bighc

Page 65: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 4.4: The fuzzy control simulation action with Big change f 1.0 and Small change *O.l 54

1 200 -

1000 Dry soi1 f W e t soi1 Dry soi1

1

Page 66: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Dry soil , Wet soi1 j Dry soi1 r' €

Figure 4.5: The fuzzy control simulation action with Big change k0.5 and Small change *os 55

Page 67: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 4.6: The fuzzy control simulation action with Big change &1.5 and S m d change & O S 56

Page 68: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 4-6 show that by increasïng the range of the output mernbexship funcf50ns,

the results were high oscillatory for dry soil, therefore the process gain was high- mth

wet soil, the controIIer gave smooth response- Therefore the gain was decreôsd. The

performance index is:

In Figure 4.7 with the following control setting:

Big% - Dec NoChange h c I f

Where these numbers are cment changes in mA.

Rf&

5.35 x 106

Selected Index

ISE

The results shown in Figure 4.7 were obtained by adding a combination of rules

between the inputs VI, V2, and V4 with the output Il and the inputs VI, Vq, and V5

with the output I2 to the initial set. The additional rules have the form:

If (VI is Low) and (V2 is Low) and (V4 is Low) then Big Increase ( Il)

If (VI is Law) and (V2 is Ok) and (V4 is Egh) then Increase ( Il)

Ref2 R.43

4.50 x 10'

Refr

5.55 x 106

If (VI is Low) and (Vq is High) and (V5 is High) then Increase ( 4)

If (VI is High) and (V4 iS High) and (V5 is High) then Big Decrease ( 12).

Ref3

These additional rules account for the interaction effect where anode protects a region

that should be protected by anode2 and vice versa.

The set point was 85hV so it is apparent that integral action removed offset. For

a dry soil where small change in current give large voltage changes. The results were

oscillatory where the process gain is high. In the wet soi1 the gain decreased to give

smooth response.

5.60 x 10" 1 5-87 x 106

The system performance of the modified control niles is:

Page 69: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 4.7: The fuzzy control simulation action with Merent d e s and Big chang f 1.0 and Small change *O-1 58

Page 70: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

h Figure 4.8 the results obtained by changing the control setting to:

SeIected Index

ISE

show that the response of the system in dry and wet soil is very smooth which means

the process gain decreased- The ISE performance isr

MI

6-19 x 105

BigDec

-0.5

[ Selected Index 1 Refi 1 Refi 1 &f3 1 RA& 1 Re& 1

With the following setting:

Ref2

3-87 x 105

Dec

-0-1

The results shown in Figure 4.9 were obtained. The integral action did remove offset-

For dry soil where the s m d current change give large voltage changes, the results were

oscülatory which means the process gai. was high. With wet soil the gain decreased to

give a smooth response- The ISE performance of the modXed control rules was:

1 ISE 1 5.68 x IO5 1 5.95 x 105 1 6.76 x 105 1 5.28 x 105 1 4.55 x 105 1

RefJ 4-38 x 105

Nochange

0-0

In Figure 4.8 and Figure 4.9 the number of d e s are 126 d e s after we added additional

18 rules to the initial sets of des . The additional d e s account for the protection of the

pipeline ends, and they have the form:

If (Vl is Low) and (V5 is Low) then Big Increase 4

&fi 3.n x 105

h c

If (VI is High) and (V5 is Low) then Increase I2

ReQ

3-55 x 105

BigInc

0-1 0-5

Page 71: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Dry soi1 Wet soi1 Dry soi1 16ûû

The,

Figure 4.8: The fuzzy control simulation action with different rules and Big change h0.5 and Small change f 0.1 60

Page 72: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

i Wet soi1 Dry soi1 - E Dry soi1 1200

Figure 4.9: The f&zy control simulation action wi th Big change f0.8 and S m d change h0.1 61

Page 73: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

If (VI is Ok) and (V5 is Ok) then Nochange ment .

The simulation results by the h z y control that are shown in Figure 4.8 and Figure

4.9 approached to the our desired set point which is 850mV. Eowever, kom the stand

point of the minimum ISE performance index, Figure 4-4 shows the optimal fuzzy control

action- The table below showed the aspects of ail the cases. r i

rules and a ciiffixent set of parameters for the membership functions. It is clear that

1 -0.5 -0-1 O +0.1 +0.5 1 1.00~10~ 1 15lsec

the performance of the fuzzy controkr depends on the parameters of the membership

126

functions and the control rules- Tuning was accomplished by changing the membership

b

The simulation of the multi anode systern with the fuzzy controller used different

functions- The tuned controUer worked well. The soi1 resistivi@ value was changed

instantaneously fiom one levd to another and then back again in all the simulation runs

whether single or multi anode system.

Page 74: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 5

Experiment al result s

A sequence of closed loop experiments was &ed out with the multi anode system

clarified in the previous chapter. These were to used ver@ the simulation results by

comparing then to physical control. The control systern consisteci of an 8 channe1 high

impedance analog to digital converter and two 0 -5mA curent sources controlled by P C

386 cornputer. The controlIer was written in Pascal-See Appendix B. The configuration

of the system is shown in Figure 5.1.

The system to be controlled was constructed by using small box of sand ( 114cm x

7 6 n ). The pipeline was modelled by a 0.75n diameter and 112cm length steel rod

buried in the sand 2 5 n deep in the middle of the box. The dimension of the reference

electrodes was 1 7 m fiom the pipeline. The anodes were with different size and position.

The reference electrodes were connected to the 5 of 8 chamel high impedance analog to

digital converter to masure the voltage at five different locations on the pipe and the

anodes were connected to two O - 5mA current sources to impress the current on both

anodes whenever the soi1 resistivity changes. The pipeline were connected the gromd of

the current sources.

Where, R + Copper/copper sulfate reference electrodes

A -+ Graphite Anodes

B -, Box filled with sand, including the pipeline

Page 75: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.1: The configuration of a real system 64

Page 76: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

C + Box containhg two power supplies and 5 pH meters

D + Cornputer interface.

The 126 d e s employed in the contxol were the same a s those are used in simulation.

Each single d e is a fiizzy relation between the voltage at VI, V2, V3, V4, V5, and the

impressed curent at each anode ( Il, I2 ). The d e s are based on the simulation results

and the understanding of the cathodic protection hction.

5.1 Results with difTerent membership funct ions

In these nuis, the controlIer was imp1emented for dlfferent singleton membership functions

with the same anode and reference electrode positions for all cases. The experimental

results for the fuzzy control are shown in the Figures below.

In Figure 5.2 the results were obtained by chmging the control setting to Big change

f 1.0, and S m d change I0.1, and the position of the anodes were as in Figure 5.3; with

the anodes in the corner of the box far away from the pipeline. In this run, the behavior

of the controller to respond to a step input is very fast response and no overshoot. At

VI, the control output of the FLC jumps to the protected voltage which is 850mV; at

V2, and V4 the pipe was alrnost protected, and at V3, the pipe was under protected, but

at V5, the pipe became over protected. By lookuig to the current change, the curent

was very high at the first stage, then at the next stages starts decreasing slightly. The

performance of the FLC in response to a step input is closer to the ideal performance.

The ISE control performance of Figure 5.2 is:

In Figure 5.4, the results were obtained by changing the control settings ( tuning the

membersbip function width ) to Big change &1.0, and Small change f 0.01. The position

of the anodes was the same as used in 5.3- where the dimension of the anodes was 17m

Selected Index

ISE

fiom the pipeline. The experimental results in Figure 5.4 have c l d e d that the new

65

Refi

8.54xlO5

h f 2

1-12x 1O6

Ref3

1.61~ 106

Ref4 UIûx1O6

Ref5

1 . 0 3 ~ IO6

Page 77: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.2: The fuzzy control performance with Big change f 1.0 and SmaU change k0.1 66

Page 78: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

R=Reference electrode

Figure 5.3: The configuration of the anodes and reference electrode positions from the pipeline 67

Page 79: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

euning of the fiizzy control is usehl where the pipeline at VI, Vz, and V4 is protected,

at V3 the FLC jumped to mder protection, but, at Vs the response was over protected-

The response in this run is very fast with low power consumption, and the integral of

the square of the error is:

which shows that the performance of the FLC in response to a step point is much

Selected Index

ISE

closer to the ideal performance-

Figure 5.5 shows the characteristic of the FLC response on the tuned membership

scale to the Big change f0.5, and S m d change f0.01. The fiizzv control performance

Refi

3 . 3 1 ~ 105

was almost as fast as in Figure 5.4 with a Merence in the current which is slightly larger,

and &O with s m d ciifferences in the integral square error ( ISE ).

The ISE control performance is:

Ref2

3.16~ 105

Re&

3-17x 105

Ref3

4.58 x105

The performance of the fuzzy logic controller with Big change f0.5, and S m d change

RefS

6.25~ 10'

ISE

f 0.1 is shown in Figure 5.6, which expresses the response of the FLC to a step input.

The response with the current sources starts increasing at the final stage. The pipeline

at the stages VI and V3 is under protected, at the stages V2 and V4 almost protected.

7-8OxlP 1 9.46~105 L

At stage V5 it is over protected. In this run, the integral square error performance is:

9.15x105 -

1.15x106 9.45x105

which is not bad.

Selected Index

ISE

By tuning the membership functions to Big change M.2, and Small change f 0.1, Fig-

ure 5.7 shows the fimq control performance where the voltage VI, Vz, V3, and V4 jumps

to a lower than the set point whereas the pipeline at these positions is under protected.

The Voltage VI jumps to the set point which means the pipe at this point is protected.

Refi

7-06x105

Ref2

5.46x105

Re&

7.58~10~

Re&

5-24x10'

Refs

6.1Ox1O5

Page 80: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.4: The fuzzy control performance with Big change f 1.0 and S m d change f 0.01 69

Page 81: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Time,

Figure 5.5: The fiizzy control performance with Big change f0.5 and S m d change f0.01 70

Page 82: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

lime,

Figure 5.6: The h z y control performance with Big change f0.5 and Srna change f0.1 71

Page 83: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

The pipe at V5 becornes over protected. This run has high cument consumption and the

response of the fuzzy control takes long time to mach the set point. The ISE control

performance of Figure 5.7 is :

Selected Index 1 Refi Refi Ref3 1 R . 4 1 Re f5 1

In this nin where the Big change of the scale of the member ship is f0.2 and the

SmaU change is &O-01. Figure 5.8 shows the response of the F'LC where is the response

is very slowly and too much curent to reach the set point. The pipeline at the voltage

VI, V4 is almost protected, at V2 is proteded, at V3 is under protected and at V5 is over

protected. The ISE control performance isr

The overd results of these physical tests is that the fuzzy logic system provides

Selected Index

ISE

satisfactory control. Tuning is accomplished by changing the sîze of the Big and Srnd

changes which affect the gain of the controller. Large changes give high gain.

Rdl

1.83 x 106

5.2 Results with difEerent position and size of anodes

Several results were carried out with the tuned controller to observe the affect of anode

position and size. The k z y control performance is shown in the figures below whereas,

the controller Ïmplemented with different position and size of anodes. The control setting

for all experiments was the same. As a result of the fact that the Big change &O-1 and

Small change f0.01. Figure 5.9 shows the position and size of the anodes.where the

dimensions of the anoda at Pi, Pz, P3, and P4 were at 17m fkom the pipeline, and the

dimensions at P5, P6, and P8 were at Sem from the pipeline.

Figure 5.10 and Figure 5.11 show the characteristics of the fuzzy control response

with large anodes at position2 and 3, and small anodes at position2 and 3 respectively.

In these nuis, the ends are uder protected by (IOmV), and the center is over protected

Refs 2.61~ 106

&f;l

1.65 x 106

Refi

1.55 x 106

Ref3

2c11x106

Page 84: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Time,

Figure 5.7 The fuzy control performance with Big change f0.2 and S m d change f0.1 73

Page 85: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.8: The fuzw control performance with Big change f0.2 and Small change &O-01 74

Page 86: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.9: The different size and position of the anodes 75

Page 87: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

by (2ûmV). At the first stage of response* where the soil resistiviw was very high gave

wide d a n c e which means stray field affect the voltage readings, and fkom the stand

point of corrosion, that means no corrosion.

Water added to simulate r a b decreases the resistivie around the pipeline and the

filzzy control starts to impress current in both anodes to inaease the voltage at each

point on the pipe. In practise, the voltage on an anode must be higher to get same

curent so power inmeases. In Figure 5.11, possibly the contact between the anode with

the soil changes the amount of cment. The controller Ltill response well. The ISE control

performasces of Figure 5.10 and 5.11 respectively arer

Selected Index

ISE

From Figure 5.10 and 5.11, the size of the anodes in this pipeline configuration was

Selected index

ISE

not too critical for the fuzzy control performance. However, the position of the anodes

Refr

3 .64~ 10''

made a difference, which means that spacing is very important for the characteristic

response of the fuzzy controller. Figure 5.12 and 5.13 illustrate the importance of the

Refi

2 . 5 7 ~ 1Olo

anode positions.

Refi

3.69~ 10l0

The fuzzy control performance show in Figure 5.12 was obtained after changing the

Re52

2 . 7 6 ~ 1010

size and the position of the anodes, where the size is small ( almost the haIf of the initial

Ref3

3 . 6 6 ~ l0lo

anodes ), and the positions are at P l and P4. The performance of the fuzzy control giws

over protection at V2, V4, and V5; protected at V3; and h o & protected at VI. The

integral square error ISE is:

Ref3

2.74~ 10lo

In Figure 5.13, the characteristic response of the fuzzy controller shows that the

Re&

3.64~ 101°

pipeline is over protected at the ends to maintain at V2 and V4 almost protected and V3

Refs 3 . 6 1 ~ 10''

2.73 x 10l0

Rf%ii

2 .72~ l0lo -

Page 88: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND
Page 89: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.11: The fuzzy control performance with srnall anode size at P2 and P3 78

Page 90: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Time,:

Figure 5.12: The fuzzy control performance with smd size anodes at positions Pl and P4 79

Page 91: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

is under protected. The size of the anodes is small and the positions at P5 and P8. The

ISE control perfommce is:

The table below showed the aspects of aJl the cases with the same range ofmembership

Selected Index

ISE

functions and different anode position:

Membersbip Range 1 ISE 1 Ekpennient Duration 1 Number of Rules ( Anode Positions 1

1 -0.1 -0-01 0 0.1 0111 1 273x10~~ 1 5 0 3 k 1 126 1 2 and 3 1

Refr 1.83~ log

1 -0.1 -0.01 O 0.1 0.01 1 2.71~10~ 1 2185sec 1 126 1 1 and 4 [

Ref2

2 .49~ 106

performance of the FLC in response to a step input much closer to the ideal performance.

These r d t s show the trends which are expected 6com an empmcal know1edge of the

1 -0.1 -0.01 0 0.1 0.01 1 2.49x106 1 1332sec

protection process. The above table also indicates the consistency obtained in these

experiments as two sets of duplicate results are shown. Although there is some variance

in the ISE d u e s due to error, the change in conditions gave a far Iarger affect.

Ref3

3.73~ 106

Moving the anodes fiom faraway to close the pipe, and decreasing the size makes the 126

2-18 x 106

land4

Ref

5.01 x 106

Page 92: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Figure 5.13: The fuzzy control performance with mail size anodes at positions at P5 and P8 81

Page 93: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Chapter 6

Conclusions and Recommendat ions

In this work, a controller for the cathodic protection of buried pipeline, has been de-

veloped, implemented and evaluated. The model is based on a fuzzy controller- The

following conclusions may be drawn from constructing and testing this system;

1- The fuzzy control protects the pipeline £iom the corrosion. The controller was

flexible, and the model conesponded well with the changing of the soil resistivity ( the

current always try to keep the voltage on the pipeline at the setpoint with lOmV under

protected at some points and 20mV over protected at other points. This is with the

acceptable range [51].

2- The contr011er worked weU in simulation, compensating for changes in soil resistiv-

ity.

3- The simulation agreed wd with physical experimental data Comparing the sim-

ulation results with the experiment r d t s . The major ciifference was due to speed of

water movement through the sand

4 Thing the membership functions was very important to obtain good fuzzy control

performance. Tuning or changing the control setting of the output membership functions

a e c t s the gain of the controller, which affects the control performance.

5- The anode positions were more important than the anode sizes. Moving the anodes

fiom faraway to close to the pipeline makg the fun, control performance much closer

Page 94: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

to the ideal-

Recommendations for future study in the area of the Fuzzy controUer are:

1- Test or implement the fkzy controlIer with a long pipeline and see how the larger

scale experiments on the long pipeline can &ct the performance of the hmy controller.

2- Design a fuzy contr011er for cathodic protection of large, buried pipe networks

where the process of protection becomg more difficult due to stray currents.

Page 95: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Bibliography

[Il Corrosion Bwics: An Introdvction National Association of Corrosion engineering,

1440 South Creek Drive, Houston, Texas 77084, 1984.

[2] Hussu A. k z y control and defiizzification- Mechatmnicsy 5 (5) :5 13-526, ~Mmch

1995.

[3] Wagdy R Anis. Design of control circuit of solar photwoltaic powered regulated

cathodic protection system. Solor en=, 55(5):363-366, 1995.

[4] Wagdy R Anis and Hany A. Mons. Photovdtaic-powered reguiated cathodic pr*

tection system. Power sources, 50:27-32, 1994.

[5] Shigeru Aoki and Kenji Amaya. Optimization of cathodic protection system by

BEM. Engineering analysis urith boundary elements, 19(2):147-156, 1997-

[6] Adrian B. and Moshe B. Matlab for Engineers. Addison-Wesley, 1995.

[7] Joseph F. Bosich. Corrosion Pmention !or Pmcticing EnMeers. Bames Noble,

hc . , New Yodq 1970-

[8] Samuel A. Bradford. Corrosion Control. Van Nostrand Reinhold, New york, 1993.

[9] F. Brichau and J. Deconin& A numerical model for cathodic protection of buried

pipes. Cornosion science, 50(1):39-49, 1994.

Page 96: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[IO] Deconinck J. Brichau F. and Driesens T. Modehg of underground cathodic protec-

tion stray currents. Corrosion-The journal of science and engineen'ng, 52(6):480-

488, June 1996.

[Il] Richard A. Corbett . Cathodic protection as an equident electrical circuit. IEEE

transactions on indwtry applimtiow, IA-21(6):15334537, 1985.

[12] Abd El-Shakow M. ElSamahy and Wagdy R Anis. Microprocesor based control

of photovoltiac cathodic protection system. Energy conversion and management,

38(1) :21-27, 1997.

[13] Brichau F. A Mathenzutid Mode[ for the Cathodic Protection of Undeqmound

Pipelines Including Stray C u m t s . PhD thesis, Vrije Universiteit Brussel, 1994.

[14] Tosato F. and Quaia S. Cathodic protection of extended burïed conductor networks:

A new design method. IEE pmceedings, 139(5):443-448, 1992.

[15] Zamani N. G. and Chuang J. M. Optimal control of current in a cathodic protection

system: A numerical investigation. Optimal contrul appl. methods, 8:339-350, 1987.

[16] C. N. Cao G. L. Song and H. C. Lin. A new technique for correlation of underground

corrosion. Corrosion science, 51(7):491497, 1995.

[17] Linda Garverick, editor. Corrosion in The Petrocha id Indwtry. Materials Park,

OH: ASM International, 1994.

[18] El Ghitani H. and Shousha A. H. Microprocesor-based cathodic protection system

using photovoltaic energy. Applied energy, 52:299-305, 1995.

[19] Marndani E. H. Advances in the linguistic synthesis of fuzzy controllers. Int. J.

Man-Machine Studies, 8:669-678, 1976.

[20] Yoichi Riichiro Ha-Jin, Yung. Fuzzy expert system for continuous speech recognition.

Ezpert systern vith applications, 9(1) :81-89, 1995.

Page 97: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[21] Albrecht Iri011, Fhzy rules and fuzy functiom: A combination of logic and arith-

metic operations for fuzzy nrimbers. Fuay sets and systems, 99:49-56, 1998.

[22] Zhang Y. Q. Kandel A. and Henne M. On use of h z y logic technology in operating

systems- Fmzy sets and systew, 99~241-251, 1998.

[23] Chen C. L. and Kuo F. C. Design and analysk of a fuzzy logic controIler- Intma-

tional j0217md of systas science, 26(5):1223-1248, 1995.

[24] Steven Hou L. and SUR W. Numerical methods for optimal control of impressed

cathodic protection systems. Intemationut Joarnal fw numm*C(LL mdhods in engi-

nemng, 37:277!3-2796, 1994. -

[25] Steven Hou L. and Sun W. Optimal positioning of anodes for cathodic protection.

Society for industrial and applied rnathematics, 34(3):855-873, 1996.

[26] Chuen Chien Lee. Fiizzy logic in control systems: l h m y logic controller-part1 &2.

IEEE transactions on systems Man and Cybernetics, 20:404-435, 1990.

[27] Huang S; Nelson R M. Rule development and adjustment strategies of a fuzzy

Iogic controller for an INAC systern: Part two- experiment. Ashare tmnsactions:

Symposia, lOO(1) :851-856, 1994.

[28] E. H. Mamdani. Application of b z y logic to approximate reasoning using linguistic

synthesis. IEEE transactions on cornputers, 26(12):1182-1191, 1977.

[29] E. H. Mamdani and Assilian S. An experiment in linguistic synthesis with a fuzzy

logic controller. International Journal of Mon-Machine Studtes, 7(l): 1-13, 1975.

[30] Jan- L. Grantner Marek J. Patyra and Kirby Koster. Digital fuzzy logic controller:

Design and implement ation. IEEE trunsactzons on futzy systems, 4(4) :439-459,

1996.

Page 98: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[31] Fontana Mars G. Corrison EngnLetming. MaterÏaI Science Engineering- McGraw-Hil,

3rd edition, 1987.

[32] Georg F. Mauer. A hizy logic controIIer for an ABS barking system. Iixe tmmac-

tions on fvay system, 3(4) Sl-388, 1995.

[33] Donald H. McIntosh. Grounding where corrosion protection is required. IEEE

transactions on indwtry applications, IA-18(6):600-607, November 1982.

[34] Marshakm A. 1. Mikhailovskii Yu N. and Petrov N. A. Monitoring of under-

ground pipeline corrosion condÏtÏon with semory instruments* Protedion of metals,

33(3) :293-295, 1997.

[35] John Morgan. Cathodic Pmtection. National Association of Corrosion Engi-

neers(NACE), 1440 South Creek Drive, Houston, Texas 77084, 2 edition, 1993.

[36] Kwok L. Tang Robert J. MulhoILand. Comparing fuzzy logic with classical controller

designs. IEEE tmnsactions on system, man, and cybernetics, SMGl7(6):10854087,

1987.

(371 Paraskevopoulos P. N. Digital Control System Prentice Hall Europe, Campus 400,

Maylands Avenue, Hemel Hempstead, Hertfordshire, HP2 7EZ, 1996.

[38] Roger Jang J. S. Gulley Ned. Fùzzy Logic Toolbox User's Guide. The Math Works,

Inc., 24 Prime Park Way, Natick, Mass. 01760-1500, 1995-

[39] Emenike C. O. Mathematical modehg of cathodic protection systems for oil and

gas facilities. Anti corrosion methods and materials, 42(4):68, 1995.

[40] Kennelley K. J. Orazem M. E., Esteban J. M. and Degerstedt R M. Mathematical

models for cathodic protection of an underground pipeluie with coating holidayspart

1-t heoratical development . Cowosion sczence, 53 (4) :264-272, 1997.

Page 99: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[41] Kennelley K. J. Orazexn M E., Esteban J. M. and Degerstedt R M. Mathematical

models for cathodic protection of an underground pipeline with coating holidays:

Part 2-case studies of pmallel anode cathodic protection systems. Cmsion-The

journal of science and engineering, 53(6):427-436, 1997.

[42] MarshaU E. Parker. Pipeline Corrosion and Cathodic Protection Gulf Publishing

Company, Houston, Taras, 2 edition, 1962.

[43] Timothy J. Ross. Fvrzy Logic with Engineering Appli~ations~ McGraw-Hill, Inc,

1995.

[44j Huang S. and Nelson R M Rule development and adjustment strategies for a fuzzy

logic controller for an HVAC system: Part one-analysis. A S H M %rt~~:Symposia,

l O O ( 1 ) :Ml-850, 1994.

[45] Deepak Sabharwal and KuIcIip S . Rattan. Design of a rulebased f u z y controller

for the pitch axis of an l lnmmed research vehicle. In Robert J. Marks II, editor:

F v r y Logzc Technology und Applications, pages 81-87, 445 Hoes Lane, Piscataway,

New Jersey 08855-1331, 1992. IEEE technid activities bomd.

[46] PhSp A. Schweitzer. Corrosion and Corrosion Protection Handbook Corrosion

Technology; 1, Corrosion TechnoIogy ( New York, N. Y. ) ;. New York: M. Dekker,

1989.

[47] PhiIip A. Schweitzer. Cornsion Engineering Randbook. Corrosion Technology; 11,

( New York, N. Y. ) ; 11. New York: M. Dekker, 1996.

(481 Burstein G. T- Shreir L. L and Jarman R A. Corrosion Volume 2: Comsion

Control. Oxford; Boston: Butt erworth-Heinemann, 3 edition, 1994.

[49] Cecil L. Smith. Digital Cornputer Pmcess Control. Intext educational publishers,

1972.

Page 100: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[50] Herbert E. Uhlig and R Wnston Revie. Cornsion and Cornsicm Contml: An In-

troduction to Cmsz'on Science and Engin-ng. A Wdey-Interscience Publication,

John Wiey & Sons, 3 edition, 1984.

[51] Kondrashova N. V. and Nesterenko S. A. Imptovement of the efficiency of cathodic

protection. Matera'& science, 32(6):653-658, 1996.

[52] Sun W. Optimal control of impressed cathodic protection systern in ship building.

Appl. Math. Modelling, 20:823-828, November 1996.

[53] Kimura Yuasa, Shioya- FoUow-up charactenstiics of a s m d automatic guided vhicle

system with fuzzy control In Robert J. Marks 11, editor, Ftrzzy h g i c Technology -

and Applications, pages 56-61, 1-1, Minamiohsawa, Hachiouji-shi, Tokyo, 192-03,

Japan, 1993. Ieee technical activities board.

[54] Chuang J. M- Zamani N. G. and Porter J. F. BEM simulation of cathodic protection

systems employed in infinite electr01ytes. International journal for numerical method

in engineering, 2k605-620, 1987.

Page 101: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Appendix A

Simulation code of single anode

systern

[System]

Name='cathodic6'

Type='mamdanil

Vérsion=2-0

NumInputs=3

NumOutputs=l

NumRules=27

AndMethod='min'

OrMethod='max'

ImpMethod='minl

AggMethod='maxl

DehzzMethod='centroid'

[ I ~ P ut11

Name='vl '

Range=[O 17001

NuMMFs=3

Page 102: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

MFl='low':'tnmf ,[-850 O 8501

MF2=70k7:'trimf, [O 850 17001

MF3='high':'trhP, [85O 1700 25501

@put21

Name='v2'

Range=[O 17001

NumhrfFs-3

MF1='low':'trimf7, [-850 O 8501

MF2='ok::'trimf',[O 850 17001

MF3='high':'himf ,[85O 1700 25501

[ I ~ P ut31

Name='v3'

Range= [O 17001

NumMFs-3

MFl=>l~w~:'trinif', [-850 O 8501

-vlFS='ok': 'trimff , [O 850 17001

M?3=%igh':'trimf', [%O 1700 25501

[Outputl]

Name=' Anodel'

Range=[-1 11

NumMFs=3

MFl='l0~':'trimf>,[-2 -1 O]

MF2='0k':'trimf ,[-1 O 11

MF3=%igh':'trimf7, [O 1 21

[Rules]

1 1 1, 3 (1) : 1

1 2 2 , 3 (1) : 1

1 3 3, 3 (1) : 1

Page 103: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[S y st em]

Name='cathodic5'

Page 104: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND
Page 105: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

MF'1='lowS:'trimf, [-=O O 8501

MF2='ok':'trimfJ,[0 850 17001

MF3='high':'trimf', [85O 1700 25501

[Outputl]

Name='anode17

Page 106: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

[System]

Name='cathodic99'

NumOutputs=l

NirmRdes=27

AndMethod='min7

OrMethod='max'

ImpMet hod= 'min'

AggMethod='max'

DefuzzMethod='centroid'

[hputll

Name='Vl '

Page 107: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Range=[O 17001

NumMFs-3

MF1='lowyr'trimf', [-850 O 8501

MF2='ok':'trimfY[O 850 17001

MF3='highY:'himf, [85O 1700 25501

Fiput21

Name='V2'

Range=[O 17001

NumME's-S

MFl='low':'tnmf',[-$50 O 8501

MF2='ok':'trimfYy [O 850 17001

MF3='highY:'trimf', [85O 17M) 25401

~ n ~ u t 3 1

Name='V3'

Range=[O 17001

NumMFs=3

MF1='low':'trimfy, [-850 O 8501

MF2='oky:'trimf', [O 850 17001

MF3='high':'trimf7, [SSO 1700 25401

[Output 11

Name='Anode(I)'

Range=[-1 11

NumMFs=5

MFl='bigdec':'trapmf',[-1-45 -1.05 -0.95 -0.551

MF2='dec':'trunf2,[-1 -0.5 O]

MF3='n0&ange':'trimf'~[-0.5 O 0.51

MF4='incY:'trimf', [O 0.5 11

MF5='biginc7:'trapmf', [O.Xi 0.95 1.05 1-45]

Page 108: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND
Page 109: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Appendix B

fuzzy logic control code for multiple

anode system

program pipeline;

{ This program simulates a pipeline in wet or dry soi1 and calculatesthe current for

anodic corrosion protection using fuzzy logic.

Pipeline written by M. Almardy and G. H a m d

Guelph, Ontario

September 1998.

Singleton form GLH 13-X-98

Control added GLH/MA CV-99 } {************************************************************** 1

uses DOS,CRT,SERIAL; { DOS for tirne, CIYT for keypressed, SERIAL for RS232 )

const

imax = 2.0; { maximum anode current )

setpt = 0.850; { protection voltage setpoint )

Blow = 0.0; { low voltage membership )

Clow = 0.850;

Aok = 0-0; { ok voltage membership )

Page 110: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

Bok = 0-850;

Cok = 1.700;

Ahigh = 0.850; { high voltage membership )

Bhigh = 1-700;

xbigdec = -0.8; { bigdecrease current membership )

xdec = -0-1; { decrease cuxent membership )

nochange = 0-0; { ok current membership )

xinc = 0.1; { increase cment membership )

xbiginc = 0-8; { bigincrease current mernbership )

Var coef : array[l..%, 1..5, L.31 of real; { regression coefficients:

index 1 is soii conductivity

index 2 is the electrode number

index 3: 1 is the contast,

2 is anode number 1

3 is anode nuder 2 )

voltage : anay[O..?] of real; { Voltage measurements in mV:

index is electrode number )

vl,v2 ,v3,v4,v5: array[l--31 of r d ; { fuzzy voltage memberships:

index is low, ok, high )

cwent : array[l..2] of real; { Protection m a t s in mA:

index is anode number )

incr : array[1..2,1..5] of real; { fuzzy current changes:

index 1 is electrode number

index 2: 1 is big decrease

2 is decrease

3 is no change

4 is increase

5 is big increase )

Page 111: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

ise : array[l..5] of real; { ISE voltage errorr

index is dectrode number )

out : text; { r d t file )

name : string; { result file name )

jlk : integer; { counters)

cond : integer; ( soil conductiviQr flag )

time : real; {runtime)

flag : char; { keyboard event flag )

start : red; { &art time,sec )

step : reaI; { step time )

next : real;

glitch : integer;

{ absolute netx sample thne )

{ ES232 error count )

wait : bookan; { wait for serial input )

iook : boolean; { RS-232 success ) {***********************************************************

XTIMER gets the system t h e as seconds past new year ****************************&******************************* 1 function xtimer:red;

var hour,minute,second,sec100 : word;

year,month,day,dayofweek : word;

a : array [1..12] of integer;

x :integer;

begh

getdate(year,month,day,dayofweek); { get system date )

a[l] :=O; a[2] :=SI; a[3] :=59; a[4]:=90; { build Julian day }

a[5] :=120; a[6]:=151; a[7]:=181; a[8]:=212;

a[9] :=243; a[10] :=273; a[ll]:=304; 4121 :=334;

x: =a [month] +day ;

Page 112: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

if (((year mod 4)=0) and (not(year mod 100) =O) { leap year correction )

and (month >= 3)) then

x:-=xtl;

gettime(hour,minute,second7sec100) ; { get system tune )

~Unei:=(x*86400-0)+((((hour*60~0)+1ninute) O ) {get seconds fiom New Year)

+second) +(seclOO/ 100.0) ;

end;

Procedure loadcoef; { read coefficients kom file )

Var CO& : text; { data file }

j,k : üiteger; { array indeces )

begin

assign (co&,'pipecoef-dat '); { set file name )

reset (CO&); { open file for read )

for j:=l to 2 do { read coeficients )

for k:=l to 5 do

readln (coefs~coef b,k,l], coef b7k,2], coef E,k,3]);

close (CO&); { close the file )

end;

(********************************************************

VOLTAGE gets ar array of VOLT [0..7] from ISYSO5.

OK is a flag for successful completion- ********************************************************* 1 Procedure isysstart; { start RS-232 luik )

begin

iook:=init -port (1 ,!36ûû,none, l,8); { open RS232 port )

iook: =clear-port (1) ;

set-read-timeout(1); { 1 sec read timeout )

wait:=tme; { wait for input chars )

Page 113: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

end;

procedure ünkerr (var reading:string);

vat muthe : real; { elapsed time, sec. }

j : hteger;

begin

runtime:=xtimer-start; { send link error msg }

wrîteIn('Link &or at ' ,rutirne: 12:2, ' Reading:' ,reading) ;

glit&=glitch+l; { count the error )

iook:=close-port@); { uninstall the port )

isysstart; { reinstall the RS-232 port )

next:=xtimer; { c as soon as possible )

end;

procedure readvolts; { read voltages )

var value : integer; { integer return value )

Channel : integer; { Channel number )

j : integer; { character count )

reading : string; { ascii from LSYSO5 )

chan : char; ( ascü Channel character )

ch : char; { ascii data character )

xx : byte; { output byte )

v : real; { temporazy for calibration )

c d : array [O..?] of real; { cdibration constants )

function hexval(j:integer) :int eger; { convert ascii to integer )

var xtemp :integer;

begin

xtemp:=ord(readingb])-48; { strïp base fiorn char )

if (xtemp > 9) then xtemp:=xtemp-7; { fix alpha ofkt )

if (xtemp z 15) then xtemp:=xtemp32; ( fix lower case ofEjet )

Page 114: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

harval:=xtemp; { r e m integer value )

end;

begin

chame1:=0; { start at cha.nnel0 )

repeat

chan:=chr(channel+48); { convert Channel to ascii )

readuig:='?07+chan+'A'; ( build cornmand string )

for j:=1 to 4 do begin { send it to ISYS05 )

xx:=ord(reading[il) ;

iook:=write-port(1~);

end;

1 { pet data string )

repeat

iook:=read-port(l,chywait);

reading lj] :=ch;

j:=j+l;

untïl (ord(ch)=lt) or (not(iook)); { ends with cr or fail )

if iook then begin

reading[O] :=chr&l) ;

vdue:=hexMi(2)*256+hexvitl(3)*16+h4(4) ; { convert to integer )

if (reading[l] = '-') then value:=due; { fk sign )

cal[O] :=l.O; { add calibration factors )

cal[l] :=l.O;

c42] :=1.0;

cal[3]:=1.0;

cd[4] :=1 .O;

4 5 1 :=1 .O;

cd[6] :=1 .O;

Page 115: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

cd[7] :=1.0;

voit age[channd] :=5-O*(value/4095 -0) +cal; ( scale reading to volts )

channel:=channel+l; { do next Channel )

end else Iinkerr(reading) ; {reset ifIinkfails )

tmtil (Channel > 7); { quit if done or fail )

end;

Procedure getvolts (Var I :integer); { calcdate voltages )

Var j : integer;

begin

if L > 0-0 Then begin

for j:=l to 5 do

Voltage el := coef[lj, 11 + (coef[l,j ,2] * m e n t [l] ) +(c~efll j ,3] *current [2]) ;

end else readwilts;

end;

(********************************************************* } IOUT outputs a m e n t in mA to MUDR05.

CHAN sets the board and channd address.

********************************************************** 1 procedure iout (var i:rea.l; var chaminteger);

var cmd : array [1..9] of char;

ma : integer;

im : array [O--31 ofreat;

board: integer;

ch : integer;

xx : byte;

j : integer;

function inthex (m:i.teger) :char;

var k : integer;

Page 116: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

begin

k:=m+48;

if k > 57 then k:=k+?;

inthex:=chr(k)

end;

begin

board:=5; { point to board )

if (chan >=2) then board:=6;

ck= chan mod 2; { set chamnel)

im[O] :=2.29; { set max output currents )

im[l]:=2.23;

im[2]:=2.21;

b[3] :=2.24;

cmd[l]:=' ?'; { build command string )

cmd [2] :=inthex(board) ;

cmd[3] :=inthex(CH) ; { set Channel number )

cmd[4]:='07;

cmd [5] :='Oy;

cmd [ô] :='O' ;

ma: =round((i/im[ch~) *255.0) ; ( scale current )

cmd[7] :=inthex(ma div 16) ; ( add to command line )

cmd[8] :=inthex(ma mod 16) ;

forj:=lto8dobegin {sendittoISYS05)

xx:=ord(cmdb]) ;

iook:=write-port(1,xx);

end;

end;

Page 117: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

function low (var x : real) : r d ;

var mu : real;

begin

if (x < Blow) then mu:=I.O;

if (X > Blow) and (x <= Clow) then mu:=(l.O/(Clow-Blow))*(Clow-x);

if (x > CIow) then mu:=û.O;

low := mu;

end;

function ok (var x : r d ) : r d ;

var mu : real;

begin

if (x < Aok) then mu:=O.O;

if (X >= Aok) and (x <= Bok) then mu:=(l.O/(Bok-Aok))*(x-Aok);

if (X > Bok) and (x <= Cok) then mu:=(l.O/(Cok-Bok))*(Cok-x);

if (x > Cok) then mu:=O.O;

ok := mu;

end;

h c t i o n high (var x : real) : real;

var mu : real;

begin

if (x < Ahigh) then mu:=O.O;

if (X > = Ahigh) and (x < = Bhigh) then mu:= (1.0/ (Bhigh-Ahigh) ) * (x- Ahigh) ;

if (x > Bhigh) then mu:=l.O;

high := mu;

end;

Page 118: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

procedure f u z d y ;

begin

vl [l] :=low (volt age[l] ) ;

vi [2] :=ok(vdtage[ll) ;

v1[3] :=high(voltage[q) ;

v2 [il :=low(voltage[2]) ;

v2 [2] :=ok(volt age[21);

v2 [3] : =high(voitage [2]) ;

v3 [il :=low (volt age[3]) ;

v3 [2] :=ok(voltage[3]) ;

v3 [3] : =high(dt age[3]) ;

v4 [l] :=low(volt age[4] ) ;

v4 [2] : =ok(volt age [4]) ;

v4 [3] : =high(voltage [4]) ;

v5 [1] :=iow (voltage[5]);

v5 [2] : =ok(volt age[5] ) ;

v5 [3] : =high(voit age [5]) ;

end; {**********************************************************

function min3 (var a, b, c : r d ) : r d ;

var x : real;

begin

c; min3 := x;

end;

Page 119: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

function max2 (var a, b : red) : r d ;

begin

if (a>b) then max2 := a else max2 := b;

end;

function min2 (var a, b : r d ) : r e e

begin

if (a<b) then min2 := a else min2 := b;

end;

procedure d e s ;

var rnuxeal;

j ,k :int eger;

begin

{ initiaiize consequent memberships )

for j := 1 to 2 do for k := 1 to 5 do incrb,k] := 0.0;

{ Rule#l..if (vl is low) and (v2 is low) and (v3 is low) bigincrease I l )

mu:=min3(vl [il, v2 [il, v3 [Il) ;

incr[1,5] := max2(incr[l,5],mu);

{ Rule#2..if (vl is low) and (v2 is ok) and (v3 is ok) increase 11 )

mu:=min3(vl [l] , v2 [2], v3 [2]) ;

incr[l,4] := m d ( incr[l,4],rnu);

{ Rule#3..if (vl is low) and (v2 is high) and (v3 is high) increase I l )

mu:=min3 (VI [il, v2 [3], v3 [3]) ;

incr[l,4] := max2( incr[l,4L mu) ;

{ Rule#4.. if (VI is low) and (v2 is low) and (v3 is ok) bigîncrease I l )

mu:=min3(vl [il, v2 [l] , v3 [2]);

incr[l,5] := m d ( incr[l,5], mu);

{ Rule#5..if (vl is low) and (v2 is low) and (v3 is high) bigincrease I l )

mu: =min3 (vl [l] , v2 [l] , v3 [3]) ;

Page 120: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

incr[l,S] := max2( inm[l,5], mu);

{ Rule#G..if (vl is low) and (v2 is ok) and (v3 is low) bigincrease Il )

m u : = ~ 3 (VI [l] , v2 [2], v3 [Il) ;

incr[l,5] := m&( ùicr[1,5], mu);

{ Rule#7-.if (vl is low) and (v2 is high) and (v3 is Iow) bigincrease 11 )

mu:=min3 (vl [l] , v2 [3], v3 [l] ) ;

incr[l,5] := m d ( incr[l,5], mu);

{ Rule#8..if (vl is low) and (v2 is ok) and (v3 is high) increase Il )

mu:=mÏn3 (vl [il, v2 [21 y v3 [31) ;

incr [l,4] := max2( hcr[l,41, mu) ;

{ Rule#9..if (vl is low) and (v2 is high) and (v3 is ok) increase Il )

rnu:=min3(vl[l], v2[3], v3[2]);

incr[l,4] := max2( incr[l,4], mu);

{ Rule#lO..if (vl is ok) and (v2 is ok) and (v3 is ok) nochange )

mu:=min3(vl[2], v2[2], v3[2]);

incr[l,3] := max2( incr[l,3], mu);

{ Rule#ll..if (vl is ok) and (v2 is low) and (v3 is low) bigincrease Il )

mu:=min3(vl [Z] , v2 [l] , v3 [ll ) ;

incr[l,5] := max2( incr[l,51, mu);

{ Rule#l2..if (vl is ok) and (v2 is high) and (v3 is high) bigdecrease Il )

mu: =min3 (VI 121, v2 [3], v3 [3]) ;

incr[l,l] := max2( incr[i,l], mu);

{ Rule#lJ..if (vl is ok) and (v2 is low) and (v3 is hi&) increase Il )

mu:=min3(vl[2], v2 [l] , v3 [3]) ;

ïncr[l,4 := m d ( incr[1,4], mu);

{ Rulel4..if (vl is ok) and (v2 is high) and (v3 is low) increase Il )

mu:=min3(vl[2], v2[3], v3[1]);

incr[i,4] := max2( incr[l,4], mu);

Page 121: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

{ Rule#15..if (vl is ok) and (v2 is Iow) and (v3 is ok) increase Xl )

m1x=min3(vl[2], v2[1], v3 [2]) ;

incr[l,4] := maS( incr[l,4], mu) ;

{ Rule#lG..if (vl is ok) and (v2 is high) and (v3 is ok) decrease Il )

mu:=&3(v1[2], v2 [3], v3 [2]);

inn[l,2] := max2( incr[l,2], mu);

{ Rule#l7-.if (vl is ok) and (v2 is ok) and (v3 is Iow) increase 11 )

mu:=min3(v1[2], v2 [2], v3 [l]) ;

incr[l,4] := max2( incr[l,4], mu) ;

{ Rule#18..if (vl is ok) and (v2 is ok) and (v3 is high) decrease Il )

mu:=min3(v1[2], v2[2], v3[3]);

incr[l,2] := ma&( incr [l,2], mu) ;

{ Rule#lS..if (vl is high) and (v2 is hi&) and (v3 is high) bigdecrease I l )

mu: =min3 (VI [3], v2 [3], v3 [3]) ;

incr[l,l] := max2( incr[l,l], mu);

{ Rule#20..if (vl is high) and (v2 is low) and (v3 is low) bigincrease 11 )

mu:=mui3(v1[3], v2 [l] , v3 [l] ) ;

incr[l,5] := max2( ina[l,5], mu);

{ Rule#2l..if (vl is high) and (v2 is ok) and (v3 is ok) decrease 11 )

mu:=min3(v1[3], v2[2], v3 [2]) ;

incr [1,2] := max2( incr [1,2], mu) ;

{ Rule#22..i£ ( vl is high) and (v2 is Iow) and (v3 is hi&) increase 11 )

mu: =min3(vl[3] , v2 [l] , v3 [3]) ;

incr[l,4] := max2( incr[l,4], mu);

{ Rule#23..if (vl is high) and (v2 is ok) and (v3 is high) bigdecrease I l )

mu:=min3(vl[3], v2 [2], v3 [3]) ;

incr[l,l] := m d ( incr[l,l], mu);

{ Rule#24..if (vl is high) and (v2 is hi&) and (v3 is lm) increase 11 )

Page 122: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

mu:=min3(v1[3], v2 [3], v3 [l] ) ;

Uicr[lA := max2( incr[l,41, mu);

{ Rule#25.jf (VI is high) and (v2 is high) and (v3 is ok) bigdecrease Il )

mu:=min3(v1[3j7 v2 [31, v3[2]) ;

incr[l,l] := max2( incr[I,I], mu);

{ Rule#26..if (vl is high) and (v2 is low) and (v3 is ok) increase Il )

mu: =min3(vl[3], v2 [1] : v3 [2]) ;

incr[l,4] := max2( incr [1,4], mu) ;

{ Rule#27..if (vl is hi&) and (v2 is ok ) and (v3 ts low) increase U )

mu:=min3(v1[3], v2 [2], v3 [II);

incr[l,4] := max2( incr[l,4], mu);

{ Rule#28..if (v3 is Iow) and (v4 is low) and (v5 is low) bigincrease 12 )

mu:=&3(v3[1], v4[1], v5 [l]) ;

incr[2,5] := max2 (incr[2,q ,mu) ;

{ Rule#29..i£ (v3 is low) and (v4 is ok) and (v5 is ok) increase I2 )

mu:=min3(v3 [l] , v4[2], v5 [2]) ;

incr[2,4] := max2( incr[2,4] p ~ u ) ;

{ Rule#3O..if (v3 is low) and (v4 is high) and (v5 is high) increase 12 )

mu:=min3 (v3 [l] , v4[3], v5 [3]) ;

incr[2,4] := max2( incr[2,4], mu);

{ Rule#31.. if (v3 is low) and (v4 is low) and (v5 is ok) bigincrease 12 )

mu: =min3(v3 [1] , v4[1], v5 [2]) ;

incr[2,5] := m a d ( ùicr[2,5], mu);

{ Rule#32..if (v3 is low) and (v4 is Iow) and (v5 is high) biginaease 12 )

mu: =min3 (v3 [l] , v4 [l] , v5 [3]) ;

incr[2,5] := max2( incr[2,5], mu);

{ Rule#33..if (v3 is low) and (v4 is ok) and (v5 is low) bigincrease 12 )

mu:=min3(v3 [l] , v4 [2], v5 [l] ) ;

Page 123: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

k[2,5] := max2( incr[2,5], mu);

( Rule#34..if (v3 is low) and (v4 is high) and (v5 is low) bigincrease 12 )

mu:=min3(v3[1], v4[3], v5[l]);

incr[2,5] := ma&( incr[2,5], mu);

( Rde#35..if (v3 is iow) and (v4 îs ok) and (v5 is high) inuease I2 )

mu:=min3(v3[1], v4[2], v5[3]);

incr[2,4] := m d ( incr[2,4], mu);

( Rule#36..if (v3 is low) and (v4 is high) and (v5 is ok) increase 22 )

mu: =min3 (v3 [l] , v4[3jy v5 [2]) ;

incr[2,4] := max2( incr[2,4], mu);

( Rule#37..if (v3 is ok) and (v4 is ok) and (v5 is ok) nochange )

mu:=min3(v3[2], v4[2], v5 [21) ;

incr[2,3] := max2( incr[2,3], mu);

( Rule#38..if (v3 is ok) and (v4 is low) and (v5 is low) biginaease i2 )

mu:=min3(v3[2], v4[1], v5 [l]) ;

incr[2,5] := max2( incr[2,5], mu);

{ Rule#39..if (v3 is ok) and (v4 is high) and (v5 is high) bigdecrease 12 )

mu:=min3 (v3 [2], v4[3], v5 [3]) ;

incr[2,1] := ma( incr[2,1], mu);

( Rule#40..if (v3 is ok) and (v4 is low) and (v5 is high) increase 12 )

mu:=min3(v3[2jY v4[1], v5[3]);

incr[2,4] := m d ( iocr[2,4], mu);

{ Rule#4ï..if (v3 is ok) and (v4 is high) and (v5 is low) increase 12 )

mu:=min3(v3 [2], v4[3], v5 [l]) ;

incr[2,4] := ma&( incr[2,4], mu);

{ Rule#42..if (v3 is ok) and (v4 iç low) and (v5 is ok) increase 12 )

mu:=min3(v3[2], v4[1], v5[21);

incr[2,4] := max2( incr[2,4], mu);

Page 124: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

{ Rule#43..if (v3 is ok) and (v4 Ïs high) and (v5 is ok) decrease 12 )

mu:=min3(v3 [2], v4[3], v5 [2]) ;

incr[2,2] := m d ( incr[2,2], mu);

{ Rule#44..if (v3 is ok) and (v4 is ok) and (v5 is low) increase 12 }

mu:=min3(v3 [2], v4[21, v5[1]) ;

incr[2,4] := m d ( incr[2,4], mu);

{ Rule#45..if (v3 is ok) and (v4 is ok) and (v5 is high) decrease I2 )

mu:=min3(v3 [2], v4 [2] , v5 [3]) ;

incr[2,21 := max2( incr[2,2], mu);

( Rule#46..if (v3 is high) and (v4 is high) and (v5 is high) bigdecrease 12 )

mu:=min3(v3[3], v4[3], v5 [3]);

incr[2,1] := m&( incr[2,l], mu);

{ Rule#47..if (v3 is high) and (v4 is low) and (v5 is low) bigincrease 12 )

mu:=min3(v3[3], v4[1], v5 [l]) ;

incr[2,5] := max2( incr[2,5], mu);

{ Rule#48.i£ (v3 is high) and (v4 is ok) and (v5 is ok) decrease 12 )

mu:=min3(v3[3], v4[2], v5 [2]) ;

incr [2,2] := max2( incr[2,2], mu) ;

{ Rule#49..if ( v3 is high) and (v4 is low) and (v5 is high) increase 12 )

mu: =min3(v3 [3], v4[1], v5 [3] ) ;

incr[2,4] := max2( incr[2,4], mu);

{ Rule#50..if (v3 is high) and (v4 is ok) and (v5 is high) bigdecrease 12 )

mu:=min3(v3[3], v4[2], v5[3]);

incr[2,1] := m&( incr [2,1], mu) ;

{ Rule#5l..if (v3 is high) and (v4 is high) and (v5 is low) increase IZ )

mu: =min3(v3 [3], v4 [3], v5 [1] ) ;

incr[2,4] := max2 ( incr[2,4], mu) ;

{ Rule#52.-if (v3 is high) and (v4 is hi&) and (v5 is ok) bigdemease I2 )

Page 125: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

mu:=min3(v3 [3], v4[3], v5 [21) ;

incr [2, 11 := m d ( incr[2,1], mu) ;

( Rule#53..if (v3 is high) and (v4 is low) and (v5 is ok) incxease 12 )

mu:=min3(v3 [3], v4[l], v5 [2]) ;

incr[2,4] := max2 ( incr[2,4], mu);

{ Ruie#54..if (v3 Ïs high) and (v4 is ok ) and (v5 is low) increase 12 )

mu:=min3(v3 [3], v@], v5 [l] ) ;

incr[2 4 := max2( incr[2,4], mu);

{ Rule#55..if (v2 is low) and (v3 is low) and (v4 is Iow) bigincrease Il )

mu:=min3(v2 [1] , v3 [l] , v4[4) ;

incr [l ,a] := max2 (incr[l, 51 ,mu) ;

{ Rule#56..if (v2 is low) and (v3 is ok) and (v4 is ok) increase Il )

mu: =min3 (v2 [l] , v3 [2], v4[2]) ;

incr[l,4] := max2( incr[l,4],mu);

{ Rule#5?..if (v2 is low) and (v3 is high) and (v4 is high) increase I l )

mu:=min3(v2 [l] , v3[3], v4[3]);

incr[1,4] := max2( incr[l,4], mu);

{ Rule#58.. if (v2 is low) and (v3 is low) and (v4 is ok) bigincrease Il )

mu: =min3(vZ [il, v3 [l] , v4[2]) ;

incr[l,5] := m a S ( incr[l,5], mu);

{ Rule#59..if (v2 is low) and (v3 is low) and (v4 is high) biginmease Il )

mu:=min3(v2 [l] , v3[l], v4[3]) ;

inrr[1,5] := max2( incr[l,5], mu);

{ Rule#GO..if (v2 is low) and (v3 is ok) and (v4 is low) bigincrease Il )

mu:=min3(v2 [l] , v3[2], v4[l]) ;

incr[l,5] := max2( incr[l,5], mu);

( Rule#Gl..if (v2 is low) and (v3 is high) and (v4 is low) bigincrease Il )

mu:=min3(v2[1], v3[3], v4[1]);

Page 126: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

incr[i ,fil := max2 ( incr [1,5], mu) ;

{ RuIe#ôZ..if (v2 is Iow) and (v3 Ïs ok) and (v4 is high) increase Il }

mu:=min3(v2 [l] , v3[2], v4[3]) ;

incr[l,4] := ma&( incr[174], mu);

{ Rule#63..if (v2 is Iow) and (v3 is high) and (v4 is ok) increase Il )

mu-.=min3(v2 [l] , v3[3], v4[2]);

incr[l,4] := max2( incr[l,4], mu);

{ Rule#64..if (v2 is ok) and (v3 is ok) and (v4 is ok) nochange )

mu:=min3(v2 [2], v3 [ZJ , v@]) ;

incr[l,3] := max2( incr[1,3], mu);

{ Rule#65..if (v2 is ok) and (v3 is low) and (v4 is Iow) biginmease Il )

mu: =min3 (v2 [2], v3 [l] , v4[l]) ;

incr[i,S] := ma&( incr[l,5], mu);

{ Rule#66..if (v2 is ok) and (v3 is high) and (v4 is high) bigdecrease Il )

mu:=rnin3(v2 [2], v3[3] , v4[3]) ;

incr[i,i] := m d ( incr[l,l], mu);

{ Rule#6?..if (v2 is ok) and (v3 is low) and (v4 is hi&) Incxease 11 )

mu:=min3 (v2 [2], v3 [l] , v4[3]) ;

incr[l,4] := m d ( incr[l,4], mu);

{ Rde68..if (v2 is ok) and (v3 is hi&) and (v4 is low) increase Il )

mu:=min3(v2 [2], v3 [3], v4[l]) ;

incr[l,4] : = max2 ( incr[l,4], mu) ;

{ Rule#69..if (v2 is ok) and (v3 is low) and (v4 is ok) increase Il )

mu: =min3 (v2 [2], v3 [l] , v4 [2]) ;

incr[l,4] := max2( incr[l,4], mu);

{ Rule#M..if (v2 is ok) and (v3 is high) and (v4 is ok) decrease Il )

mu: =min3(vZ [2], v3 [3], v4 [2]) ;

incr[l,2] := max2( incr[l,2], mu);

Page 127: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

{ Rde#7l..if (v2 is ok) and (v3 is ok) and (v4 is low) increase 11 )

rnu:=min3(v2[2], v3[2], v4[1]);

incr[l,4] := max2( incr[l,4], mu);

{ Rule#72..if (v2 is ok) and (v3 is ok) and (v4 is high) decrease Il }

mu:=min3 (v2 [Z] , v3 [2], v4 [3]) ;

incr[l,2] := max2( incr[l,2], mu);

{ Rule#73..if (v2 is high) and (v3 is high) and (v4 is higb) bigdecrease Il )

mu:=min3(v2[3], v3[3], v4[3]);

incr[i,i] := maxZ( incr[i,l], mu);

{ Rule#74..if (v2 is high) and (v3 Ïs low) and (v4 is low) biginmese 11 )

mu:=min3(v2[3], v3 [l] , v4[1]) ;

încr[l,5] := max2( incr[l,5], mu);

( Rule#75..if (v2 is high) and (v3 is ok) and (v4 is ok) decrease 11 )

mu:=min3(v2 [3], v3 [2I, v@]) ;

incr [i , Z] : = max2 ( incr [l,2], mu) ;

{ Rule#76..if ( v2 is high) and (v3 is low) and (v4 is high) increase I l )

mu:=min3(v2 [3], v3[l], v4[3]) ;

incr[l,4] := ma&( incr[l,4], mu);

{ Rule#77..if (v2 is high) and (v3 is ok) and (v4 is high) bigdecrease I l )

mu:=min3(v2 [3], v3 [2], v4[3]) ;

incr[i,i] := maxZ( incr[i,l], mu);

{ Rule#?S..if (v2 is hi&) and (v3 is high) and (v4 is low) increase 11 )

mu: =min3(v2 [3], v3 [3], v4 [l] ) ;

incr[l,4] := max2( incr[l,4], mu);

{ Rule#?9..i£ (v2 is hi&) and (v3 is high) and (v4 is ok) bigdecrease I l )

mu:=min3(v2 [3], v3 [3], v4[2]) ;

incr[l,l] := max2( incr[l,l], mu);

{ Rule#80..if (v2 is hi&) and (v3 is low) and (v4 is ok) increase 11 )

Page 128: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

mu:=min3(v2 [3], v3 [l] , v4 [2J) ;

incr[l,4] := max2( incr[l,4], mu);

{ Rule#8l..if (v2 is high) and (v3 is ok ) and (v4 is low) innease 11 )

mu:=min3(v2[3], v3[2], v4[1]) ;

Ïncr[l,4] := max2( incr[l,4], mu);

{ Rule#82.-Z (v2 is low) and (v3 is low) and (v4 is low) bigincrease 12 }

mu:=min3(v2 [l] , v3 [l] , v4[4) ;

incr[2,51 := max2(incr[2,5],mu);

{ Rule#83..i£ (v2 is low) and (v3 is ok) and (v4 is ok) increase I2 )

mu:=min3(v2 [Il, v3[2j7 v4[2]) ;

incr[2,4] := max2( incr[2,4] ,mu) ;

{ Rule#84..if (v2 is low) and (v3 is high) and (v4 is high) increase I2 )

mu:=min3(v2 [il, v3 [3], v4 [3]) ;

incr[2,4] := max2( incr[2,4], mu) ;

{ Rule#85.. if (v2 is low) and (v3 is low) and (v4 is ok) bigincrease I2 }

mu: =min3(v2 [Il, v3[1], v4[2]) ;

incr[2,5] := max2( incr[2,5], mu);

{ Rule#86..if (v2 is low) and (v3 is low) and (v4 is high) biguicrease I2 }

mu:=min3(v2 [l] , v3 [l] , v4[3]) ;

incr[2,5] := ma&( incr[2,5], mu);

{ Rule#87..if (v2 is low) and (v3 is ok) and (v4 is low) bigincrease 12 }

mu:=min3 (v2 [l] , v3 [2], v4[I] ) ;

incr[2,5] := max2( incr[2,5], mu);

( Rule#88..if (v2 is low) and (v3 is high) and (v4 is low) biginmese I2 }

mu:=min3(~2[1], v3[3], v4[l]) ;

incr[2,5] := max2( incr[2,q, mu);

{ Rule#89..if (v2 is low) and (v3 is ok) and (v4 is high) increase 12 )

mu:=min3(v2 [l] , v3 [2], v4[3]) ;

Page 129: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

ï~cr[2,4] := max2( incr[2,41, mu);

{ RuIe#9O..if (v2 is low) and (v3 is hi&) and (v4 is ok) increase I2 )

mu:=min3(v2 [il, v3 [3], v4 [2]);

incr[2,4] := max2( incr[2,4], mu);

{ RuIe#Sl..if (v2 is ok) and (v3 is ok) and (v4 is ok) nochange )

mu:=min3(v2 [2], v3[2], v4[2]) ;

incr[2,3] := d( iacr[2,3], mu);

{ Rule#92..if (v2 is ok) and (v3 is low) and (v4 is low) bigincrease 12 )

mu:=min3 (v2 [2], v3 [l 1 , v4[1]) ;

incr[2,5] := max2( incr[2,5], mu);

{ Rule#93..if (v2 is ok) and (v3 is high) and (v4 is high) bigdecrease 12 )

mu: =mùi3(v2 [2], v3 [3], v4[3]);

incr[2,1] := maxZ( incr[2,1], mu);

{ Rule#94-.if (v2 is ok) and (v3 is low) and (v4 is high) increase 12 )

mu:=min3(v2 [21, v3 [l] , v4[3]) ;

incr[2,4] := m d ( incr[2,4], mu);

{ Rule#95..if (v2 is ok) and (v3 is high) and (v4 is low) increase I2 )

mu:=min3(v2 [21, v3 [3], v4[1]);

incr[2,41 := m d ( incr[2,4], mu);

{ Rule#96..if (v2 is ok) and (v3 is Iow) and (v4 is ok) increase 12 )

mu:=min3(v2 [2], v3 [l] , v4[2] ) ;

incr[2,4] := max2( incr[2,4], mu);

{ Rule#97..if (v2 is ok) and (v3 is high) and (v4 is ok) decrease 12 )

mu:=min3(v2 [2], v3 [3], v4[2]);

incr[2,2] := max2( incr[2,2], mu);

{ Rule#98..if (v2 is ok) and (v3 is ok) and (v4 is Iow) increase 12 )

mu: =min3 (v2 [2], v3 [2], v4[1]) ;

incr[2,4] := m&( incr[2,4], mu);

118

Page 130: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

( Rule#99..if (v2 is ok) and (v3 is ok) and (v4 is high) decrease 12 )

mu:=min3(v2[2], v3[2], v4[3]);

incr[2,2] := max2 ( incr[2,2], mu) ;

{ Rde#iOO..if (v2 is high) and (v3 is high) and (v4 is high) bigdecrease 12 )

mu:=min3 (v2 [3], v3 [3], v4 [3]) ;

incr [2J] := max2( incr[2,1], mu) ;

{ Rule#lOl..if (v2 is high) and (v3 is low) and (v4 is low) bigincrease I2 )

mu:=min3(v2 [3], v3 [l] , v4[lJ) ;

incr[2,5] := max2( incr[2,5], mu) ;

{ Rde#lO2..if (v2 îs high) and (v3 is ok) and (v4 is ok) decrease I2 )

mu: =min3 (v2 [3], v3 [2], v4[2]) ;

incr[2,2] := max2( incr[2,2], mu);

{ Rule#103..if ( v2 is high) and (v3 is low) and (v4 is high) increase 12 )

mu: =min3 (v2 [3], v3 [Il, v4[3]) ;

i n42 $41 := max2 ( incr [2,4], mu) ;

{ Rule#104..if (v2 is high) and (v3 is ok) and (v4 is high) bigdecrease I2 )

mu:=min3(v2 [3], v3[2], v4[3]) ;

incr[2,1] := m d ( incr[2,1], mu);

{ Rule#105..if (v2 is high) and (v3 is high) and (v4 is low) increase 12 )

mu:=min3(v2 [3], v3[3], v4[l]) ;

incr [2,4] := max2 ( incr[2,4], mu) ;

{ Rule#IOG..if (v2 is high) and (v3 is high) and (v4 is ok) bigdecrease 12 )

mu:=min3(v2[3], v3[3], v4[2]);

incr[2,1] := m a d ( incr[2,1], mu);

{ Rule#lO?..if (v2 is high) and (v3 is low) and (v4 is ok) increase 12 }

mu:=min3(v2 [3], v3 [l] , v4[2]) ;

incr[2,4] := max2( incr[2,4], mu);

{ Rule#108..if (v2 is high) and (v3 is ok ) and (v4 is low) increase 12 )

Page 131: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

mur=min3(v2 [3], v3[2], v4[1]);

ina[2,4] := ma;x2( incr[2,4], mu);

{ Rule#lOS..if (vl is low) and (v5 is low) then bigincrease Il)

mu:=min2 (VI [il, v5 [II) ;

incr[l,5] z= max2( incr[l,51, mu);

{ Rule#llO..if (vl is low) and (v5 is ok) then bigincrease I l )

mu:=min2 (vl [il, v5 [2]) ;

ina[i15] := max2( uicr[l,5], mu);

{ RuIe#lll.. if (vl k low) and (v5 is high) then inaease Il)

mu:=min2 (vl [il, v5 [3]);

incr[l,4] := max2( incr[l,4], mu);

{ Rule#ll2..if (vl is ok) and (v5 is ok) then nochange)

mu:=min2(vl[2], v5 (21) ;

ina[1,3] := ma;x2( incr[l,3], mu);

{ Rule#113.. if (vl is ok) and (v5 is low) then bigincrease Il)

mu:=min2 (vl[2], v5 [l] ) ;

incr[i,S] := ma&( incr[l,S], mu);

{ Rule#114..if (vl is ok) and (v5 is high) then decrease 11)

mu:=min2 (vl[2], v5 [3]) ;

incr[l,2] := m d ( incr[1,2], mu);

{ Rde#115..if (vl is high) and (v5 is high) then bigdecrease 11)

mu:=d(vl[3] , v5 [3]) ;

ina[l,i] := mad( incr[l,l], mu);

{ Rule#ll6.. if (vl is high) and (v5 is low) then increase Il)

mu:=min2(~1[3], v5[1]);

incr[l,4] := m a ( incr[l,4], mu);

{ Rule#117..if (vl is high) and (v5 is ok) then decrease 11)

mu:=min2 (vl[3], v5 [2]) ;

Page 132: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

incr[l,2] := ma&( incr[1721, mu);

{ Rule#118.if (vl is low) and (v5 is low) then bigincrease 12)

mu: =min2 (vl [l] , v5 [II) ;

incr[2,5] := max2( incr[2,51, mu);

{ RuIe#119.jf (vl is low) and (v5 is ok) then bigincrease 12)

mu:=minz(vl [il, v5[2]) ;

incr [2,5] := max2 ( incr [2,5], mu) ;

{ Rule#120.. if (vl is l m ) and (v5 is high) then increase 12)

mu:=minz (vl [il, v5 [3]);

incr[2,4] := ma&( incr[2,4], mu);

{ Rule#12l..if (vl is ok) and (v5 is ok) then nochange)

mu:=min2(v1[2], v5 [2]);

incr[2,3] := &( incr[2,3], mu) ;

{ Rule#122.. if (VI is ok) and (v5 is Iow) then bigjncrease 12)

mu:=min2 (vl[2], v5 [l] ) ;

incr [2,5] := max2 ( incr [2,5], mu) ;

{ Rule#123..if (VI is ok) and (v5 is high) then decrease 12)

mu:=minz(vi [2] , v5 [3]) ;

incr[2,2] := max2( incr[2,2], mu);

{ Rule#124..if (vl is high) and (v5 is high) then bigdecrease I2)

mu: =min2 (vl[3], v5 [3]) ;

incr[2,l] := max2( incr[2,1], mu);

{ Rule#125.. if (vl is high) and (v5 is low) then incresse 12)

mu:=minz(v1[3], v5[1]);

incr [2,4] := max2 ( incr[2,4], mu) ;

{ Rule#126..ii (vl is high) and (v5 is ok) then decrease 12)

mu:=min2(vl[3], v5[2]);

incr[2,2] := max2( incr[2,2], mu);

Page 133: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

end; (******#***************-*******#***************#*****************

DEFUZZLFfCAîTON ******************************************************************** }

function cofg (var k : integer) : r d ;

va.r num,denom : real;

begin

nu,:= incr b, l] %bigdec + incr [k,2] *xdec + incrk,3] %nochange

+ incrky4] '5anc + incr[k,5] 5cbigi.c;

denom:= incrF,l]+Himb,2]+in~1b3] tinm~~4]+ïncr[k15]; if denom = 0.0 then

cofg:=O.O else cofg := num/denorn;

end;

procedure datalog;

var j :integer;

begin

for j :=l to 5 do iseü]:=iseb] +((voltageb]-setpt ) * ( v o l t e t ) ) ;

write(time:6:3,' ');

for j:=l to 5 do write(voltageü]:8:3,' ');

write(' ');

for j:=l to 2 do write(c~ffent~]:6:3,' ');

writeln;

ante(out ,time:6:3,' ') ;

for j:=l to 5 do write(out,voltage~]:9:3,' ');

for j:=l to 2 do write(out,cu~~ent~]:6:3,' ');

writeln(out, flag) ;

end;

begin

writeln('Pipeiine Ver 6-V-99') ;

Page 134: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

write('Enter output file name:'); .

readln(name) ;

asçign(out parne);

rewrite(out) ;

isysstart;

glitchr=O; { initialize RS-232 err count )

step := 5-0; { set sampling tirne }

start := xtimer; { pet run &art time )

next := xtimq { nui right now )

time:=O; { initialize elapsed time }

cond:=O; { use mea~u~ed data )

if (cond O O) then loadcoef; { in simulation, get regression }

forj:=lto2docurrent~]:=O.O; {initializecurrents)

forj:=lto5doiselj]:=O.O; {initializeisevalue)

repeat

getvoolt s (cond) ;

t h e := xtimer - start; flag := ' ';

if keypressed then flag := readkey;

fuzzis.; rules;

for j:=1 to 2 do begin

cment [il :=current Ci] +cofg(j) ;

if currentlj] > imax then currentfi]:=imax;

if current [il c 0.0 then current b] :=0.0; Iout ( cment El, j ) ;

end;

dat alog;

next := next + step;

Page 135: DESIGN OF FUZZY LOGE CONTROLLER FOR THE ...collectionscanada.gc.ca/obj/s4/f2/dsk1/tape8/PQDD_0007/...ABSTRACT DESIGN OF FUZZY LOGIC CONTROLLER FOR THE CATHODIC PROTECTION OF UNDERGROUND

repeat mtil xtimer > next;

mtil( flag = 'Q' );

writeh(0ut) ;

writeln(out,'ISE control performance:');

for j j:=l to 5 do Wnteln(out,' ElectrodeYj:2,': ',ise[i]:9) ;

ciose(out ) ;

writeln;

writeln('E3E control performance:') ;

for j:=l to 5 do writeln(' Electrode'j:P,': ',ise[i]:S);

if (glitch O) then Wfiteln(gfitch:5,' communication faults');

end.