8. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Blocks
Betweentheoperatingsystemandtheuser programsthere are theso-calledOrganization Blocks (OBs).
“Block” is an importantconceptin PCS 7.Asummaryof theblocks used in thesystemis listed in Table above
When ablock is created,it mustbe "declared"as a function block (FB), a function call (FC), ora basic operation,(BOP).
A FB is a block with memory; in other words the data exist during processing from one cycle to another and can be
accessed.Tomakethe dataaccessible, a datablock(DB) is created for eachblockinstance.
In amulti-instance block,the calling FB contains subsidiary FBs butonly onecommonDB is created.
A FC is a block without memory; in other words the values generated by the block are processed immediately. No data
blockis required for aFC. A FC does nothavedefault values at theoutputs.
A BOPis also a blockwithout memory.Theyare usedfor simple functions suchasAND,OR, etc.
Basic operations are programcomponentsin CFC andare enteredas theSCL statementsduring compilation.
BOPs are locatedin the CFC Chart folder. Refer toPicture whereBOPs are indicated bythebookicons.
9. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Integrating Libraries
تلفیقکتابخانههایازساختهشپیدربرنامهکاربر-موقعنصبسیستممهندسی(PCS7-ES)کتابخانههایPCS7کهحاویبالکها
وچارتهایازپیشساخته،هستندبهصورتاتوماتیکنصبمیگردند.
بالکهایموردنیازبرایایجادبرنامهکاربربایستیدرپروژهتلفیق(integrated)شوند.
برنامهکاربربهکمکویرایشگرچارتهایCFCوSFCایجادمیگردد.بالکهایارایهشدهدرمحیطCFCًااساسازکتابخانههای
واقعدرS7ManagerدرآدرسFile -> Open -> Librariesنشاتگیرندیم.
برایمشاهدهکتابخانههامیتوانبهمسیرFile -> Open -> Librariesمراجعهکرد.
براینمایشومخفیکردناینکتابخانههانیزمیتوانازفرمانFile -> Manage-> Hide / Displayاستفادهکرد.
Master Data Library : MDL
کتابخانهخاصپروژهباشدیم.ازنسحهPCS7 V7.0بهباالعالوهبرپروژههامیتوانکتابخانههارانیزدریکMultiprojectقرار
داد.
میتوانیکیازاینکتابخانههارابهعنوانکتابخانهخاصهایهدادپروژهبرایذخیرهسازیبالکهاوچارتهااستفادهکرد.تا
درتمامپروژههابهصورتیکشکلازبالکهاوچارتهااستفادهکرد.
کتابخانهMDLتنهامیتواندحاوییکپوشهS7 Programباشد.
برایتعریفیککتابخانهدرجشدهدریکMultiproject،بهعنوانکتابخانهMD،درمحیطComponent Viewکتابخانهراانتخاب
کردهوازفرمانزیراستفادهکنید.
File Multiproject Defineas Master Data Library
10. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Master data Library
It is recommendedthatthe blocksused in a project(user-definedor the system libraries) arecollected into the projectmaster library.
Block types used in a particular project,no matter they are PCS 7 library blocks or created by user, they have to be available in the master data
library.
After you are sure that all blocks required are in the master data library or located in a project library, it is recommended to hide all other
libraries including the PCS 7 standard libraries as they havebeenadapted into the project library.
To hide a library, use the Managefunction of the SIMATIC Manager,the menu path, File > Manage.SeePicture.
From time to time, you have to be sure that blocks used in a project are in the master data library. It is particularly important that there is no
conflict in block numbersand symbolic nameswithin the masterdata library.
13. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
When youplacea blockon a CFC chart, youplaceonly its instanceon the chart.
Instancemeansa usageof a blocktype.
When draggingthe Valve block,FB73, from the PCS 7 library anddroppingit on to a CFC, aninstance ofFB73 is placedonthe chart. The
blocktype is left in the Blocksfolder (Prog1)andin the CFC Chart folder.See Picture Above.
Further Instanceblocks canbe draggedfroma type in the CFC Chart folder ratherthan fromlibraries or from the Blocksfolder. The formeris
faster as nochecksfor discrepancybetweena blocktype in the CFC Chartfolder andBlocks folderare
performed.
Note
In areal project, themasterdatalibrary is usedthroughoutaproject engineeringcycle. Block typesare createdin or copied
intothe masterdatalibrary. Themasterdatalibrary is theonlysourcefor a particular project.
Youcancreate anynumberofblock instancesfrom a blocktype.Youcan assignnamestotheseblockinstances,
interconnectthem,andassignparameterstothem withoutchangingthefunctionality ofthe type.
14. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Block typesare ready-madeprogramsections that canbe insertedin a CFC chart.
When ablock typeis inserted, a blockinstanceis created.You cancreateany numberof blockinstancesfroma block type.
For the SIMATIC S7 CPUs, the blocktypes arecreated,edited, andcompiledin the LadderLogic editor (LAD), Statement List (STL) editor
or StructuredControl Language(SCL) editor.
For PCS 7 projects, functionblocksare createdin the SCL or by compilingcharts as blocks.
Block typesof a project arelocatedin theBlocks folderas shown in Picture.
Blocks folderalso containsother blocks,e.g. systemfunction blocks(SFB), datablocks (DB), andorganizationی blocks(OB)
The blocktypes of Blocksfolder arealso shown in the CFC library catalogueso that theycan beaccessedin theCFC editor. In Picture
Above,block typeof the S7 program,Prog1,are shown.
Block typesare obtainedfromthreesources, whichare fromthe systemlibraries, fromuser-designedlibraries, or createdin theproject. The
threesourcesof block typesare shownin Picture.
Block typesare also storedin theCFC Chart folder.The CFC Chartfolder containsblocksindicated bythe blue boxesas shownin Picture.
15. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Block typesare identified bytheir numbersandsymbolicnameswhile symbolic namesare optional.
When thesystem blocksare used,their symbolicnamesareautomaticallyenteredin the Symbols table.
The nameof theblock is usuallyenteredin the Symbols table or Symbolseditor. In Picture, a blocktype, FB73, has asymbolic name
VALVE, which is definedin the Symbolstable .
Block types
Theblocktypedeterminesthecharacteristics (algorithm) for all implementationsof this type.
A blocktyperepresents atemplatefor anynumberof instancesanddescribes howtheseinstancesare structuredinternally.
All instancesof a blocktypeobeythesamebasic definition as regardstheir characteristics andtheir data structure.
Block Instances
A blockinstanceis aconcreteobject generatedaccordingtoits type(blocks) description.
Thetypedescribesthe characteristics andinformation structurefor theinstance while thecurrent stateof eachinstance
dependsonits actually executedoperationsandis reflected in theinformation contents.
Eachinstancehas auniqueidentifier thatenablesinstances tobedistinguishedfrom oneanother.
21. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
makethe requiredinterconnectionsin the chartsbetweenoutputs andinputs.
You cancreatethe interconnectionsof blocksconvenientlyby :
clicking onthegraphicuser interface oftheCFC editorwith themouse.
Click first theoutputof ablock andthentheinputyouwantto connecttoit. After clicking ontheinput,theinterconnection
is displayedas aline.
TheCFC Editor automatically drawslines in thebestposition.
Thepositionof thelines hasnoeffect onthefunctionof theinterconnection.
Note
If youmakeanincorrect interconnection:
Right-click ontheline of theincorrectly interconnectionandselect themenucommandEdit > Delete.
22. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Textual interconnection is a virtual connection arising when a partner chart is moved to another S7 program or when it is created deliberately.
Textual interconnectionis indicated by a yellowtriangle as shown in Picture 2.25.
ایجاداتصالمتنی:دوروشوجوددارد.
روشاول:رویپایهورودییاخروجیبالکموردنظرباماوسکلیککردهوسپسرویپایهورودییا
خروجیبالکدیگرکهدرصفحهنمایشآوردهشدهباماوسکلیککنیمیم.
–امکاناتصالورودیبهورودییاخروجیبهخروجیوجودندارد.
روشدوم:راستکلیکبررویورودیموردنظروانتخابگزینهTextualinterconnection
–پنجرهرمذکوفقطایربهایهپایورودیبالکظاهرشودیموآدرسپایهخروجیواردشودیم.
–درصورتیکسانبودنسطحHierarchyآدرسمبداو،مقصدینیازبهذکرنامسطحنیستوردستوبا
عالمتشروعشودیم.
–نامبالکدریکCFCکهشاملچندینشیتمی،باشدبفردرمنحصاست.
–پرچمنگرزردنشاندهندهاشکالدردهیسآدریاعدمشناساییمقصدمیباشد.
23. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
If the connectedpartneris movedbackor a purposely-createdtextualinterconnectionis fulfilled, the textual interconnection will beclosed by
using the Close or“MakeTextual Interconnection”functionandthe yellow triangle disappeared.See Picture
The “MakeTextual Interconnections”functioncanalso be performedwhencompilingprogram.
Note:
Copyingor movingchartsin the Plant view within a CPU will retainall the interconnectionsbetweenchartswhile adaptthe interconnections
automaticallyto new paths.
When copyingor movinga plant hierarchicalfolder containingchart(s)and picture(s),interconnectionsbetweenthe charts andbetween
blocksand their graphicobjects(icons) areretainedand adapted.
Therefore,textual interconnectionswill not occurin the two casesabove.
24. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Exercise
تمرین:درPlant Viewیکچارتبنامtestایجادودرداخلآنبالکهایباالرادرجکنید.برای
اینکارپوشهReactorsi/Testiرابهعنوانسطوحفرآیندیایجادکنید.هردوبالکدرOB32اجرامی-
شود.اولینبالکتایپPT1_PودومینبالکیکجمعکنندهچهارتاییADD4_Pباشدیم.
------------------------------------------------------------------------------------------------
Steps 1. Call the projectin plant view. Createfolder.
2. Insert new CFC chart in the correspondinghierarchycontainer.
3. Define predecessorfor installation.
4. Enter blocksfromthe library into thechart andnamethem.
5. Set parametersfor blockson the sheetand interconnectthem.
6. Compile, downloadandtest program.
------------------------------------------------------------------------------------------------
Procedure In the blocknames,"i" stands for yourgroupnumber.
Add PH 1.Select the plant hierarchyview in the SIMATIC Managervia menucommand
View Plant View
Select the "REACTORSi" folder in the project PRO_ASi. Then
right-click andselect New Object... HierarchyFolder
to insert a newfolder. Renamethe folder "TESTi"
Createa chart 2.Select the "TESTi" folder,
right-click andselect New Object... CFC
to insert a chart. Nameyourchart "ATTEMPTi"
OpenChart Select the "ATTEMPTi" chart. To openthe chart,
right-click andselect Open Object(or double-click)
25. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Settings for
compile 5. Charts must be convertedfromthe graphicformto machinelanguageanddownloadedto theAS.
To initiate the conversionfrom a CFC chart, select
Chart Compile Charts asProgram
(or click the circledC Compile icon).
The entire softwareis compiledfor theCPU whichis associatedwith this CFC chart.
A dialog boxis displayedfor the compilationsettings (see slide).
Only"Entire Program"is possible under"Scope"thefirst timeyoucompile.Youcanselect "Changesonly" for anysubsequent compilations (after
changes/additions).
ImportantOption
"Generatemoduledrivers" (only meaningfulif thereis a minimumof onechanneldriver in the chart). This
results in the CFC creatingadditional chartswith the requireddriversfor data transferwith the I/O modules
anddiagnostics capability.
A chart "@CPU_RT" is createdin addition. The "CPU_RT" block insertedthere monitorsthe CPU
performancein order to avoida CPU stop (fordetails onthe block functions,pleaserefer to its online help)
Downloading:
The compiledchartsmust now bedownloadedto theCPU. Activate the following menucommandto start this
process:
PLC Download
or click on theDownloadicon (circledon the slide).
The first time the chart is downloaded,it is only possible to downloadthe entireprogram(in combinationwith
CPU Stop andautomaticdeletion of the programstill residingin the CPU).
26. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Testing in CFC
To test yourprogram,follow the menupath: Debug> Test Mode.You canmonitor I/O valuesby addingthem into Watch List. Then,the
valuesare highlightedin yellow.
Right click on anI/O andthen “addI/O to Watch List.
To changea value online, doubleclick an input, e.g. AUTO_OC. The I/O Propertiesdialog will openandyou canset a new valuefor the
variable.See Picture.
Note
To operatethe valvein the CFC Test Mode youset andreset AUTO_OC.
To be ableto operatethe valve,youneedto enablethe use of AUTO_OC by setting LIOP_SEL and AUT_L both to be “True”.
The library functionVALVE is explainedin details in Next Chapter
27. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Thereare two Test Modesnamely:
ProcessModeandLaboratoryMode.
Youcanchooseoneof thembefore testing.Toswitchbetweenthetwomodes,follow themenupath:
– Debug> ProcessMode(or LaboratoryMode).
In processmode,communicationfor the online dynamicupdateof blocksis restricted andthus causesmoderateload on the CP and bus.
When thetest modeis activated,all blocksare assignedthe "watch off" attribute.
The laboratorymodeallows convenientandefficient testing and commissioning.In contrast to processmode,the laboratorymodedoesnot
restrict communicationfor online dynamicupdateof blocks. So, use the laboratorymodewith caution.
When thetest modeis activated,all blocksare assignedthe "watch on" attribute.
29. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
With Memory Reset
ObjectهاوTagهادزWINCCپاکشدهوازنوساختهمیشود.
باکامپایلOSدیتاازسیستمASدرESبهOSمنتقلمیگردد.
درصورتظاهرشدنپیامخطادرشروعکامپایلبهمعنیکامپایلنشدنیکیاچندCFCمیباشد.
30. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
With Memory Reset
ObjectهاوTagهادزWINCCپاکشدهوازنوساختهمیشود.
باکامپایلOSدیتاازسیستمASدرESبهOSمنتقلمیگردد.
درصورتظاهرشدنپیامخطادرشروعکامپایلبهمعنیکامپایلنشدنیکیاچندCFCمیباشد.
31. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
درصورتیکهتایپفانکشنهایکبالاستفادهشدهدرچارتتغییر،یابدتوانیمهایکبالاستفادهشدهرابروزآوریکردهو
باتایپجدیدجایگزیننمود.
اینکارباimportکردنتایپجدیدبهپوشهCFC Chartانجامگیردیم.
بینهایکبالموجوددرپوشهBlocksکهتایپجدیدوجودداردوپوشهChartsمقایسهصورتگیردیم.
Central typechangesmeanthat all instancesof a block typealreadyincludedin CFC charts areautomaticallyupdatedif the blocktype is
changed.For example,a userblock is modified later afterits instanceshavebeenused in CFC charts. You can
updateall the instancesbyimporting the newtype to the CFC Chart Folder.
The function, “Importingblock type”,canbe foundfollowing the menupath: Options > BlockTypes. See Picture
Alternatively, you canusethe New Version functionto updateblocktypes usedin a project. SeePicture.
The BlockTypes dialog is whereblock typesare comparedbetweenthe Blocks folderandthe CFC Chartfolder. Block typesin thesetwo
folders haveto bethe same.
The functionof the central typechangeis useful andpowerful.If the PCS 7 library blockshavebeenchangedbySiemens dueto a newer
releaseof the system. Youhaveto decideif the newerversionof the blocks is to beusedin yourproject.
32. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
If block instancesaredeletedfrom a chartor deletedbecauseof deleting charts, their types will not be deletedeither fromthe CFC Chart
folder orfrom the Blocksfolder thoughthe blocktypes arenot used in the project.
Block typesthat are not usedin a projectcanbe removedfromthe project byusing the Clean up functionas shown in Picture
Using the function, youwill be askedif block typeis to be removedfromthe CFC Chartfolder (Steps 2 and 3 in Picture) andBlocksfolder
(Steps 3 and 4 in Picture 6.10)respectively.
Note
The library blocks,e.g. SFB36 as in Picture, could beremovedas they arecontainedin the firmwareof AS.
33. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Locate Change To detect possible changes between e.g.
already instantiated blocks in the project and
the associated library substitute
before any further use, you can compare blocks - as shown above:
Right-click on selected blocks or blocks to be checked (here FBs from the
library --> Compare blocks... --> Specify comparison path/objects (here
select block container for the project).
Result A: No deviations identified in compared objects
Result B: List of objects with deviation + specific description
Note This is only a "fast comparison" without additional options (where are any
differences?).
From the PCS 7 viewpoint, the VXM option (Version Cross Manager) offers
more efficient information (also for non-programmers). This application will be
discussed later. However, the VXM does not evaluate the consequences for the
S7 program if the change were carried out.
A further possibility is shown on the next pages.
This indicates the consequences of a possible synchronization with the option
for aborting the commenced synchronization if the change does not appear to
be appropriate (e.g. downloading only possible with CPU stop).
34. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Functions couldcall other functions.
The calledfunctions aresub-functionsandareblock typesthem. For example,a closedloop controlblock calls a signaling blockanda
controlling block.
When copyinga multi-instanceblock to a project (to the Blocksfolder) all sub-blockshaveto be copiedinto the blockfolder as well.
Note
Called SFBs and SFCs, suchas SFC6 (RD_SINFO) or SFB0 (CTU) arelocated firstly in the PCS 7 libraries andcopiedinto your S7 program
whenyou compilethe calling block.
Called FBs are copiedto the blockfolder whenyouinsert thecalling block in a CFC chart if they are locatedin the samelibrary as the calling
block. Otherwise, the calledblocks haveto becopiedinto the S7 programBlocks foldermanually.
35. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Multiple Instance The FB602 is structured so that another, already existing FB40 can be called
within it. This FB is detected as static variable with the data type FB and allows
to achieve nesting of variables and concentration of all instance data in one
instance data block (multiple instance).
Structure If you want to look at the structure of your new block, proceed as follows:
- In the block folder of your library, select FB40 (INT_P), then
right-click and select Open Object.
LAD/STL/FBD is opened.
- Close the block only via
File -> Close (Do not save, if you are prompted to save!)
- In this editor open your block FB602 (V_SIM_FB) via
right-click and select Object -> Open
Now you can see the above structure on your screen.
Attributes - Position the mouse pointer in a line (with green marking), then
right-click and select Object properties -> Attributes
to display the table with attributes (properties) of the parameter.
Changes If you change/supplement attributes here, and then save the block, it will be
given an STL identification. The changes must be made known to the CFC (if
the block has already been used). Further consequences arise from the type of
modified attributes.
36. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
The interface between the operating system of a CPU and the user program are the tasks known in S7 as organization blocks (OB).Using these
OBs, specific programsections canbe executedat certain times and in certain situations.
There areOBs for CPU startup, for processinterrupts, and for cyclic interrupts(with different time bases)etc.
For example,OB32has cyclicinterrupts every 1 second.Function blocksinserted in OB32are called every second.
When ablock is inserted in a chart, by defaultit is automatically installed in OB35. The cycletime of OB35 is 0.1 seconds.
OBs cannotbe inserted nor edited in CFC. In CFC, the OBs are displayed in the Runtimeeditor.
OBs with differenttime cycles areset in the HW Config as illustrated in Picture.
Note
The defaultcycles areset as in Picture. It is recommended notto changethe default settings.
38. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
When ablock insertedinto a CFC chart, a blockis installed in a runtime groupin default OB.
It is important to re-locatethe runtime groupinto an appropriateOB.
A runtime groupis createdwhenyou insert a CFC chart.
When ablock is placedon anempty CFC chart, the blockis installed inside the group.Subsequentlydragged-and-droppedblockson the chart
arearrangedin the groupandthe orderin which they areplaced.
پردازشبالک
هایکمحلپردازشپیشفرضبالPCS7درOB35(Cyclic InterruptOBs-100ms)است.
هایکتابخانهکبیشتربالPCS7فقطدرCyclic InterruptOBsقابلاجراهست.
درصورتیکهحجماجرایبرنامهبهصورتیباشدکهاجرایآنبیشاززمانتنظیمشدهدرHWConfigبرایOBموردنظر
باشد.CPUبامشکلمواجهخواهدشدکهاینمشکلدرOB1وجودندارد.
شمارهRuntime GroupشمارهمربوطبهچارتCFCدرزیرمجموعهOBوشمارهRuntimeSequenceشمارهیاترتیباختصاص
باشدیدادهشدهبرایپردازشبالکدردرونچارتم.
درفهرستRuntimeGroupتمامOBهایتعریفشدهدرS7اندهلیستشد.ممکناستCPUانتخابشدهتماماینOBهارا
پشتیبانینکند.
درصورتعدموجودOBدرCPUگرددیبرنامهدچارفالتم.
اگربالکیبهصورتمستقیموبدونGroupدرزیرOB35قرارگیرددراینصورتشماره1/-خواهدگرفت.
39. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Run Sequence
بررویآیکونRun Sequenceدرمیلهابزار(کهبهصورتدایرهقرمزرنگنشاندادهشده)کلیککنید.یکپنجرهبازمیشود
کهدرآنتمامبالکهایOBمربوطبهCPUفهرستشدهاست.
وقتییکپروژهایجادمیشودپیشفرض(Predecessor)نصببالکهادرOBهابررویOB35تنظیمشدهاست.بهاینمعنیکه
وقتییکچارتایجادمیشود.یکruntime groupبهصورتاتوماتیکدرOB35بهاسمهمان
چارتایجادشودیم.وقتیبالکهابهچارتاضافهمیشوندبهصورتاتوماتیکدراینRuntime
Groupگروهبندیمیشوند.
Moving the RuntimeGroup
برایتغییرOBمربوطبهیکRun Time Group(چارتCFC)سیمبلپوشهRun Time Groupایجادشدهبرایچارتجدید(َالمث
پوشهTestدرشکلباال)راباماوسگرفتهوبهداخلیکOBدیگر(OB32)بکشیدکهدرداخل
CPUاینOBباسیکلزمانیمتفاوتاجرامیشود.
برایاینکهدرزمانایجادچارتهای،جدیدهاتچاردریکOBدیگریغیرازOB35نصبشوندبایستییکپیشفرض
نصبدیگری(Predecessorfor installation)تعریفکرد.
Predecessorfor Installation
برایتغییرOB،فرضشپیOBموردنظر(مثالOB32)رااتخابکردهوسپسباراستکلیکرویآنگزینهPredecessor for
installation positionرااجراکنید.بااینکارمکانجدیدپسازتاییدپنجرهعملیاتیتعیینمیشود.
لذابالکهایبعدیدرRun Time Groupانتخابشدهقرارخواهندگرفت.
Run Time GroupبهصورترنگسبزروشنخواهدشدوپیشفرضجدیدOB32/testدرقسمتپایینوسمتراستپنجره
CFCنشاندادهخواهدشد.(شکلراببینید).
40. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
The defaultsequenceof blocksin anOB by no meansrepresentsthe signal flow betweenthe blocks. Generally,blocks shouldbe executedin
a logic sequencewhichdependson signal flows. For example,blocksin Picture should bearrangedin the
following order:
(1) Block FB_OPENor FB_CLOSE
(2) Block VALVE
(3) Block OUT
To arrangeblocksin a logic order, the function“OptimizeRun Sequence”is used.
The menupathto call up the functionandsettings of the function is illustrated in Picture.
If “Optimize runsequence”is performed,the blocks of the groupwill bearrangedaccordingto the signal flow sequencebetween theblocks.
In debuggingandtesting, youcanactivate or de-activatethe Optimize run sequencefunction byselect or de-selectthe Active box(Step 3 of
Picture).
41. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Reductionratio
The reductionratio determineswhethertheCFCblocks/SFCchartsofa runtime groupare processedeachtime oronlyevery nth time thetaskis
executed."n"is an integer(n = 2t,where 0 <= t <= 15).
The cycle times are a multiple ofthebasic reductionratio ofthetask.
Example:
Basic cycle ofa cyclic interrupt(OB 33): 500ms
Possibleclock cycles with reductionratio: 1 s, 2s, 4 s, 8 s,16 s, etc.
The default settingis 1 sotheblock/SFCchart is executedin every cycle (in OB 33every500ms).
Phaseoffsetallows a uniformdistributionofload within theCPU.It mustbe consideredin conjunctionwith "n", thereductionratio. The blocks or
SFCchartsofthe runtimegroupare executedas oftenas specified by"n", offset by"m"unitsofthe taskcycle. "m" is an integer, where0<= m<=
(n-1).
Example:
Basic cycle ofa cyclic interrupt: 500ms
Reductionratio: 16(i.e., theblock/SFCchart is processedatintervals of 8 s)
Phaseoffset:3. The block/SFCchart is processedat intervals of 1.5s, 9.5 s, 17.5s,etc.
The default is 0; in otherwords,the block/SFCchart is executedwithouta phaseoffset.
"Optimizerunsequence"option
Youcan select/deselectthecheckboxin orderto include orexcludea runtime groupfrom run sequenceoptimization.If theruntime groupscontains
F objects,the optionis notenabled.
Youwill find moredetailed information in: Optimizing therun sequence
"Active"option
Youcan select/deselectthecheckboxin orderto enable/disablethe runtimegroupfor processing,if it is notinterconnected.Aninterconnection
alwayshas priority.
In the detailwindowof theruntimeeditorin thecolumn"Inactive", the modeofthe runtimegroupis displayed.The namecorrespondswiththatof
theruntime propertiesfield ofa block. This character"!" meansthatthe relevant runtimegroupis inactive; this character "?" meansthatthe runtime
groupEN is interconnectedorSFCaccessexistsandtherefore is notin static processmode(may beactive or inactive).
Usingthe shortcutmenucommandsSwitchonRuntimeGroupandSwitchoff RuntimeGroup,youcan select ordeselectthe optionfortheselected
runtimegroup,withoutinitiating the objectproperties.
42. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
The Optimize runsequenceoption hasto beset oneby onefor eachruntime group.However,the option is set by default.
The Optimize runsequencefunctionis executedby the menupath as illustrated in Picture.
The Optimizing runsequencefunctionis relevantto all runtime groupsratherthan the blocksin an AS that havebeenactivated forthe
function. Therefore,the function couldchangea largenumberof blockscontainedin differentCFC chartsand
has a globalimpact onthe behaviorof runtimeperformanceof a S7 program.
After optimizing run sequence, the blocks on the
chart, val, are re-arranged.
44. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Runtime groups can be activated or deactivated individually (for example by a block output of the "BOOL"data type).
If a runtime group is deactivated, the blocks it contains will not be executed when the program is executed.
You can also de-activate an OB in runtime.
کنترلیکCFCازیکCFCدیگر
رویخروجیبالکدریکCFCکلیکوگزینهInterconnection to Runtime Groupکنیمیراانتخابم
سپسازلیستنمایشدادهشدهOBوCFCموردنظربکاررفتهدرآنOBکنیمیراانتخابم.
بااینکارپرچمقرمزرنگدربخشاتصاالتخروجیCFCشودیاولظاهرم.
بااینکارEnableمربوطبهCFCدومبهیکشدنخروجیموردنظردرCFCاولبستگیخواهدداشت.
هادرکبررویبالCFCشودیدومعالمتسوال؟ظاهرم.
45. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Interconnecting Runtime GroupStatically
If youselect a runtimegroupin theruntimesequenceandopenits properties,theActive optionis set.This meansthatallblocks
from this groupare takeninto accountfor eachOB pass.
If youdeactivatethis option,noneoftheblocks in thegroupare takenintoaccount/processed.
In theassociatedCFC chart all blocksdisplay a red exclamationmarkin therectangle showingtheexecutiondata.This indicates to
theconfiguringengineer that theblockis notactive!
Alternative Select the runtimegroupin theruntimesequenceandexecutetheprocessusingthe contextmenuby
right-clickingandselectingSwitchon(activate)RuntimeGroup or
right-clickingandselectingSwitch off(Deactivate)runtimegroup
48. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Chart inChart Purposeofthis technique: Todesignclear,well-structured charts.
Chart sectionsthat are repeatedlyusedwith thesamestructurecanbe combinedtolooklike onechart with a predefinedsheetbar -
andthuslike a blockwith I/O.
Procedure 1.Thelower-levelchart is created andgiveninterconnections(this canalso becarried outin a (masterdata) library).
2.Thepreviouslycreated chartis inserted in the higher-levelchart.Thereit its displayed like ablock;its sheetbar(I/O) was
defined in step1.
3.If thelower-level chart wascreated in a library andwasdraggedintothetopchart,it will notbeshownin theproject's chartfolder
(as youcan onlysee thetopchart there).Theassociated blocksare inserted in theruntimesequence.Youcanchangetheir sequence
in there if required.
Alternative: If youobtainthe"New chart" from theCatalog tab"Blocks" andplace it as anemptychart in theCFC chart,thenyoucan implement
a top-downapproach- i.e. reverse thesequencein points 1and2in theabovedescribedprocedure:
1.In thehigher-level chart,first place "only" emptycharts aswildcards for specific functions; thefunctionis documentedfirst
"only" as nameof therespective empty"black box".Theresult is a functionoverviewchart consistingof thevariousindividual
charts.
In thesecondstep,thedetails are addedtotheseindividual chartsas lower-levelcharts,i.e. "filled" with blockfunctionality and
providedwithchart interconnections.
3.Nowyoucan interconnecttheindividual charts in thehigher-level chart.
49. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
the chart-in-charttechniqueis a functionfor efficient engineering.
This involvesinserting oneCFC chartinto another.The insertedchart thenbecomesthe hierarchicalchartandthe other the basechart.
This enablesyouto createa chart onceand thenuse it as the basis for numerousothercharts. This means,for example,you cancreatea
simulation chartfor a valveand theninsert this simulation chart as a hierarchicalchart into the basechart for
the "valve"processtag.
Of course,you canopenandedit the hierarchicalchartfrom the basechartat anytime.
Example:
As mentionedandshown in Picture, You couldplacea chart ontoanotherchart. the chart, CFC_val, is placedonto CFC_2.
The chartnesting structure is displayedin the Blocks/chartscatalogueas shown in Picture whereChart CFC_2containsCFC_val.
Picture also shows howto openthe original chart(Step 3).
52. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Compiling CFC chartas block type(Chart-in-Block)
You cancompilea chartas a block. Blockinstancesin the chartbecomesubsectionsof the chart block.A chartblockis then a blocktype.
Note
To makea chartout of a block, the blocksin the chartmust not be installed in a runtime groupandtheyshould not haveinterconnectionsto
other charts.
53. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
پسازتعریفI/Oبراییک،چارتتوانیمچارترابهعنوانیکبلوککامپایلکرد.
لذابرایاستفادهازبالکدرهاتچارنیازاستکهبرایIOهایچارتکههایرپارامتبالکحاصلازکامپایلخواهد،بود
همانندSCLهایییویژگ(attributes)تعریفکنیم.
تصویرنشانمیدهدکهچگونهبرایبازکردنخواصمتغیرمحاورهارائهشدهاستکهیکنمودار
I / Oتعریفرامشخصویژگیهایسیستمبراییکمتغیروجوددارد.
پنجرهتعریفیویژگبرایپارامترهایانتخاب،شدهدرتصویرباالنشاندادهشدهاست.
54. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
For analogvariables, engineeringunits areprovidedat block instances.See Picture.
You canedit andadd units in the file andthey becomeavailablesystem-wide.When upgradingthe PCS 7 systeminstallation, you should
rememberto backup the files.
Storing of the engineering
units
55. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
In the Test Modeof the CFC, you cantest anddebugyourprogram.
The CFC test modeis convenientfortesting oneCFC sheet.
To monitor andmanipulatevariablesfromdifferent chartsand/orfrom differentCPUs, youcould usethe DynamicDisplay function.
56. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
TestMode Youmustactivate "test mode"totest thefunctiondownloadedtotheAS.
First activate
Debug ProcessMode Or
Debug LaboratoryMode
toselect/checktheappropriate testenvironment.
Usethe following commandtoactivate/deactivatetest mode:
Debug TestMode
With laboratoryoperation,monitoringis automatically activatedfor theparametersspecified "for test".Duringprocess operation,
youmust select therequired blockeach timeandidentify it for monitoringby
right-clickandselectingWatchOn
Test 1 If thetest modeis active andtheparameters tobetestedhaveayellow background(default settingfor updatedvalues),youcanset
parametersfor theinput parameter.Thenewvalue is written tothe ASandtotheproject.
Changethevalueonthe"First" block,"U" input.Monitortheresult onthe"Second" block,"V" output.
Test 2 DynamicDisplay offers an additionaltest procedure.Youcanopena displaywindowin CFC:
View DynamicDisplay
Use"drag anddrop"in this windowtodragtheblock parametersyouwant tomonitor(from anyoftheprojects- evenfrom different
CPUs). Oneline in thetable is reservedfor eachparameter.
Uponactivation oftest mode,youcanmonitoror edit (if permissible) theseselected parameters.
Youcandelete severalparametersyounolongerneedbyselecting therelevant line,right-clickingandselectingDelete.
YoucanusetheNew ,Renameor Delete buttonsin the tablewindowtocreate, renameor delete newdynamicdisplays.
57. مدرس:اکبری صادق
Tel. 09123182734
SIMATIC PCS7 Training
CFC Language
پتروفن شرکت–امام بندر
نیرو آب-پاییز96
Additionalexercise(option)
Trytorecognize theconsequencesof anOB32overload.Use theLOADblock from theKURSBS60library for thispurpose(see
slide). SupplementtheCFC "Attempti"chartas suggestedabove.
-----------------------------------------------------------------------------------------------------
Procedure 1.LOADblock:Switch theloadonusing"ON"=1. Increase theOB32loadbyincreasing theparameter "CYCL".
2.INT block:With theparameters"TI"=1 and"U"=1,theblockwill incrementthe output"ACTUAL" eachtime OB32is called. If
Test Testsettings Monitoringcycle = 1second
is set in theCFC, thevalue of theoutputwill be incrementedby1 everysecondin test mode.This applies tonormaloperation.
Increase theCYCL input ofthe LOADblock,andobservetheoutput"V" of theINTblock.
Also checkthediagnosticsbuffer of yourCPU usingthe CFC menu
PLC Moduleinformation "Diagnostics buffer" tab
andthe(OB1) cycle time in thetabwith this name.
3.Connectthe output"V" oftheINT blocktotheinput"U" of theMEAS_MONblock.
In thelatter, select "Long-term archiving" in theproperties of theinput"U" under"Archive".
4.Compile anddownloadtheAS
5.Compile theOS. Theparameter"U" of theMEAS_MOSis created therein TagLogging,in the"System archives" archive.
6.Activate theOS,andcreate anonline trendfor this variable. Carry outthesameincrease totheload in theAS, andcheck the
reaction ontheOS.