paper4 -

Upload: ganeshbtech

Post on 06-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 paper4 -

    1/12

    FuzzyLogicControlinAutonomousRobotics:

    InvestigatingtheMotorolaMC68HC12onaLineFollowingRobot

    DavidOlsen

    DepartmentofElectricalandComputerEngineering

    UniversityofMinnesotaDuluth

    1023UniversityDrive

    Duluth,MN55812.USA

    FacultyAdvisor:Dr.MarianS.Stachowicz

    Abstract

    Autonomousrobotsystemsrequirecomplexcontrolsystems.FuzzyLogic,amathematicalsystemdevelopedbyProfessorLotfiZadeh,helpstoreducethecomplexityofmodelingnonlinearproblems.Inthe1990s,MotoroladevelopedtheMC68HC12microcontrollerwithnativeFuzzyLogicinstructions.ThisresearchdeterminedtheeffectivenessoftheMC68HC12sFuzzyLogicinstructionsforroboticcontrol.ThisresearchinvolveddesigningaroboticplatformusingtheMC68HC12andtestingbinarylogiccontrolsystemsagainstFuzzyLogiccontrolsystems.Theresearchanalyzedthetwosystemsusingfourcriteria:(1)thesizeofmemoryrequiredtodevelopthecontrolsystem,(2)theeaseofwritingthecontrolsoftware,

    (3)howwellthecontrolsystemmanagedthefunctionsoftherobot,and(4)theoverallprocessingpowerofthesystem.TheresultsshowedthatFuzzyLogicuseslessmemorythanbinarylogicandismucheasiertodesign,althoughmoredifficulttoprograminitially.FuzzyLogiccancontrolmorefunctionsoftherobotandhasgreaterprocessingcapabilities.Thepower,easeofuse,andsmallsizeofFuzzyLogicinstructionsma

    eFuzzyLogicapracticalsolutiontoautonomousroboticcontrolsystems.

    Keywords:FuzzyLogic,robotics,controlsystems,HC12

    1.Introduction

    Theexpansionofroboticsandmicrocontrollersintothefacetsofeverydaylifeincreasestheneedtodevelopefficientcontrolsystems.Anon-traditionalapproachtocontrolsystemdesignistheuseofFuzzyLogic.

    FuzzyLogicextendsfromthetraditionalcrispboundariesofAristotelianlogic(trueorfalse)toincludetheconceptofpartialtruthhavingtruth-valuesbetweencompletelytrueandcompletelyfalse.Dr.LotfiZadehofUniversityofCali

  • 8/2/2019 paper4 -

    2/12

    orniaBer

    eleyfirstintroducedthesefuzzymethodsin1965[1].Thesemethodsallowtheengineertousenaturallanguagetodescribeandimplementthecontrolsystem.FuzzyLogicuseslinguisticvaluestorepresentpartoftherangeanordinarycrispvariablemayassume[2].Forexample,avariablet,thatrepresentstemperature,mayvaryfrom0oCto100oC.Alinguisticvalue,COLDmaybeusedtorepresenttemperaturesfrom0oCto10oCwhileotherlinguisticvaluesrepresentotherranges.FuzzyLogicma

    esitpossibletosolvecomplex,ill-definedproblemswherethereisalargedegreeofexpert

    nowledgeorthesolutioniseasytodescribelinguistically[3].

    ApplicationsofFuzzyLogicareappearinginmanyindustries.FuzzyLogicenablesdesignerstomodelcomplexsystemsmorequic

    lyandeffectivelythantraditionalapproaches.Consumerappliances,automobileengines,transmissions,andindustrialsystemsareallusingFuzzyLogictechniques.

    MotorolasHC68HC12(HC12)microcontrollerincorporatesseveralFuzzyLogicprimitivesdirectlyinitsinstructionset.TheinstructionsetcontainstheFuzzyLogicoperationsoftrapezoidalmembership,ruleevaluation,andweightedaveragedefuzzification.ThemicrocontrolleralsoincludesotherinstructionsthatarehelpfulinFuzzyLogicapplicationssuchasMIN/MAXinstructionsandtableloo

    ups[4].MotorolasHC12allowsthedevelopmentoflow-levelapplicationsthatcanutilizetheuniquefeaturesofFuzzyLogic.

    Thegoalofthisprojectistodesignandbuildanautonomouslinefollowing

    robotbasedonFuzzyLogictechniques.TherobotusestheMotorolaHC68HC12microcontroller.ThisprojectinvolvesinvestigatingtheHC12sFuzzyLogicinstructionsetandanalyzingitsabilitytocontrolanautonomousrobot.Therobotinthisprojectservesasatestbedforseveralpiecesofsoftware.Thesesoftwareprogramsincludeinitialtestscripts,severalcontrolsystembasedontraditionallogic,andseveralcontrolsystemsbasedonfuzzysystems.Thebestclassicallogicandfuzzycontrolsystemsarecomparedinvarioustests.Thesetestsinvolvedtherobotfollowingablac lineonthefloor.

    2.FuzzyLogicontheHC12

    Asstatedintheintroduction,MotoroladesignedtheHC12withadvancedcapabilitiestohandleFuzzyLogiccalculations.TheHC12containsfourinstructionsthatarespecifictoFuzzyLogic.Theseinstructionsare:

    MEMEvaluatesthetrapezoidalmembershipfunctionsREV/REVWPerformsunweighted/weightedMIN-MAXruleevaluationWAVPerformsweightedaveragedefuzzification

    ThefollowingsectiondescribesthebasicsofFuzzyLogicontheMotorolaHC12.ThissectionwillonlyserveasanintroductiontofuzzyprogrammingontheHC12andisnotareplacementforthemanufacturesdocumentation.Thissectionassumesthatthereaderhassome

    nowledgeofFuzzyLogic.

    2.1fuzzylogicbasics

  • 8/2/2019 paper4 -

    3/12

    ThedesignofaFuzzyLogicinterfacefortheHC12consistsoftwoparts.First,theusermustdesigna

    nowledgebasethatcontainsthemembershipfunctionsandtheruleset.Thesecondpartistheinference

    ernelthatta

    esthesysteminputsandproducesthesystemoutputsbasedonthe

    nowledgebase[5].Figure1showsthebasicstructureoftheFuzzyLogicsystem.

    Figure1:Bloc

    diagramofafuzzylogicsystem[5].

    2.2fuzzificationstrategy(MEM)

    Fuzzificationistheprocessbywhichsysteminputsareevaluatedtodeterminethedegreeatwhichtheybelongtoaparticularfuzzyset,onascalefrom00toFFinhexadecimal[5].TheMEMinstructionevaluatestrapezoidalmembershipfunctions.Thesefunctionsdefinethefuzzyset,thefoundationofFuzzyLogic.Afuzzysetisasetwithoutacrisp,clearlydefinedboundary.Itcancontainelementswithonlyapartialdegreeofmembership.Forexample,themembershipfunctionforCOLDcouldequalFFfortemperaturesbelow7oCandslopedownto00toward10oC.TheMEMinstructioncomparesthesysteminputagainstthemembersh

    ipfunctiontodeterminethedegreeoftruthofafuzzyinput.

    They-axisinFigure2representsthedegreeoftruthfromcompletelyfalse(00)tocompletelytrue(FF).Thex-axisrepresentstherangeofinputvaluesfortheparticularsysteminput.TheMEMfunctionwor

    sbyfindingthey-value,givenasysteminput(x-value)andthemembershipfunction.MEMreturnsthepercentageoftruth(y-axisvalue)fortheparticularfuzzyset.Theresultisasetoffuzzyvaluesthatdescribecharacteristicsofinputvariablesinthesystem.

    Figure2:Trapezoidalmembershipfunction.Thex-axisrepresentstheinputrangeandthey-axisrepresentsthedegreeoftruth[5].

    TodefineatrapezoidalmembershipfunctionfortheHC12,youneedfourvalues:(1)thestartofthetrapezoid,(2)thefirstslope,(3)secondslope,and(4)theendpointofthetrapezoid.Figure2labelsthesepointsandshowsthememoryrepresentation.Theusershoulddefinethetrapezoidalinmemoryasfollows:

    LABEL_MFDC.B$40,$D0,$08,$04

    Theprogramshoulduseadescriptivelabelbecausetheprogrammerwillneedthislabelduringfuzzification.Forexample,COLD_MFcouldrepresentamembershipfunctionofthefuzzysetCOLDwherethepostfix_MFremindstheprogrammerthatthisvariablerepresentsamembershipfunction.Atrapezoidaldefinitionisneededforeachmembershipfunction.

  • 8/2/2019 paper4 -

    4/12

    2.3ruledefinitionandevaluation(REV/REVW)

    RuleevaluationishowFuzzyLogicperformscalculations.ThefuzzyvaluesproducedbytheMEMfunctionarepassedthroughtherulelisttofindthefuzzyoutput.ThetwotypesofrulesthattheHC12allowsareweighted(REVW),whereeachrulecanhaveadifferentweights;andun-weighted,(REV)wereallruleshaveequalweight.Anexampleofarulelist:

    IftemperatureisCOLDandwindisHIGH,thenheatisonHIGH.

    IftemperatureisWARMandwindisLOW,thenheatisonLOW.

    IftemperatureisHOTandwindisLOW,thenheatisOFF.

    AfterthefuzzyinputsareevaluatedwithREV/REVW,thesystemsfuzzyoutputsindicatethedegreetowhichanoutputshouldhaveaspecificvalue.Theseoutp

    utsmustthenundergodefuzzificationbeforetheirvaluesareuseful.Creatingtherulelistisactuallyverysimple.Theantecedents(leftsideoftherule)arethefuzzyinputscreatedbytheMEMinstruction(e.g.,atemperaturereadingevaluatedwiththeCOLD,WARMandHOTmembershipfunctions).Theconsequents(rightsideoftherule)arethefuzzyoutputsofthesystem.DuringREV,eachantecedentisjoinedusingthefuzzyandoperator(MIN).Thisminimumvalueiscomparedtothecurrentfuzzyoutputofeachconsequentusingthefuzzyoroperator(MAX),andthemaximumofthesetwovaluesisstoredineachconsequent(fuzzyoutput).Inotherwords,theoveralltruthofaruleisstoredinthefuzzyoutputsandifasubsequentruleistruer,thenthefuzzyoutputsareupdatedtoreflectthisnewvalue.

    Therulelistisstoredinmemoryasalistofpointerstofuzzyinputs(ante

    cedents),areservedseparatorvalue,alistofpointerstofuzzyoutputs(consequents),andthenanotherseparator.Eachrulefollowsthispatternandtherulelististerminatedbyanendrulereservedvalue.

    RULE_LISTDC.BP_TisCold,P_WisHigh,SEPARATOR,P_HeatHigh,SEPARATOR

    DC.BP_TisWarm,P_WisLow,SEPARATOR,P_HeatLow,SEPARATOR

    2.4defuzzificationstrategy(WAV)

    ThefinalstepintheFuzzyLogiccalculationisdefuzzification,whentherawfuzzyoutputsareevaluatedtocreateacompositesystemoutput.Unli

    etheinput,thefuzzyoutputmembershipfunctionisnottrapezoidalbutasingleton.Thissingletonindicatesonesystemoutputvalueforeachfuzzyoutput.Theoutputmembershipsingletonsarearraignedinmemoryinthesameorderastheircorrespondingfuzzyoutputs.WAVcalculatesasumofproductsofeachfuzzyoutputva

  • 8/2/2019 paper4 -

    5/12

    luetimesitssingletonvalueandasumofallofthefuzzyoutputvalues.ThefirstsumisdividedbythesecondusingEDIVtoproduceanoverallvaluethatisthedefuzzifiedoutputofthesystem.Defuzzificationcreatesaweightedaveragesystemoutputbasedonthetruthofthefuzzyoutputs.

    2.5fuzzyinference

    ernel

    Theinference

    ernelcontainsalloftheinstructionsthatma

    eupthefuzzysystem.The

    ernelutilizesthe

    nowledgebasetocreateasystemoutputfromgivensysteminputs[5].Allofthefuzzyinstructionsrequireproperinitializationoftheaccumulators,indexregisters,andfuzzyvalues.Thesedetailsarebeyondthescopeofthispaperandcanbefoundinthemanufacturesdocumentation.Thesampleprogramlisting,AppendixA,alsoincludescommentsondevelopingthefuzzy

    ernel.

    ReaderswantingmoreinformationareencouragedtorefertotheFuzzyLogicSupportchapterintheMotorola68HC12CPU12ReferenceManualforadetailedexplanationoftheFuzzyLogicinstructionset.

    3.ControlSoftware

    TotestifFuzzyLogicisasuperiorsolutiontotheproblemsofautonomousroboticcontrol,thisprojectinvolvedcreatingtwocontrolsystems.Thefirstsystemusestraditionallogictocontrolthesystem.ThissystemdoesnotuseanyofthemicrocontrollersembeddedFuzzyLogicfunctions.ThesecondrobotreliessolelyontheHC12sFuzzyLogicinstructions.ThissecondsystemusesFuzzyLogicforallofitscontrolprocessing.BothcontrolsystemsonlyusedtheHC12son

    boardRAMarea(512bytes)forprogramstorage.

    3.1traditionalcontrolsystem

    ThetraditionalcontrolsystemdoesnotuseanoftheFuzzyLogicinstructionsontheHC12.Itreliesontestingeachinputastrueorfalseandthenusesanif-elseprogrammingstructuretodeterminethecorrectsystemoutput.BecauseofthelimitedsizeofRAMavailableforprogramming,thebinaryrobotreliesonanexternalchiptoconverttheanalogsignalsfromthesensorstoabinary,ono

    roff,form.Thecontrolstructureissimplifiedtoreducethenecessaryamountofmemoryneededforstorage.Thetraditionalcontrolsystemusesthefollowingrules:

    CentersensoronGoStraightLeftsensoronTurnRightRightsensoronTurnLeftNosensorsonStop

  • 8/2/2019 paper4 -

    6/12

    Themotorcontrolofthissystemislimitedtoonespeedforstraight,left,andright.Becausethesystemreliesonanexternalchiptoconverttheanalogsensorvalues,itisunabletodetectwhenthesensorispartiallyontheline.Whilethissimplifiesprogramming,itreducestheeffectiveresolutionofthesensors.

    3.2fuzzycontrolsystem

    ThesmallamountofRAMalsolimitsthefuzzycontrolsystem.However,thefuzzyinstructionsareabletohandlefarmorecontrolsystemcomputationsthanthetraditionalsysteminasimilaramountofmemory.First,thefuzzysystemusestheanalogvaluesfromthesensors.Thisgivesthefuzzyrobotthebenefitofbeingabletotellexactlywhenthesensorisleavingthelineandtobemorerobusttochangesintheenvironment.Second,thissystemhasthreelevelsofspeedforeachdirection.Thisgivesthefuzzycontrolsystemimprovedturningability.

    Thefuzzycontrolsystemta estheanalogvaluefromthesensorsandassigns

    aleveloftruthtoafuzzyvalue.Thiscontrolsystemusedtwofuzzymembershipfunctionsforeachsensor:ONandOFF,tocreateatotalofsixfuzzyinputvalues.

    Fuzzycontrolsystemsarebasedonrules.Thecontrolsystemusestheserulestoevaluatethefuzzyvaluesandcreateafuzzyoutput.Table1showstherulesbaseduponthetruthofthefuzzyinputvaluesandthecorrespondingfuzzyoutputsusedinthiscontrolsystem.Inthetable,thereareONandOFFfuzzyvaluesforeachofthethreesensors.ThesystemcombinesthetruthofthethreefuzzyinputsforeachruleusingthefuzzyMINoperator.Thisminimumvalueisstoredinthefuzzyoutputsunlesstheoutputsalreadyhaveagreatervaluestoredfromapreviousrule.Thesystemfindstheoutputthatbestfitthefuzzyinputs.

    Table1.FuzzyRuleList.Thistableshowstherulelistthatevaluatestheoutputspeedanddirectiongiventhefuzzyinputvariables.ThisrulelistisevaluatedusingtheREVinstructionontheMC68HC12.

    FuzzyInputsFuzzyOutputsLeftCenterRightSpeed

    DirectionOffOffOffStopLineFinderOnOff

  • 8/2/2019 paper4 -

    7/12

    OffSlowHardLeftOnOnOffMediumLeftOnOnOnSlowLineFinderOffOnOffFastStraightOffOn

    OnMediumRightOffOffOnSlowHardRightOnOffOn

    StopLineFinder

    4.HardwareImplementation

    Thisprojectusesacustomrobotdesignedtotestthevariouscontrolsystems.Thisrobothasalinesensorandtwomotors.TherobotcanalsohandleIRdistancesensors,butthedistancesensorsarenotusesinthetestingportionofthi

    sproject.

    4.1baseandmotors

    Thetestrobotconsistsofaplywoodbaseandusesdifferentialsteering.Themotorsaretwoservos,modifiedtoallowcontinuousrevolution.Servosareusefu

  • 8/2/2019 paper4 -

    8/12

    lforsmallrobotsbecausetheservohasanintegratedmotorcontrolleranditprovidesadequatetorqueforasmallrobot[6].Ballcasterssupportthefrontandbac

    oftherobot.Thisallowstherobottoturnonitscenter.Arechargeablebatterypac

    powersthemotors,linesensor,andthemicrocontroller.

    4.2linesensor

    ThecustomlinesensorisacollectionofthreeIRphototransistor,transmitterpairsthatsensewhentherobotincenteredontheline,totheleft,andtotheright.ThesesensorsfeedanalogdataintotheHC12sA/Dportsforprocessing.TheanalogvaluesrepresenttheIRreflectivityofthesurfacebelowthelinesensoratthreepoints.BecausethesensorcontainsIRtransmitters,sensorwor

    swithoutambientlighting.

    5.Testing

    Thetworobotcontrolsystemsweretestedonavarietyoftrac

    s.Thesetrac

    swerecreatedbyplacingblac

    electricaltapeonawooden,carpeted,andcementfloor.Thetrac

    sincludedastraightline,a45-degreeangleturn,a90-degreeangleturn,anda12-inchradiusovalshapedring.Thelightinglevelwas eptconstantthroughoutthetrials.Thetestingmeasurementsincludeaqualitativedescriptionoftherobotsabilitytostayonthelinewithoutwiggleorovercorrection.

    6.Results

    Foreachofthetesttrac

    s,bothrobotsmaintainedcontrolandfollowedtheline.Thetraditionalcontrolsystemdidhavemorewiggleasitmoveddownthestraightsection.Thisrobotwasunabletocenteritselfonthelineandinsteadzigzaggeddowntheline.Thefuzzyrobotsystemwasabletoquic

    lyfindandholdthetruecourseoftheline.Thefuzzyrobotsystemalsomadefewercorrectionsduringtheturnsintheovaltesttrac

    .Thetraditionalrobothadtocorrectitscoursemanymoretimesduringtheovalturns.Thefuzzyrobotsystemhadamuchsmoothercoursethroughoutthetrac

    .Neitherrobotwasunabletoma

    eanyoftheturnsinthetest.

    Inadditiontocomparingattheperformanceofthetwodifferentcontrolsystems,thisprojectalsoloo

    satthememoryrequirements,theeaseofwritingthecontrolsoftware,andtheprocessingpowerofthesystem.Forthetwosystemstested,theFuzzyLogicsystemusedmorememory.However,italsoprocessedsignificantlymoreinformationandgaveresultswithfinerresolution.Achievingthissamelevelofprocessingusingthetraditionalsystemwouldhavemadethetraditionalsystemsmemoryrequirementsmuchlarger.

    Thefuzzysystemisinitiallymoredifficulttoprogrambecausethesyntaxoftheinstructionsandtheformatofthe

    nowledgebaseinmemoryisunclear.Ho

  • 8/2/2019 paper4 -

    9/12

    wever,itismucheasiertomodifythefuzzycontrolsystemtochangesintheenvironmentorsystemoutputsbecauseonlythemembershipfunctionsneedtochange.Forthetraditionalsystem,theentirelogicofthecontrolsystemmayneedtobemodified.ItismoreintuitivetoprograminFuzzyLogicbecauseoftheeaseofcreatingalinguisticsolutiontothecontrolproblem.Thisintuitivenaturema

    esFuzzyLogiceasiertoprogramthantraditionallogicforcomplexcontrolproblems.

    7.Conclusion

    FuzzyLogicrepresentsatremendousadvancementinautonomousroboticcontrolsystems.TheMotorolaMC68HC12sinstructionsetwillma edesigningfuzzysolutionsonmicrocontrollersmucheasierthaninthepast.FuzzyLogiciswellsuitedforcomplexcontrolproblemsli

    eautonomouscontrol,butitmaybetoodifficultforsimplecontrolsystems.TheHC12sfuzzyinstructionssimplifythedesigncycleforcontrolsystemdesignersandprovideanalternativetotraditionalcontrolmethodologies.ThefuzzysystemdevelopedbyMotorolaisaverypowerfulsetofinstructionsthatwillhaveadramaticimpactoncontrolsystemsinmanyindustries.

    8.References

    [1]Reuss,RobertF,etal.FuzzyLogicControlinaLineFollowingRobot.http://www.cs.unr.edu/~simon/fuzzy/fuzzylogic.htm[01/22/2002].

    [2]Kandel,Abraham,etal.FuzzyControlSystems.BocaRaton:CRCPress,1994.

    [3]Stachowicz,M.S.andBeall,L.,"FuzzyLogicPac

    ageforMathematica",Wolf

    ramResearch,Inc.,2000.

    [4]M.S.StachowiczandC.Carroll,"IntelligentSystemsonMotorola'sMicrocontroller:ATeamDesignWor

    shop,"Proceedingsofthe2000InternationalConferenceonEngineeringEducation,Taiwan,August14-18,2000.

    [5]MotorolaSemiconductor,CPU12ReferenceManual.MotorolaInc.,1999.

    [6]McComb,Gordon.TheRobotBuildersBonanza.NewYor

    :MCGraw-Hill,2001.

    AppendixA.ExampleFuzzyAssemblyListing

    ThefollowcodeexampleliststheoverallstructureofanassemblyprogramfortheHC12thatutilizesFuzzyLogic.Thissimplifiedexampleta

    estwosysteminputs,temperatureandwindspeed;andproducesonesystemoutput,heat.Inputvariables,storedin$0800and$0801,havebeenscaledfrom0016toff16.Therangeoftheheatoutputisfrom0016toff16.Refertosection2fordetailsont

  • 8/2/2019 paper4 -

    10/12

    heFuzzyLogicoperators.

    ORG$0900;MemorylocationforFuzzyKnowledgeBase

    ;###FuzzyConstants###

    MARKEREQU$FE;Usedtoseparaterulesections

    ENDROEQU$FF;Usedtofinishtherulelist

    ;###RelativePointers###

    P_COLDEQU$00;Pointerstotherelativelocationsofthefuzzy

    P_WARMEQU$01;InputandOutputvariables

    P_HOTEQU$02

    P_CALMEQU$03

    P_WINDYEQU$04

    P_NoHtEQU$05

    P_LowHtEQU$06

    P_MedHtEQU$07

    P_HiHtEQU$08

    ;###MembershipFunctions###

    COLD_MFDC$00,$76,$00,$05;TemperatureMembershipfunctions

    WARM_MFDC$56,$AC,$07,$07;Point1,Point2,Slope1,Slope2

    HOT_MFDC$8C,$FF,$07,$00

    CALM_MFDC$00,$60,$00,$07;WindMembershipfunctions

    WINDY_MFDC$50,$FF,$07,$00

    ;###OutputSingletons###

    No_Heat_FSDC$00;TheFuzzysystemwillta

    etheweightedaverage

    Low_Heat_FSDC$56;ofthesevaluesbasedonthetruthsofthe

    Med_Heat_FSDC$AC;correspondingFuzzyoutputvariables

    High_Heat_FSDC$FF

    ;###FuzzyVariables###

  • 8/2/2019 paper4 -

    11/12

    COLD_FIDS$01;TheseinstructionsreservebytesfortheFuzzy

    WARM_FIDS$01;inputandoutputvariables.

    HOT_FIDS$01;(NOTE:Thisvariableorderingiswhatdeterminesthe

    CALM_FIDS$01;relativelocationsstoredaboveandcanbethe

    WINDY_FIDS$01;sameorderingasthemembershipfunctions.)

    NoHeat_FODS$01

    LowHeat_FODS$01

    MedHeat_FODS$01

    HHeat_FODS$01

    ;###RULEDefinitions###

    RULE_START

    DCP_COLD,P_WINDY,MARKER,P_HiHt,MARKER;Thissectiondefinestherulelist

    DCP_COLD,P_CALM,MARKER,P_MedHt,MARKER;Therulesaredefinedasrelative

    DCP_WARM,P_WINDY,MARKER,P_MedHt,MARKER;pointerstothelocationsof

    DCP_WARM,P_CALM,MARKER,P_LowHt,MARKER;Fuzzyinputandoutputvariables.

    DCP_HOT,P_WINDY,MARKER,P_LowHt,MARKER;MARKERandENDROarecon

    stants

    DCP_HOT,P_CALM,MARKER,P_NoHt,ENDRO;$FE,$FFrespectively

    org$0803;MemorystartinglocationforInferenceKernel

    ;###Fuzzificationfortemperaturedata###

    LDX#COLD_MF;Firstofthreemembershipfunctionfortemperature

    LDY#COLD_FI;Locationoffirstfuzzyinputvariablefortemperatur

    e

    LDAA$0800;Locationoftemperaturedatainsystem

    LDAB#$03;Numberofmembershipfunctionsfortemperature

    TEMPFUZZ:MEM;Thisloopwillprocesseachofthethreemembershipfunctions

    DBNEB,TEMPFUZZ;andcreatethethreefuzzyinputvariables

  • 8/2/2019 paper4 -

    12/12

    ;###Fuzzificationforwinddata###

    LDX#CALM_MF;Firstoftwomembershipfunctionforwind

    LDY#CALM_FI;Locationoffuzzywind(Theselasttwolinesareoptionalbecause

    ;AccumulatorXandYalreadyhavethecorrectvalues)

    LDAA$0801;Locationofwinddatainsystem

    LDAB#$02;Numberofmembershipfunctionsforwind

    WINDFUZZ:MEM;Thisloopwillprocesseachofthetwomembershipfunctions

    DBNEB,WINDFUZZ;andcreatethetwofuzzyinputvariables

    ;###RULEEVALUATION###

    RULE:LDAB#$04;Firstyoumustclearoutthefuzzyoutputvariables

    CLEAROUT:CLR1,Y+

    DBNEB,CLEAROUT

    LDY#COLD_FI;PointatstartofFuzzyInputvariables

    LDX#RULE_START;Pointatstartofrulelist

    LDAA#$FF;MustloadAAwith$FF

    REV

    ;###DEFUZZIFICATION###

    LDX#No_Heat_FS;Pointtosingletonpositions

    LDY#NoHeat_FO;PointtoFuzzyOutputlocations

    LDAB#$04;NumberofFuzzyOutputs

    WAV;Calculatesumsforweightedaverage

    EDIV;Finaldividestep

    TFRY,D;MovetheresultstoA:B

    STAB$0802;Storesystemoutputs