|
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="2018-07-27T15:43:56"> |
|
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 </localVars> |
|
68 </interface> |
|
69 <body> |
|
70 <FBD> |
|
71 <comment localId="4" height="109" width="350"> |
|
72 <position x="102" y="438"/> |
|
73 <content> |
|
74 <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> |
|
75 </content> |
|
76 </comment> |
|
77 <comment localId="3" height="407" width="680"> |
|
78 <position x="21" y="15"/> |
|
79 <content> |
|
80 <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. |
|
81 |
|
82 Modbus extensions requires native Modbus RTU/TCP library to be installed nearby Beremiz. |
|
83 Following directory structure is expected: |
|
84 <Parent directory> |
|
85 "beremiz" |
|
86 "Modbus" |
|
87 |
|
88 If Modbus library is installed elsewhere, then place corresponding paths |
|
89 in CFLAGS/LDFLAGS in project settings. |
|
90 |
|
91 For GNU/Linux to install Modbus library in parent directory run following commands: |
|
92 $ hg clone https://bitbucket.org/mjsousa/modbus Modbus |
|
93 $ cd Modbus |
|
94 $ make |
|
95 |
|
96 After that Modbus extension is ready to be used in Beremiz projects.]]></xhtml:p> |
|
97 </content> |
|
98 </comment> |
|
99 <block localId="5" typeName="CTU" instanceName="CTU0" executionOrderId="0" height="80" width="52"> |
|
100 <position x="346" y="605"/> |
|
101 <inputVariables> |
|
102 <variable formalParameter="CU" edge="rising"> |
|
103 <connectionPointIn> |
|
104 <relPosition x="0" y="30"/> |
|
105 <connection refLocalId="6" formalParameter="OUT"> |
|
106 <position x="346" y="635"/> |
|
107 <position x="303" y="635"/> |
|
108 </connection> |
|
109 </connectionPointIn> |
|
110 </variable> |
|
111 <variable formalParameter="R"> |
|
112 <connectionPointIn> |
|
113 <relPosition x="0" y="50"/> |
|
114 </connectionPointIn> |
|
115 </variable> |
|
116 <variable formalParameter="PV"> |
|
117 <connectionPointIn> |
|
118 <relPosition x="0" y="70"/> |
|
119 <connection refLocalId="7"> |
|
120 <position x="346" y="675"/> |
|
121 <position x="324" y="675"/> |
|
122 <position x="324" y="703"/> |
|
123 <position x="302" y="703"/> |
|
124 </connection> |
|
125 </connectionPointIn> |
|
126 </variable> |
|
127 </inputVariables> |
|
128 <inOutVariables/> |
|
129 <outputVariables> |
|
130 <variable formalParameter="Q"> |
|
131 <connectionPointOut> |
|
132 <relPosition x="52" y="30"/> |
|
133 </connectionPointOut> |
|
134 </variable> |
|
135 <variable formalParameter="CV"> |
|
136 <connectionPointOut> |
|
137 <relPosition x="52" y="50"/> |
|
138 </connectionPointOut> |
|
139 </variable> |
|
140 </outputVariables> |
|
141 </block> |
|
142 <block localId="6" typeName="Generator" instanceName="Generator0" executionOrderId="0" height="60" width="79"> |
|
143 <position x="224" y="605"/> |
|
144 <inputVariables> |
|
145 <variable formalParameter="PON"> |
|
146 <connectionPointIn> |
|
147 <relPosition x="0" y="30"/> |
|
148 <connection refLocalId="1"> |
|
149 <position x="224" y="635"/> |
|
150 <position x="154" y="635"/> |
|
151 </connection> |
|
152 </connectionPointIn> |
|
153 </variable> |
|
154 <variable formalParameter="POFF"> |
|
155 <connectionPointIn> |
|
156 <relPosition x="0" y="50"/> |
|
157 <connection refLocalId="1"> |
|
158 <position x="224" y="655"/> |
|
159 <position x="189" y="655"/> |
|
160 <position x="189" y="635"/> |
|
161 <position x="154" y="635"/> |
|
162 </connection> |
|
163 </connectionPointIn> |
|
164 </variable> |
|
165 </inputVariables> |
|
166 <inOutVariables/> |
|
167 <outputVariables> |
|
168 <variable formalParameter="OUT"> |
|
169 <connectionPointOut> |
|
170 <relPosition x="79" y="30"/> |
|
171 </connectionPointOut> |
|
172 </variable> |
|
173 </outputVariables> |
|
174 </block> |
|
175 <inVariable localId="1" executionOrderId="0" height="30" width="138" negated="false"> |
|
176 <position x="16" y="620"/> |
|
177 <connectionPointOut> |
|
178 <relPosition x="138" y="15"/> |
|
179 </connectionPointOut> |
|
180 <expression>T#1s</expression> |
|
181 </inVariable> |
|
182 <inVariable localId="7" executionOrderId="0" height="30" width="138" negated="false"> |
|
183 <position x="164" y="688"/> |
|
184 <connectionPointOut> |
|
185 <relPosition x="138" y="15"/> |
|
186 </connectionPointOut> |
|
187 <expression>32767</expression> |
|
188 </inVariable> |
|
189 <inOutVariable localId="2" executionOrderId="0" height="30" width="138" negatedOut="false" negatedIn="false"> |
|
190 <position x="544" y="640"/> |
|
191 <connectionPointIn> |
|
192 <relPosition x="0" y="15"/> |
|
193 <connection refLocalId="5" formalParameter="CV"> |
|
194 <position x="544" y="655"/> |
|
195 <position x="398" y="655"/> |
|
196 </connection> |
|
197 </connectionPointIn> |
|
198 <connectionPointOut> |
|
199 <relPosition x="138" y="15"/> |
|
200 </connectionPointOut> |
|
201 <expression>Counter</expression> |
|
202 </inOutVariable> |
|
203 <outVariable localId="8" executionOrderId="0" height="30" width="138" negated="false"> |
|
204 <position x="762" y="640"/> |
|
205 <connectionPointIn> |
|
206 <relPosition x="0" y="15"/> |
|
207 <connection refLocalId="2"> |
|
208 <position x="762" y="655"/> |
|
209 <position x="682" y="655"/> |
|
210 </connection> |
|
211 </connectionPointIn> |
|
212 <expression>MasterWriteToReg0</expression> |
|
213 </outVariable> |
|
214 <inVariable localId="9" executionOrderId="0" height="30" width="152" negated="false"> |
|
215 <position x="81" y="747"/> |
|
216 <connectionPointOut> |
|
217 <relPosition x="152" y="15"/> |
|
218 </connectionPointOut> |
|
219 <expression>MasterReadFromReg1</expression> |
|
220 </inVariable> |
|
221 <outVariable localId="10" executionOrderId="0" height="30" width="137" negated="false"> |
|
222 <position x="547" y="747"/> |
|
223 <connectionPointIn> |
|
224 <relPosition x="0" y="15"/> |
|
225 <connection refLocalId="9"> |
|
226 <position x="547" y="762"/> |
|
227 <position x="233" y="762"/> |
|
228 </connection> |
|
229 </connectionPointIn> |
|
230 <expression>CounterReadBack</expression> |
|
231 </outVariable> |
|
232 <comment localId="11" height="109" width="350"> |
|
233 <position x="85" y="825"/> |
|
234 <content> |
|
235 <xhtml:p><![CDATA[Modbus TCP Slave just copies received register value from holding register to input register.]]></xhtml:p> |
|
236 </content> |
|
237 </comment> |
|
238 <inVariable localId="12" executionOrderId="0" height="30" width="152" negated="false"> |
|
239 <position x="82" y="970"/> |
|
240 <connectionPointOut> |
|
241 <relPosition x="152" y="15"/> |
|
242 </connectionPointOut> |
|
243 <expression>SlaveHoldReg0</expression> |
|
244 </inVariable> |
|
245 <outVariable localId="13" executionOrderId="0" height="30" width="123" negated="false"> |
|
246 <position x="548" y="970"/> |
|
247 <connectionPointIn> |
|
248 <relPosition x="0" y="15"/> |
|
249 <connection refLocalId="12"> |
|
250 <position x="548" y="985"/> |
|
251 <position x="234" y="985"/> |
|
252 </connection> |
|
253 </connectionPointIn> |
|
254 <expression>SlaveInputReg0</expression> |
|
255 </outVariable> |
|
256 </FBD> |
|
257 </body> |
|
258 </pou> |
|
259 <pou name="Generator" pouType="functionBlock"> |
|
260 <interface> |
|
261 <outputVars> |
|
262 <variable name="OUT"> |
|
263 <type> |
|
264 <BOOL/> |
|
265 </type> |
|
266 </variable> |
|
267 </outputVars> |
|
268 <inputVars> |
|
269 <variable name="PON"> |
|
270 <type> |
|
271 <TIME/> |
|
272 </type> |
|
273 </variable> |
|
274 <variable name="POFF"> |
|
275 <type> |
|
276 <TIME/> |
|
277 </type> |
|
278 </variable> |
|
279 </inputVars> |
|
280 <localVars> |
|
281 <variable name="T1"> |
|
282 <type> |
|
283 <derived name="TON"/> |
|
284 </type> |
|
285 </variable> |
|
286 <variable name="T2"> |
|
287 <type> |
|
288 <derived name="TOF"/> |
|
289 </type> |
|
290 </variable> |
|
291 </localVars> |
|
292 </interface> |
|
293 <body> |
|
294 <ST> |
|
295 <xhtml:p><![CDATA[T1( IN := NOT T2.Q, PT := POFF); |
|
296 T2( IN := T1.Q, PT := PON); |
|
297 OUT := T2.Q;]]></xhtml:p> |
|
298 </ST> |
|
299 </body> |
|
300 </pou> |
|
301 </pous> |
|
302 </types> |
|
303 <instances> |
|
304 <configurations> |
|
305 <configuration name="config"> |
|
306 <resource name="resource1"> |
|
307 <task name="task0" priority="0" interval="T#20ms"> |
|
308 <pouInstance name="instance0" typeName="program0"/> |
|
309 </task> |
|
310 </resource> |
|
311 </configuration> |
|
312 </configurations> |
|
313 </instances> |
|
314 </project> |