ABB DCS 系统 培训课程 系列讲座 Code sorting.docx
《ABB DCS 系统 培训课程 系列讲座 Code sorting.docx》由会员分享,可在线阅读,更多相关《ABB DCS 系统 培训课程 系列讲座 Code sorting.docx(7页珍藏版)》请在冰豆网上搜索。
ABBDCS系统培训课程系列讲座Codesorting
Chapter18Codesorting
18.1GeneralInformation
18.1.1Description
Thischapterdescribesthedifferentmethodsofcodesortingandhowtohandleloops.
18.1.2Objectives
Oncompletionofthischapteryouwillbeableto:
∙Describethedifferencesbetweendifferentmethodsofcodesorting
∙Describetheadvantagesofeachmethod
∙Analyzeandsolveloopsintheprogramcode.
18.1.3ReferenceDocumentation
Usetheonlinehelp:
Contentstab,ControlModuleDiagramEditor>WorkingwithControlModules
18.2
Lesson1-Codesorting
18.2.1Description
Thischapterdescribesthedifferentmethodsofcodesortingandhowtohandleloops.
18.2.2Objectives
Oncompletionofthislessonyouwillbeableto:
∙Describethedifferencesbetweendifferentmethodsofcodesorting
∙Describetheadvantagesofeachmethod
∙Analyzeandsolveloopsintheprogramcode.
18.2.3AccordingtoIEC61131-3
Theexecutionorderoffunctionblocksfollowstheprogramflowasimplementedbytheprogrammer.
18.2.4ControlModuleCodeSorting-introduction
ForControlModules,thecompileranalyzeseachcodeblock(ST,IL,FBD,andLD-SFCistreatedsomewhatdifferently,seeremarkbelow)separatelywithrespecttowhichvariablesthatarereadandwritten,respectively,byeachblock.Thecompilerthendeterminestheoptimalexecutionorder.Acodeblockthatassignsavaluetoavariablehastobeexecutedbeforetheblockthatreadsthevariablevalue(comparefigurebelowinwhichthecodeblockincontrolmodule1mustbeexecutedbeforethecodeblockincontrolmodule2).
Thetechniqueiscalledcodesortingandmeansthattheoptimalexecutionorderwillbebasedondataflowinsteadofprogramflow(asisthecaseforfunctionblocks).Codesortingguaranteesthatthecodewillbeexecutedincorrectorder.Codesortingsuppressestime-delaysandresultsinthatanewcontrolmoduleautomaticallybecomescorrectlyplacedintheprocess.
ForanyfromcontrolmodulescalledFunctionBlocks,itisonlytheparameterinterface(In,Out,orIn_out)thataffectsthecode-blocksorting.Thatis,noanalysisismadeonhowtheFunctionBlocksactuallyusetheparameters.Inaddition,FunctionBlockreferencestoexternalvariablesdonotaffecttheexecutionorderofcontrolmodulecodeblocks.
Codesortinghasnoeffectoncontrolmodulesconnectedtodifferenttasks.
WithinaSFCcodeblockonlytheNactionparts(notP1orP2actions)aresorted.
18.2.5Loophandling
However,incaseboththecontrolmodulesusethesamevariableforbothreadingandwriting,thecompilergivesawarningmessagethataloopexists,meaningthattheexecutionordercannotberesolved:
Thiscaseyieldsthefollowingerrorinformation:
Intheexampleabove,theRequestvaluedeterminestheDelivervalue,which,inturn,determinestheRequestvalue.Thisconditionisshownintheautomaticallygeneratedtextfile,wherethefigureswithinparenthesesrefertowhichcodeblocktherespectiveparameterdependson.Providedthatcirculardependenceactuallyexists(andisnotmerelyaresultofaprogrammingerror),theproblemcanbesolvedbyassigningaState-qualifiertotheDeliveredvariableandintroducinganewcodeblockinControlModule1,Code_Block_12:
Theloopdependencyisnoweliminated;Delivered:
oldstoresthevaluefromthepreviousscanandDelivered:
newcontainstheupdatedvaluefromthecurrentscan.Hence,theexecutionorderbecomesCode_Block_11-Code_Block_21-Code_Block_12.Theapproachisparticularlyvaluableforcomplexapplications,whicharedifficulttomonitormanually.
18.2.5.1RemarksonState
Statecanonlybespecifiedforlocalvariablesoftypebool,int,uint,dint,andreal.IfyouforsomereasonwanttooverridethesortingandtherebyavoidtheStateimplications,youcanassignthenosortattributetothevariable.
18.2.5.2RemarksonNoSort
Incorrectlyused,thenosortattributemaycauseimproperexecutionandapplicationfailure.Nosortshouldtypicallybeusedonlywhenthecodeblockconnectionsthemselvesunambiguouslydeterminetheexecutionorder
Usenosortonlyifyouknowthedataflowcharacteristicsindetail.
18.2.6
CodeSortingAdvantages
Theadvantagesofcodesortingarebestillustratedwithacoupleofexamples:
FirstconsideraPIDcascadeloop(usedforupdatingthePIDintegratorsincaseofmanualoperation),inwhichdataflowinbothdirectionsbetweenthemasterandtheslave.Thisishandledbythe"Back"codeblocksattheendofthescan.Thisisnotpossibletodowithfunctionblocksifyouwanttoworkinanobject-orientedwayandavoidtimedelays.
Second,nowconsideranapplicationaccordingtotheillustrationbelow.Let'ssaythatsometimeaftertheapplicationwassetup,theneedforathirdconveyerarises.Becauseofthecodesorting,aControlModulerepresentingthefunctionalityofthenewconveyerbecomesaddedandconnectedintherightplaceintheapplicationlogic(providedthattheapplicationhasbeenproperlydesignedinthespecificationphase).
18.3Exercise18.1–Codesorting
Pleasedoexercise18.1
Dukantagbortdennaosynligatextmenlåt
nedanståendePageBreakliggakvar!
Låtävendenefterföljandesidanliggakvar!
Thispageisintentionallyleftblank
Thispageisintentionallyleftblank
Osynligtext:
NästasidamåstebörjapåUDDAsidnummer
LämnaENellerTVÅtommasidorhärOVANFÖR.
NedanståendeSectionBreakfårINTEtasbort!
Kompletteratomsidavidbehovmednedanståendetext
Thispageisintentionallyleftblank
TABLEOFCONTENTS
Chapter18Codesorting1
18.1GeneralInformation1
18.1.1Description1
18.1.2Objectives1
18.1.3ReferenceDocumentation1
18.2Lesson1-Codesorting2
18.2.1Description2
18.2.2Objectives2
18.2.3AccordingtoIEC61131-32
18.2.4ControlModuleCodeSorting-introduction2
18.2.5Loophandling3
18.2.5.1RemarksonState4
18.2.5.2RemarksonNoSort4
18.2.6CodeSortingAdvantages5
18.3Exercise18.1–Codesorting6
Dukantabortdennaosynligatextmenlåt
nedanståendePageBreakliggakvar!
Låtävendenefterföljandesidanliggakvar!
Thispageisintentionallyleftblank