Functions and FBWord格式.docx

上传人:b****4 文档编号:6229117 上传时间:2023-05-06 格式:DOCX 页数:10 大小:48.11KB
下载 相关 举报
Functions and FBWord格式.docx_第1页
第1页 / 共10页
Functions and FBWord格式.docx_第2页
第2页 / 共10页
Functions and FBWord格式.docx_第3页
第3页 / 共10页
Functions and FBWord格式.docx_第4页
第4页 / 共10页
Functions and FBWord格式.docx_第5页
第5页 / 共10页
Functions and FBWord格式.docx_第6页
第6页 / 共10页
Functions and FBWord格式.docx_第7页
第7页 / 共10页
Functions and FBWord格式.docx_第8页
第8页 / 共10页
Functions and FBWord格式.docx_第9页
第9页 / 共10页
Functions and FBWord格式.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Functions and FBWord格式.docx

《Functions and FBWord格式.docx》由会员分享,可在线阅读,更多相关《Functions and FBWord格式.docx(10页珍藏版)》请在冰点文库上搜索。

Functions and FBWord格式.docx

Lesson1-UsingFunctionsandFunctionBlocks

11.2.1Description

ThislessondescribeshowtouseFunctionsandFunctionBlocksinthedifferentlanguages.

11.2.2Objectives

Oncompletionofthislessonyouwillbeableto:

∙UseFunctionsandFunctionBlocksinthedifferentlanguages.

11.2.3ThedifferencebetweenFunctionsandFunctionBlocks

11.2.3.1Function

∙Haveavalue.

∙Canbeusedinexpressions.

∙Donotretaintheiroldvaluesanddoalwaysgivethesamevaluewhentheinputparametershavethesamevalue.

11.2.3.2Functionblock

∙Havebothinputandoutputparameters.

∙Cangiveseveraloutputvaluesusingparameters.

∙Retaintheirvalues,fromthelastcall,whencalledthesecondtime.Cangivedifferentoutputvalueseveniftheinputvaluesarethesame.

∙Havetobemadeintoaninstance.

11.2.4Insertinglibraries

RightclickontheLibrariesiconandselectInsertLibrarytoinsertalibrarytoyourproject.

11.2.5Somestandardfunctionsandfunctionblocks

ThelibrarySystemLibcontainsanumberofpredefinedFunctionsandFunctionBlocks.

11.2.5.1Datatypeconversion

TheareanumberofpredefineddataconvertersinthelibrarySystemLib.Forexamplebool_to_dint,andreal_to_dint.

11.2.5.2Mathematicalfunctions

TheareanumberofpredefinedmathematicalfunctionsinthelibrarySystemLib.Forexamplesin,cos,add,ln,sqrt.

11.2.5.3Countersandtimers

TheareanumberofpredefinedcountersandtimersinthelibrarySystemLib.ForexampleCTU(CounterUp),CTD(CounterDown),TOn(Timerondelay),Tof(Timeroffdelay).

11.2.6UsingFunctionsindifferentlanguages

11.2.6.1STandSFC

AfunctioncallinSTisdonebywritingthenameofthefunctionintheeditororbyusingthe

button,pressing<

CtrlL>

orselecting(Insert>

Function…).AnexamplewiththefunctionAddinST:

11.2.6.2FBD

Usethetoolbarbutton

orselect(Insert>

Function/Functionblock...)orpress<

Ctrl+K>

todisplaythedialogboxcontainingtheavailablefunctionsandfunctionblocks.Ifthefunctionorfunctionblockisextensible,i.e.canbecalledwithavaryingnumberofinputs,youcanenterthenumberinthePropertiesSizefield.

AnexamplewiththefunctionAddinFBD:

11.2.6.3

IL

AfunctioncallinILisdonebywritingthenameofthefunctionintheinstructionfieldorusingthe

button,press<

CtrlJ>

orselect(Insert>

Function…).

AnexamplewiththefunctionAddinIL:

11.2.6.4LD

Useoneofthetoolbarbuttons

Left,Right,ParallelFunction/Functionblock...)todisplaythedialogboxcontainingtheavailablefunctionsandfunctionblocks.Ifthefunctionorfunctionblockisextensible,i.e.canbecalledwithavaryingnumberofinputs,youcanenterthenumberinthePropertiesSizefield.

AnexamplewiththefunctionAddinLD:

11.2.7Instantiating/UsingFBInstancesindifferentlanguages

11.2.7.1STandSFC

YoumustcreateaninstanceofthefunctionblockbeforeitisusedintheSTorSFCeditor.Theinstanceiscreatedlikethis:

∙ClickontheFunctionblockstaboftheProgram,ControlModuleTypeorFunctionblocktype.

∙WritethenameofthefunctionblockyouintendtouseintheFunctionBlockTypefieldorpress<

CtrlJ>

.

∙GivethefunctionblockasuitablenameintheNamefield.

∙WriteadescriptionintheDescriptionfield.

∙Callforthefunctionblockbywritinglikethisinthecodeblockwereyouintendtouseit:

TimerCloseDoor(

∙Anewwindowliketheonebelowwillbevisible.WritesuitablevariablesintheActualParameterfield.

11.2.7.2FBD

SamasusingfunctionsinFBD.ItisnotnecessarytodeclareafunctionorfunctionblockbeforeusingitintheFBDeditor.

11.2.7.3IL

YoumustcreateaninstanceofthefunctionblockbeforeitisusedintheILeditor.Theinstanceiscreatedlikethis:

CtrlJ>

∙Callforthefunctionblockbywritinglikethisinthecodeblock.

11.2.7.4LD

ItisnotnecessarytodeclareafunctionorfunctionblockbeforeusingitintheFBDeditor.

∙Usethetoolbarbuttons

Left,Right,ParallelFunction/Functionblock...),todisplaythedialogboxcontainingtheavailablefunctionsandfunctionblocks.TheInsertFunction/FunctionBlockcommanddisplaysadialogboxshowingfunctionsandfunctionblocksavailableforinsertion.

∙ThedialogboxisthesameastheoneintheFBDeditor(above).

∙Declaresuitablevariableswithcorrectdatatypestotheparametersofthefunctionblock.

∙Connectthepinsofthefunctionblockwiththevariables.

11.3Exercise11.1–UsingFunctionBlocks

Pleasedoexercise11.1

11.4

Lesson2-CreatingFunctionBlocks

11.4.1Description

ThislessondescribeshowtodeclareuserdefinedFunctionBlocksinlibraries.

11.4.2Objectives

11.4.3Creatingauserlibrary

RightclickontheLibrariesiconandselectNewLibrarytoinsertalibrarytoyourproject.

11.4.3.1Whyusinglibraries?

Itisrecommendedtocreateownlibrarieswhenyouworkinalargerproject,becausethenyougetabetterstructureoftheproject.AnothermajoradvantagesofcreatingownlibrariesarethatitispossibletoreusetheDatatypes,FunctionBlocktypesandControlModuletypesinotherprojects.

11.4.4CreatingaFunctionblocktype

RightclickontheFunctionBlockTypesiconandselectNewFunctionBlockType…tocreateanewFunctionBlockType.Thiscouldbedoneinanapplicationoralibrary.

11.4.4.1WhycreatingFunctionBlockTypes?

ItisrecommendedtocreateownFunctionblocktypes,becausethenyoumakeitpossibletoreusethecodelater.

11.4.4.2

FunctionBlockTypeEditor

Thecontentofthefunctionblocktypeisdisplayedinaneditor.Youcandefinefunctionblocktypes,whichcanbeusedinotherPOU:

s.Parameters,variablesandfunctionblocksthatareusedmustbedeclaredinthedeclarationpane.Codeisenteredinthecodepane.Afunctionblocktypetypicallyusesthefollowingelements,whicharedeclaredinseparatetabsinthedeclarationpane:

∙ParametersVariablesthatpassesvaluesinoroutfromtheprogram.Theoptionsare:

in,outandin_out.Itisnotallowedtosetaninitialvalueonaparameter

∙LocalVariablesusedinthefunctionblock.

∙ExternalvariablesGloballydefinedvariablesintheapplicationeditormustbespecifiedasexternalvariablestobeaccessedbythefunctionblock.

∙Functionblocks.Youmustexplicitlydeclarefunctionblockstousethem(notnecessaryintheFBDandLDeditors).

11.4.5MoveFBbetweenlibraries

Itispossibletomovefunctionsorfunctionblocksbetweenlibrariesorapplications,byusingthecopyandpastefunction.

11.5Exercise11.2–CreatingFunctionBlocks

Pleasedoexercise11.2

Dukantagbortdennaosynligatextmenlå

t

nedanstå

endePageBreakliggakvar!

vendenefterfö

ljandesidanliggakvar!

Thispageisintentionallyleftblank

Osynligtext:

stasidamå

stebö

rjapå

UDDAsidnummer

mnaENellerTVÅ

tommasidorhä

rOVANFÖ

R.

Nedanstå

endeSectionBreakfå

rINTEtasbort!

Kompletteratomsidavidbehovmednedanstå

endetext

TABLEOFCONTENTS

Chapter11FunctionandFunctionBlocks1

11.1GeneralInformation1

11.1.1Description1

11.1.2Objectives1

11.1.3ReferenceDocumentation1

11.2Lesson1-UsingFunctionsandFunctionBlocks2

11.2.1Description2

11.2.2Objectives2

11.2.3ThedifferencebetweenFunctionsandFunctionBlocks2

11.2.3.1Function2

11.2.3.2Functionblock2

11.2.4Insertinglibraries2

11.2.5Somestandardfunctionsandfunctionblocks3

11.2.5.1Datatypeconversion3

11.2.5.2Mathematicalfunctions3

11.2.5.3Countersandtimers3

11.2.6UsingFunctionsindifferentlanguages3

11.2.6.1STandSFC3

11.2.6.2FBD3

11.2.6.3IL4

11.2.6.4LD4

11.2.7Instantiating/UsingFBInstancesindifferentlanguages4

11.2.7.1STandSFC4

11.2.7.2FBD5

11.2.7.3IL5

11.2.7.4LD6

11.3Exercise11.1–UsingFunctionBlocks6

11.4Lesson2-CreatingFunctionBlocks7

11.4.1Description7

11.4.2Objectives7

11.4.3Creatingauserlibrary7

7

11.4.4CreatingaFunctionblocktype7

11.4.4.2FunctionBlockTypeEditor8

11.4.5MoveFB

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2