andrej@2252: <?xml version='1.0' encoding='utf-8'?>
andrej@2252: <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">
andrej@2252:   <fileHeader companyName="Beremiz" productName="Beremiz" productVersion="1" creationDateTime="2018-07-27T13:19:12"/>
andrej@2252:   <contentHeader name="Modbus" modificationDateTime="2018-07-27T15:43:56">
andrej@2252:     <coordinateInfo>
andrej@2252:       <fbd>
andrej@2252:         <scaling x="0" y="0"/>
andrej@2252:       </fbd>
andrej@2252:       <ld>
andrej@2252:         <scaling x="0" y="0"/>
andrej@2252:       </ld>
andrej@2252:       <sfc>
andrej@2252:         <scaling x="0" y="0"/>
andrej@2252:       </sfc>
andrej@2252:     </coordinateInfo>
andrej@2252:   </contentHeader>
andrej@2252:   <types>
andrej@2252:     <dataTypes/>
andrej@2252:     <pous>
andrej@2252:       <pou name="program0" pouType="program">
andrej@2252:         <interface>
andrej@2252:           <localVars>
andrej@2252:             <variable name="Counter">
andrej@2252:               <type>
andrej@2252:                 <INT/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="CounterReadBack">
andrej@2252:               <type>
andrej@2252:                 <INT/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </localVars>
andrej@2252:           <localVars>
andrej@2252:             <variable name="MasterWriteToReg0" address="%QW0.0.0.0">
andrej@2252:               <type>
andrej@2252:                 <INT/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="MasterReadFromReg1" address="%IW0.0.1.0">
andrej@2252:               <type>
andrej@2252:                 <INT/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="SlaveHoldReg0" address="%IW0.1.0.0">
andrej@2252:               <type>
andrej@2252:                 <WORD/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="SlaveInputReg0" address="%QW0.1.1.0">
andrej@2252:               <type>
andrej@2252:                 <WORD/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </localVars>
andrej@2252:           <localVars>
andrej@2252:             <variable name="CTU0">
andrej@2252:               <type>
andrej@2252:                 <derived name="CTU"/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="Generator0">
andrej@2252:               <type>
andrej@2252:                 <derived name="Generator"/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </localVars>
andrej@2252:         </interface>
andrej@2252:         <body>
andrej@2252:           <FBD>
andrej@2252:             <comment localId="4" height="109" width="350">
andrej@2252:               <position x="102" y="438"/>
andrej@2252:               <content>
andrej@2252:                 <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>
andrej@2252:               </content>
andrej@2252:             </comment>
andrej@2252:             <comment localId="3" height="407" width="680">
andrej@2252:               <position x="21" y="15"/>
andrej@2252:               <content>
andrej@2252:                 <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.
andrej@2252: 
andrej@2252: Modbus extensions requires native Modbus RTU/TCP library to be installed nearby Beremiz.
andrej@2252: Following directory structure is expected:
andrej@2252: <Parent directory>
andrej@2252:   "beremiz"
andrej@2252:   "Modbus"
andrej@2252: 
andrej@2252: If Modbus library is installed elsewhere, then place corresponding paths
andrej@2252: in CFLAGS/LDFLAGS in project settings.
andrej@2252: 
andrej@2252: For GNU/Linux to install Modbus library in parent directory run following commands:
andrej@2252: $ hg clone https://bitbucket.org/mjsousa/modbus Modbus
andrej@2252: $ cd Modbus
andrej@2252: $ make
andrej@2252: 
andrej@2252: After that Modbus extension is ready to be used in Beremiz projects.]]></xhtml:p>
andrej@2252:               </content>
andrej@2252:             </comment>
andrej@2252:             <block localId="5" typeName="CTU" instanceName="CTU0" executionOrderId="0" height="80" width="52">
andrej@2252:               <position x="346" y="605"/>
andrej@2252:               <inputVariables>
andrej@2252:                 <variable formalParameter="CU" edge="rising">
andrej@2252:                   <connectionPointIn>
andrej@2252:                     <relPosition x="0" y="30"/>
andrej@2252:                     <connection refLocalId="6" formalParameter="OUT">
andrej@2252:                       <position x="346" y="635"/>
andrej@2252:                       <position x="303" y="635"/>
andrej@2252:                     </connection>
andrej@2252:                   </connectionPointIn>
andrej@2252:                 </variable>
andrej@2252:                 <variable formalParameter="R">
andrej@2252:                   <connectionPointIn>
andrej@2252:                     <relPosition x="0" y="50"/>
andrej@2252:                   </connectionPointIn>
andrej@2252:                 </variable>
andrej@2252:                 <variable formalParameter="PV">
andrej@2252:                   <connectionPointIn>
andrej@2252:                     <relPosition x="0" y="70"/>
andrej@2252:                     <connection refLocalId="7">
andrej@2252:                       <position x="346" y="675"/>
andrej@2252:                       <position x="324" y="675"/>
andrej@2252:                       <position x="324" y="703"/>
andrej@2252:                       <position x="302" y="703"/>
andrej@2252:                     </connection>
andrej@2252:                   </connectionPointIn>
andrej@2252:                 </variable>
andrej@2252:               </inputVariables>
andrej@2252:               <inOutVariables/>
andrej@2252:               <outputVariables>
andrej@2252:                 <variable formalParameter="Q">
andrej@2252:                   <connectionPointOut>
andrej@2252:                     <relPosition x="52" y="30"/>
andrej@2252:                   </connectionPointOut>
andrej@2252:                 </variable>
andrej@2252:                 <variable formalParameter="CV">
andrej@2252:                   <connectionPointOut>
andrej@2252:                     <relPosition x="52" y="50"/>
andrej@2252:                   </connectionPointOut>
andrej@2252:                 </variable>
andrej@2252:               </outputVariables>
andrej@2252:             </block>
andrej@2252:             <block localId="6" typeName="Generator" instanceName="Generator0" executionOrderId="0" height="60" width="79">
andrej@2252:               <position x="224" y="605"/>
andrej@2252:               <inputVariables>
andrej@2252:                 <variable formalParameter="PON">
andrej@2252:                   <connectionPointIn>
andrej@2252:                     <relPosition x="0" y="30"/>
andrej@2252:                     <connection refLocalId="1">
andrej@2252:                       <position x="224" y="635"/>
andrej@2252:                       <position x="154" y="635"/>
andrej@2252:                     </connection>
andrej@2252:                   </connectionPointIn>
andrej@2252:                 </variable>
andrej@2252:                 <variable formalParameter="POFF">
andrej@2252:                   <connectionPointIn>
andrej@2252:                     <relPosition x="0" y="50"/>
andrej@2252:                     <connection refLocalId="1">
andrej@2252:                       <position x="224" y="655"/>
andrej@2252:                       <position x="189" y="655"/>
andrej@2252:                       <position x="189" y="635"/>
andrej@2252:                       <position x="154" y="635"/>
andrej@2252:                     </connection>
andrej@2252:                   </connectionPointIn>
andrej@2252:                 </variable>
andrej@2252:               </inputVariables>
andrej@2252:               <inOutVariables/>
andrej@2252:               <outputVariables>
andrej@2252:                 <variable formalParameter="OUT">
andrej@2252:                   <connectionPointOut>
andrej@2252:                     <relPosition x="79" y="30"/>
andrej@2252:                   </connectionPointOut>
andrej@2252:                 </variable>
andrej@2252:               </outputVariables>
andrej@2252:             </block>
andrej@2252:             <inVariable localId="1" executionOrderId="0" height="30" width="138" negated="false">
andrej@2252:               <position x="16" y="620"/>
andrej@2252:               <connectionPointOut>
andrej@2252:                 <relPosition x="138" y="15"/>
andrej@2252:               </connectionPointOut>
andrej@2252:               <expression>T#1s</expression>
andrej@2252:             </inVariable>
andrej@2252:             <inVariable localId="7" executionOrderId="0" height="30" width="138" negated="false">
andrej@2252:               <position x="164" y="688"/>
andrej@2252:               <connectionPointOut>
andrej@2252:                 <relPosition x="138" y="15"/>
andrej@2252:               </connectionPointOut>
andrej@2252:               <expression>32767</expression>
andrej@2252:             </inVariable>
andrej@2252:             <inOutVariable localId="2" executionOrderId="0" height="30" width="138" negatedOut="false" negatedIn="false">
andrej@2252:               <position x="544" y="640"/>
andrej@2252:               <connectionPointIn>
andrej@2252:                 <relPosition x="0" y="15"/>
andrej@2252:                 <connection refLocalId="5" formalParameter="CV">
andrej@2252:                   <position x="544" y="655"/>
andrej@2252:                   <position x="398" y="655"/>
andrej@2252:                 </connection>
andrej@2252:               </connectionPointIn>
andrej@2252:               <connectionPointOut>
andrej@2252:                 <relPosition x="138" y="15"/>
andrej@2252:               </connectionPointOut>
andrej@2252:               <expression>Counter</expression>
andrej@2252:             </inOutVariable>
andrej@2252:             <outVariable localId="8" executionOrderId="0" height="30" width="138" negated="false">
andrej@2252:               <position x="762" y="640"/>
andrej@2252:               <connectionPointIn>
andrej@2252:                 <relPosition x="0" y="15"/>
andrej@2252:                 <connection refLocalId="2">
andrej@2252:                   <position x="762" y="655"/>
andrej@2252:                   <position x="682" y="655"/>
andrej@2252:                 </connection>
andrej@2252:               </connectionPointIn>
andrej@2252:               <expression>MasterWriteToReg0</expression>
andrej@2252:             </outVariable>
andrej@2252:             <inVariable localId="9" executionOrderId="0" height="30" width="152" negated="false">
andrej@2252:               <position x="81" y="747"/>
andrej@2252:               <connectionPointOut>
andrej@2252:                 <relPosition x="152" y="15"/>
andrej@2252:               </connectionPointOut>
andrej@2252:               <expression>MasterReadFromReg1</expression>
andrej@2252:             </inVariable>
andrej@2252:             <outVariable localId="10" executionOrderId="0" height="30" width="137" negated="false">
andrej@2252:               <position x="547" y="747"/>
andrej@2252:               <connectionPointIn>
andrej@2252:                 <relPosition x="0" y="15"/>
andrej@2252:                 <connection refLocalId="9">
andrej@2252:                   <position x="547" y="762"/>
andrej@2252:                   <position x="233" y="762"/>
andrej@2252:                 </connection>
andrej@2252:               </connectionPointIn>
andrej@2252:               <expression>CounterReadBack</expression>
andrej@2252:             </outVariable>
andrej@2252:             <comment localId="11" height="109" width="350">
andrej@2252:               <position x="85" y="825"/>
andrej@2252:               <content>
andrej@2252:                 <xhtml:p><![CDATA[Modbus TCP Slave just copies received register value from holding register to input register.]]></xhtml:p>
andrej@2252:               </content>
andrej@2252:             </comment>
andrej@2252:             <inVariable localId="12" executionOrderId="0" height="30" width="152" negated="false">
andrej@2252:               <position x="82" y="970"/>
andrej@2252:               <connectionPointOut>
andrej@2252:                 <relPosition x="152" y="15"/>
andrej@2252:               </connectionPointOut>
andrej@2252:               <expression>SlaveHoldReg0</expression>
andrej@2252:             </inVariable>
andrej@2252:             <outVariable localId="13" executionOrderId="0" height="30" width="123" negated="false">
andrej@2252:               <position x="548" y="970"/>
andrej@2252:               <connectionPointIn>
andrej@2252:                 <relPosition x="0" y="15"/>
andrej@2252:                 <connection refLocalId="12">
andrej@2252:                   <position x="548" y="985"/>
andrej@2252:                   <position x="234" y="985"/>
andrej@2252:                 </connection>
andrej@2252:               </connectionPointIn>
andrej@2252:               <expression>SlaveInputReg0</expression>
andrej@2252:             </outVariable>
andrej@2252:           </FBD>
andrej@2252:         </body>
andrej@2252:       </pou>
andrej@2252:       <pou name="Generator" pouType="functionBlock">
andrej@2252:         <interface>
andrej@2252:           <outputVars>
andrej@2252:             <variable name="OUT">
andrej@2252:               <type>
andrej@2252:                 <BOOL/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </outputVars>
andrej@2252:           <inputVars>
andrej@2252:             <variable name="PON">
andrej@2252:               <type>
andrej@2252:                 <TIME/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="POFF">
andrej@2252:               <type>
andrej@2252:                 <TIME/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </inputVars>
andrej@2252:           <localVars>
andrej@2252:             <variable name="T1">
andrej@2252:               <type>
andrej@2252:                 <derived name="TON"/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:             <variable name="T2">
andrej@2252:               <type>
andrej@2252:                 <derived name="TOF"/>
andrej@2252:               </type>
andrej@2252:             </variable>
andrej@2252:           </localVars>
andrej@2252:         </interface>
andrej@2252:         <body>
andrej@2252:           <ST>
andrej@2252:             <xhtml:p><![CDATA[T1( IN := NOT T2.Q, PT := POFF);
andrej@2252: T2( IN := T1.Q,     PT := PON);
andrej@2252: OUT := T2.Q;]]></xhtml:p>
andrej@2252:           </ST>
andrej@2252:         </body>
andrej@2252:       </pou>
andrej@2252:     </pous>
andrej@2252:   </types>
andrej@2252:   <instances>
andrej@2252:     <configurations>
andrej@2252:       <configuration name="config">
andrej@2252:         <resource name="resource1">
andrej@2252:           <task name="task0" priority="0" interval="T#20ms">
andrej@2252:             <pouInstance name="instance0" typeName="program0"/>
andrej@2252:           </task>
andrej@2252:         </resource>
andrej@2252:       </configuration>
andrej@2252:     </configurations>
andrej@2252:   </instances>
andrej@2252: </project>