tests/projects/modbus_test_tcp/plc.xml
changeset 3926 a6ec38dcbfb5
equal deleted inserted replaced
3925:1d383b4c0a23 3926:a6ec38dcbfb5
       
     1 <?xml version='1.0' encoding='utf-8'?>
       
     2 <project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
       
     3   <fileHeader companyName="Beremiz" productName="Beremiz" productVersion="1" creationDateTime="2018-07-27T13:19:12"/>
       
     4   <contentHeader name="Modbus" modificationDateTime="2024-04-04T17:20:49">
       
     5     <coordinateInfo>
       
     6       <fbd>
       
     7         <scaling x="0" y="0"/>
       
     8       </fbd>
       
     9       <ld>
       
    10         <scaling x="0" y="0"/>
       
    11       </ld>
       
    12       <sfc>
       
    13         <scaling x="0" y="0"/>
       
    14       </sfc>
       
    15     </coordinateInfo>
       
    16   </contentHeader>
       
    17   <types>
       
    18     <dataTypes/>
       
    19     <pous>
       
    20       <pou name="program0" pouType="program">
       
    21         <interface>
       
    22           <localVars>
       
    23             <variable name="Counter">
       
    24               <type>
       
    25                 <INT/>
       
    26               </type>
       
    27             </variable>
       
    28             <variable name="CounterReadBack">
       
    29               <type>
       
    30                 <INT/>
       
    31               </type>
       
    32             </variable>
       
    33           </localVars>
       
    34           <localVars>
       
    35             <variable name="MasterWriteToReg0" address="%QW0.0.0.0">
       
    36               <type>
       
    37                 <INT/>
       
    38               </type>
       
    39             </variable>
       
    40             <variable name="MasterReadFromReg1" address="%IW0.0.1.0">
       
    41               <type>
       
    42                 <INT/>
       
    43               </type>
       
    44             </variable>
       
    45             <variable name="SlaveHoldReg0" address="%IW0.1.0.0">
       
    46               <type>
       
    47                 <WORD/>
       
    48               </type>
       
    49             </variable>
       
    50             <variable name="SlaveInputReg0" address="%QW0.1.1.0">
       
    51               <type>
       
    52                 <WORD/>
       
    53               </type>
       
    54             </variable>
       
    55           </localVars>
       
    56           <localVars>
       
    57             <variable name="CTU0">
       
    58               <type>
       
    59                 <derived name="CTU"/>
       
    60               </type>
       
    61             </variable>
       
    62             <variable name="Generator0">
       
    63               <type>
       
    64                 <derived name="Generator"/>
       
    65               </type>
       
    66             </variable>
       
    67             <variable name="TestAllEqual0">
       
    68               <type>
       
    69                 <derived name="TestAllEqual"/>
       
    70               </type>
       
    71             </variable>
       
    72           </localVars>
       
    73         </interface>
       
    74         <body>
       
    75           <FBD>
       
    76             <comment localId="4" height="109" width="350">
       
    77               <position x="102" y="438"/>
       
    78               <content>
       
    79                 <xhtml:p><![CDATA[Modbus TCP Master writes counter value to one holding register on Modbus TCP Slave and reads it back from other input register.]]></xhtml:p>
       
    80               </content>
       
    81             </comment>
       
    82             <comment localId="3" height="407" width="680">
       
    83               <position x="21" y="15"/>
       
    84               <content>
       
    85                 <xhtml:p><![CDATA[This examples shows how to work with Modbus extension. It uses Modbus TCP, but the same functions are available for Modbus RTU as well. Buth protocols are supported.
       
    86 
       
    87 Modbus extensions requires native Modbus RTU/TCP library to be installed nearby Beremiz.
       
    88 Following directory structure is expected:
       
    89 <Parent directory>
       
    90   "beremiz"
       
    91   "Modbus"
       
    92 
       
    93 If Modbus library is installed elsewhere, then place corresponding paths
       
    94 in CFLAGS/LDFLAGS in project settings.
       
    95 
       
    96 For GNU/Linux to install Modbus library in parent directory run following commands:
       
    97 $ hg clone https://bitbucket.org/mjsousa/modbus Modbus
       
    98 $ cd Modbus
       
    99 $ make
       
   100 
       
   101 After that Modbus extension is ready to be used in Beremiz projects.]]></xhtml:p>
       
   102               </content>
       
   103             </comment>
       
   104             <block localId="5" typeName="CTU" instanceName="CTU0" executionOrderId="0" height="80" width="52">
       
   105               <position x="346" y="605"/>
       
   106               <inputVariables>
       
   107                 <variable formalParameter="CU" edge="rising">
       
   108                   <connectionPointIn>
       
   109                     <relPosition x="0" y="30"/>
       
   110                     <connection refLocalId="6" formalParameter="OUT">
       
   111                       <position x="346" y="635"/>
       
   112                       <position x="303" y="635"/>
       
   113                     </connection>
       
   114                   </connectionPointIn>
       
   115                 </variable>
       
   116                 <variable formalParameter="R">
       
   117                   <connectionPointIn>
       
   118                     <relPosition x="0" y="50"/>
       
   119                   </connectionPointIn>
       
   120                 </variable>
       
   121                 <variable formalParameter="PV">
       
   122                   <connectionPointIn>
       
   123                     <relPosition x="0" y="70"/>
       
   124                     <connection refLocalId="7">
       
   125                       <position x="346" y="675"/>
       
   126                       <position x="324" y="675"/>
       
   127                       <position x="324" y="703"/>
       
   128                       <position x="302" y="703"/>
       
   129                     </connection>
       
   130                   </connectionPointIn>
       
   131                 </variable>
       
   132               </inputVariables>
       
   133               <inOutVariables/>
       
   134               <outputVariables>
       
   135                 <variable formalParameter="Q">
       
   136                   <connectionPointOut>
       
   137                     <relPosition x="52" y="30"/>
       
   138                   </connectionPointOut>
       
   139                 </variable>
       
   140                 <variable formalParameter="CV">
       
   141                   <connectionPointOut>
       
   142                     <relPosition x="52" y="50"/>
       
   143                   </connectionPointOut>
       
   144                 </variable>
       
   145               </outputVariables>
       
   146             </block>
       
   147             <block localId="6" typeName="Generator" instanceName="Generator0" executionOrderId="0" height="60" width="82">
       
   148               <position x="224" y="605"/>
       
   149               <inputVariables>
       
   150                 <variable formalParameter="PON">
       
   151                   <connectionPointIn>
       
   152                     <relPosition x="0" y="30"/>
       
   153                     <connection refLocalId="1">
       
   154                       <position x="224" y="635"/>
       
   155                       <position x="154" y="635"/>
       
   156                     </connection>
       
   157                   </connectionPointIn>
       
   158                 </variable>
       
   159                 <variable formalParameter="POFF">
       
   160                   <connectionPointIn>
       
   161                     <relPosition x="0" y="50"/>
       
   162                     <connection refLocalId="1">
       
   163                       <position x="224" y="655"/>
       
   164                       <position x="189" y="655"/>
       
   165                       <position x="189" y="635"/>
       
   166                       <position x="154" y="635"/>
       
   167                     </connection>
       
   168                   </connectionPointIn>
       
   169                 </variable>
       
   170               </inputVariables>
       
   171               <inOutVariables/>
       
   172               <outputVariables>
       
   173                 <variable formalParameter="OUT">
       
   174                   <connectionPointOut>
       
   175                     <relPosition x="82" y="30"/>
       
   176                   </connectionPointOut>
       
   177                 </variable>
       
   178               </outputVariables>
       
   179             </block>
       
   180             <inVariable localId="1" executionOrderId="0" height="30" width="138" negated="false">
       
   181               <position x="16" y="620"/>
       
   182               <connectionPointOut>
       
   183                 <relPosition x="138" y="15"/>
       
   184               </connectionPointOut>
       
   185               <expression>T#1s</expression>
       
   186             </inVariable>
       
   187             <inVariable localId="7" executionOrderId="0" height="30" width="138" negated="false">
       
   188               <position x="164" y="688"/>
       
   189               <connectionPointOut>
       
   190                 <relPosition x="138" y="15"/>
       
   191               </connectionPointOut>
       
   192               <expression>32767</expression>
       
   193             </inVariable>
       
   194             <inOutVariable localId="2" executionOrderId="0" height="30" width="138" negatedOut="false" negatedIn="false">
       
   195               <position x="544" y="640"/>
       
   196               <connectionPointIn>
       
   197                 <relPosition x="0" y="15"/>
       
   198                 <connection refLocalId="5" formalParameter="CV">
       
   199                   <position x="544" y="655"/>
       
   200                   <position x="398" y="655"/>
       
   201                 </connection>
       
   202               </connectionPointIn>
       
   203               <connectionPointOut>
       
   204                 <relPosition x="138" y="15"/>
       
   205               </connectionPointOut>
       
   206               <expression>Counter</expression>
       
   207             </inOutVariable>
       
   208             <outVariable localId="8" executionOrderId="0" height="30" width="146" negated="false">
       
   209               <position x="762" y="640"/>
       
   210               <connectionPointIn>
       
   211                 <relPosition x="0" y="15"/>
       
   212                 <connection refLocalId="2">
       
   213                   <position x="762" y="655"/>
       
   214                   <position x="682" y="655"/>
       
   215                 </connection>
       
   216               </connectionPointIn>
       
   217               <expression>MasterWriteToReg0</expression>
       
   218             </outVariable>
       
   219             <inVariable localId="9" executionOrderId="0" height="30" width="154" negated="false">
       
   220               <position x="81" y="747"/>
       
   221               <connectionPointOut>
       
   222                 <relPosition x="154" y="15"/>
       
   223               </connectionPointOut>
       
   224               <expression>MasterReadFromReg1</expression>
       
   225             </inVariable>
       
   226             <comment localId="11" height="109" width="350">
       
   227               <position x="85" y="825"/>
       
   228               <content>
       
   229                 <xhtml:p><![CDATA[Modbus TCP Slave just copies received register value from holding register to input register.]]></xhtml:p>
       
   230               </content>
       
   231             </comment>
       
   232             <inVariable localId="12" executionOrderId="0" height="30" width="152" negated="false">
       
   233               <position x="82" y="970"/>
       
   234               <connectionPointOut>
       
   235                 <relPosition x="152" y="15"/>
       
   236               </connectionPointOut>
       
   237               <expression>SlaveHoldReg0</expression>
       
   238             </inVariable>
       
   239             <outVariable localId="13" executionOrderId="0" height="30" width="123" negated="false">
       
   240               <position x="548" y="970"/>
       
   241               <connectionPointIn>
       
   242                 <relPosition x="0" y="15"/>
       
   243                 <connection refLocalId="12">
       
   244                   <position x="548" y="985"/>
       
   245                   <position x="234" y="985"/>
       
   246                 </connection>
       
   247               </connectionPointIn>
       
   248               <expression>SlaveInputReg0</expression>
       
   249             </outVariable>
       
   250             <block localId="14" typeName="TestAllEqual" instanceName="TestAllEqual0" executionOrderId="0" width="106" height="100">
       
   251               <position x="763" y="712"/>
       
   252               <inputVariables>
       
   253                 <variable formalParameter="in0">
       
   254                   <connectionPointIn>
       
   255                     <relPosition x="0" y="30"/>
       
   256                   </connectionPointIn>
       
   257                 </variable>
       
   258                 <variable formalParameter="in1">
       
   259                   <connectionPointIn>
       
   260                     <relPosition x="0" y="50"/>
       
   261                   </connectionPointIn>
       
   262                 </variable>
       
   263                 <variable formalParameter="in2">
       
   264                   <connectionPointIn>
       
   265                     <relPosition x="0" y="70"/>
       
   266                   </connectionPointIn>
       
   267                 </variable>
       
   268                 <variable formalParameter="success">
       
   269                   <connectionPointIn>
       
   270                     <relPosition x="0" y="90"/>
       
   271                   </connectionPointIn>
       
   272                 </variable>
       
   273               </inputVariables>
       
   274               <inOutVariables/>
       
   275               <outputVariables/>
       
   276             </block>
       
   277             <inOutVariable localId="10" executionOrderId="0" width="137" height="30" negatedOut="false" negatedIn="false">
       
   278               <position x="547" y="747"/>
       
   279               <connectionPointIn>
       
   280                 <relPosition x="0" y="15"/>
       
   281                 <connection refLocalId="9">
       
   282                   <position x="547" y="762"/>
       
   283                   <position x="235" y="762"/>
       
   284                 </connection>
       
   285               </connectionPointIn>
       
   286               <connectionPointOut>
       
   287                 <relPosition x="137" y="15"/>
       
   288               </connectionPointOut>
       
   289               <expression>CounterReadBack</expression>
       
   290             </inOutVariable>
       
   291             <inVariable localId="15" executionOrderId="0" width="26" height="24" negated="false">
       
   292               <position x="705" y="770"/>
       
   293               <connectionPointOut>
       
   294                 <relPosition x="26" y="12"/>
       
   295               </connectionPointOut>
       
   296               <expression>5</expression>
       
   297             </inVariable>
       
   298           </FBD>
       
   299         </body>
       
   300       </pou>
       
   301       <pou name="Generator" pouType="functionBlock">
       
   302         <interface>
       
   303           <outputVars>
       
   304             <variable name="OUT">
       
   305               <type>
       
   306                 <BOOL/>
       
   307               </type>
       
   308             </variable>
       
   309           </outputVars>
       
   310           <inputVars>
       
   311             <variable name="PON">
       
   312               <type>
       
   313                 <TIME/>
       
   314               </type>
       
   315             </variable>
       
   316             <variable name="POFF">
       
   317               <type>
       
   318                 <TIME/>
       
   319               </type>
       
   320             </variable>
       
   321           </inputVars>
       
   322           <localVars>
       
   323             <variable name="T1">
       
   324               <type>
       
   325                 <derived name="TON"/>
       
   326               </type>
       
   327             </variable>
       
   328             <variable name="T2">
       
   329               <type>
       
   330                 <derived name="TOF"/>
       
   331               </type>
       
   332             </variable>
       
   333           </localVars>
       
   334         </interface>
       
   335         <body>
       
   336           <ST>
       
   337             <xhtml:p><![CDATA[T1( IN := NOT T2.Q, PT := POFF);
       
   338 T2( IN := T1.Q,     PT := PON);
       
   339 OUT := T2.Q;]]></xhtml:p>
       
   340           </ST>
       
   341         </body>
       
   342       </pou>
       
   343       <pou name="TestAllEqual" pouType="functionBlock">
       
   344         <interface>
       
   345           <inputVars>
       
   346             <variable name="in0">
       
   347               <type>
       
   348                 <INT/>
       
   349               </type>
       
   350             </variable>
       
   351             <variable name="in1">
       
   352               <type>
       
   353                 <INT/>
       
   354               </type>
       
   355             </variable>
       
   356             <variable name="in2">
       
   357               <type>
       
   358                 <INT/>
       
   359               </type>
       
   360             </variable>
       
   361             <variable name="success">
       
   362               <type>
       
   363                 <BOOL/>
       
   364               </type>
       
   365             </variable>
       
   366           </inputVars>
       
   367         </interface>
       
   368         <body>
       
   369           <ST>
       
   370             <xhtml:p><![CDATA[IF in0 = in1 AND in1 = in2 AND NOT(success) THEN
       
   371   success := TRUE;
       
   372   { printf("TEST OK\n"); fflush(stdout); }
       
   373 END_IF;]]></xhtml:p>
       
   374           </ST>
       
   375         </body>
       
   376       </pou>
       
   377     </pous>
       
   378   </types>
       
   379   <instances>
       
   380     <configurations>
       
   381       <configuration name="config">
       
   382         <resource name="resource1">
       
   383           <task name="task0" priority="0" interval="T#20ms">
       
   384             <pouInstance name="instance0" typeName="program0"/>
       
   385           </task>
       
   386         </resource>
       
   387       </configuration>
       
   388     </configurations>
       
   389   </instances>
       
   390 </project>