7. Writing Custom Function Blocks 7–1 Internal
Participant Guide Writing Custom Function Blocks Contents of This Module Module Objectives............................................................................5 7–3 Writing Custom Function Blocks....................................................6 Networks ...................................................................................................... 6 Creating an UPDOWN Counter ................................................................... 7 Lab 31: Creating an UPDOWN Counter..........................................8 Introduction.................................................................................................. 8 Objectives .................................................................................................... 8 Lab Procedure ............................................................................................. 8 Place and Connect Function Blocks on the Logic Sheet .......................... 8 Place and Connect Input Variables on the Logic Sheet.......................... 11 Place and Connect Output Variables on the Logic Sheet ....................... 14 Invert an Input and an Output ................................................................ 16 Creating a Function Block Using ST Editor................................ 18 ST Logic for the function block ................................................................ 18 Lab 32: Creating a Function Block Using ST Editor .................. 19 Introduction................................................................................................ 19 Objectives .................................................................................................. 19 Lab Procedure ........................................................................................... 19 Create a Function Block Using the ST Editor ......................................... 19 Lab 33: Creating a Move Function............................................... 22 Introduction................................................................................................ 22 Objectives .................................................................................................. 22 Lab Procedure ........................................................................................... 22 Change an Input Value to an Output Value ............................................ 22 Lab 34: Creating a Rising Trigger Function Block..................... 25 Introduction................................................................................................ 25 Objectives .................................................................................................. 25 Lab Procedure ........................................................................................... 25 Add Horizontal Dividers to the Logic Sheet ............................................ 25 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Place a Rising Trigger Function Block in the Second Network ............... 25 Lab 35: Creating a Timer .............................................................. 28 Introduction................................................................................................ 28 Objectives .................................................................................................. 28 Lab Procedure ........................................................................................... 28 Create a Timer....................................................................................... 28 Lab 36: Invoking an UPDOWN Function Block .......................... 32 Introduction................................................................................................ 32 Objectives .................................................................................................. 32 Lab Procedure ........................................................................................... 32 Invoke an UPDOWN Function Block ...................................................... 32 Lab 37: Invoking an Average Function Block ............................ 35 Introduction................................................................................................ 35 Objectives .................................................................................................. 35 Lab Procedure ........................................................................................... 35 Invoke an Average Function Block ......................................................... 35 7–4 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Module Objectives After completing this module, you can • Create a project with a program that has five distinct networks. • Create an UPDOWN Counter. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–5 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Writing Custom Function Blocks This section explains how to create a project with a program that has five distinct networks. The project combines the developer's tools and techniques used in previous modules to create custom function blocks that are then copied into the program. You will use the FBD and the ST editors to create user-defined function blocks that will be invoked by the program. You will then place the function blocks in a user-defined library. Finally, you will create a program with five networks, invoking the custom function blocks. Networks The program has five networks: • Network 1 - Uses a MOVE function to change the value of one variable to the same value as another variable. • Network 2 - Uses a Rising Trigger function block to change the status of one variable to that of another variable for one scan. • Network 3 - Uses a Timer to change the status of one variable to that of another input variable after five seconds. 7–6 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks • Network 4 - Invokes a user-defined UPDOWN function block that uses an input value and counts up to 100, then counts down to zero, while displaying the current value. • Network 5 - Invokes a user-defined Average function block that calculates the average value of the output value of UPDOWN as it counts up to 100, then counts down to zero. Creating an UPDOWN Counter In this section, you will create a user-defined function block that counts from zero to 100 and then count down from 100 to zero. For this function block, while the input count (Count) is True, the function block will count up to the maximum count (Max_Count) of 100, then count down to zero. This logic has an inverted input. The value for the input is changed to the opposite value when the function block is executed. For example, if the value is True, it is changed to False. When an input or output is inverted, a small circle is displayed on the terminal of the function. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–7 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Lab 31: Creating an UPDOWN Counter Introduction In this lab, you will create a user-defined function block that counts from zero to 100; and then count down from 100 to zero. For this function block while the input count Count is True, the function block will count up to the maximum count Max_Count of 100 and count down to zero. This logic has an inverted input. The input value is changed to the opposite value when the function block is executed. For example, if the value is True, it changes to False. When an input or output are inverted, a small circle is displayed on the terminal of the function. Figure 1 shows the completed logic. Figure 1 Objectives After completing this lab, you can: • Place and connect function blocks on the logic sheet • Place and connect input variables on the logic sheet • Place and connect output variables on the logic sheet • Invert an input and an output Lab Procedure Place and Connect Function Blocks on the Logic Sheet Create a new document named UPDOWN. In the Name field, enter UPDOWN. In the Document Type area, click Function Block. In the Language area, click Function Block Diagram. 7–8 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks In the Application Type area, click Safety and Control. Click OK. On the toolbar, click the Select Function (Block) button, and then place a Count Up/ Count Down (CTUD) function block on the logic sheet. Double-click the CTUD function block to show the Item Properties dialog box. In the Instance Name field, enter CTUD_01. Click Apply and close the dialog box. Click the Select Function (Block) button, and then place a Set/Reset (SR) function block on the logic sheet to the right of the CTUD block. Double-click the SR function block to show the Item Properties dialog box. 7–9 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide In the Instance Name field, enter SR_01. Click Apply and close the dialog box. Click the Select Function (Block) button and place an Integer to Real (INT_TO_REAL) function on the logic sheet below the SR function block. Repeat the previous step to place two AND gates to the left of the CTUD function block. 7–10 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Click the Wire Tool button and draw wires from: − The output terminal of the top AND gate to the CU input connector on the CTUD function block − The output terminal of the bottom AND gate to the CD input connector on the CTUD function block − The QU output terminal on the CTUD function block to the S1 input connector on the SR function block − The QD output terminal on the CTUD function block to the R (Reset) input connector on the SR function block − The CV output terminal on the CTUD function block to the input connector of the INT_TO_REAL function Place and Connect Input Variables on the Logic Sheet On the toolbar, click the Input Variable Tool button, and then place two variables to the left of the AND gate. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–11 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Connect the top input variable to the top terminals of each AND gate. Double-click the input variable to show the Item Properties dialog box. On the Variable tab, in the Variable Name field, enter Count. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL and the Variable Type is set to Input. Close the dialog box. 7–12 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Connect the bottom input variable to the Present Value (PV) input terminal on the CTUD function block. Double-click the input variable to show the Item Properties dialog box. In the Variable Name field, enter Max_Count. Click Apply. On the Declaration tab, verify that the Data Type is set to INT and the Variable Type is set to Input. Click Apply and close the dialog box. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–13 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Place and Connect Output Variables on the Logic Sheet On the toolbar, click the Output Variable Tool button and connect the output variables to the output terminals on the SR function block and the INT_TO_REAL function. Double-click the output variable connected to the SR output to show the Item Properties dialog box. In the Name field, enter Count_Down. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL and that the Variable Type is set to Output. Close the dialog box. 7–14 Double-click the output variable connected to the INT_TO_REAL output to show the Item Properties dialog box. In the Name field, enter Current_Value. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Click Apply. On the Declaration tab, verify that the Data Type is set to Real and the Variable Type is set to Output. Close the dialog box. On the toolbar, click the Output Variable Tool button and place an output variable on the logic sheet. Connect the variable to the lower input connector of each of the AND gates. Double-click the top output variable to show the Item Properties dialog box. On the Variable tab, in the Variable Name field, enter Count_Down. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL and the Variable Type is set to Output. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–15 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Close the dialog box. This variable now receives output from the SR_01 function block and inputs into the AND gate. Invert an Input and an Output Double-click the bottom AND function to create a NOT operation for it. The Item Properties dialog box appears. In the Inputs field, click the 02-:ANY_BIT variable. Check Invert Input. Click Apply and close the dialog box. The inverted input symbol appears at the terminal. 7–16 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Double-click the SR function block to create a NOT operation using the invert feature. The Item Properties dialog box appears. Click the Outputs option and click 01-Q1 : BOOL. Check the Invert Input/Output checkbox. Click Apply and close the dialog box. The inverted input symbol appears at the terminal. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–17 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Creating a Function Block Using ST Editor This section explains how to create a function block using the ST editor. ST Logic for the function block This function block takes the values of the output from the user-derived function block UPDOWN and calculates the average value of the outputs as long as UPDOWN is executing. This is the completed ST logic for the function block. FUNCTION_BLOCK (*External Interface *) VAR_INPUT RESET: BOOL; (* 1=Reset, 0=Calculate *) CURRENT_VALUE : REAL; (* Current Value from UPDOWN *) END_VAR VAR_OUTPUT STATUS : BOOL; (* State=> 1 = Resetting, 0=Calculating *) XOUT : REAL; (* Averaged Output *) END_VAR VAR SAMPLE_CNT : REAL := 0.0; (* Number of iterations of this function block *) SUM : REAL := 0.0 ; (* Running Sum *) END VAR (* Function Block Body *) IF RESET THEN SUM := 0.0 ; SAMPLE_CNT :=0.0 ELSE SUM := SUM + CURRENT_VALUE; SAMPLE_CNT := SAMPLE_CNT + 1.0 ; XOUT := SUM / SAMPLE_CNT; END_IF ; STATUS : = RESET; END_FUNCTION_BLOCK 7–18 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Lab 32: Creating a Function Block Using ST Editor Introduction In this lab, you will create a function block using the ST editor. This function block takes the value of the output from the user-defined function block UPDOWN and calculates the average value of the outputs, while UPDOWN is executing. Objectives After completing this lab, you can create a function block using the ST editor. Lab Procedure Create a Function Block Using the ST Editor Create a new document named AVERAGE. In the Name field, enter AVERAGE. In the Document Type area, click Function Block. In the Language area, click Structured Text. In the Application Type area, click Safety and Control. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–19 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Click OK. The ST template is shown on the logic sheet. 7–20 Use the ST editor to create and declare the input variables for the function block. FUNCTION BLOCK (*EXTERNAL INTERFACE*) VAR_INPUT RESET: BOOL; (* 1=Reset, 0=Calculate *) CURRENT_VALUE : REAL; (* Current Value from UPDOWN *) END_VAR Use the ST editor to create and declare the output variables for the function block. VAR_OUTPUT STATUS : BOOL; (* State=> 1 = Resetting, 0=Calculating *) XOUT : REAL; (* Averaged Output *) END_VAR Use the ST editor to create and declare the variables for the function block in the Function Block Body area. VAR SAMPLE_CNT : REAL:=0.0; (* Number of iterations of this function block *) SUM : REAL := 0.0 ; (* Running Sum *) END_VAR 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Use the ST editor to create the function block logic. (* Function Block Body *) IF RESET THEN SUM := 0.0 ; SAMPLE_CNT :=0.0 ELSE SUM := SUM + CURRENT_VALUE; SAMPLE_CNT := SAMPLE_CNT + 1.0 ; XOUT := SUM / SAMPLE_CNT END_IF ; STATUS : = RESET; END_FUNCTION_BLOCK Click the Compile button. Click OK to save changes. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–21 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Lab 33: Creating a Move Function Introduction In this lab, you will create the first network to change the value of a variable to the same value of another variable, using the move function. A Move function assigns an input value to an output value. For this function, Output_1 will have the same value as Input_1. This is the completed logic for the first network. Figure 2 Objectives After completing this lab, you can change an input value to an output value, using the Move function. Lab Procedure Change an Input Value to an Output Value Create a new document named FBD_Program. In the Name field, enter FBD_Program. In the Document Type area, click Program. In the Language area, click Function Block Diagram. In the Application Type area, click Control. 7–22 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Click the Select Function (Block) button and place a Move function on the logic sheet. On the toolbar, click the Tagname Tool button and connect an input variable to the input terminal of the Move function. Double-click the input variable to show the Item Properties dialog box. In the Variable Name field, enter Input_1. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Click Apply and close the dialog box. On the toolbar, click the Tagname Tool button and connect an output variable to the output terminal of the Move function. Double-click the output variable to show the Item Properties dialog box. In the Variable Name field, enter Output_1. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Click Apply and close the dialog box. On the toolbar, click the Comment Tool button to place a comment box on the sheet. In the Comment field, enter Output_1 will have the same value as Input_1. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–23 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Close the dialog box. On the Document menu, click Save Program. 7–24 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Lab 34: Creating a Rising Trigger Function Block Introduction In this lab, you will create a rising Trigger function block. The second network uses a Rising Trigger function block to change the status of one variable to another for one scan. The Rising Trigger function block (R_TRIG) sets the output Q on the rising edge of the CLK input. A rising edge is a change from false to true (0 to 1). The output Q is true, if the input CLK was false during the previous evaluation and true during the current evaluation of the function block instance; otherwise, the output Q is false. For this function, the below figure shows a completed logic; when Input_2 goes TRUE, Output_2 goes TRUE for one scan. Figure 3 Objectives After completing this lab, you can: • Add horizontal dividers to the logic sheet. • Place a Rising Trigger function block in the second network. Lab Procedure Add Horizontal Dividers to the Logic Sheet On the toolbar, click the Horizontal Network Divider button, and then place a network divider on the logic sheet below the Move function. Repeat the previous step to create four additional networks, leaving logic workspace between each network. Place a Rising Trigger Function Block in the Second Network Click the Select Function (Block) button, and then place a R_TRIG (Rising Trigger) function block on the logic sheet. Double-click the R_TRIG function block to show the Item Properties dialog box. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–25 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide In the Instance Name field, enter R_TRIG_1. Close the dialog box. Note: You can create and use multiple instances of the same function or function block while each instance performs the same operations on different sets of variables. Click the Tagname Tool button and connect an input variable to the input terminal of the R_TRIG function block. Double-click the input variable to show the Item Properties dialog box. In the Variable Name field, enter Input_2. 7–26 Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Close the dialog box. Click the Tagname Tool button, and then connect an output variable to the output terminal of the R_TRIG function block. Double-click the output variable to show the Item Properties dialog box. In the Variable Name field, enter Output_2. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Close the dialog box. Place a comment box on the logic sheet. In the Comment field, enter When Input_2 goes True, Output_2 goes True for one scan. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Close the dialog box. On the Document menu, click Save Program. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–27 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Lab 35: Creating a Timer Introduction In this lab, you will create a TON (Timer On) function block to change the status of a variable to that of another input variable after five seconds. For this function block, Figure 4 shows a completed logic; when Input_3 goes TRUE, Output_3 goes TRUE after 5 seconds. Figure 4 Objectives After completing this lab, you can create a timer. Lab Procedure Create a Timer Click the Select Function (Block) button and place a TON function block on the logic sheet. Double-click the TON function block to show the Item Properties dialog box. In the Instance Name field, enter TON_1. 7–28 You are now using an instance of the TON function block named TON_1. Click the Tagname Tool button and connect an input variable to the input terminal of the TON function block. Double-click the input variable to show the Item Properties dialog box. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks In the Variable Name field, enter Input_3. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Close the dialog box. Click the Tagname Tool button and connect an output variable to the Q output terminal of the TON function block. Double-click the output variable to show the Item Properties dialog box. In the Variable Name field, enter Output_3. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL. Close the dialog box. On the toolbar, click the Constant Tool button, and then connect a constant to the PT terminal of the TON function block. Double-click the constant variable to show the Item Properties dialog box. In the Value field, enter T#5s. This sets the Pulse Time of the timer to 5 seconds interval. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–29 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide In the Data Type drop-down list, click TIME. Click Apply and close the dialog box. Click the Local Variable Tool button, and then connect a variable to the ET terminal of the TON function block. Double-click the Local Variable Tool button to show the Item Properties dialog box. In the Name field, enter TON_1_ET. On the Declaration tab, set the Data Type to TIME and the Variable Type to Local. In the Description field, enter Elapsed Time. 7–30 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Click Apply and close the dialog box. Place a comment box on the logic sheet. In the Comment field, enter When Input_3 goes TRUE, Output_3 foes TRUE after five seconds. Close the dialog box. On the Document menu, click Save Program. On the File menu, click Save Project. In the Comments for Audit Trail box, enter a relative comment. Click OK. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–31 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Lab 36: Invoking an UPDOWN Function Block Introduction In this lab, you will create a fourth network that invokes the UPDOWN function block created earlier. UPDOWN takes an input value and counts up to 100, and then counts down to zero, showing the current value. For this function block, Figure 5 shows a completed logic; when Input_4 is True, UPDOWN_01 continuously counts from zero to 100, and then from 100 to zero. Figure 5 Objectives After completing this lab, you can invoke an UPDOWN function block. Lab Procedure Invoke an UPDOWN Function Block Click UPDOWN and place the function block in the fourth network. Click the Tagname Tool button and connect a variable to the COUNT input terminal of the UPDOWN function block. Double-click the variable. In the Variable Name field, enter Input_4. Click Apply. Verify that the Data Type is set to BOOL and close the Declaration dialog box. Click the Tagname Tool button and connect a variable to the Current Value output terminal of the UPDOWN function block. Double-click the variable. In the Variable Name field, enter Current_Value. Click Apply. 7–32 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Verify that the Data Type is set to REAL and close the Declaration dialog box. Click the Constant Tool button, and then connect a constant to the Max_Count terminal of the UPDOWN function block. Double-click the constant to show the Item Properties dialog box. In the Value field, enter 100. In the Data Type drop-down list, click INT. Click Apply and close the dialog box. Double-click the UPDOWN function block to show the Item Properties dialog box. In the Instance Name field, enter UPDOWN_01. Click Apply and close the dialog box. You are now using an instance of the user_defined UPDOWN function block named UPDOWN_01. Add a comment box to the right of the output variable. In the Comment field, enter Invoking an UPDOWN user-derived function block, when Input_4 is TRUE, UPDOWN_01 continuously counts from zero to 100, then from 100 to zero. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–33 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Close the dialog box. Compile the logic. When asked to save changes, click Yes. Save the project. 7–34 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Lab 37: Invoking an Average Function Block Introduction In this lab, you will add a network that invokes the Average function block created previously, using Structured Text (ST). The Average function block calculates the average value of the UPDOWN output value as it counts up to 100, then counts down to zero. For this function block, Running_Average takes the Current_Value of the UPDOWN_1 function block in Network 4, and then calculates the average value (Running_Average_Value) of the output as long as the value of Input_5 is True. Figure 6 shows a completed logic. Figure 6 Objectives After completing this lab, you can invoke an Average function block. Lab Procedure Invoke an Average Function Block Click the Average function block and place it in the fifth network on the logic sheet. Click the Local Variable Tool button and connect a variable to the Reset input terminal of the Average function block. Double-click the variable. In the Variable Name field, enter Input_5. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL and the Variable Type is set to Local. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–35 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Close the dialog box. Click the Tagname Tool button and connect a variable to the Current Value input terminal of the Average function block. Double-click the variable. In the Variable Name field, enter Current_Value. Click Apply. Note: Current_Value is the output from the UPDOWN function block in Network four. On the Declaration tab, verify that the Data Type is set to Real. Close the dialog box. Click the Local Variable Tool button and connect a variable to the Status output terminal of the Average function block. Double-click the variable. In the Variable Name field, enter END. Click Apply. On the Declaration tab, verify that the Data Type is set to BOOL and the Variable Type is set to Local. 7–36 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Participant Guide Writing Custom Function Blocks Repeat step 8 to connect a variable to the XOUT terminal of the Average function block. 20. Repeat steps 9 - 13, and configure the following as shown: Variable Name: Running_Average_Value Data Type: Real Note: Running_Average_Value is the average value of the output from the UPDOWN function block in Network four. Double-click the Average function block to show the Item Properties dialog box. In the Instance Name field, enter Running_Average. Click Apply. Close the dialog box. You are now using an instance of the user-defined Average function block named Running_Average. Add a comment box to the right of the output variable. In the Comment Text box, enter Invoking an Average user-defined function block. Running_Average takes the Current_Value of the UPDOWN_01 function block (referenced above and calculates the Running_Average_Value of the output from the function block) as long as the value of Input_5 is True. 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 7–37 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved Internal
Writing Custom Function Blocks Participant Guide Close the dialog box. Compile the logic. When asked to save changes, click Yes. Save the project. You have now completed the logic of the project. 7–38 8602 Triconex General Purpose (Tri-GP) Configuration and Implementation A.0 Schneider Electric Proprietary and Confidential Information © 2021 Schneider Electric Systems USA, Inc. All Rights Reserved
Search
Read the Text Version
- 1 - 38
Pages: