Skip to main content
留学咨询

辅导案例-IEC61499

By May 15, 2020No Comments

Benjamin Tan, Hammond Pearce IEC61499 Function Blocks Lab COMPSYS 725 2019 – Computer Networks and Distributed Applications Objectives: 1. Gain hands-on experience with FBDK, the industry reference implentation of IEC 61499 Function Blocks (FBs). 2. Experience how to create, compile, test, and modify a Basic Function Block (BFB) type. 3. Experience execution of distributed FB applications. 4. Modifying a Composite Function Block (CFB) to increase its functionality. How to Install FBDK Download the FBDK.zip file from Canvas. Extract this file to your H: drive. Inside, you will find “editor.jar”. You can run this by opening a command prompt and writing “java -jar editor.jar”. Alternatively, if you are on windows, you can double click “editor.bat”. NOTE: don’t run the editor jar directly, as fbdk outputs debugging text to the terminal. If you have no terminal, you cannot see the text. If everything works, you will be prompted with an EULA, which you can agree with to continue. Benjamin Tan, Hammond Pearce Then, you will be shown the editor view: Modify an existing FB type Open function block type X2Y2_ST using File/Open (/student/X2Y2_ST.fbt). Try to run it by clicking at the “Launch” button ( next to the “Run” menu item). Perhaps you will see something like shown in Error! Reference source not found., – the “UNSUPPORTED_TYPE” error message. This is because the block has not been compiled yet. Compile the block to the Java class by File/Save as or Alt-S shortcut. You will see the dialog Error! Reference source not found.(b) where you need to tick box next to Java (if you have changed anything in the block and also the one next to XML) and then OK. Make sure that in the field “Package” you see fb.rt.student. If you see then the window Error! Reference source not found.(c), then the compilation was successful! In case you something like in Error! Reference source not found. (d), then the preference needs to be changed by clicking on the preference icon . Clicking on it will bring up the dialog shown in Error! Reference source not found.. Edit the location where java sdk/jre was installed. Don’t forget to click on save! Benjamin Tan, Hammond Pearce Figure 1 a) Attempted to run before compilation; b) Start compilation dialog; c) Successful compilation; d) Unsuccessful compilation. Now run the block in the test environment by Run/Launch/ X2Y2_ST. The test environment is producing a frame in which you can test just one function block by entering its input parameters. Unfortunately, not all of the input fields have labels, so you need to guess. NOTE: The default behaviour of FBDK when closing is to “discard changes”. Be careful to save your work. Now let us change the function block type name to MY_X2Y2_J.fbt by clicking at the Name/Comment item in the tree in the left pane of the editor. Figure 2) Testing X2Y2_ST Benjamin Tan, Hammond Pearce Save the block using Alt-S (tick on XML). Now you can start making some modifications. For example, let us change the formula and compute X2+Y2. For doing that you need to modify algorithm REQ, which will be written in JAVA instead of original Structured Text (ST). Just double click on it and see the following picture (on the right side): Click Java radio button and the structured text algorithm will be automatically converted to equivalent JAVA text. Now change the code in the box to: OUT.value = X.value*X.value+Y.value*Y.value; Note, that all function block variables are objects, that is why their values are accessed by X.value, Y.value, etc. Figure 3) Edit Algorithm window Try to run by Run/Launch/MY_X2Y2_J – WHAT HAPPENED? You again get the message UNSUPPORTED TYPE. Remember that you have changed the block’s name, but have not compiled it with new name yet. Compile the new block by saving it as Java (Alt-S, tick on Java, then OK) and try to run it again. Make sure that the block computes now X2+Y2! Now, let us experiment with adding more inputs and outputs to the function block and with modifying the ECC. For example, to add new inputs click right Button of mouse on the function block shape and follow the menu: New/Variable/Input as shown in Figure 4. Figure 4) New Event/Variable Menu Benjamin Tan, Hammond Pearce Add a new numeric input Z (of type REAL), an event input XYZ, an event output CNF2 and a data output OUT2. When block is activated by XYZ event, it shall compute OUT2=X+Y+Z and signal the event CNF2. NOTE: to create an association between an event input and data input position mouse to the left of the event input (on the word EVENT), hold ALT and press LEFT mouse button. (MacOS users hold CONTROL). While holding the mouse button, drag the cursor to the data input name as illustrated in Figure 5, positioning the cursor at the data type name (BOOL on the picture). Figure 5) An event/data association When you are finished adding all the new IO and associations, your FB should look like Figure 6. Figure 6) The completed FB interface Now, let us modify the block’s body. In the navigation tree, click on the ECC icon. Go to the Edit pane. Make right mouse click and select New/Algorithm from the pop-up menu. You will see the Edit Algorithm window. 1. Set the algorithm name “XYZ_COMP” 2. Set the type to be Java 3. Enter java code to set OUT2.value to be the sum of X.value, Y.value, and Z.value 4. Now your window should look like Figure 7. Benjamin Tan, Hammond Pearce Figure 7) Algorithm XYZ_COMP Press OK to save the algorithm XYZ_COMP. Aside: Manual editing of FB via the XML All editing can be also accomplished by direct access to the XML text of the function block description. For example, let us insert the action manually, modifying directly the XML source of the MY_X2Y2_J.fbt file as follows: 1. Click on the state REQ – the corresponding XML element will be highlighted in yellow (Figure 8); 2. Copy the nested element and paste it to the element corresponding state XYZ_S; 3. Modify the element: change the algorithm name (to XYZ_COMP) and output event (to CNF2), and set the x and y. 4. Parse the edited XML by pressing the Parse button . It should now look like Figure 9. Figure 8) Existing ECC state highlighted Figure 9) New ECC state in XML Benjamin Tan, Hammond Pearce Now you can connect the new state XYZ_S to the state START. Remember – the connector works when Alt is pressed. (Figure 10). Figure 10) Draw Transition Double click on the transition condition from START to XYZ_S (currently – 1) and select the event XYZ from the menu as follows, In case the Event drop box is greyed out, make sure you select an empty data from the Guard Condition drop box(Guard Condition should not show the value 1). Similarly connect from XYZ_S state to START and let the Guard Condition be default value 1. (Figure 11) Figure 11) Set transition guard Save the resultant FB, compile it, and run. Check if the block does what you want. ADD DEBUG PRINTOUT TO ALL ALGORITHMS IN THE FB Run and see the printouts of the execution trace in the command line window of Java. Now let us experiment with changing the ECC. Delete the transition from state START to XYZ_S – just right mouse click on the condition of the transition (XYZ), and select Delete from the menu. Also delete the transition from REQ to START. Then connect REQ with XYZ_S with a transition having condition XYZ. The resulting ECC will look as in Figure 12. Save and compile the block. BEFORE RUNNING IT YOU NEED TO RESTART FBDK. OTHERWISE FBDK WILL PROBABLY RUN THE OLD CLASS (with non-modified ECC) WHICH IS STILL LOADED. Benjamin Tan, Hammond Pearce Figure 12) Modified ECC Enter X, Y, Z values 1, 2 and 3 as shown in Figure 13. Then press XYZ. What you see? No reaction since in the current state the block is not expecting this event input. Figure 13) Test values Press then REQ and the OUT result -3.0 will be displayed (12+22 = 5). Now the ECC is in state REQ a
nd if you press XYZ, then there will be reaction: value 6.0 for OUT2 and output event CNF2. After experimenting with the modified MY_X2Y2_J, modify its ECC back to the previous version! Save and compile. It will be used in further exercises. Using a modified FB Type in a System Configuration System configuration is the only structure of IEC 61499 that is supposed to be immediately executable. It does not need to be compiled to Java. Provided that all the types used in it (devices, resources and function blocks) are compiled and stored correctly, a system configuration can be started from FBDK. Open system configuration X2Y2_TESTL. Explore its devices and resources by double clicking them in the navigation tree and/or double clicking the blocks in the editor pane. You will find that this system configuration uses X2Y2 Function Block (in RES2, it is called TESTEE) and “wraps it” with HMI and communication functions. Try to run it. Since it uses the X2Y2 function block, you will need to open and compile X2Y2.fbt (save as xml/java) before running the system configuration. Now it should run, and you will be presented with two windows. One of them has editable values in it. When you edit them and press [return], the system is invoked. Figure 14) One window for each device – this is a distributed application! Benjamin Tan, Hammond Pearce Now we will modify the X2Y2_TESTL system configuration to use your MY_X2Y2_J function block type. In Resource 1: 1. add a new IN_ANY FB with name IN3. a. You can do this by right click / new FB / hmi / IN_ANY, b. OR you can modify the XML (like the ECC example earlier) but using the resource tag instead. 2. Change the local publisher XY of type PUBL_2 to XYZ of type PUBL_3. a. Right click on the instance name and modify instance name. Choose the type name from browsing in package net. b. OR, change the TYPE tag to be PUBL_2 in the XML and parse. 3. Adjust connections: a. remove event link from IN2.INITO to XYZ.INIT, b. add event link from IN2.INITO to IN3.INIT, c. add event link from IN3.INITO to XYZ.INIT, d. add event link from IN3.IND to XYZ.REQ, e. add data link IN3.OUT to XYZ.SD_3. 4. Resource 1 should now look like Figure 15. Figure 15) RES1 modifications finished. In Resource 2: 1. Change TESTEE type to MY_X2Y2_J. 2. Then, change XY type to SUBL_3 and instance name to XYZ (the block instance name is used as an ID for communication). 3. Adjust connections: a. Connect XYZ.IND to TESTEE.XYZ. b. Connect XYZ.RD_3 to TESTEE.Z. c. Connect TESTEE.CNF2 to OUT.REQ. d. Connect TESTEE.OUT2 to OUT.IN. 4. Resource 2 should now look like Figure 16. Benjamin Tan, Hammond Pearce Figure 16) RES2 Modifications finished Run the new project and ensure that it behaves as you would expect. This lab is now finished. Good luck. Please keep talking to your teaching staff for assistance. Don’t leave the assignment to the last minute. Work well with your group.

admin

Author admin

More posts by admin