{"id":3763,"date":"2026-11-24T11:35:55","date_gmt":"2026-11-24T03:35:55","guid":{"rendered":"https:\/\/resource.fatek.com\/index.php\/2026\/11\/24\/mplc-m09-en-03\/"},"modified":"2026-11-24T11:35:55","modified_gmt":"2026-11-24T03:35:55","slug":"mplc-m09-en-03","status":"publish","type":"post","link":"https:\/\/resource.fatek.com\/index.php\/2026\/11\/24\/mplc-m09-en-03\/","title":{"rendered":"Chapter 3 Function\/Function Block Program"},"content":{"rendered":"<h2>Chapter 3 Function\/Function Block Program<\/h2>\n<p>In this chapter, it will introduce how to create a FCM program in UperLoigc, set FCM parameters and  properties. <\/p>\n<h3>3-1 Create a new Project<\/h3>\n<p>Step 1. Select the\u3010Menu\u3011in the upper left corner of UperLogic. &gt;\u3010New\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 1\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-001.png\" \/><\/p>\n<p>Step 2. The PLC module selection window pops up  \u2460 Select product Series (Select the ME series in the picture below)  \u2461 Select Model (Select ME3C6-1616 in the picture below) <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 2\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-002.png\" \/><\/p>\n<p>Step 3. Set project information  \u2462 Select programming language (Select the ladder in the picture below)  \u2460 Finish <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 3\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-003.png\" \/><\/p>\n<p>Step 4. After finish, the main program unit editing screen will be displayed. <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 4\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-004.png\" \/><\/p>\n<h3>3-2 Add A New FCM Program<\/h3>\n<p>Step 1. Select \u3010Project Management\u3011in the Uperlogic&gt;\u3010Program Unit\u3011&gt;\u3010FCM Program\u3011&gt;Right click&gt; \u3010FCM Program Add\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 5\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-005.png\" \/><\/p>\n<p>Step 2. Pops up\u3010FCM Property\u3011setting windows &gt; Set\u3010FCM Property\u3011 &gt; After the setting is completed,  press [OK] to complete the new FCM program. (Please refer to <span style=\"color:#0563C1\">Chapter 3-4<\/span> for FCM properties.) <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 6\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-006.png\" \/><\/p>\n<h3>3-3 FCM Variable<\/h3>\n<p>FCM has independent internal relays and internal registers. Internal variables can only be used in FCM  program. Some internal relays and internal registers can exchange data with external program unit  registers. These are local variables, only valid within the specific FCM. Each time the FCM is executed, it  has its own independent variable space, ensuring that the function block can be reused without affecting  other logic. <\/p>\n<p><strong><span style=\"color:#FF0000\">[Note] <\/span><\/strong><strong>When encapsulating the FCM function block, it is important to pay attention to the use of <\/strong> <strong>global register types, such as R\/D\/M. Avoid misuse and accessing duplicate register locations in other <\/strong> <strong>programs during calls, as this may cause logic malfunctions. To fully encapsulate the FCM, only the <\/strong> <strong>following types of variables must be used within the FCM program. <\/strong><\/p>\n<p><strong>FCM Variable: <\/strong><\/p>\n<table>\n<tr>\n<td colspan=\"3\">\n<p>ITEM <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"4\">\n<p>Bit <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>Input Pin <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Output Pin <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Internal Variable Temp Bit<span style=\"color:#FFFFFF\"> <\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_STATIC <\/p>\n<\/td>\n<td>\n<p>Internal Variable Static Bit<span style=\"color:#FFFFFF\"> <\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"4\">\n<p>WORD <\/p>\n<\/td>\n<td>\n<p>VAR_PARA_IN <\/p>\n<\/td>\n<td>\n<p>Input Parameter <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_PARA_OUT <\/p>\n<\/td>\n<td>\n<p>Output Parameter <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_PARA_INOUT <\/p>\n<\/td>\n<td>\n<p>Input \/Output Parameter \/ internal Variable Static Word <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>internal Variable Temp Word <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 7\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-007.png\" \/><\/p>\n<h3>3-4 FCM Property<\/h3>\n<p>FCM Property <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 8\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-008.png\" \/><\/p>\n<p>\u2022   Program Unit Name : Function\/Function Block Program Name\u3002(English and Number Only) <\/p>\n<p>\u2022   Language: Editing Language of Function\/Function Block Program, e.g., LD(Ladder),ST, etc.\u3002 <\/p>\n<p>\u2022   Number of Input : Number of Function\/Function Block Program Input Pins\u3002 <\/p>\n<p>\u2022   Number of output: Number of Function\/Function Block Program Output Pins\u3002 <\/p>\n<p>\u2022   Number of Parameter : Number of Function\/Function Block Program Parameters\u3002 <\/p>\n<p>\u2022   +VAR_STATIC: Add Internal Static Variable <\/p>\n<p>\u2022   +VAR_TEMP: Add Internal Temp Variable <\/p>\n<p>\u2022   Variable : Set the Name, Data Type, Array, Class, Initial Value of the variable. <\/p>\n<h4>3-4-1 Variable Name<\/h4>\n<p>All variables can be modified to have names that are a mixture of English and numbers, except for EN,  which is used as the Function instruction trigger pin, so it has a fixed name. Use different background  colors to distinguish different types of variables. <\/p>\n<p><strong>Variable Name <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Variable <\/p>\n<\/td>\n<td>\n<p>Length <\/p>\n<\/td>\n<td>\n<p>Color of Background <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>Red <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>Yellow <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>Green <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>Blue <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>STATIC Variable <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>White <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TEMP Variable <\/p>\n<\/td>\n<td>\n<p>20 words by English letters and numbers <\/p>\n<\/td>\n<td>\n<p>White <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h4>3-4-2 Variable Class<\/h4>\n<p>These are local variables, only valid within the specific FCM. Each time the function block is executed, it  has its own independent variable space, ensuring that the FCM can be reused without affecting other  logic. <\/p>\n<p><strong>Variable Class <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Variable <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<td>\n<p>Symbol <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"4\">\n<p>EN <\/p>\n<\/td>\n<td rowspan=\"4\">\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>The pin that triggers FCM execution in the <\/p>\n<\/td>\n<td rowspan=\"4\">\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 9\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-009.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>program unit. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>When FCM is executed, it receives the bool status <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>from the program unit. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>Input <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>When FCM is executed, it receives the bool status from the program unit. <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 10\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-010.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td>\n<p>Output <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Output the Bool status of the FCM operation result <\/p>\n<p>to the program unit <\/p>\n<\/td>\n<td>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 11\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-011.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"7\">\n<p>Parameter <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>VAR_PARA_IN <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>When FCM is executed, it receives the value from <\/p>\n<p>the program unit. <\/p>\n<\/td>\n<td>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 12\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-012.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>* Mark\u3010\uff29\u3011means IN type <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>VAR_PARA_OUT <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>Output the value of the FCM operation result to <\/p>\n<p>the program unit <\/p>\n<\/td>\n<td>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 13\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-013.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>*Mark\u3010\uff2f\u3011means OUT type <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>VAR_PARA_INOUT <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>When FCM is executed, it first receives the value <\/p>\n<p>from the program unit. <\/p>\n<p>When the FCM operation is completed, Output the <\/p>\n<p>value of the FCM operation result to the program <\/p>\n<p>unit <\/p>\n<\/td>\n<td>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 14\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-014.png\" \/><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>* Mark\u3010\uff29\u3011means IN type <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>*Mark\u3010\uff2f\u3011means OUT type <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>STATIC Variable <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>VAR_STATIC <\/p>\n<\/td>\n<td>\n<p>The life cycle of VAR_STATIC lasts from the moment <\/p>\n<\/td>\n<td rowspan=\"3\"><\/td>\n<\/tr>\n<tr>\n<td>\n<p>the FCM is called, which means the result from the <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>last call will remain and be available in the next call. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>TEMP Variable <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>The life cycle of VAR_TEMP ends at the time the <\/p>\n<\/td>\n<td rowspan=\"2\"><\/td>\n<\/tr>\n<tr>\n<td>\n<p>FCM returns. <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p><strong><span style=\"color:#FF0000\">[Note] <\/span><\/strong><strong>When encapsulating the FCM function block, it is important to pay attention to the use of <\/strong> <strong>global register types, such as R\/D\/M. Avoid misuse and operations that access duplicate register <\/strong> <strong>locations in other programs during calls, as this may cause logic malfunctions. To fully encapsulate the <\/strong> <strong>FCM, only the aforementioned types of variables must be used within the FCM program.<\/strong><strong> <\/strong><\/p>\n<p><strong>STATIC BIT<\/strong>:  <\/p>\n<p>\u2022   The life cycle of VAR_STATIC lasts from the moment the FCM is called, which means the result from  the last call will remain and be available in the next call. <\/p>\n<p>\u2022   Static bit is only initialized once at the first call of the FCM <\/p>\n<p>VAR_STATIC BIT : VAR_STATIC (Bool)  VAR_ STATIC WORD : VAR_PARA_INOUT <\/p>\n<p><strong>TEMP BIT<\/strong>:  <\/p>\n<p>\u2022   The life cycle of VAR_TEMP ends at the time the FCM returns. <\/p>\n<p>\u2022   Temp bit is re-initialized at each cycle <\/p>\n<p>VAR_TEMP BIT  : VAR_TEMP (Bool)  VAR_TEMP WORD : VAR_TEMP (16Bit-Int, 16Bit-Uint, 32Bit-Int, 32Bit-Uint, Float) <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 15\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-015.png\" \/><\/p>\n<p><strong>STATIC BIT &amp; TEMP BIT initialization timing diagram <\/strong><\/p>\n<h4>3-4-3 Variable Data Type<\/h4>\n<p><strong>Variable Data Type <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Variable <\/p>\n<\/td>\n<td>\n<p>Data Type <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>EN <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>High Level Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Bool, Pulse Rising  <\/p>\n<\/td>\n<td>\n<p>Rising Edge Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>16Bit-Int, 16Bit-Uint, 32Bit-Int, 32Bit-Uint, Float <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Pointer <\/p>\n<\/td>\n<td>\n<p>Class must be VAR_PARA_INOUT <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>STATIC Variable <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>TEMP Variable <\/p>\n<\/td>\n<td>\n<p>Bool, 16Bit-Int, 16Bit-Uint, 32Bit-Int, 32Bit-Uint, Float <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p>Trigger type of EN <\/p>\n<p>High Level Trigger<strong> (Bool)<\/strong>: Which runs a particular FCM when EN is ON.  Rising Edge Trigger<strong> (Bool, Pulse Rising):<\/strong> Which runs a particular FCM at the moment when EN changes <\/p>\n<p>the status from OFF to ON.  Edge trigger function is more efficient than Level trigger function because Edge trigger function is only  executed at the rising edge of EN signal. This can significantly reduce system loading. <\/p>\n<p>Example: In chapters 3-5, If the user wants to calculate the water level depth, the rising edge only needs  to trigger the execution of the Container function once. If high level trigger, the Container function will be  executed once in each scan cycle. <\/p>\n<p>Pointer parameter vs Regular parameter <\/p>\n<p><strong>\u3010Pointer parameter\u3011 VAR_PARA_INOUT (Pointer) <\/strong> 1. The memory <strong>address<\/strong> of the parameter is passed into the FCM. (Call by Reference) <\/p>\n<p>2. Pointer parameter doesn&#x27;t need to have an initial value as FCM always reads value from the memory  address.  3. the FCM program changes the value of parameter directly. <\/p>\n<p>*Only when the parameter is used as VAR_PARA_INOUT can select the\u3010Pointer parameter\u3011. <\/p>\n<p><strong>\u3010Regular parameter\u3011 VAR_PARA_INOUT (16Bit-Int, 16Bit-Uint, 32Bit-Int, 32Bit-Uint, Float) <\/strong><\/p>\n<p>1. Only the value of parameter is copied to the temp memory of FCM. (Call by Value)  2. Regular parameter can be initialized either with an initial value or the value passed from main <\/p>\n<p>program <\/p>\n<p>3. The FCM program changes the value passed from the parameter doesn\u2019t affect the value of  parameter. (Ex. If R0 is regular parameter, R0 value is not changed during the FCM life.) <\/p>\n<p><strong>\u3010Multi-cycle instruction\u3011 <\/strong><\/p>\n<p>Multi-cycle instructions run in the background and don&#x27;t end with scan cycle.  INOUT type parameter will then get unexpected value from unmanaged memory. So multi-cycle  instructions must use \u3010Pointer parameter\u3011to run. <\/p>\n<p>*Please refer to Appendix 1 <span style=\"color:#0563C1\">Multi-cycle Instruction<\/span> <\/p>\n<h4>3-4-4 Variable Array<\/h4>\n<p>Array serves as a way to pass a list of registers into and out of the FCM memory. <\/p>\n<p><strong>Array <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Variable <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>Array <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Number of <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>VAR_PARA_INOUT <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>PAR [0\u2026199] <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>Maximum length is 200. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Parameter <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>*Array INOUT parameter behavior is the same as Pointer INOUT parameter (Please refer to <span style=\"color:#0563C1\">3-4-3 Variable <\/span> <span style=\"color:#0563C1\">Data Type<\/span>) <\/p>\n<p><strong>Example: <\/strong><\/p>\n<p>Set a VAR_PARA_INOUT parameter and set 5 lengths of Array. Fill in R0 in the FCM instruction PAR. <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 16\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-016.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 17\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-017.png\" \/><\/p>\n<p>When EN triggers the FCM Function Instruction, pass ARRAY into the FCM Function Instruction <\/p>\n<p>Main Unit Function Instruction <\/p>\n<p>R0 \u2192 PAR[0] <\/p>\n<table>\n<tr>\n<td>\n<p>R0 <\/p>\n<\/td>\n<td>\n<p>\u2192 <\/p>\n<\/td>\n<td>\n<p>PAR[0] <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>R1 <\/p>\n<\/td>\n<td>\n<p>\u2192 <\/p>\n<\/td>\n<td>\n<p>PAR[1] <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>R2 <\/p>\n<\/td>\n<td>\n<p>\u2192 <\/p>\n<\/td>\n<td>\n<p>PAR[2] <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>R3 <\/p>\n<\/td>\n<td>\n<p>\u2192 <\/p>\n<\/td>\n<td>\n<p>PAR[3] <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>R4 <\/p>\n<\/td>\n<td>\n<p>\u2192 <\/p>\n<\/td>\n<td>\n<p>PAR[4] <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>When the FCM Function Instruction operation is completed, ARRAY is passed out of the FCM Function  Instruction. <\/p>\n<table>\n<tr>\n<td>\n<p>Main Unit <\/p>\n<\/td>\n<td>\n<p>Function Instruction <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>R0 <\/p>\n<p>R1 <\/p>\n<p>R2 <\/p>\n<p>R3 <\/p>\n<p>R4 <\/p>\n<\/td>\n<td>\n<p>\u2190 PAR[0] <\/p>\n<p>\u2190 PAR[1] <\/p>\n<p>\u2190 PAR[2] <\/p>\n<p>\u2190 PAR[3] <\/p>\n<p>\u2190 PAR[4] <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h4>3-4-5 Variable Initial Value<\/h4>\n<p>Setting the initial value of FCM variables <\/p>\n<p>\u2022   IN parameters don\u2019t need to have an initial value as the main program always pass a value to IN  parameter (Register or constant) <\/p>\n<p>\u2022   OUT parameters has to be initialized with an initial value <\/p>\n<p>\u2022   INOUT parameters can be initialized either with an initial value or with a value passed from main  program <\/p>\n<p>\u2022   Static variables are only initialized with initial values when FCM is executed for the first time. <\/p>\n<p><strong>Variable Initial Value <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Variable <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>symbol <\/p>\n<\/td>\n<td>\n<p>Value <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>Output <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p> Initialized every time when <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 18\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-018.png\" \/><\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>Determine the data type of the initial value based on the data type of the variable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>FCM is executed <\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td rowspan=\"13\">\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>VAR_PARA_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>VAR_PARA_OUT <\/p>\n<\/td>\n<td>\n<p> Initialized every time when <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 19\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-019.png\" \/><\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>Determine the data type of the initial value based on the data type of the variable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>FCM is executed <\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td rowspan=\"9\">\n<p>VAR_PARA_INOUT <\/p>\n<\/td>\n<td rowspan=\"9\">\n<p> Initialized every time when FCM is executed <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 20\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-020.png\" \/><\/p>\n<\/td>\n<td>\n<p>Determine the data type of the initial value based <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>on the data type of the variable or turn off the <\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>initialization function and initialize it with the <\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td>\n<p>value passed by the main program unit. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>*Fill in the blank value to indicate [DISABLE], <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>without initialization. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p>STATIC Variable <\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>VAR_STATIC <\/p>\n<\/td>\n<td>\n<p> Only initialized the first time <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 21\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-021.png\" \/><\/p>\n<\/td>\n<td rowspan=\"3\">\n<p>Determine the data type of the initial value based on the data type of the variable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>when FCM is executed <\/p>\n<\/td>\n<\/tr>\n<tr>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p>TEMP Variable <\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p> Initialized every time when <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 22\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-022.png\" \/><\/p>\n<\/td>\n<td rowspan=\"2\">\n<p>Determine the data type of the initial value based <\/p>\n<p>on the data type of the variable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>FCM is executed <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h3>3-5 Function\/Function Block Instruction (Using FCM)<\/h3>\n<p>F The FCM instruction is the same as the general Function instruction. Trigger the EN pin by different  conditions to execute the FCM instruction. The FCM instruction will execute the ladder program of the  FCM based on the input pin status and input parameter value, and then put the operation results into the  output parameters and output pins to provide subsequent control to the program unit. <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 23\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-023.png\" \/><\/p>\n<p>Trigger the EN of FMC Function Instruction<\/p>\n<p>FCM reads input pin status and input parameter values<\/p>\n<p>FCM puts the value into the FCM internal register<\/p>\n<p>FCM operation execution<\/p>\n<p>FCM outputs the internal register of the operation result to the output pin and output parameter<\/p>\n<p>Wait for next trigger<\/p>\n<h4>3-5-1 Function Block vs Function<\/h4>\n<p>Function  Functions are code blocks or subroutines without dedicated memory. Each starts from the initial value. <\/p>\n<p>Trigger the EN of Function (Using FCM)<\/p>\n<p>Function reads input pin status and input parameter values<\/p>\n<p>Function puts the value into the FCM internal register<\/p>\n<p>FCM operation execution<\/p>\n<p>Function outputs the internal register of the operation result to the output pin and output parameter<\/p>\n<p>Wait for next trigger<\/p>\n<p>Function Block  Function block are code blocks that store their values permanently in instance code blocks, so they  remain available after the block has been executed. The next execution can continue with the previous  results. <\/p>\n<p>* Please refer to Chapter 3-4-2 <\/p>\n<p>Trigger the EN of Function Block (Using FCM)<\/p>\n<p>Function Block reads input pin status, input parameter values, in\/output parameter values<span style=\"color:#FF0000\">(Inculde Pointer and <\/span><\/p>\n<p><span style=\"color:#FF0000\">Array), Static Bit<\/span><\/p>\n<p>Function Block puts the value into the FCM internal register<\/p>\n<p>FCM operation execution<\/p>\n<p>Function Block outputs the internal register of the operation result to the output pin, output parameter, <\/p>\n<p>in\/output parameter values<span style=\"color:#FF0000\">(Inculde Pointer and Array), Static Bit<\/span><\/p>\n<p>Wait for next trigger<\/p>\n<h3>3-6 Function Program Sample<\/h3>\n<h4>3-6-1 Water Container<\/h4>\n<p>Application  A cube-like water container with fixed inside length and width. Make a function which be able to calculate  the depth of water according to the water volume parameter. If the volume is over 6000ml, high limit  alarm is ON. If the volume is less than 1000ml, low limit alarm is ON. <\/p>\n<p>Function Instruction <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 24\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-024.png\" \/><\/p>\n<p><strong>Input\/Output Pins and Parameters <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input Pins <\/p>\n<\/td>\n<td>\n<p>EN.P <\/p>\n<\/td>\n<td>\n<p>Rising edge trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output Pins <\/p>\n<\/td>\n<td>\n<p>HLMT <\/p>\n<\/td>\n<td>\n<p>High limit alert <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>LLMT <\/p>\n<\/td>\n<td>\n<p>Low limit alarm <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input Parameters <\/p>\n<\/td>\n<td>\n<p>Lvol <\/p>\n<\/td>\n<td>\n<p>Water Level volume <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output Parameters <\/p>\n<\/td>\n<td>\n<p>LDep <\/p>\n<\/td>\n<td>\n<p>Water Level depth <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>Function Property  1 number of input (input pin), 2 numbers of output (output pin), 2 numbers of parameter, 3 VAR_TEMPs. <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 25\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-025.png\" \/><\/p>\n<p><strong>Varialbe <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Data Type <\/p>\n<\/td>\n<td>\n<p>Array <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>Initial Value <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EN.P <\/p>\n<\/td>\n<td>\n<p>Bool; Pulse Rising <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Rising edge trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>HLMT <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>High limit alert <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>LLMT <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Low limit alarm <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Lvol <\/p>\n<\/td>\n<td>\n<p>16Bit-Int <\/p>\n<\/td>\n<td>\n<p>DISABLE <\/p>\n<\/td>\n<td>\n<p>VAR_PARA_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Water Level volume <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>LDep <\/p>\n<\/td>\n<td>\n<p>16Bit-Int <\/p>\n<\/td>\n<td>\n<p>DISABLE <\/p>\n<\/td>\n<td>\n<p>VAR_PARA_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Water Level depth <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BoxW <\/p>\n<\/td>\n<td>\n<p>16Bit-Int <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 20 every time <\/p>\n<\/td>\n<td>\n<p>The width of the box is fixed at <\/p>\n<p>20 units <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BoxL <\/p>\n<\/td>\n<td>\n<p>16Bit-Int <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 50 every time <\/p>\n<\/td>\n<td>\n<p>The length of the box is fixed at <\/p>\n<p>50 units <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TP0 <\/p>\n<\/td>\n<td>\n<p>16Bit-Int <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>For calculation <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>Function Internal Program  \u3010Container\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 26\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-026.png\" \/><\/p>\n<p><strong>N000<\/strong> Use Fun171 to compare the input Lvol (water level volume) and trigger HLMT (output upper <\/p>\n<p>limit alarm) when it exceeds 6000 units. <\/p>\n<p><strong>N001<\/strong> Use Fun172 to compare the input Lvol (water level volume) and trigger the LLMT (output lower <\/p>\n<p>limit alarm) when it is lower than 1000 units. <\/p>\n<p><strong>N002<\/strong> If the input Lvol (water level volume) does not exceed HLMT (high limit alarm) and is lower than <\/p>\n<p>LLMT (lower limit alarm), divide Lvol (water level volume) by the width and length of the  container to calculate LDep (water level depth), and output it to the outside. <\/p>\n<p>Function Internal Program in ST Language <\/p>\n<p>IF Lvol &gt; 6000 THEN      HLMT := TRUE;  END_IF <\/p>\n<p>IF Lvol &lt; 1000 THEN      LLMT := TRUE;  END_IF <\/p>\n<p>IF NOT HLMT AND NOT LLMT THEN      TP0:= Lvol \/ BoxW;      LDep:= TP0 \/ BoxL;  END_IF <\/p>\n<p>behavioral description  \u3010Container\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 27\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-027.png\" \/><\/p>\n<p>Step 1. Enter Lvol (water level volume) in R0 <\/p>\n<p>Step 2. Trigger EN.P of the Function instruction with M0 (Rising edge trigger) <\/p>\n<p>Step 3. R10 will display the calculated LDep (water level depth) or High and low limit alarm <\/p>\n<p>(HLMT\/LLMT) output alarm <\/p>\n<p>Multiple use  Multiple use of Function instructions in the main program <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 28\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-028.png\" \/><\/p>\n<p>N000 Input 1000 units of water volume and output 1 unit of water depth.  N001 Input 2000 units of water volume and output 2 units of water depth. <\/p>\n<p>The result of 2 FCMs not interfering with each other. <\/p>\n<h3>3-7 Function Block Program Sample<\/h3>\n<h4>3-7-1 TV Remote<\/h4>\n<p>Application  A TV remote controls the sound volume of TV and can be adjusted based on its previous volume. The  volume value ranges from 0~10. <\/p>\n<p>Function Block Instruction <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 29\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-029.png\" \/><\/p>\n<p><strong>Input\/Output Pins and Parameters <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input Pins <\/p>\n<\/td>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>High Level Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>VolUp <\/p>\n<\/td>\n<td>\n<p>Volume Up <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>VolDn <\/p>\n<\/td>\n<td>\n<p>Volume Down <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output Pins <\/p>\n<\/td>\n<td>\n<p>Max <\/p>\n<\/td>\n<td>\n<p>Volume is Max <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>Mute <\/p>\n<\/td>\n<td>\n<p>Volume is Mute <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input\/Output Parameters <\/p>\n<\/td>\n<td>\n<p>Volume <\/p>\n<\/td>\n<td>\n<p>Volume <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>Function Block Property  3 numbers of input (input pins), 2 numbers of output (output pins), and 1 number of parameter.<\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 30\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-030.png\" \/><\/p>\n<p><strong>Variable <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Data Type <\/p>\n<\/td>\n<td>\n<p>Array <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>Initial Value <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>High Level Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VolUp<strong> <\/strong><\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Volume Up <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VolDn<strong> <\/strong><\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Volume Down <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Max <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Volume is Max <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Mute <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Volume is Mute <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span style=\"color:#FF0000\">Volume <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">16Bit-Int <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">DISABLE <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">VAR_PARA_INOUT <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">DISABLE <\/span><\/p>\n<\/td>\n<td>\n<p>Volume<span style=\"color:#FF0000\"> <\/span><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p><span style=\"color:#FF0000\">*The volume here uses VAR_PARA_INOUT to remember the last volume. Input the last volume from the <\/span> <span style=\"color:#FF0000\">external register to the Function Block when executing the Function Block.<\/span> <span style=\"color:#FF0000\">At the end of the Function <\/span> <span style=\"color:#FF0000\">Block, the volume is output to the external register for use when the Function Block is executed next time. <\/span><\/p>\n<p>Function Block Internal Program  \u3010TV Remote\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 31\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-031.png\" \/><\/p>\n<p>N000 When VolUp is triggered at rising-edge, we use Fun15 to increase volume.  N001 When VolDn is triggered at rising-edge, we use Fun16 to decrease volume. <\/p>\n<p>The above operations work shall work exclusively in this case. <\/p>\n<p>N002 With the use of Fun171, the volume will remain at 10 and set Max as ON at the same time when <\/p>\n<p>over 9 <\/p>\n<p>N003 With the use of Fun172, the volume will remain at 0 and set Mute as ON at the same time when <\/p>\n<p>under 1. <\/p>\n<p>Function Block Internal Program in ST Language <\/p>\n<p>IF R_TRIG( S:=VolUp ) THEN      IF NOT VolDn THEN         Volume:= Volume+1;      END_IF  END_IF <\/p>\n<p>IF R_TRIG( S:=VolDn ) THEN      IF NOT VolUp THEN          Volume:= Volume-1;      END_IF  END_IF <\/p>\n<p>if Volume &gt; 9 THEN      Max:=TRUE;      Volume:=10;  ELSEIF Volume &lt; 1 THEN      Mute:=FALSE;      Volume:=0;  END_IF <\/p>\n<p>Action Description <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 32\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-032.png\" \/><\/p>\n<p>Step 1. Trigger VolUp (volume up) or VolDn (volume down) to increase\/decrease the volume. <\/p>\n<p>Step 2. The Volume up to 10 and can&#x27;t continue to increase. <\/p>\n<p>Step 3. The Volume down to 0 and can&#x27;t continue to decrease. <\/p>\n<p>Multiple use  Multiple use of Function Block instructions in the main program <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 33\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-033.png\" \/><\/p>\n<p>N000 Control the R10 of volume  N001 Control the R110 of volume  The result of 2 FCMs not interfering with each other. <\/p>\n<h4>3-7-2 TV Remote Timer<\/h4>\n<p>Application  The TV remote example can only be increase\/decrease volume one unit per time. The real TV remote  allows user to increase volume faster as the button pressed longer. Volume value range from 0~500. <\/p>\n<p>Function Block Instruction <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 34\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-034.png\" \/><\/p>\n<p><strong>Input\/Output Pins and Parameters <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Parameter <\/p>\n<\/td>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input Pins <\/p>\n<\/td>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>High Level Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>VolUp <\/p>\n<\/td>\n<td>\n<p>Volume Up <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>VolDn <\/p>\n<\/td>\n<td>\n<p>Volume Down <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Output Pins <\/p>\n<\/td>\n<td>\n<p>Max <\/p>\n<\/td>\n<td>\n<p>Volume is Max <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>Mute <\/p>\n<\/td>\n<td>\n<p>Volume is Mute <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Input\/Output Parameters <\/p>\n<\/td>\n<td>\n<p>Volume <\/p>\n<\/td>\n<td>\n<p>Volume <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>TCv1 <\/p>\n<\/td>\n<td>\n<p>For Fun87 Timer <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\n<p>TCv2 <\/p>\n<\/td>\n<td>\n<p>For Fun87 Timer <\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p>Function Property  3 numbers of input (input pins), 2 numbers of output (output pins), and 3 numbers of parameter.<\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 35\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-035.png\" \/><\/p>\n<p><strong>Variable <\/strong><\/p>\n<table>\n<tr>\n<td>\n<p>Name <\/p>\n<\/td>\n<td>\n<p>Data Type <\/p>\n<\/td>\n<td>\n<p>Array <\/p>\n<\/td>\n<td>\n<p>Class <\/p>\n<\/td>\n<td>\n<p>Initial Value <\/p>\n<\/td>\n<td>\n<p>Description <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EN <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>High Level Trigger <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VolUp<strong> <\/strong><\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Volume Up <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VolDn<strong> <\/strong><\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_IN <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>Volume Down <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Max <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Volume is Max <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Mute <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_SIG_OUT <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td>\n<p>Volume is Mute <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span style=\"color:#FF0000\">Volume <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">16Bit-Int <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">DISABLE <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">VAR_PARA_INOUT <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">DISABLE <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">Volume <\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span style=\"color:#FF0000\">TCv1 <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">Pointer <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">&#8212; <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">VAR_PARA_INOUT <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">&#8212; <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">For Fun87 Timer CV <\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span style=\"color:#FF0000\">TCv2 <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">Pointer <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">&#8212; <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">VAR_PARA_INOUT <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">&#8212; <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">For Fun87 Timer CV <\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BtnP <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Add_S <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Add_M <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p>Add_L <\/p>\n<\/td>\n<td>\n<p>Bool <\/p>\n<\/td>\n<td>\n<p>&#8212; <\/p>\n<\/td>\n<td>\n<p>VAR_TEMP <\/p>\n<\/td>\n<td>\n<p>Initialized to 0 every time <\/p>\n<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<p><span style=\"color:#FF0000\">T_200ms <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">Bool <\/span><\/p>\n<\/td>\n<td>\n<p>&#8212;<span style=\"color:#FF0000\"> <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">VAR_STATIC <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">Initialized to 0 on the first time <\/span><\/p>\n<\/td>\n<td>\n<p><span style=\"color:#FF0000\">For Fun87 Timer out <\/span><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p><span style=\"color:#FF0000\">*The volume here uses VAR_PARA_INOUT to remember the last volume. Input the last volume from the <\/span> <span style=\"color:#FF0000\">external register to the Function Block when executing the Function Block.<\/span> <span style=\"color:#FF0000\">At the end of the Function <\/span> <span style=\"color:#FF0000\">Block, the volume is output to the external register for use when the Function Block is executed next time. <\/span><\/p>\n<p><span style=\"color:#FF0000\">*The example uses the multi-cycle instruction Fun87. In order to allow TIMER&#x27;s timing and output status <\/span> <span style=\"color:#FF0000\">to span multiple scan times in the Function Block, Fun87&#x27;s CV uses Pointer(VAR_PARA_INOUT)\uff0cFun87&#x27;s <\/span> <span style=\"color:#FF0000\">out pin uses VAR_STATIC BIT.<\/span> <\/p>\n<p>Function Internal Program  \u3010TV Remote_Timer\u3011 <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 36\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-036.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 37\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-037.png\" \/><\/p>\n<p>N000 Connect VolUp and VolDn in parallel into a BtnP signal  N001 In VolUp or VolDn is ON, Fun87 is used to generate a 200ms pulse.  N002 In VolUp or VolDnON, use Fun87 timing.  N003 Fun87_TCv2 outputs Add_S when the timer reaches 1 second  N004 F Fun87_TCv2 outputs Add_M when the timer reaches 1.5 seconds  N005 Fun87_TCv2 outputs Add_L when the timer reaches 2 seconds  N006 VolUp ON. Rising edge increases volume.  N007 Keep pressing VolUp for more than 1 second, and use 200ms pulses to increase differently <\/p>\n<p>according to Fun87_TCv2. <\/p>\n<p>N008 VolDn ON, Rising edge lowers the volume.  N009 Keep pressing VolDn for more than 1 second, and use 200ms pulses to increase differently <\/p>\n<p>according to Fun87_TCv2. <\/p>\n<p>N0010 With the use of Fun171, the volume will remain at 500 and set Max as ON at the same time <\/p>\n<p>when over 499. <\/p>\n<p>N0011 With the use of Fun172, the volume will remain at 0 and set Mute as ON at the same time when <\/p>\n<p>under 1. <\/p>\n<p>Function Internal Program in ST Language <\/p>\n<p>BtnP:=VolUp or VolDn; <\/p>\n<p>ACTimer_10MS( TIM:= true, EN:=BtnP AND NOT T_200ms , CV:=TCv1 , PV:=20   , TUP=&gt;T_200ms ,  NUP=&gt;InZone);  ACTimer_10MS( TIM:= true, EN:=BtnP , CV:=TCv2 , PV:=200  , TUP=&gt;InZone  , NUP=&gt;InZone); <\/p>\n<p>IF TCv2&gt;=200 Then      Add_L:=true;  elseIF TCv2&gt;=150 Then      Add_M:=true;  elseIF TCv2&gt;=100 Then      Add_S:=true;  END_IF <\/p>\n<p>IF R_TRIG( S:=VolUp ) THEN     Volume:= Volume+1;  END_IF <\/p>\n<p>IF VolUp and T_200ms THEN          IF Add_S THEN          Volume:= Volume+5;      ELSEIF Add_M THEN <\/p>\n<p>        Volume:= Volume+12;      ELSEIF Add_L THEN          Volume:= Volume+20;      END_IF  END_IF <\/p>\n<p>IF R_TRIG( S:=VolDn ) THEN      Volume:= Volume-1;  END_IF <\/p>\n<p>IF VolDn and T_200ms THEN          IF Add_S THEN          Volume:= Volume-5;      ELSEIF Add_M THEN          Volume:= Volume-12;      ELSEIF Add_L THEN          Volume:= Volume-20;      END_IF  END_IF <\/p>\n<p>if Volume &gt; 499 THEN      Max:=TRUE;      Volume:=500;  ELSEIF Volume &lt; 1 THEN      Mute:=TRUE;      Volume:=0;  END_IF <\/p>\n<p>\u52d5\u4f5c\u8aaa\u660e <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 38\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-038.png\" \/><\/p>\n<p>Step 1. Trigger VolUp (volume up) or VolDn (volume down) to increase\/decrease the volume. <\/p>\n<p>Step 2. Press to increase or decrease the volume by 1 level within 1 second. Press for 1 to 1.5 seconds <\/p>\n<p>to increase or decrease the volume by 5 levels every 0.2 seconds. Press for 1.5 to 2 seconds to  increase or decrease the volume by 12 levels every 0.2 seconds. Press for more than 2 seconds  to increase or decrease the volume every 0.2 seconds. Reduce the volume by 20 bars. <\/p>\n<p>Step 3. The Volume up to 500 and can&#x27;t continue to increase. <\/p>\n<p>Step 4. The Volume down to 0 and can&#x27;t continue to decrease.  Multiple use  Multiple use of Function Block instructions in the main program <\/p>\n<p><img decoding=\"async\" alt=\"mplc-m09-en-03 - 39\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/mplc-m09-en-03\/mplc-m09-en-03-039.png\" \/><\/p>\n<p>N002 Control the R0 of volume  N003 Control the R100 of volume  The result of 2 FCMs not interfering with each other. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chapter 3 Function\/Function Block Program In this chapt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":["post-3763","post","type-post","status-publish","format-standard","hentry","category-en-mplc-m09"],"_links":{"self":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts\/3763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/comments?post=3763"}],"version-history":[{"count":1,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts\/3763\/revisions"}],"predecessor-version":[{"id":3767,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts\/3763\/revisions\/3767"}],"wp:attachment":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/media?parent=3763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/categories?post=3763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/tags?post=3763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}