Diff of /trunk/2.0.0.1/+CTRLBYTE/Monarco HAT library for codesys 2.0.0.1.library.xml [000000] .. [r4]  Maximize  Restore

Switch to unified view

a b/trunk/2.0.0.1/+CTRLBYTE/Monarco HAT library for codesys 2.0.0.1.library.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<project xmlns="http://www.plcopen.org/xml/tc6_0200">
3
  <fileHeader companyName="" productName="CODESYS" productVersion="CODESYS V3.5 SP13" creationDateTime="2018-09-21T11:46:51.6132905" />
4
  <contentHeader name="Monarco HAT library for CODESYS" version="2.0.0.1" modificationDateTime="2018-07-29T18:12:20.818347" organization="Monarco.io" author="Aliazzzz">
5
    <Comment>.. _description: 
6
7
Library containing device support for Monarco HAT hardware developped by the guys from Monarco.io.
8
9
I decided to write this library because the hardware is very solid, but a CODESYS implementation was missing.
10
Writing this library was fun, but took a lot of sweat and time, please refer to this work when you use it =).
11
12
I am not affiliated with Monarco.io in any way, shape or form.
13
14
Released under Unlicense.
15
16
17
Enjoy!
18
19
20
**Getting started**
21
22
To use the HAT, RS-485 and the Realtime Clock under CODESYS, please follow these steps. RTC requires no Linux side config apart from the overlay;
23
24
1) On your Raspberry Pi, switch to root user: sudo -s
25
26
2) Disable Linux console on UART: **sed 's/ console=serial0,[0-9]\+//' -i /boot/cmdline.txt**
27
28
3) Run the following command to get device-tree overlay definition for the RS-485 on the Monarco HAT: **wget www.monarco.io/download/monarco-fix-4-9.dtbo**
29
30
4) Copy it to /boot/overlays: **sudo cp monarco-fix-4-9.dtbo /boot/overlays**
31
32
5) Afterwards add dtoverlay=monarco-fix-4-9 line to the /boot/config.txt file: **echo dtoverlay=monarco-fix-4-9 &gt;&gt; /boot/config.txt**
33
34
6) Reboot your Raspberry Pi: **reboot**
35
36
7) After reboot, check the output of the following command: **ls -l /dev/serial0**
37
38
8) The response should read **"/dev/serial0 -&gt; ttyAMA0"**
39
40
9) Again, switch to root user: **sudo -s  cd etc/**
41
42
10) Then: **nano CODESYSControl.cfg**
43
44
11) Add the following lines: **[SysCom] Linux.Devicefile=/dev/ttyAMA**
45
46
12) Then reboot your Raspberry Pi again: **reboot**
47
48
13) After reboot: **Now you can use the HAT, RS-485 and the Real-Time Clock in CODESYS!** from within an IEC application via a comlib of you own flavour (like CAA SerialCOM library).
49
50
.. image:: ../Images/MonarcoHAT.png
51
52
53
* Real Time Clock (RTC)
54
* RS-485 Interface
55
* 1-Wire Interface (1w)
56
* 4 Digital Inputs
57
* 4 Digital Outputs
58
* 2 Analog Inputs 12 bits without sign: (0 - 4095) 0..10V / 0..25mA
59
* 2 Analog Outputs 12 bit without sign: (0 - 4095) 0..10V
60
* LEDs: 1 × orange, 8 × green LEDs
61
* Power supply: 10-30 VDC, powers also the Raspberry Pi
62
63
64
This library is based on Hardware version 0106, Firmware version 2006.
65
66
67
.. image:: ../Images/schematics.png</Comment>
68
    <coordinateInfo>
69
      <fbd>
70
        <scaling x="1" y="1" />
71
      </fbd>
72
      <ld>
73
        <scaling x="1" y="1" />
74
      </ld>
75
      <sfc>
76
        <scaling x="1" y="1" />
77
      </sfc>
78
    </coordinateInfo>
79
    <addData>
80
      <data name="http://www.3s-software.com/plcopenxml/projectinformation" handleUnknown="implementation">
81
        <ProjectInformation>
82
          <property name="Author" type="string">Aliazzzz</property>
83
          <property name="Company" type="string">Monarco.io</property>
84
          <property name="DefaultNamespace" type="string">MNR</property>
85
          <property name="Description" type="string">.. _description: 
86
87
Library containing device support for Monarco HAT hardware developped by the guys from Monarco.io.
88
89
I decided to write this library because the hardware is very solid, but a CODESYS implementation was missing.
90
Writing this library was fun, but took a lot of sweat and time, please refer to this work when you use it =).
91
92
I am not affiliated with Monarco.io in any way, shape or form.
93
94
Released under Unlicense.
95
96
97
Enjoy!
98
99
100
**Getting started**
101
102
To use the HAT, RS-485 and the Realtime Clock under CODESYS, please follow these steps. RTC requires no Linux side config apart from the overlay;
103
104
1) On your Raspberry Pi, switch to root user: sudo -s
105
106
2) Disable Linux console on UART: **sed 's/ console=serial0,[0-9]\+//' -i /boot/cmdline.txt**
107
108
3) Run the following command to get device-tree overlay definition for the RS-485 on the Monarco HAT: **wget www.monarco.io/download/monarco-fix-4-9.dtbo**
109
110
4) Copy it to /boot/overlays: **sudo cp monarco-fix-4-9.dtbo /boot/overlays**
111
112
5) Afterwards add dtoverlay=monarco-fix-4-9 line to the /boot/config.txt file: **echo dtoverlay=monarco-fix-4-9 &gt;&gt; /boot/config.txt**
113
114
6) Reboot your Raspberry Pi: **reboot**
115
116
7) After reboot, check the output of the following command: **ls -l /dev/serial0**
117
118
8) The response should read **"/dev/serial0 -&gt; ttyAMA0"**
119
120
9) Again, switch to root user: **sudo -s  cd etc/**
121
122
10) Then: **nano CODESYSControl.cfg**
123
124
11) Add the following lines: **[SysCom] Linux.Devicefile=/dev/ttyAMA**
125
126
12) Then reboot your Raspberry Pi again: **reboot**
127
128
13) After reboot: **Now you can use the HAT, RS-485 and the Real-Time Clock in CODESYS!** from within an IEC application via a comlib of you own flavour (like CAA SerialCOM library).
129
130
.. image:: ../Images/MonarcoHAT.png
131
132
133
* Real Time Clock (RTC)
134
* RS-485 Interface
135
* 1-Wire Interface (1w)
136
* 4 Digital Inputs
137
* 4 Digital Outputs
138
* 2 Analog Inputs 12 bits without sign: (0 - 4095) 0..10V / 0..25mA
139
* 2 Analog Outputs 12 bit without sign: (0 - 4095) 0..10V
140
* LEDs: 1 × orange, 8 × green LEDs
141
* Power supply: 10-30 VDC, powers also the Raspberry Pi
142
143
144
This library is based on Hardware version 0106, Firmware version 2006.
145
146
147
.. image:: ../Images/schematics.png</property>
148
          <property name="DocFormat" type="string">reStructuredText</property>
149
          <property name="LibDocContent" type="string">CommentsAndDocs</property>
150
          <property name="Project" type="string">Monarco HAT library for codesys 2.0.0.1</property>
151
          <property name="Title" type="string">Monarco HAT library for CODESYS</property>
152
          <property name="Version" type="version">2.0.0.1</property>
153
        </ProjectInformation>
154
      </data>
155
      <data name="http://www.3s-software.com/plcopenxml/autogeneratedobjects" handleUnknown="implementation">
156
        <AutogeneratedObjects>
157
          <libraryInfoFunctions>true</libraryInfoFunctions>
158
          <projectInfoFunctions>false</projectInfoFunctions>
159
          <propertyAccessorFunctions>false</propertyAccessorFunctions>
160
        </AutogeneratedObjects>
161
      </data>
162
    </addData>
163
  </contentHeader>
164
  <types>
165
    <dataTypes />
166
    <pous>
167
      <pou name="IoDrvMonarco" pouType="functionBlock">
168
        <interface>
169
          <localVars>
170
            <variable name="_IIoDrv">
171
              <type>
172
                <derived name="ICmpIoDrv" />
173
              </type>
174
            </variable>
175
            <variable name="_IIoDrvParameter">
176
              <type>
177
                <derived name="ICmpIoDrvParameter" />
178
              </type>
179
            </variable>
180
            <variable name="Monarco">
181
              <type>
182
                <derived name="MonarcoItf" />
183
              </type>
184
            </variable>
185
            <variable name="_dwInUse">
186
              <type>
187
                <DWORD />
188
              </type>
189
            </variable>
190
            <variable name="_xBackGroundDiagStarted">
191
              <type>
192
                <BOOL />
193
              </type>
194
            </variable>
195
            <variable name="_bDeactivated">
196
              <type>
197
                <BOOL />
198
              </type>
199
            </variable>
200
          </localVars>
201
          <addData>
202
            <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
203
              <Inheritance>
204
                <Extends>IoDrvBase</Extends>
205
                <Implements>ICmpIoDrvParameter</Implements>
206
              </Inheritance>
207
            </data>
208
            <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
209
              <Attributes>
210
                <Attribute Name="symbol" Value="readwrite" />
211
              </Attributes>
212
            </data>
213
          </addData>
214
        </interface>
215
        <body>
216
          <ST>
217
            <xhtml xmlns="http://www.w3.org/1999/xhtml" />
218
          </ST>
219
        </body>
220
        <addData>
221
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
222
            <Method name="FB_Init">
223
              <interface>
224
                <returnType>
225
                  <BOOL />
226
                </returnType>
227
                <inputVars>
228
                  <variable name="bInitRetains">
229
                    <type>
230
                      <BOOL />
231
                    </type>
232
                  </variable>
233
                  <variable name="bInCopyCode">
234
                    <type>
235
                      <BOOL />
236
                    </type>
237
                  </variable>
238
                </inputVars>
239
                <localVars>
240
                  <variable name="Result">
241
                    <type>
242
                      <UDINT />
243
                    </type>
244
                  </variable>
245
                  <variable name="CLASSID_CCmpIoDrvTemplate">
246
                    <type>
247
                      <DWORD />
248
                    </type>
249
                  </variable>
250
                </localVars>
251
                <documentation>
252
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
253
                </documentation>
254
              </interface>
255
              <body>
256
                <ST>
257
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Init_Count := FB_Init_Count + 1;
258
259
m_Info.szDriverName := 'IoDrvMonarco';
260
m_Info.szVendorName := 'Monarcio.IO';
261
m_Info.szDeviceName := 'Monarco HAT';
262
m_Info.wModuleType := 501;
263
264
_IIoDrv := THIS^;
265
_IIoDrvParameter := THIS^;
266
267
m_IBaseItf := THIS^;
268
m_hInterface := IoMgrRegisterInstance2(dwClassId:=CLASSID_CCmpIoDrvTemplate, pItf:=m_IBaseItf, pResult:=ADR(Result));
269
FB_Init := TRUE;</xhtml>
270
                </ST>
271
              </body>
272
              <addData />
273
            </Method>
274
          </data>
275
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
276
            <Method name="FB_Exit">
277
              <interface>
278
                <returnType>
279
                  <BOOL />
280
                </returnType>
281
                <inputVars>
282
                  <variable name="bInCopyCode">
283
                    <type>
284
                      <BOOL />
285
                    </type>
286
                  </variable>
287
                </inputVars>
288
                <documentation>
289
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
290
                </documentation>
291
              </interface>
292
              <body>
293
                <ST>
294
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Exit_Count := FB_Exit_Count + 1;
295
FB_Exit := TRUE;
296
</xhtml>
297
                </ST>
298
              </body>
299
              <addData />
300
            </Method>
301
          </data>
302
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
303
            <Method name="FB_Reinit">
304
              <interface>
305
                <returnType>
306
                  <BOOL />
307
                </returnType>
308
                <documentation>
309
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
310
                </documentation>
311
              </interface>
312
              <body>
313
                <ST>
314
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Reinit_Count := FB_Reinit_Count + 1;
315
FB_Reinit := TRUE;</xhtml>
316
                </ST>
317
              </body>
318
              <addData />
319
            </Method>
320
          </data>
321
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
322
            <Method name="QueryInterface">
323
              <interface>
324
                <returnType>
325
                  <pointer>
326
                    <baseType>
327
                      <pointer>
328
                        <baseType>
329
                          <BYTE />
330
                        </baseType>
331
                      </pointer>
332
                    </baseType>
333
                  </pointer>
334
                </returnType>
335
                <inputVars>
336
                  <variable name="iid">
337
                    <type>
338
                      <DWORD />
339
                    </type>
340
                    <documentation>
341
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> InterfaceID </xhtml>
342
                    </documentation>
343
                  </variable>
344
                  <variable name="pResult">
345
                    <type>
346
                      <pointer>
347
                        <baseType>
348
                          <UDINT />
349
                        </baseType>
350
                      </pointer>
351
                    </type>
352
                  </variable>
353
                </inputVars>
354
                <documentation>
355
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow'}</xhtml>
356
                </documentation>
357
              </interface>
358
              <body>
359
                <ST>
360
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">QueryInterface_Count := QueryInterface_Count + 1;
361
IF iid = ITFID_ICmpIoDrv THEN
362
    QueryInterface := ADR(_IIoDrv);
363
    AddRef();
364
    IF (pResult &lt;&gt; 0) THEN
365
        pResult^ := Errors.ERR_OK;
366
    END_IF
367
    RETURN; 
368
ELSIF iid = ITFID_ICmpIoDrvParameter THEN
369
    QueryInterface := ADR(_IIoDrvParameter);
370
    AddRef();
371
    IF (pResult &lt;&gt; 0) THEN
372
        pResult^ := Errors.ERR_OK;
373
    END_IF  
374
    RETURN; 
375
ELSE
376
    QueryInterface := SUPER^.QueryInterface(iid, pResult);
377
END_IF
378
</xhtml>
379
                </ST>
380
              </body>
381
              <BuildProperties>
382
                <EnableSystemCall>true</EnableSystemCall>
383
              </BuildProperties>
384
              <addData />
385
            </Method>
386
          </data>
387
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
388
            <Method name="Initialize">
389
              <interface>
390
                <returnType>
391
                  <UDINT />
392
                </returnType>
393
                <inputVars>
394
                  <variable name="wModuleType">
395
                    <type>
396
                      <UINT />
397
                    </type>
398
                  </variable>
399
                  <variable name="dwInstance">
400
                    <type>
401
                      <UDINT />
402
                    </type>
403
                  </variable>
404
                  <variable name="pConnector">
405
                    <type>
406
                      <pointer>
407
                        <baseType>
408
                          <derived name="IoConfigConnector" />
409
                        </baseType>
410
                      </pointer>
411
                    </type>
412
                  </variable>
413
                </inputVars>
414
                <documentation>
415
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
416
                </documentation>
417
              </interface>
418
              <body>
419
                <ST>
420
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">Initialize_Count := Initialize_Count + 1;
421
422
m_wModuleType := wModuleType;
423
m_dwInstance := dwInstance;
424
m_Info.wModuleType := wModuleType;
425
426
Monarco.Initialize(wModuleType, dwInstance, pConnector);
427
428
Initialize := Errors.ERR_OK;</xhtml>
429
                </ST>
430
              </body>
431
              <addData />
432
            </Method>
433
          </data>
434
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
435
            <Method name="IoDrvReadParameter">
436
              <interface>
437
                <returnType>
438
                  <UDINT />
439
                </returnType>
440
                <inputVars>
441
                  <variable name="pConnector">
442
                    <type>
443
                      <pointer>
444
                        <baseType>
445
                          <derived name="IoConfigConnector" />
446
                        </baseType>
447
                      </pointer>
448
                    </type>
449
                  </variable>
450
                  <variable name="pParameter">
451
                    <type>
452
                      <pointer>
453
                        <baseType>
454
                          <derived name="IoConfigParameter" />
455
                        </baseType>
456
                      </pointer>
457
                    </type>
458
                  </variable>
459
                  <variable name="pData">
460
                    <type>
461
                      <pointer>
462
                        <baseType>
463
                          <BYTE />
464
                        </baseType>
465
                      </pointer>
466
                    </type>
467
                  </variable>
468
                  <variable name="dwBitSize">
469
                    <type>
470
                      <DWORD />
471
                    </type>
472
                  </variable>
473
                  <variable name="dwBitOffset">
474
                    <type>
475
                      <DWORD />
476
                    </type>
477
                  </variable>
478
                </inputVars>
479
              </interface>
480
              <body>
481
                <ST>
482
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF    pConnector = 0 OR pParameter = 0 OR pData = 0 THEN
483
    IoDrvReadParameter := Errors.ERR_PARAMETER;
484
    RETURN; 
485
END_IF
486
487
// All standard parameters of our device are handled by the IO-manager!
488
IoDrvReadParameter := Errors.ERR_FAILED;
489
</xhtml>
490
                </ST>
491
              </body>
492
              <BuildProperties>
493
                <EnableSystemCall>true</EnableSystemCall>
494
              </BuildProperties>
495
              <addData />
496
            </Method>
497
          </data>
498
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
499
            <Method name="IoDrvWriteParameter">
500
              <interface>
501
                <returnType>
502
                  <UDINT />
503
                </returnType>
504
                <inputVars>
505
                  <variable name="pConnector">
506
                    <type>
507
                      <pointer>
508
                        <baseType>
509
                          <derived name="IoConfigConnector" />
510
                        </baseType>
511
                      </pointer>
512
                    </type>
513
                  </variable>
514
                  <variable name="pParameter">
515
                    <type>
516
                      <pointer>
517
                        <baseType>
518
                          <derived name="IoConfigParameter" />
519
                        </baseType>
520
                      </pointer>
521
                    </type>
522
                  </variable>
523
                  <variable name="pData">
524
                    <type>
525
                      <pointer>
526
                        <baseType>
527
                          <BYTE />
528
                        </baseType>
529
                      </pointer>
530
                    </type>
531
                  </variable>
532
                  <variable name="dwBitSize">
533
                    <type>
534
                      <DWORD />
535
                    </type>
536
                  </variable>
537
                  <variable name="dwBitOffset">
538
                    <type>
539
                      <DWORD />
540
                    </type>
541
                  </variable>
542
                </inputVars>
543
                <localVars>
544
                  <variable name="pParam">
545
                    <type>
546
                      <pointer>
547
                        <baseType>
548
                          <derived name="IoConfigParameter" />
549
                        </baseType>
550
                      </pointer>
551
                    </type>
552
                  </variable>
553
                  <variable name="pstDiagString">
554
                    <type>
555
                      <pointer>
556
                        <baseType>
557
                          <string />
558
                        </baseType>
559
                      </pointer>
560
                    </type>
561
                  </variable>
562
                </localVars>
563
              </interface>
564
              <body>
565
                <ST>
566
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 OR pParameter = 0 OR pData = 0 THEN
567
    IoDrvWriteParameter := Errors.ERR_PARAMETER;
568
    RETURN; 
569
END_IF
570
571
IoDrvWriteParameter := Errors.ERR_FAILED;</xhtml>
572
                </ST>
573
              </body>
574
              <BuildProperties>
575
                <EnableSystemCall>true</EnableSystemCall>
576
              </BuildProperties>
577
              <addData />
578
            </Method>
579
          </data>
580
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
581
            <Method name="IoDrvGetConnector">
582
              <interface>
583
                <returnType>
584
                  <pointer>
585
                    <baseType>
586
                      <derived name="IoConfigConnector" />
587
                    </baseType>
588
                  </pointer>
589
                </returnType>
590
                <inputVars>
591
                  <variable name="pResult">
592
                    <type>
593
                      <pointer>
594
                        <baseType>
595
                          <derived name="RTS_IEC_RESULT" />
596
                        </baseType>
597
                      </pointer>
598
                    </type>
599
                  </variable>
600
                </inputVars>
601
              </interface>
602
              <body>
603
                <ST>
604
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF m_pConnector = 0 THEN
605
    IF pResult &lt;&gt; 0 THEN
606
        pResult^ := Errors.ERR_FAILED;
607
    END_IF
608
    IoDrvGetConnector := 0; 
609
    RETURN;
610
END_IF
611
IF pResult &lt;&gt; 0 THEN
612
    pResult^ := Errors.ERR_OK;
613
END_IF
614
IoDrvGetConnector := m_pConnector;
615
616
</xhtml>
617
                </ST>
618
              </body>
619
              <BuildProperties>
620
                <EnableSystemCall>true</EnableSystemCall>
621
              </BuildProperties>
622
              <addData />
623
            </Method>
624
          </data>
625
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
626
            <Method name="IoDrvIdentify">
627
              <interface>
628
                <returnType>
629
                  <UDINT />
630
                </returnType>
631
                <inputVars>
632
                  <variable name="pConnector">
633
                    <type>
634
                      <pointer>
635
                        <baseType>
636
                          <derived name="IoConfigConnector" />
637
                        </baseType>
638
                      </pointer>
639
                    </type>
640
                  </variable>
641
                </inputVars>
642
                <documentation>
643
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
644
                </documentation>
645
              </interface>
646
              <body>
647
                <ST>
648
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvIdentify_Count := IoDrvIdentify_Count + 1;
649
IoDrvIdentify := Errors.ERR_NOTIMPLEMENTED;</xhtml>
650
                </ST>
651
              </body>
652
              <BuildProperties>
653
                <EnableSystemCall>true</EnableSystemCall>
654
              </BuildProperties>
655
              <addData />
656
            </Method>
657
          </data>
658
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
659
            <Method name="IoDrvWatchdogTrigger">
660
              <interface>
661
                <returnType>
662
                  <UDINT />
663
                </returnType>
664
                <inputVars>
665
                  <variable name="pConnector">
666
                    <type>
667
                      <pointer>
668
                        <baseType>
669
                          <derived name="IoConfigConnector" />
670
                        </baseType>
671
                      </pointer>
672
                    </type>
673
                  </variable>
674
                </inputVars>
675
                <documentation>
676
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
677
                </documentation>
678
              </interface>
679
              <body>
680
                <ST>
681
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWatchdogTrigger_Count := IoDrvWatchdogTrigger_Count + 1;
682
IoDrvWatchdogTrigger := Errors.ERR_OK;</xhtml>
683
                </ST>
684
              </body>
685
              <BuildProperties>
686
                <EnableSystemCall>true</EnableSystemCall>
687
              </BuildProperties>
688
              <addData />
689
            </Method>
690
          </data>
691
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
692
            <Method name="IoDrvGetModuleDiagnosis">
693
              <interface>
694
                <returnType>
695
                  <UDINT />
696
                </returnType>
697
                <inputVars>
698
                  <variable name="pConnector">
699
                    <type>
700
                      <pointer>
701
                        <baseType>
702
                          <derived name="IoConfigConnector" />
703
                        </baseType>
704
                      </pointer>
705
                    </type>
706
                  </variable>
707
                </inputVars>
708
              </interface>
709
              <body>
710
                <ST>
711
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 THEN
712
    //we are called from the background task
713
    _xBackGroundDiagStarted := TRUE;
714
END_IF
715
716
//Todo: update connectorflags if something changed
717
718
IoDrvGetModuleDiagnosis_Count := IoDrvGetModuleDiagnosis_Count + 1;
719
IoDrvGetModuleDiagnosis := Errors.ERR_NOTIMPLEMENTED;</xhtml>
720
                </ST>
721
              </body>
722
              <BuildProperties>
723
                <EnableSystemCall>true</EnableSystemCall>
724
              </BuildProperties>
725
              <addData />
726
            </Method>
727
          </data>
728
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
729
            <Method name="IoDrvWriteOutputs">
730
              <interface>
731
                <returnType>
732
                  <UDINT />
733
                </returnType>
734
                <inputVars>
735
                  <variable name="pConnectorMapList">
736
                    <type>
737
                      <pointer>
738
                        <baseType>
739
                          <derived name="IoConfigConnectorMap" />
740
                        </baseType>
741
                      </pointer>
742
                    </type>
743
                  </variable>
744
                  <variable name="nCount">
745
                    <type>
746
                      <DINT />
747
                    </type>
748
                  </variable>
749
                </inputVars>
750
                <localVars>
751
                  <variable name="i">
752
                    <type>
753
                      <DINT />
754
                    </type>
755
                  </variable>
756
                  <variable name="j">
757
                    <type>
758
                      <DINT />
759
                    </type>
760
                  </variable>
761
                  <variable name="wSize">
762
                    <type>
763
                      <WORD />
764
                    </type>
765
                  </variable>
766
                  <variable name="pbyIecAddress">
767
                    <type>
768
                      <pointer>
769
                        <baseType>
770
                          <BYTE />
771
                        </baseType>
772
                      </pointer>
773
                    </type>
774
                  </variable>
775
                  <variable name="bySrcValue">
776
                    <type>
777
                      <BYTE />
778
                    </type>
779
                  </variable>
780
                  <variable name="wSrcIndex">
781
                    <type>
782
                      <WORD />
783
                    </type>
784
                  </variable>
785
                  <variable name="bySrcMask">
786
                    <type>
787
                      <BYTE />
788
                    </type>
789
                  </variable>
790
                  <variable name="wDestIndex">
791
                    <type>
792
                      <WORD />
793
                    </type>
794
                  </variable>
795
                  <variable name="ptr">
796
                    <type>
797
                      <pointer>
798
                        <baseType>
799
                          <BYTE />
800
                        </baseType>
801
                      </pointer>
802
                    </type>
803
                  </variable>
804
                  <variable name="ptrW">
805
                    <type>
806
                      <pointer>
807
                        <baseType>
808
                          <WORD />
809
                        </baseType>
810
                      </pointer>
811
                    </type>
812
                  </variable>
813
                  <variable name="ptrB">
814
                    <type>
815
                      <pointer>
816
                        <baseType>
817
                          <BYTE />
818
                        </baseType>
819
                      </pointer>
820
                    </type>
821
                  </variable>
822
                </localVars>
823
                <documentation>
824
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
825
                </documentation>
826
              </interface>
827
              <body>
828
                <ST>
829
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWriteOutputs_Count := IoDrvWriteOutputs_Count + 1;
830
831
IF pConnectorMapList = 0 OR nCount = 0 THEN
832
    IoDrvWriteOutputs := Errors.ERR_PARAMETER;
833
    RETURN;
834
END_IF
835
836
FOR i:=0 TO nCount - 1 DO
837
    IF (pConnectorMapList[i].dwNumOfChannels = 0) THEN
838
        CONTINUE;
839
    END_IF
840
    FOR j:= 0 TO UDINT_TO_UINT(pConnectorMapList[i].dwNumOfChannels) - 1 DO
841
        wSrcIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8; 
842
        pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress;         
843
        
844
        IF (pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId &gt;= 2000 AND pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId&lt;=2002)
845
            OR (pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId &gt;= 9010 AND pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId&lt;=9016)
846
            OR (pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId &gt;= 9030 AND pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId&lt;=9031) THEN
847
            IF pConnectorMapList[i].pChannelMapList[j].wSize = 1 THEN
848
                bySrcValue := pbyIecAddress[wSrcIndex];
849
                        
850
                IF (pbyIecAddress[wSrcIndex] AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8)) &lt;&gt; 0 THEN
851
                {IF defined (pou:SysCpuSetBit2)}
852
                    SysCpuSetBit2(pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8);         
853
                {ELSE}    
854
                    SysCpuSetBit(pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8);          
855
                {END_IF}    
856
                ELSE
857
                {IF defined (pou:SysCpuResetBit2)}
858
                    SysCpuResetBit2(pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8);               
859
                {ELSE}    
860
                    SysCpuResetBit(pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8);                
861
                {END_IF}    
862
                END_IF          
863
            ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 8 THEN
864
                ptr:= pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific;
865
                ptr^ := pbyIecAddress[wSrcIndex];
866
            END_IF
867
        ELSIF pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId = 2100 THEN
868
            IF pConnectorMapList[i].pChannelMapList[j].wSize = 16 THEN
869
                ptrW:= pbyIecAddress;   
870
                Monarco.wAOut1 := ptrW^;
871
            END_IF
872
        ELSIF pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId = 2101 THEN
873
            IF pConnectorMapList[i].pChannelMapList[j].wSize = 16 THEN
874
                ptrW:= pbyIecAddress;   
875
                Monarco.wAOut2 := ptrW^;
876
            END_IF
877
        END_IF
878
    END_FOR
879
END_FOR
880
881
IoDrvWriteOutputs := Errors.ERR_OK;</xhtml>
882
                </ST>
883
              </body>
884
              <BuildProperties>
885
                <EnableSystemCall>true</EnableSystemCall>
886
              </BuildProperties>
887
              <addData />
888
            </Method>
889
          </data>
890
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
891
            <Method name="IoDrvUpdateMapping">
892
              <interface>
893
                <returnType>
894
                  <UDINT />
895
                </returnType>
896
                <inputVars>
897
                  <variable name="pTaskMapList">
898
                    <type>
899
                      <pointer>
900
                        <baseType>
901
                          <derived name="IoConfigTaskMap" />
902
                        </baseType>
903
                      </pointer>
904
                    </type>
905
                  </variable>
906
                  <variable name="nCount">
907
                    <type>
908
                      <DINT />
909
                    </type>
910
                  </variable>
911
                </inputVars>
912
                <documentation>
913
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
914
                </documentation>
915
              </interface>
916
              <body>
917
                <ST>
918
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateMapping_Count := IoDrvUpdateMapping_Count + 1;
919
920
IF (pTaskMapList = 0) THEN
921
    IoDrvUpdateMapping := Errors.ERR_PARAMETER;
922
    RETURN;
923
END_IF
924
925
IoDrvUpdateMapping := Errors.ERR_OK;</xhtml>
926
                </ST>
927
              </body>
928
              <BuildProperties>
929
                <EnableSystemCall>true</EnableSystemCall>
930
              </BuildProperties>
931
              <addData />
932
            </Method>
933
          </data>
934
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
935
            <Method name="IoDrvUpdateConfiguration">
936
              <interface>
937
                <returnType>
938
                  <UDINT />
939
                </returnType>
940
                <inputVars>
941
                  <variable name="pConnectorList">
942
                    <type>
943
                      <pointer>
944
                        <baseType>
945
                          <derived name="IoConfigConnector" />
946
                        </baseType>
947
                      </pointer>
948
                    </type>
949
                  </variable>
950
                  <variable name="nCount">
951
                    <type>
952
                      <DINT />
953
                    </type>
954
                  </variable>
955
                </inputVars>
956
                <localVars>
957
                  <variable name="pParameter">
958
                    <type>
959
                      <pointer>
960
                        <baseType>
961
                          <derived name="IoConfigParameter" />
962
                        </baseType>
963
                      </pointer>
964
                    </type>
965
                  </variable>
966
                  <variable name="pChild">
967
                    <type>
968
                      <pointer>
969
                        <baseType>
970
                          <derived name="IoConfigConnector" />
971
                        </baseType>
972
                      </pointer>
973
                    </type>
974
                  </variable>
975
                  <variable name="pstConnectorVendorName">
976
                    <type>
977
                      <pointer>
978
                        <baseType>
979
                          <string />
980
                        </baseType>
981
                      </pointer>
982
                    </type>
983
                  </variable>
984
                  <variable name="pstConnectorDeviceName">
985
                    <type>
986
                      <pointer>
987
                        <baseType>
988
                          <string />
989
                        </baseType>
990
                      </pointer>
991
                    </type>
992
                  </variable>
993
                  <variable name="dwTest">
994
                    <type>
995
                      <pointer>
996
                        <baseType>
997
                          <DWORD />
998
                        </baseType>
999
                      </pointer>
1000
                    </type>
1001
                  </variable>
1002
                  <variable name="Result">
1003
                    <type>
1004
                      <derived name="RTS_IEC_RESULT" />
1005
                    </type>
1006
                  </variable>
1007
                </localVars>
1008
                <documentation>
1009
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
1010
                </documentation>
1011
              </interface>
1012
              <body>
1013
                <ST>
1014
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateConfiguration_Count := IoDrvUpdateConfiguration_Count + 1;
1015
IoDrvUpdateConfiguration := Errors.ERR_OK;
1016
1017
IF (pConnectorList = 0) THEN
1018
    // Reset application
1019
    // TODO: Free resources
1020
    RETURN;
1021
END_IF
1022
1023
m_pConnector := IoMgrConfigGetConnector(pConnectorList, ADR(nCount), m_wModuleType, m_dwInstance);
1024
1025
IF m_pConnector = 0 THEN
1026
    IoDrvUpdateConfiguration := ERRORS.ERR_PARAMETER;
1027
    RETURN;
1028
END_IF
1029
1030
//check if device is enabled in the device tree
1031
IF (m_pConnector^.dwFlags AND ConnectorFlags.CF_ENABLE) = 0 THEN
1032
    _bDeactivated := TRUE;
1033
    IoDrvUpdateConfiguration := Errors.ERR_OK;
1034
    RETURN;
1035
END_IF
1036
1037
IF m_pConnector^.hIoDrv = 0 THEN
1038
    m_pConnector^.hIoDrv := m_hInterface;
1039
    m_pConnector^.pFather^.hIoDrv := m_hInterface;
1040
    
1041
    {IF defined (pou:IoMgrConfigSetDiagnosis)}
1042
    IoMgrConfigSetDiagnosis(m_pConnector,
1043
                            ConnectorFlags.CF_DRIVER_AVAILABLE OR
1044
                            ConnectorFlags.CF_CONNECTOR_FOUND OR
1045
                            ConnectorFlags.CF_CONNECTOR_CONFIGURED OR
1046
                            ConnectorFlags.CF_CONNECTOR_ACTIVE);
1047
    {END_IF}
1048
    
1049
    {IF defined (pou:IoMgrConfigSetDiagnosis)}
1050
    IoMgrConfigSetDiagnosis(m_pConnector^.pFather,
1051
                            ConnectorFlags.CF_DRIVER_AVAILABLE OR
1052
                            ConnectorFlags.CF_CONNECTOR_FOUND OR
1053
                            ConnectorFlags.CF_CONNECTOR_CONFIGURED OR
1054
                            ConnectorFlags.CF_CONNECTOR_ACTIVE);
1055
    {END_IF}
1056
1057
    {IF defined (pou:IoMgrSetDriverProperties)}         
1058
        IoMgrSetDriverProperties(m_hInterface, DRVPROP_CONSISTENCY OR DRVPROP_BACKGROUND_GETDIAG);
1059
        //Note: background diagnosis property flag is optional (supported with 3.5.1.0 runtime)
1060
    {END_IF}                        
1061
1062
    //Setup I/O area
1063
    pParameter := IoMgrConfigGetParameter(m_pConnector, 2000);      (* outputs *)
1064
    IF (pParameter &lt;&gt; 0) THEN
1065
        pParameter^.dwDriverSpecific := ADR(Monarco.byDOut);                    
1066
    END_IF
1067
1068
    
1069
    //Go through all childs of the device
1070
    pChild := IoMgrConfigGetFirstChild(m_pConnector, ADR(nCount), m_pConnector);
1071
    WHILE (pChild &lt;&gt; 0) DO
1072
        IF (pChild^.dwFlags AND ConnectorFlags.CF_ENABLE) &lt;&gt; 0 THEN
1073
            pChild^.hIoDrv := m_hInterface; 
1074
            {IF defined (pou:IoMgrConfigSetDiagnosis)}
1075
            IoMgrConfigSetDiagnosis(pChild,
1076
                                    ConnectorFlags.CF_DRIVER_AVAILABLE OR
1077
                                    ConnectorFlags.CF_CONNECTOR_FOUND OR
1078
                                    ConnectorFlags.CF_CONNECTOR_CONFIGURED OR
1079
                                    ConnectorFlags.CF_CONNECTOR_ACTIVE);
1080
            {END_IF}
1081
        END_IF
1082
        pChild := IoMgrConfigGetNextChild(pChild, ADR(nCount), m_pConnector);
1083
    END_WHILE
1084
    
1085
END_IF</xhtml>
1086
                </ST>
1087
              </body>
1088
              <BuildProperties>
1089
                <EnableSystemCall>true</EnableSystemCall>
1090
              </BuildProperties>
1091
              <addData />
1092
            </Method>
1093
          </data>
1094
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1095
            <Method name="IoDrvStartBusCycle">
1096
              <interface>
1097
                <returnType>
1098
                  <UDINT />
1099
                </returnType>
1100
                <inputVars>
1101
                  <variable name="pConnector">
1102
                    <type>
1103
                      <pointer>
1104
                        <baseType>
1105
                          <derived name="IoConfigConnector" />
1106
                        </baseType>
1107
                      </pointer>
1108
                    </type>
1109
                  </variable>
1110
                </inputVars>
1111
                <documentation>
1112
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
1113
                </documentation>
1114
              </interface>
1115
              <body>
1116
                <ST>
1117
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvStartBusCycle_Count := IoDrvStartBusCycle_Count + 1;
1118
1119
//if background diagnosis is not active call IoDrvGetModuleDiagnosis; normally it will be called by the runtime if DRVPROP_BACKGROUND_GETDIAG is set
1120
IF NOT _xBackGroundDiagStarted THEN
1121
    IoDrvGetModuleDiagnosis(m_pConnector); //DRVPROP_BACKGROUND_GETDIAG not set or runtime version &lt; V3.5.1.0
1122
END_IF
1123
1124
//optional: call IoDrvWatchdogTrigger or set driver property DRVPROP_WATCHDOG in UpdateConfiguration
1125
IoDrvWatchdogTrigger(pConnector);
1126
1127
IF NOT _bDeactivated THEN
1128
    Monarco.AfterReadInputs();
1129
    Monarco.BeforeWriteOutputs();
1130
END_IF
1131
1132
IoDrvStartBusCycle := Errors.ERR_OK;</xhtml>
1133
                </ST>
1134
              </body>
1135
              <BuildProperties>
1136
                <EnableSystemCall>true</EnableSystemCall>
1137
              </BuildProperties>
1138
              <addData />
1139
            </Method>
1140
          </data>
1141
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1142
            <Method name="IoDrvScanModules">
1143
              <interface>
1144
                <returnType>
1145
                  <UDINT />
1146
                </returnType>
1147
                <inputVars>
1148
                  <variable name="pConnector">
1149
                    <type>
1150
                      <pointer>
1151
                        <baseType>
1152
                          <derived name="IoConfigConnector" />
1153
                        </baseType>
1154
                      </pointer>
1155
                    </type>
1156
                  </variable>
1157
                  <variable name="ppConnectorList">
1158
                    <type>
1159
                      <pointer>
1160
                        <baseType>
1161
                          <pointer>
1162
                            <baseType>
1163
                              <derived name="IoConfigConnector" />
1164
                            </baseType>
1165
                          </pointer>
1166
                        </baseType>
1167
                      </pointer>
1168
                    </type>
1169
                  </variable>
1170
                  <variable name="pnCount">
1171
                    <type>
1172
                      <pointer>
1173
                        <baseType>
1174
                          <DINT />
1175
                        </baseType>
1176
                      </pointer>
1177
                    </type>
1178
                  </variable>
1179
                </inputVars>
1180
                <documentation>
1181
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
1182
                </documentation>
1183
              </interface>
1184
              <body>
1185
                <ST>
1186
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvScanModules_Count := IoDrvScanModules_Count + 1;
1187
IoDrvScanModules := Errors.ERR_NOTIMPLEMENTED;</xhtml>
1188
                </ST>
1189
              </body>
1190
              <BuildProperties>
1191
                <EnableSystemCall>true</EnableSystemCall>
1192
              </BuildProperties>
1193
              <addData />
1194
            </Method>
1195
          </data>
1196
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1197
            <Method name="IoDrvReadInputs">
1198
              <interface>
1199
                <returnType>
1200
                  <UDINT />
1201
                </returnType>
1202
                <inputVars>
1203
                  <variable name="pConnectorMapList">
1204
                    <type>
1205
                      <pointer>
1206
                        <baseType>
1207
                          <derived name="IoConfigConnectorMap" />
1208
                        </baseType>
1209
                      </pointer>
1210
                    </type>
1211
                  </variable>
1212
                  <variable name="nCount">
1213
                    <type>
1214
                      <DINT />
1215
                    </type>
1216
                  </variable>
1217
                </inputVars>
1218
                <localVars>
1219
                  <variable name="i">
1220
                    <type>
1221
                      <DINT />
1222
                    </type>
1223
                  </variable>
1224
                  <variable name="j">
1225
                    <type>
1226
                      <DINT />
1227
                    </type>
1228
                  </variable>
1229
                  <variable name="wSize">
1230
                    <type>
1231
                      <WORD />
1232
                    </type>
1233
                  </variable>
1234
                  <variable name="pbyIecAddress">
1235
                    <type>
1236
                      <pointer>
1237
                        <baseType>
1238
                          <BYTE />
1239
                        </baseType>
1240
                      </pointer>
1241
                    </type>
1242
                  </variable>
1243
                  <variable name="pwIecAddress">
1244
                    <type>
1245
                      <pointer>
1246
                        <baseType>
1247
                          <WORD />
1248
                        </baseType>
1249
                      </pointer>
1250
                    </type>
1251
                  </variable>
1252
                  <variable name="prIecAddress">
1253
                    <type>
1254
                      <pointer>
1255
                        <baseType>
1256
                          <REAL />
1257
                        </baseType>
1258
                      </pointer>
1259
                    </type>
1260
                  </variable>
1261
                  <variable name="prPiXtendSrc">
1262
                    <type>
1263
                      <pointer>
1264
                        <baseType>
1265
                          <REAL />
1266
                        </baseType>
1267
                      </pointer>
1268
                    </type>
1269
                  </variable>
1270
                  <variable name="bySrcValue">
1271
                    <type>
1272
                      <BYTE />
1273
                    </type>
1274
                  </variable>
1275
                  <variable name="bySrcMask">
1276
                    <type>
1277
                      <BYTE />
1278
                    </type>
1279
                  </variable>
1280
                  <variable name="wSrcIndex">
1281
                    <type>
1282
                      <WORD />
1283
                    </type>
1284
                  </variable>
1285
                  <variable name="wDestIndex">
1286
                    <type>
1287
                      <WORD />
1288
                    </type>
1289
                  </variable>
1290
                </localVars>
1291
                <documentation>
1292
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">{attribute 'conditionalshow' := 'IoDrvDebug'}</xhtml>
1293
                </documentation>
1294
              </interface>
1295
              <body>
1296
                <ST>
1297
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvReadInputs_Count := IoDrvReadInputs_Count + 1;
1298
1299
IF pConnectorMapList = 0 OR nCount = 0 THEN
1300
    IoDrvReadInputs := Errors.ERR_PARAMETER;
1301
    RETURN;
1302
END_IF
1303
1304
FOR i:=0 TO nCount - 1 DO
1305
    IF (pConnectorMapList[i].dwNumOfChannels = 0) THEN
1306
        CONTINUE;
1307
    END_IF
1308
     
1309
    FOR j:= 0 TO UDINT_TO_UINT(pConnectorMapList[i].dwNumOfChannels) - 1 DO     
1310
        IF pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId =1000 THEN
1311
            
1312
            pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress;
1313
            wDestIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8;
1314
            
1315
            IF (pConnectorMapList[i].pChannelMapList[j].wSize = 1) THEN
1316
                IF (Monarco.byDIn AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8)) &lt;&gt; 0 THEN
1317
                {IF defined (pou:SysCpuSetBit2)}
1318
                    SysCpuSetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);          
1319
                {ELSE}    
1320
                    SysCpuSetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);           
1321
                {END_IF}    
1322
                ELSE
1323
                {IF defined (pou:SysCpuResetBit2)}
1324
                    SysCpuResetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);            
1325
                {ELSE}    
1326
                    SysCpuResetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);         
1327
                {END_IF}    
1328
                END_IF                      
1329
            ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 8 THEN
1330
                pbyIecAddress[wDestIndex] := Monarco.byDIn;
1331
            END_IF
1332
                        
1333
        ELSIF pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId = 1110  THEN
1334
            pwIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress;
1335
            pwIecAddress^:= Monarco.wAIn1;
1336
        ELSIF pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId = 1111  THEN
1337
            pwIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress;
1338
            pwIecAddress^:= Monarco.wAIn2;      
1339
        END_IF      
1340
    END_FOR
1341
END_FOR
1342
1343
IoDrvReadInputs := Errors.ERR_OK;</xhtml>
1344
                </ST>
1345
              </body>
1346
              <BuildProperties>
1347
                <EnableSystemCall>true</EnableSystemCall>
1348
              </BuildProperties>
1349
              <addData />
1350
            </Method>
1351
          </data>
1352
          <data name="http://www.3s-software.com/plcopenxml/buildproperties" handleUnknown="implementation">
1353
            <BuildProperties>
1354
              <CompilerDefines>IoDrvDebug</CompilerDefines>
1355
            </BuildProperties>
1356
          </data>
1357
        </addData>
1358
      </pou>
1359
      <pou name="MonarcoItf" pouType="functionBlock">
1360
        <interface>
1361
          <inputVars>
1362
            <variable name="byDOut">
1363
              <type>
1364
                <BYTE />
1365
              </type>
1366
            </variable>
1367
            <variable name="wAOut1">
1368
              <type>
1369
                <WORD />
1370
              </type>
1371
            </variable>
1372
            <variable name="wAOut2">
1373
              <type>
1374
                <WORD />
1375
              </type>
1376
            </variable>
1377
          </inputVars>
1378
          <outputVars>
1379
            <variable name="byDIn">
1380
              <type>
1381
                <BYTE />
1382
              </type>
1383
            </variable>
1384
            <variable name="wAIn1">
1385
              <type>
1386
                <WORD />
1387
              </type>
1388
            </variable>
1389
            <variable name="wAIn2">
1390
              <type>
1391
                <WORD />
1392
              </type>
1393
            </variable>
1394
          </outputVars>
1395
          <localVars>
1396
            <variable name="_xInit">
1397
              <type>
1398
                <BOOL />
1399
              </type>
1400
              <initialValue>
1401
                <simpleValue value="TRUE" />
1402
              </initialValue>
1403
            </variable>
1404
            <variable name="stHwConfig">
1405
              <type>
1406
                <derived name="stHWConfig1" />
1407
              </type>
1408
              <documentation>
1409
                <xhtml xmlns="http://www.w3.org/1999/xhtml">Inputs</xhtml>
1410
              </documentation>
1411
            </variable>
1412
            <variable name="stAOut">
1413
              <type>
1414
                <derived name="stAOut" />
1415
              </type>
1416
            </variable>
1417
            <variable name="stDOut">
1418
              <type>
1419
                <derived name="stDOut" />
1420
              </type>
1421
            </variable>
1422
            <variable name="byLeds">
1423
              <type>
1424
                <BYTE />
1425
              </type>
1426
            </variable>
1427
            <variable name="udiPWM1freq">
1428
              <type>
1429
                <UDINT />
1430
              </type>
1431
            </variable>
1432
            <variable name="rDutyCycleDOut1">
1433
              <type>
1434
                <REAL />
1435
              </type>
1436
            </variable>
1437
            <variable name="rDutyCycleDOut2">
1438
              <type>
1439
                <REAL />
1440
              </type>
1441
            </variable>
1442
            <variable name="rDutyCycleDOut3">
1443
              <type>
1444
                <REAL />
1445
              </type>
1446
            </variable>
1447
            <variable name="udiPWM2freq">
1448
              <type>
1449
                <UDINT />
1450
              </type>
1451
            </variable>
1452
            <variable name="rDutyCycleDOut4">
1453
              <type>
1454
                <REAL />
1455
              </type>
1456
            </variable>
1457
            <variable name="xOperational">
1458
              <type>
1459
                <BOOL />
1460
              </type>
1461
              <documentation>
1462
                <xhtml xmlns="http://www.w3.org/1999/xhtml">Outputs</xhtml>
1463
              </documentation>
1464
            </variable>
1465
            <variable name="stDIn">
1466
              <type>
1467
                <derived name="stDIn" />
1468
              </type>
1469
            </variable>
1470
            <variable name="stAIn">
1471
              <type>
1472
                <derived name="stAIn" />
1473
              </type>
1474
            </variable>
1475
            <variable name="stCounter1Config">
1476
              <type>
1477
                <derived name="stCounter1Config" />
1478
              </type>
1479
            </variable>
1480
            <variable name="stCounter2Config">
1481
              <type>
1482
                <derived name="stCounter2Config" />
1483
              </type>
1484
            </variable>
1485
            <variable name="stPWM1">
1486
              <type>
1487
                <derived name="stPWM1" />
1488
              </type>
1489
            </variable>
1490
            <variable name="stPWM2">
1491
              <type>
1492
                <derived name="stPWM2" />
1493
              </type>
1494
            </variable>
1495
            <variable name="stHATinfo">
1496
              <type>
1497
                <derived name="stHATinfo" />
1498
              </type>
1499
            </variable>
1500
            <variable name="eComStatus">
1501
              <type>
1502
                <derived name="eMonarcoComStatus" />
1503
              </type>
1504
            </variable>
1505
            <variable name="_uiNumberOfDevices">
1506
              <type>
1507
                <INT />
1508
              </type>
1509
              <documentation>
1510
                <xhtml xmlns="http://www.w3.org/1999/xhtml">Parameters</xhtml>
1511
              </documentation>
1512
            </variable>
1513
            <variable name="_stControlByte">
1514
              <type>
1515
                <derived name="stControlByte" />
1516
              </type>
1517
            </variable>
1518
            <variable name="_ControlByte8">
1519
              <type>
1520
                <BYTE />
1521
              </type>
1522
            </variable>
1523
            <variable name="_uiWatchDog">
1524
              <type>
1525
                <UINT />
1526
              </type>
1527
            </variable>
1528
            <variable name="_uiLastWatchDog">
1529
              <type>
1530
                <UINT />
1531
              </type>
1532
            </variable>
1533
            <variable name="_stRS485Mode">
1534
              <type>
1535
                <derived name="stRS485Mode" />
1536
              </type>
1537
            </variable>
1538
            <variable name="_stHWConfig1">
1539
              <type>
1540
                <derived name="stHWConfig1" />
1541
              </type>
1542
            </variable>
1543
            <variable name="_stLastCounter1Cfg">
1544
              <type>
1545
                <derived name="stCounter1Config" />
1546
              </type>
1547
            </variable>
1548
            <variable name="_stLastCounter2Cfg">
1549
              <type>
1550
                <derived name="stCounter2Config" />
1551
              </type>
1552
            </variable>
1553
            <variable name="_AfterReadInputs">
1554
              <type>
1555
                <UINT />
1556
              </type>
1557
            </variable>
1558
            <variable name="_BeforeWriteOutputs">
1559
              <type>
1560
                <UINT />
1561
              </type>
1562
            </variable>
1563
            <variable name="_abyIntTxBuf">
1564
              <type>
1565
                <array>
1566
                  <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1567
                  <baseType>
1568
                    <BYTE />
1569
                  </baseType>
1570
                </array>
1571
              </type>
1572
            </variable>
1573
            <variable name="_abyIntRxBuf">
1574
              <type>
1575
                <array>
1576
                  <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1577
                  <baseType>
1578
                    <BYTE />
1579
                  </baseType>
1580
                </array>
1581
              </type>
1582
            </variable>
1583
          </localVars>
1584
          <addData>
1585
            <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
1586
              <Inheritance>
1587
                <Extends>SPI</Extends>
1588
              </Inheritance>
1589
            </data>
1590
          </addData>
1591
        </interface>
1592
        <body>
1593
          <ST>
1594
            <xhtml xmlns="http://www.w3.org/1999/xhtml">//********************************
1595
//  base SPI implementation 
1596
//********************************
1597
SUPER^();
1598
1599
//********************************
1600
//      get SPI State 
1601
//********************************
1602
CASE _iState OF
1603
0:
1604
    IF SUPER^.init() THEN
1605
        // get only once
1606
        THIS^.getHATinfo();
1607
        _iState := 1;
1608
    END_IF  
1609
1610
1:  _iState := 10;
1611
END_CASE
1612
1613
//********************************
1614
//  is device operational 
1615
//********************************
1616
IF _iState = 10 THEN
1617
    xOperational        :=  TRUE;
1618
ELSE
1619
    xOperational        :=  FALSE;
1620
END_IF
1621
1622
1623
</xhtml>
1624
          </ST>
1625
        </body>
1626
        <addData>
1627
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1628
            <Method name="getHATinfo">
1629
              <interface>
1630
                <localVars>
1631
                  <variable name="wValue">
1632
                    <type>
1633
                      <WORD />
1634
                    </type>
1635
                  </variable>
1636
                  <variable name="eCmd">
1637
                    <type>
1638
                      <derived name="eServiceCommand" />
1639
                    </type>
1640
                  </variable>
1641
                  <variable name="eComStatus">
1642
                    <type>
1643
                      <derived name="eMonarcoComStatus" />
1644
                    </type>
1645
                  </variable>
1646
                  <variable name="J">
1647
                    <type>
1648
                      <INT />
1649
                    </type>
1650
                  </variable>
1651
                  <variable name="wReqAdr">
1652
                    <type>
1653
                      <WORD />
1654
                    </type>
1655
                  </variable>
1656
                  <variable name="awSrvAnwser">
1657
                    <type>
1658
                      <array>
1659
                        <dimension lower="1" upper="9" />
1660
                        <baseType>
1661
                          <WORD />
1662
                        </baseType>
1663
                      </array>
1664
                    </type>
1665
                  </variable>
1666
                  <variable name="cpu_l">
1667
                    <type>
1668
                      <DWORD />
1669
                    </type>
1670
                  </variable>
1671
                  <variable name="cpu_h">
1672
                    <type>
1673
                      <DWORD />
1674
                    </type>
1675
                  </variable>
1676
                  <variable name="lwcpu">
1677
                    <type>
1678
                      <LWORD />
1679
                    </type>
1680
                  </variable>
1681
                </localVars>
1682
                <addData>
1683
                  <data name="http://www.3s-software.com/plcopenxml/accessmodifiers" handleUnknown="implementation">
1684
                    <AccessModifiers Private="true" />
1685
                  </data>
1686
                </addData>
1687
                <documentation>
1688
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">Read current FW, HW revision and CPU-ID       </xhtml>
1689
                </documentation>
1690
              </interface>
1691
              <body>
1692
                <ST>
1693
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">//********************************
1694
//Read FW, HW revision and CPU-ID 
1695
//********************************
1696
FOR J := 1 TO 9 DO
1697
    CASE J OF
1698
        1:      eCmd := eServiceCommand.SDC_FIXED_STATUSWORD; //bogus question (ABCD)
1699
        2:      eCmd := eServiceCommand.SDC_FIXED_FWVERL;
1700
        3:      eCmd := eServiceCommand.SDC_FIXED_FWVERH;
1701
        4:      eCmd := eServiceCommand.SDC_FIXED_HWVERL;
1702
        5:      eCmd := eServiceCommand.SDC_FIXED_HWVERH;
1703
        6:      eCmd := eServiceCommand.SDC_FIXED_CPUID1;
1704
        7:      eCmd := eServiceCommand.SDC_FIXED_CPUID2;
1705
        8:      eCmd := eServiceCommand.SDC_FIXED_CPUID3;
1706
        9:      eCmd := eServiceCommand.SDC_FIXED_CPUID4;
1707
    END_CASE
1708
    wValue              := TO_WORD(eServiceCommand.SDC_FIXED_STATUSWORD);
1709
    eComStatus          := THIS^.ServiceRequest( wValue := wValue, eCommand := eCmd, xWrite := FALSE );
1710
    // Get result
1711
    eComStatus          := THIS^.dataTransfer();
1712
    awSrvAnwser[J]      := MEM.PackBytesToWord(_abyIntRxBuf[1], _abyIntRxBuf[0]);
1713
END_FOR
1714
1715
// Store anwsers in status
1716
THIS^.stHATinfo.dwFWVersion := MEM.PackWordsToDword(awSrvAnwser[3],awSrvAnwser[2]);
1717
THIS^.stHATinfo.dwHWversion := MEM.PackWordsToDword(awSrvAnwser[5],awSrvAnwser[4]);
1718
cpu_l                       := MEM.PackWordsToDword(awSrvAnwser[7],awSrvAnwser[6]);
1719
cpu_h                       := MEM.PackWordsToDword(awSrvAnwser[9],awSrvAnwser[8]);
1720
lwcpu                       := cpu_h;
1721
lwcpu                       := SHL(lwcpu,32);
1722
THIS^.stHATinfo.lwCpuID     := lwcpu OR cpu_l;</xhtml>
1723
                </ST>
1724
              </body>
1725
              <addData />
1726
            </Method>
1727
          </data>
1728
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1729
            <Method name="getCRC">
1730
              <interface>
1731
                <returnType>
1732
                  <WORD />
1733
                </returnType>
1734
                <inputVars>
1735
                  <variable name="abyBuf">
1736
                    <type>
1737
                      <array>
1738
                        <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1739
                        <baseType>
1740
                          <BYTE />
1741
                        </baseType>
1742
                      </array>
1743
                    </type>
1744
                  </variable>
1745
                </inputVars>
1746
                <localVars>
1747
                  <variable name="uiSizeTx">
1748
                    <type>
1749
                      <UINT />
1750
                    </type>
1751
                  </variable>
1752
                  <variable name="udiCRCLen">
1753
                    <type>
1754
                      <UDINT />
1755
                    </type>
1756
                  </variable>
1757
                  <variable name="pByteTx">
1758
                    <type>
1759
                      <pointer>
1760
                        <baseType>
1761
                          <BYTE />
1762
                        </baseType>
1763
                      </pointer>
1764
                    </type>
1765
                  </variable>
1766
                  <variable name="CheckSum">
1767
                    <type>
1768
                      <WORD />
1769
                    </type>
1770
                  </variable>
1771
                </localVars>
1772
                <addData>
1773
                  <data name="http://www.3s-software.com/plcopenxml/accessmodifiers" handleUnknown="implementation">
1774
                    <AccessModifiers Private="true" />
1775
                  </data>
1776
                </addData>
1777
                <documentation>
1778
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">Returns CRC16 checksum for input buffer
1779
byte 24 and 25 are not taken in account, they hold the crc16 itself</xhtml>
1780
                </documentation>
1781
              </interface>
1782
              <body>
1783
                <ST>
1784
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">// startadress of bytes
1785
pByteTx                             := ADR(abyBuf); 
1786
1787
// calculate CRC-16 checksum, beware that for the checksum calculation, we need to skip the checksum itself
1788
uiSizeTx                            := SIZEOF(abyBuf);
1789
1790
// should always be 24 / 16#18
1791
udiCRCLen                           := (uiSizeTx -16#02);   
1792
    
1793
CheckSum                            := MEM.CRC16_Modbus( pByteTx, TO_UINT(udiCRCLen) );
1794
1795
// return checksum
1796
getCRC                              := CheckSum;</xhtml>
1797
                </ST>
1798
              </body>
1799
              <addData />
1800
            </Method>
1801
          </data>
1802
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1803
            <Method name="dataTransfer">
1804
              <interface>
1805
                <returnType>
1806
                  <derived name="eMonarcoComStatus" />
1807
                </returnType>
1808
                <localVars>
1809
                  <variable name="tmpRxBuf">
1810
                    <type>
1811
                      <array>
1812
                        <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1813
                        <baseType>
1814
                          <BYTE />
1815
                        </baseType>
1816
                      </array>
1817
                    </type>
1818
                  </variable>
1819
                  <variable name="udiBufSize">
1820
                    <type>
1821
                      <UDINT />
1822
                    </type>
1823
                  </variable>
1824
                  <variable name="xDone">
1825
                    <type>
1826
                      <BOOL />
1827
                    </type>
1828
                  </variable>
1829
                  <variable name="CRC">
1830
                    <type>
1831
                      <WORD />
1832
                    </type>
1833
                  </variable>
1834
                </localVars>
1835
                <addData>
1836
                  <data name="http://www.3s-software.com/plcopenxml/accessmodifiers" handleUnknown="implementation">
1837
                    <AccessModifiers Private="true" />
1838
                  </data>
1839
                </addData>
1840
                <documentation>
1841
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Handles the SPI data transfer to the Monarco Hat </xhtml>
1842
                </documentation>
1843
              </interface>
1844
              <body>
1845
                <ST>
1846
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">//init temporay buffer before filling;
1847
//flush(tmpRxBuf);
1848
1849
// determine size of buffer
1850
udiBufSize                      := SIZEOF( THIS^._abyIntTxBuf );
1851
1852
(* Sets CRC16 checksum, for Tx byte array [24] and [25]*)
1853
CRC                             := THIS^.getCRC( THIS^._abyIntTxBuf );
1854
THIS^._abyIntTxBuf[24]          := WORD_TO_BYTE(CRC);
1855
THIS^._abyIntTxBuf[25]          := WORD_TO_BYTE(SHR(CRC,8));
1856
1857
// Send, Recv
1858
xDone := THIS^.transferExt( pabyTxBuffer := ADR( THIS^._abyIntTxBuf ), 
1859
                         pabyRxBuffer := ADR( tmpRxBuf ),       // write result into a temporary buffer for post-analysis. Beware that the received answser is from the last question, not the current question.
1860
                         udiLen       := udiBufSize, 
1861
                         uiDelayus    := 5,
1862
                         udispeedHz   := 0); 
1863
1864
IF NOT xDone THEN 
1865
    // Send, Recv failed
1866
    DataTransfer := eMonarcoComStatus.ERROR;
1867
ELSE
1868
    // OK?
1869
    IF THIS^.checkCRC(tmpRxBuf) THEN
1870
        //CRC okay, return the recv buffer
1871
        THIS^._abyIntRxBuf  := tmpRxBuf;
1872
        DataTransfer        := eMonarcoComStatus.SUCCES;
1873
    ELSE
1874
        //CRC not okay, return an empty buffer
1875
        flush(tmpRxBuf);
1876
        THIS^._abyIntRxBuf  := tmpRxBuf;
1877
        DataTransfer        := eMonarcoComStatus.CrcFail;
1878
    END_IF
1879
END_IF;</xhtml>
1880
                </ST>
1881
              </body>
1882
              <addData />
1883
            </Method>
1884
          </data>
1885
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1886
            <Method name="flush">
1887
              <interface>
1888
                <returnType>
1889
                  <BOOL />
1890
                </returnType>
1891
                <inputVars>
1892
                  <variable name="abyRxBuf">
1893
                    <type>
1894
                      <array>
1895
                        <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1896
                        <baseType>
1897
                          <BYTE />
1898
                        </baseType>
1899
                      </array>
1900
                    </type>
1901
                  </variable>
1902
                </inputVars>
1903
                <localVars>
1904
                  <variable name="i">
1905
                    <type>
1906
                      <UINT />
1907
                    </type>
1908
                  </variable>
1909
                </localVars>
1910
                <addData>
1911
                  <data name="http://www.3s-software.com/plcopenxml/accessmodifiers" handleUnknown="implementation">
1912
                    <AccessModifiers Private="true" />
1913
                  </data>
1914
                </addData>
1915
                <documentation>
1916
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Initialises the entire buffer with 16#00 (flush)</xhtml>
1917
                </documentation>
1918
              </interface>
1919
              <body>
1920
                <ST>
1921
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">//flush the temporary receive buffer before filling;
1922
FOR i :=0 TO (ParamList.MONARCO_STRUCT_SIZE-1) DO
1923
    abyRxBuf[i] := 16#00;
1924
END_FOR
1925
flush := TRUE;</xhtml>
1926
                </ST>
1927
              </body>
1928
              <addData />
1929
            </Method>
1930
          </data>
1931
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1932
            <Method name="checkCRC">
1933
              <interface>
1934
                <returnType>
1935
                  <BOOL />
1936
                </returnType>
1937
                <inputVars>
1938
                  <variable name="abyRxBuf">
1939
                    <type>
1940
                      <array>
1941
                        <dimension lower="0" upper="(ParamList.MONARCO_STRUCT_SIZE - 1)" />
1942
                        <baseType>
1943
                          <BYTE />
1944
                        </baseType>
1945
                      </array>
1946
                    </type>
1947
                  </variable>
1948
                </inputVars>
1949
                <localVars>
1950
                  <variable name="CRC">
1951
                    <type>
1952
                      <WORD />
1953
                    </type>
1954
                  </variable>
1955
                  <variable name="CRCLo">
1956
                    <type>
1957
                      <BYTE />
1958
                    </type>
1959
                  </variable>
1960
                  <variable name="CRCHi">
1961
                    <type>
1962
                      <BYTE />
1963
                    </type>
1964
                  </variable>
1965
                </localVars>
1966
                <addData>
1967
                  <data name="http://www.3s-software.com/plcopenxml/accessmodifiers" handleUnknown="implementation">
1968
                    <AccessModifiers Private="true" />
1969
                  </data>
1970
                </addData>
1971
              </interface>
1972
              <body>
1973
                <ST>
1974
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">CRC           := THIS^.GetCRC(abyRxBuf);
1975
CRCHi           := WORD_TO_BYTE(CRC);
1976
CRCLo           := WORD_TO_BYTE(SHR(CRC,8));
1977
1978
// check to self calculated CRC against the sent CRC, Equal = OK
1979
IF (CRCHi = abyRxBuf[ParamList.MONARCO_STRUCT_SIZE - 2]) AND (CRCLo = abyRxBuf[ParamList.MONARCO_STRUCT_SIZE - 1]) THEN 
1980
    checkCRC := TRUE;
1981
ELSE
1982
    checkCRC := FALSE;
1983
END_IF;</xhtml>
1984
                </ST>
1985
              </body>
1986
              <addData />
1987
            </Method>
1988
          </data>
1989
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1990
            <Method name="setDutyCycleDOut4">
1991
              <interface>
1992
                <returnType>
1993
                  <derived name="eMonarcoComStatus" />
1994
                </returnType>
1995
                <inputVars>
1996
                  <variable name="rDutyCycle">
1997
                    <type>
1998
                      <REAL />
1999
                    </type>
2000
                    <documentation>
2001
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle [0.0 .. 1.0] with 0 = 0% and 1 = 100%</xhtml>
2002
                    </documentation>
2003
                  </variable>
2004
                </inputVars>
2005
                <localVars>
2006
                  <variable name="wDC">
2007
                    <type>
2008
                      <WORD />
2009
                    </type>
2010
                    <documentation>
2011
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle as a Word (0..65535)</xhtml>
2012
                    </documentation>
2013
                  </variable>
2014
                </localVars>
2015
                <documentation>
2016
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Set PWM1 Channel B (DOUT2) duty cycle   </xhtml>
2017
                </documentation>
2018
              </interface>
2019
              <body>
2020
                <ST>
2021
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">wDC := getDutyCycle( rDutyCycle := rDutyCycle );
2022
2023
//   18.0   2.0  PWM2 Dutycycle ch A
2024
THIS^._abyIntTxBuf[18]              := WORD_TO_BYTE(wDC);   // bitmask to protect prescaler
2025
THIS^._abyIntTxBuf[19]              := WORD_TO_BYTE(SHR(wDC,8));</xhtml>
2026
                </ST>
2027
              </body>
2028
              <addData />
2029
            </Method>
2030
          </data>
2031
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2032
            <Method name="setDutyCycleDOut2">
2033
              <interface>
2034
                <returnType>
2035
                  <derived name="eMonarcoComStatus" />
2036
                </returnType>
2037
                <inputVars>
2038
                  <variable name="rDutyCycle">
2039
                    <type>
2040
                      <REAL />
2041
                    </type>
2042
                    <documentation>
2043
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle [0.0 .. 1.0] with 0 = 0% and 1 = 100%</xhtml>
2044
                    </documentation>
2045
                  </variable>
2046
                </inputVars>
2047
                <localVars>
2048
                  <variable name="wDC">
2049
                    <type>
2050
                      <WORD />
2051
                    </type>
2052
                    <documentation>
2053
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle as a Word (0..65535)</xhtml>
2054
                    </documentation>
2055
                  </variable>
2056
                </localVars>
2057
                <documentation>
2058
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Set PWM1 Channel B (DOUT2) duty cycle   </xhtml>
2059
                </documentation>
2060
              </interface>
2061
              <body>
2062
                <ST>
2063
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">wDC := getDutyCycle( rDutyCycle := rDutyCycle );
2064
2065
//   12.0   2.0  PWM1 Dutycycle ch B
2066
THIS^._abyIntTxBuf[12]              := WORD_TO_BYTE(wDC);   // bitmask to protect prescaler
2067
THIS^._abyIntTxBuf[13]              := WORD_TO_BYTE(SHR(wDC,8));</xhtml>
2068
                </ST>
2069
              </body>
2070
              <addData />
2071
            </Method>
2072
          </data>
2073
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2074
            <Method name="setPWM1freq">
2075
              <interface>
2076
                <returnType>
2077
                  <derived name="eMonarcoComStatus" />
2078
                </returnType>
2079
                <inputVars>
2080
                  <variable name="udiHz">
2081
                    <type>
2082
                      <UDINT />
2083
                    </type>
2084
                    <documentation>
2085
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> base frequency of the PWM, anywhere from 1Hz to 100kHz (10 Hz = 10, 100kHz = 100000)
2086
 A setting higher then 100kHz and lower then 1Hz will be limited to 100kHz and 1Hz.</xhtml>
2087
                    </documentation>
2088
                  </variable>
2089
                </inputVars>
2090
                <localVars>
2091
                  <variable name="_uidiHz">
2092
                    <type>
2093
                      <UDINT />
2094
                    </type>
2095
                  </variable>
2096
                  <variable name="ePrescale">
2097
                    <type>
2098
                      <derived name="ePrescaler" />
2099
                    </type>
2100
                  </variable>
2101
                  <variable name="uiRangeLow">
2102
                    <type>
2103
                      <UINT />
2104
                    </type>
2105
                    <documentation>
2106
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Determined prefered prescaler</xhtml>
2107
                    </documentation>
2108
                  </variable>
2109
                  <variable name="uiRangeHigh">
2110
                    <type>
2111
                      <UINT />
2112
                    </type>
2113
                  </variable>
2114
                  <variable name="uiTOP">
2115
                    <type>
2116
                      <UINT />
2117
                    </type>
2118
                  </variable>
2119
                  <variable name="fPWM">
2120
                    <type>
2121
                      <WORD />
2122
                    </type>
2123
                    <documentation>
2124
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Determined TOP setting</xhtml>
2125
                    </documentation>
2126
                  </variable>
2127
                </localVars>
2128
                <documentation>
2129
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">  Just set a frequency between 1 and 100 kHz and the PWM will be set according to below settings;
2130
2131
  f_PWM = 32 MHz / ( prescaler × TOP )
2132
2133
 Where **prescaler can be (1, 8, 64, 512)** and **TOP can be 0 to 65532**.
2134
 TOP is represented by 14bit value in process data and then multiplied by 4.
2135
 Modulated value is represented by 16 bits in process data and internally scaled to 0 to TOP range.
2136
 The lowest possible prescaler should be preferred for given frequency.
2137
 Because this leads to a bigger value of TOP and so a better resolution of the modulated value.
2138
2139
    ==========  ================================  =================================
2140
 Prescaler   Recommended range low boundary    Recommended range high boundary
2141
    ==========  ================================  =================================
2142
    1           ≥ 1 kHz TOP = 32000               ≤ 100 kHz TOP = 320
2143
    8           ≥ 100 Hz TOP = 40000              &lt; 1 kHz TOP = 4000
2144
    64          ≥ 10 Hz TOP = 50000               &lt; 100 Hz TOP = 5000
2145
    512         ≥ 1 Hz TOP = 62500                &lt; 10 Hz TOP = 6250
2146
    ==========  ================================  =================================
2147
2148
 Example:
2149
  f_PWM = 10Hz =&gt; 16#C352 = 50002
2150
   prescaler = 64, TOP = 50000 =&gt; 10 = 32x10^6 / (64 x 50000)
2151
</xhtml>
2152
                </documentation>
2153
              </interface>
2154
              <body>
2155
                <ST>
2156
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">/// clip the input Hz on lower and upper bound, so;
2157
_uidiHz := LIMIT( 1, udiHz, 100000);
2158
2159
/// Determine prescaler and TOP according to table
2160
CASE _uidiHz OF
2161
    1..9            : ePrescale     := ePrescaler.ScaleFactor512;
2162
                      uiTOP         := TO_UINT( (32000000/ 512/ _uidiHz));// interpolate between 1 and 9Hz
2163
    
2164
    10..99          : ePrescale     := ePrescaler.ScaleFactor64;
2165
                      uiTOP         := TO_UINT( (32000000/ 64/ _uidiHz)); // interpolate between 10 and 100Hz
2166
    
2167
    100..999        : ePrescale     := ePrescaler.ScaleFactor8;
2168
                      uiTOP         := TO_UINT( (32000000/ 8/ _uidiHz));// interpolate between 100 and 1000Hz
2169
        
2170
    1000..100000    : ePrescale     := ePrescaler.ScaleFactor1;
2171
                      uiTOP         := TO_UINT( (32000000/ 1/ _uidiHz));// interpolate between 1000 and 100000Hz
2172
END_CASE
2173
2174
/// Now set prescaler
2175
CASE ePrescale OF 
2176
///  00  0 : prescaler =   1
2177
    ePrescaler.ScaleFactor1 :   fPWM.0 := FALSE;
2178
                                fPWM.1 := FALSE;
2179
///  01  1 : prescaler =   8
2180
    ePrescaler.ScaleFactor8 :   fPWM.0 := TRUE;
2181
                                fPWM.1 := FALSE;
2182
///  10  2 : prescaler =  64    
2183
    ePrescaler.ScaleFactor64 :  fPWM.0 := FALSE;
2184
                                fPWM.1 := TRUE;
2185
///  11  3 : prescaler = 512    
2186
    ePrescaler.ScaleFactor512 : fPWM.0 := TRUE;
2187
                                fPWM.1 := TRUE;
2188
END_CASE
2189
2190
//   8.0   2.0  PWM1 frequency
2191
THIS^._abyIntTxBuf[8]           := WORD_TO_BYTE(fPWM) AND 16#FC;    // bitmask to protect prescaler
2192
THIS^._abyIntTxBuf[9]           := WORD_TO_BYTE(SHR(fPWM,8));</xhtml>
2193
                </ST>
2194
              </body>
2195
              <addData />
2196
            </Method>
2197
          </data>
2198
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2199
            <Method name="setDutyCycleDOut3">
2200
              <interface>
2201
                <returnType>
2202
                  <derived name="eMonarcoComStatus" />
2203
                </returnType>
2204
                <inputVars>
2205
                  <variable name="rDutyCycle">
2206
                    <type>
2207
                      <REAL />
2208
                    </type>
2209
                    <documentation>
2210
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle [0.0 .. 1.0] with 0 = 0% and 1 = 100%</xhtml>
2211
                    </documentation>
2212
                  </variable>
2213
                </inputVars>
2214
                <localVars>
2215
                  <variable name="wDC">
2216
                    <type>
2217
                      <WORD />
2218
                    </type>
2219
                    <documentation>
2220
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle as a Word (0..65535)</xhtml>
2221
                    </documentation>
2222
                  </variable>
2223
                </localVars>
2224
                <documentation>
2225
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Set PWM1 Channel C (DOUT3) duty cycle   </xhtml>
2226
                </documentation>
2227
              </interface>
2228
              <body>
2229
                <ST>
2230
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">wDC := getDutyCycle( rDutyCycle := rDutyCycle );
2231
2232
//   12.0   2.0  PWM1 Dutycycle ch C
2233
THIS^._abyIntTxBuf[14]              := WORD_TO_BYTE(wDC);   // bitmask to protect prescaler
2234
THIS^._abyIntTxBuf[15]              := WORD_TO_BYTE(SHR(wDC,8));</xhtml>
2235
                </ST>
2236
              </body>
2237
              <addData />
2238
            </Method>
2239
          </data>
2240
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2241
            <Method name="setDutyCycleDOut1">
2242
              <interface>
2243
                <returnType>
2244
                  <derived name="eMonarcoComStatus" />
2245
                </returnType>
2246
                <inputVars>
2247
                  <variable name="rDutyCycle">
2248
                    <type>
2249
                      <REAL />
2250
                    </type>
2251
                    <documentation>
2252
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle [0.0 .. 1.0] with 0 = 0% and 1 = 100%</xhtml>
2253
                    </documentation>
2254
                  </variable>
2255
                </inputVars>
2256
                <localVars>
2257
                  <variable name="wDC">
2258
                    <type>
2259
                      <WORD />
2260
                    </type>
2261
                    <documentation>
2262
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Duty Cycle as a Word (0..65535)</xhtml>
2263
                    </documentation>
2264
                  </variable>
2265
                </localVars>
2266
                <documentation>
2267
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Set PWM1 Channel A (DOUT1) duty cycle   </xhtml>
2268
                </documentation>
2269
              </interface>
2270
              <body>
2271
                <ST>
2272
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">wDC := getDutyCycle( rDutyCycle := rDutyCycle );
2273
2274
//   10.0   2.0  PWM1 Dutycycle ch A
2275
THIS^._abyIntTxBuf[10]              := WORD_TO_BYTE(wDC);   // bitmask to protect prescaler
2276
THIS^._abyIntTxBuf[11]              := WORD_TO_BYTE(SHR(wDC,8));</xhtml>
2277
                </ST>
2278
              </body>
2279
              <addData />
2280
            </Method>
2281
          </data>
2282
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2283
            <Method name="setAOutWord">
2284
              <interface>
2285
                <returnType>
2286
                  <derived name="eMonarcoComStatus" />
2287
                </returnType>
2288
                <inputVars>
2289
                  <variable name="wAOut1">
2290
                    <type>
2291
                      <WORD />
2292
                    </type>
2293
                  </variable>
2294
                  <variable name="wAOut2">
2295
                    <type>
2296
                      <WORD />
2297
                    </type>
2298
                  </variable>
2299
                </inputVars>
2300
                <localVars>
2301
                  <variable name="v1">
2302
                    <type>
2303
                      <WORD />
2304
                    </type>
2305
                  </variable>
2306
                  <variable name="v2">
2307
                    <type>
2308
                      <WORD />
2309
                    </type>
2310
                  </variable>
2311
                </localVars>
2312
                <documentation>
2313
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Write Analog Out Channels as words</xhtml>
2314
                </documentation>
2315
              </interface>
2316
              <body>
2317
                <ST>
2318
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">// limit the value's
2319
v1 := LIMIT(0, wAOut1, Paramlist.MONARCO_ADC_RANGE_MAX );
2320
v2 := LIMIT(0, wAOut2, Paramlist.MONARCO_ADC_RANGE_MAX );
2321
2322
THIS^._abyIntTxBuf[20]          := WORD_TO_BYTE(v1);
2323
THIS^._abyIntTxBuf[21]          := WORD_TO_BYTE(SHR(v1,8));
2324
THIS^._abyIntTxBuf[22]          := WORD_TO_BYTE(v2);       
2325
THIS^._abyIntTxBuf[23]          := WORD_TO_BYTE(SHR(v2,8));</xhtml>
2326
                </ST>
2327
              </body>
2328
              <addData />
2329
            </Method>
2330
          </data>
2331
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2332
            <Method name="setAOut">
2333
              <interface>
2334
                <returnType>
2335
                  <derived name="eMonarcoComStatus" />
2336
                </returnType>
2337
                <inputVars>
2338
                  <variable name="stAOut">
2339
                    <type>
2340
                      <derived name="stAOut" />
2341
                    </type>
2342
                  </variable>
2343
                </inputVars>
2344
                <localVars>
2345
                  <variable name="v1">
2346
                    <type>
2347
                      <WORD />
2348
                    </type>
2349
                  </variable>
2350
                  <variable name="v2">
2351
                    <type>
2352
                      <WORD />
2353
                    </type>
2354
                  </variable>
2355
                </localVars>
2356
                <documentation>
2357
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Write Analog Out Channels as a struct</xhtml>
2358
                </documentation>
2359
              </interface>
2360
              <body>
2361
                <ST>
2362
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">// limit the value's
2363
v1 := LIMIT(0, stAOut.wAOut1, Paramlist.MONARCO_ADC_RANGE_MAX );
2364
v2 := LIMIT(0, stAOut.wAOut2, Paramlist.MONARCO_ADC_RANGE_MAX );
2365
2366
THIS^._abyIntTxBuf[20]          := WORD_TO_BYTE(v1);
2367
THIS^._abyIntTxBuf[21]          := WORD_TO_BYTE(SHR(v1,8));
2368
THIS^._abyIntTxBuf[22]          := WORD_TO_BYTE(v2);       
2369
THIS^._abyIntTxBuf[23]          := WORD_TO_BYTE(SHR(v2,8));</xhtml>
2370
                </ST>
2371
              </body>
2372
              <addData />
2373
            </Method>
2374
          </data>
2375
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2376
            <Method name="setPWM2freq">
2377
              <interface>
2378
                <returnType>
2379
                  <derived name="eMonarcoComStatus" />
2380
                </returnType>
2381
                <inputVars>
2382
                  <variable name="udiHz">
2383
                    <type>
2384
                      <UDINT />
2385
                    </type>
2386
                    <documentation>
2387
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> base frequency of the PWM, anywhere from 1Hz to 100kHz (10 Hz = 10, 100kHz = 100000)
2388
 A setting higher then 100kHz and lower then 1Hz will be limited to 100kHz and 1Hz.</xhtml>
2389
                    </documentation>
2390
                  </variable>
2391
                </inputVars>
2392
                <localVars>
2393
                  <variable name="_uidiHz">
2394
                    <type>
2395
                      <UDINT />
2396
                    </type>
2397
                  </variable>
2398
                  <variable name="ePrescale">
2399
                    <type>
2400
                      <derived name="ePrescaler" />
2401
                    </type>
2402
                  </variable>
2403
                  <variable name="uiRangeLow">
2404
                    <type>
2405
                      <UINT />
2406
                    </type>
2407
                    <documentation>
2408
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Determined prefered prescaler</xhtml>
2409
                    </documentation>
2410
                  </variable>
2411
                  <variable name="uiRangeHigh">
2412
                    <type>
2413
                      <UINT />
2414
                    </type>
2415
                  </variable>
2416
                  <variable name="uiTOP">
2417
                    <type>
2418
                      <UINT />
2419
                    </type>
2420
                  </variable>
2421
                  <variable name="fPWM">
2422
                    <type>
2423
                      <WORD />
2424
                    </type>
2425
                    <documentation>
2426
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Determined TOP setting</xhtml>
2427
                    </documentation>
2428
                  </variable>
2429
                </localVars>
2430
                <documentation>
2431
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">  Just set a frequency between 1 and 100 kHz and the PWM will be set according to below settings;
2432
2433
  f_PWM = 32 MHz / ( prescaler × TOP )
2434
2435
 Where **prescaler can be (1, 8, 64, 512)** and **TOP can be 0 to 65532**.
2436
 TOP is represented by 14bit value in process data and then multiplied by 4.
2437
 Modulated value is represented by 16 bits in process data and internally scaled to 0 to TOP range.
2438
 The lowest possible prescaler should be preferred for given frequency.
2439
 Because this leads to a bigger value of TOP and so a better resolution of the modulated value.
2440
2441
    ==========  ================================  =================================
2442
 Prescaler   Recommended range low boundary    Recommended range high boundary
2443
    ==========  ================================  =================================
2444
    1           ≥ 1 kHz TOP = 32000               ≤ 100 kHz TOP = 320
2445
    8           ≥ 100 Hz TOP = 40000              &lt; 1 kHz TOP = 4000
2446
    64          ≥ 10 Hz TOP = 50000               &lt; 100 Hz TOP = 5000
2447
    512         ≥ 1 Hz TOP = 62500                &lt; 10 Hz TOP = 6250
2448
    ==========  ================================  =================================
2449
2450
 Example:
2451
  f_PWM = 10Hz =&gt; 16#C352 = 50002
2452
   prescaler = 64, TOP = 50000 =&gt; 10 = 32x10^6 / (64 x 50000)
2453
</xhtml>
2454
                </documentation>
2455
              </interface>
2456
              <body>
2457
                <ST>
2458
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">/// clip the input Hz on lower and upper bound;
2459
_uidiHz := LIMIT( 1, udiHz, 100000);
2460
2461
//// Determine prescaler and TOP according to table
2462
CASE _uidiHz OF
2463
    1..9            : ePrescale     := ePrescaler.ScaleFactor512;
2464
                      uiTOP         := TO_UINT( (32000000/ 512/ _uidiHz));// interpolate between 1 and 9Hz
2465
    
2466
    10..99          : ePrescale     := ePrescaler.ScaleFactor64;
2467
                      uiTOP         := TO_UINT( (32000000/ 64/ _uidiHz)); // interpolate between 10 and 100Hz
2468
    
2469
    100..999        : ePrescale     := ePrescaler.ScaleFactor8;
2470
                      uiTOP         := TO_UINT( (32000000/ 8/ _uidiHz));// interpolate between 100 and 1000Hz
2471
        
2472
    1000..100000    : ePrescale     := ePrescaler.ScaleFactor1;
2473
                      uiTOP         := TO_UINT( (32000000/ 1/ _uidiHz));// interpolate between 1000 and 100000Hz
2474
END_CASE
2475
2476
/// Now set prescaler
2477
/// bit 15 ..  2 : TOP / 4
2478
CASE ePrescale OF 
2479
///  00  0 : prescaler =   1
2480
    ePrescaler.ScaleFactor1 :   fPWM.0 := FALSE;
2481
                                fPWM.1 := FALSE;
2482
///  01  1 : prescaler =   8
2483
    ePrescaler.ScaleFactor8 :   fPWM.0 := TRUE;
2484
                                fPWM.1 := FALSE;
2485
///  10  2 : prescaler =  64    
2486
    ePrescaler.ScaleFactor64 :  fPWM.0 := FALSE;
2487
                                fPWM.1 := TRUE;
2488
///  11  3 : prescaler = 512    
2489
    ePrescaler.ScaleFactor512 : fPWM.0 := TRUE;
2490
                                fPWM.1 := TRUE;
2491
END_CASE
2492
2493
//   8.0   2.0  PWM1 frequency
2494
THIS^._abyIntTxBuf[16]          := WORD_TO_BYTE(fPWM);
2495
THIS^._abyIntTxBuf[17]          := WORD_TO_BYTE(SHR(fPWM,8));</xhtml>
2496
                </ST>
2497
              </body>
2498
              <addData />
2499
            </Method>
2500
          </data>
2501
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2502
            <Method name="getServiceResponse">
2503
              <interface>
2504
                <returnType>
2505
                  <derived name="eMonarcoComStatus" />
2506
                </returnType>
2507
                <outputVars>
2508
                  <variable name="Response">
2509
                    <type>
2510
                      <derived name="stServiceResponse" />
2511
                    </type>
2512
                  </variable>
2513
                </outputVars>
2514
                <localVars>
2515
                  <variable name="rsp">
2516
                    <type>
2517
                      <derived name="stServiceResponse" />
2518
                    </type>
2519
                  </variable>
2520
                </localVars>
2521
                <documentation>
2522
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Reads the most recent service reponse</xhtml>
2523
                </documentation>
2524
              </interface>
2525
              <body>
2526
                <ST>
2527
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">//send/receive           
2528
getServiceResponse          := THIS^.dataTransfer();
2529
2530
rsp.wServiceValue           := MEM.PackBytesToWord(_abyIntRxBuf[1],_abyIntRxBuf[0]);
2531
rsp.wServiceAddress         := MEM.PackBytesToWord(_abyIntRxBuf[3],_abyIntRxBuf[2]);
2532
2533
CASE rsp.wServiceValue OF
2534
    /// Set the error bit
2535
    Paramlist.MONARCO_SERVICE_STATUS_OK         :   Response.xError     := FALSE;                       
2536
    Paramlist.MONARCO_SERVICE_ERROR_UNKNOWN_REG :   Response.xError     := TRUE;
2537
    Paramlist.MONARCO_SERVICE_ERROR_CRC         :   Response.xError     := TRUE;                                        
2538
END_CASE
2539
2540
/// just give the response back
2541
Response.wServiceValue      := MEM.PackBytesToWord(_abyIntRxBuf[1],_abyIntRxBuf[0]);
2542
Response.wServiceAddress    := MEM.PackBytesToWord(_abyIntRxBuf[3],_abyIntRxBuf[2]);</xhtml>
2543
                </ST>
2544
              </body>
2545
              <addData />
2546
            </Method>
2547
          </data>
2548
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2549
            <Method name="setDOut">
2550
              <interface>
2551
                <inputVars>
2552
                  <variable name="stDOut">
2553
                    <type>
2554
                      <derived name="stDOut" />
2555
                    </type>
2556
                  </variable>
2557
                </inputVars>
2558
                <documentation>
2559
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Write Digital Out Channels as a struct;</xhtml>
2560
                </documentation>
2561
              </interface>
2562
              <body>
2563
                <ST>
2564
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">THIS^._abyIntTxBuf[7].0   := stDOut.xDOut1;
2565
THIS^._abyIntTxBuf[7].1 := stDOut.xDOut2;
2566
THIS^._abyIntTxBuf[7].2 := stDOut.xDOut3;
2567
THIS^._abyIntTxBuf[7].3 := stDOut.xDOut4;</xhtml>
2568
                </ST>
2569
              </body>
2570
              <addData />
2571
            </Method>
2572
          </data>
2573
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2574
            <Method name="setDOutBool">
2575
              <interface>
2576
                <inputVars>
2577
                  <variable name="xDOut0">
2578
                    <type>
2579
                      <BOOL />
2580
                    </type>
2581
                  </variable>
2582
                  <variable name="xDOut1">
2583
                    <type>
2584
                      <BOOL />
2585
                    </type>
2586
                  </variable>
2587
                  <variable name="xDOut2">
2588
                    <type>
2589
                      <BOOL />
2590
                    </type>
2591
                  </variable>
2592
                  <variable name="xDOut3">
2593
                    <type>
2594
                      <BOOL />
2595
                    </type>
2596
                  </variable>
2597
                </inputVars>
2598
                <documentation>
2599
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Write Digital Out Channels as booleans</xhtml>
2600
                </documentation>
2601
              </interface>
2602
              <body>
2603
                <ST>
2604
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">THIS^._abyIntTxBuf[7].0   := xDOut0;
2605
THIS^._abyIntTxBuf[7].1 := xDOut1;
2606
THIS^._abyIntTxBuf[7].2 := xDOut2;
2607
THIS^._abyIntTxBuf[7].3 := xDOut3;</xhtml>
2608
                </ST>
2609
              </body>
2610
              <addData />
2611
            </Method>
2612
          </data>
2613
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2614
            <Method name="setDOutByte">
2615
              <interface>
2616
                <inputVars>
2617
                  <variable name="byDOut">
2618
                    <type>
2619
                      <BYTE />
2620
                    </type>
2621
                  </variable>
2622
                </inputVars>
2623
                <documentation>
2624
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Write Digital Out Channels as a byte</xhtml>
2625
                </documentation>
2626
              </interface>
2627
              <body>
2628
                <ST>
2629
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">THIS^._abyIntTxBuf[7].0   := byDOut.0;
2630
THIS^._abyIntTxBuf[7].1 := byDOut.1;
2631
THIS^._abyIntTxBuf[7].2 := byDOut.2;
2632
THIS^._abyIntTxBuf[7].3 := byDOut.3;</xhtml>
2633
                </ST>
2634
              </body>
2635
              <addData />
2636
            </Method>
2637
          </data>
2638
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2639
            <Method name="getDInByte">
2640
              <interface>
2641
                <returnType>
2642
                  <derived name="eMonarcoComStatus" />
2643
                </returnType>
2644
                <outputVars>
2645
                  <variable name="byDIn">
2646
                    <type>
2647
                      <BYTE />
2648
                    </type>
2649
                  </variable>
2650
                </outputVars>
2651
                <documentation>
2652
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">  Read the Digital In channel value's as a single byte</xhtml>
2653
                </documentation>
2654
              </interface>
2655
              <body>
2656
                <ST>
2657
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">byDIn.0               := THIS^._abyIntRxBuf[7].0;
2658
byDIn.1                 := THIS^._abyIntRxBuf[7].1;
2659
byDIn.2                 := THIS^._abyIntRxBuf[7].2;
2660
byDIn.3                 := THIS^._abyIntRxBuf[7].3;</xhtml>
2661
                </ST>
2662
              </body>
2663
              <addData />
2664
            </Method>
2665
          </data>
2666
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2667
            <Method name="getDInBool">
2668
              <interface>
2669
                <returnType>
2670
                  <derived name="eMonarcoComStatus" />
2671
                </returnType>
2672
                <outputVars>
2673
                  <variable name="xDIn0">
2674
                    <type>
2675
                      <BOOL />
2676
                    </type>
2677
                  </variable>
2678
                  <variable name="xDIn1">
2679
                    <type>
2680
                      <BOOL />
2681
                    </type>
2682
                  </variable>
2683
                  <variable name="xDIn2">
2684
                    <type>
2685
                      <BOOL />
2686
                    </type>
2687
                  </variable>
2688
                  <variable name="xDIn3">
2689
                    <type>
2690
                      <BOOL />
2691
                    </type>
2692
                  </variable>
2693
                </outputVars>
2694
                <documentation>
2695
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">  Read the Digital In channel value's as seperate booleans</xhtml>
2696
                </documentation>
2697
              </interface>
2698
              <body>
2699
                <ST>
2700
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">xDIn0                 := THIS^._abyIntRxBuf[7].0;
2701
xDIn1               := THIS^._abyIntRxBuf[7].1;
2702
xDIn2               := THIS^._abyIntRxBuf[7].2;
2703
xDIn3               := THIS^._abyIntRxBuf[7].3;</xhtml>
2704
                </ST>
2705
              </body>
2706
              <addData />
2707
            </Method>
2708
          </data>
2709
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2710
            <Method name="getDIn">
2711
              <interface>
2712
                <returnType>
2713
                  <derived name="eMonarcoComStatus" />
2714
                </returnType>
2715
                <outputVars>
2716
                  <variable name="stDIn">
2717
                    <type>
2718
                      <derived name="stDIn" />
2719
                    </type>
2720
                  </variable>
2721
                </outputVars>
2722
                <documentation>
2723
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">  Read the Digital In channel value's as a struct</xhtml>
2724
                </documentation>
2725
              </interface>
2726
              <body>
2727
                <ST>
2728
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">stDIn.xDIn1           := THIS^._abyIntRxBuf[7].0;
2729
stDIn.xDIn2             := THIS^._abyIntRxBuf[7].1;
2730
stDIn.xDIn3             := THIS^._abyIntRxBuf[7].2;
2731
stDIn.xDIn4             := THIS^._abyIntRxBuf[7].3;</xhtml>
2732
                </ST>
2733
              </body>
2734
              <addData />
2735
            </Method>
2736
          </data>
2737
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2738
            <Method name="getAInWord">
2739
              <interface>
2740
                <returnType>
2741
                  <derived name="eMonarcoComStatus" />
2742
                </returnType>
2743
                <outputVars>
2744
                  <variable name="wAIn1">
2745
                    <type>
2746
                      <WORD />
2747
                    </type>
2748
                  </variable>
2749
                  <variable name="wAIn2">
2750
                    <type>
2751
                      <WORD />
2752
                    </type>
2753
                  </variable>
2754
                </outputVars>
2755
                <documentation>
2756
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read the AIn channel value's</xhtml>
2757
                </documentation>
2758
              </interface>
2759
              <body>
2760
                <ST>
2761
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">wAIn1             := MEM.PackBytesToWord(THIS^._abyIntRxBuf[21],THIS^._abyIntRxBuf[20]);
2762
wAIn2               := MEM.PackBytesToWord(THIS^._abyIntRxBuf[23],THIS^._abyIntRxBuf[22]);</xhtml>
2763
                </ST>
2764
              </body>
2765
              <addData />
2766
            </Method>
2767
          </data>
2768
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2769
            <Method name="ServiceRequest">
2770
              <interface>
2771
                <returnType>
2772
                  <derived name="eMonarcoComStatus" />
2773
                </returnType>
2774
                <inputVars>
2775
                  <variable name="wValue">
2776
                    <type>
2777
                      <WORD />
2778
                    </type>
2779
                  </variable>
2780
                  <variable name="eCommand">
2781
                    <type>
2782
                      <derived name="eServiceCommand" />
2783
                    </type>
2784
                    <documentation>
2785
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> The value which you want set,</xhtml>
2786
                    </documentation>
2787
                  </variable>
2788
                  <variable name="xWrite">
2789
                    <type>
2790
                      <BOOL />
2791
                    </type>
2792
                    <initialValue>
2793
                      <simpleValue value="TRUE" />
2794
                    </initialValue>
2795
                    <documentation>
2796
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> The service which you want to set,</xhtml>
2797
                    </documentation>
2798
                  </variable>
2799
                </inputVars>
2800
                <localVars>
2801
                  <variable name="stRequest">
2802
                    <type>
2803
                      <derived name="stServiceRequest" />
2804
                    </type>
2805
                  </variable>
2806
                </localVars>
2807
                <documentation>
2808
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">Set a free configurable service request to write (or read) a service register</xhtml>
2809
                </documentation>
2810
              </interface>
2811
              <body>
2812
                <ST>
2813
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">stRequest.wServiceValue           := wValue;
2814
stRequest.wServiceAddress       := Paramlist.SDC_ADDRESS_MASK AND TO_WORD(eCommand);
2815
stRequest.wServiceAddress.12    := xWrite;
2816
                        
2817
// Service Data Request         
2818
THIS^._abyIntTxBuf[0]           := WORD_TO_BYTE(stRequest.wServiceValue); // ServiceValueHi;
2819
THIS^._abyIntTxBuf[1]           := WORD_TO_BYTE(SHR(stRequest.wServiceValue,8)); // ServiceValueLo;
2820
THIS^._abyIntTxBuf[2]           := WORD_TO_BYTE(stRequest.wServiceAddress);//ServiceRegisterHi;
2821
THIS^._abyIntTxBuf[3]           := WORD_TO_BYTE(SHR(stRequest.wServiceAddress,8));//ServiceRegisterLo;
2822
                                
2823
//send/receive                  
2824
ServiceRequest                  := THIS^.dataTransfer();</xhtml>
2825
                </ST>
2826
              </body>
2827
              <addData />
2828
            </Method>
2829
          </data>
2830
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2831
            <Method name="getAIn">
2832
              <interface>
2833
                <returnType>
2834
                  <derived name="eMonarcoComStatus" />
2835
                </returnType>
2836
                <outputVars>
2837
                  <variable name="stAIn">
2838
                    <type>
2839
                      <derived name="stAIn" />
2840
                    </type>
2841
                  </variable>
2842
                </outputVars>
2843
                <documentation>
2844
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read the AIn channel value's</xhtml>
2845
                </documentation>
2846
              </interface>
2847
              <body>
2848
                <ST>
2849
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">stAIn.wAIn1               := MEM.PackBytesToWord(THIS^._abyIntRxBuf[21],THIS^._abyIntRxBuf[20]);
2850
stAIn.wAIn2             := MEM.PackBytesToWord(THIS^._abyIntRxBuf[23],THIS^._abyIntRxBuf[22]);</xhtml>
2851
                </ST>
2852
              </body>
2853
              <BuildProperties>
2854
                <LinkAlways>true</LinkAlways>
2855
              </BuildProperties>
2856
              <addData />
2857
            </Method>
2858
          </data>
2859
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2860
            <Method name="SetUserLED">
2861
              <interface>
2862
                <returnType>
2863
                  <derived name="eMonarcoComStatus" />
2864
                </returnType>
2865
                <inputVars>
2866
                  <variable name="byLeds">
2867
                    <type>
2868
                      <BYTE />
2869
                    </type>
2870
                    <documentation>
2871
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> Sets Userled 1..8 on or off</xhtml>
2872
                    </documentation>
2873
                  </variable>
2874
                </inputVars>
2875
                <documentation>
2876
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">   Set User LEDs (0..7) On / Off via a byte, led1 = byte.0.. led8 = byte.7</xhtml>
2877
                </documentation>
2878
              </interface>
2879
              <body>
2880
                <ST>
2881
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">//   10.0   2.0  PWM1 Dutycycle ch A
2882
THIS^._abyIntTxBuf[5]               := byLeds;  // set userled mask
2883
THIS^._abyIntTxBuf[6]               := byLeds;  // set userled</xhtml>
2884
                </ST>
2885
              </body>
2886
              <addData />
2887
            </Method>
2888
          </data>
2889
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2890
            <Method name="AfterReadInputs">
2891
              <interface>
2892
                <returnType>
2893
                  <INT />
2894
                </returnType>
2895
              </interface>
2896
              <body>
2897
                <ST>
2898
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">///********************************
2899
///  Continous intputs
2900
///********************************
2901
SUPER^.AfterReadInputs();
2902
2903
IF _iState = 10 THEN
2904
    
2905
    // SPI reads/writes outputs in a single read/write action
2906
    THIS^.getDInByte(byDin =&gt; byDin);
2907
    THIS^.getAInWord(wAIn1 =&gt; wAIn1, wAIn2 =&gt; wAIn2);
2908
    THIS^.setDoutByte(byDout := byDOut);
2909
    THIS^.setAOutWord(wAout1 := wAOut1, wAOut2 := wAOut2);
2910
    
2911
    _BeforeWriteOutputs := _BeforeWriteOutputs +1;
2912
    eComStatus  := THIS^.dataTransfer();
2913
END_IF
2914
</xhtml>
2915
                </ST>
2916
              </body>
2917
              <addData />
2918
            </Method>
2919
          </data>
2920
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2921
            <Method name="BeforeWriteOutputs">
2922
              <interface>
2923
                <returnType>
2924
                  <INT />
2925
                </returnType>
2926
              </interface>
2927
              <body>
2928
                <ST>
2929
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">///********************************
2930
///  Continous Outputs
2931
///******************************** 
2932
SUPER^.BeforeWriteOutputs();
2933
2934
IF _iState = 10 THEN
2935
    _BeforeWriteOutputs := _BeforeWriteOutputs +1;
2936
END_IF</xhtml>
2937
                </ST>
2938
              </body>
2939
              <addData />
2940
            </Method>
2941
          </data>
2942
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
2943
            <Method name="Initialize">
2944
              <interface>
2945
                <returnType>
2946
                  <UDINT />
2947
                </returnType>
2948
                <inputVars>
2949
                  <variable name="wModuleType">
2950
                    <type>
2951
                      <UINT />
2952
                    </type>
2953
                  </variable>
2954
                  <variable name="dwInstance">
2955
                    <type>
2956
                      <UDINT />
2957
                    </type>
2958
                  </variable>
2959
                  <variable name="pConnector">
2960
                    <type>
2961
                      <pointer>
2962
                        <baseType>
2963
                          <derived name="IoConfigConnector" />
2964
                        </baseType>
2965
                      </pointer>
2966
                    </type>
2967
                  </variable>
2968
                </inputVars>
2969
                <localVars>
2970
                  <variable name="pParam1">
2971
                    <type>
2972
                      <pointer>
2973
                        <baseType>
2974
                          <derived name="IoConfigParameter" />
2975
                        </baseType>
2976
                      </pointer>
2977
                    </type>
2978
                  </variable>
2979
                  <variable name="pParam10">
2980
                    <type>
2981
                      <pointer>
2982
                        <baseType>
2983
                          <derived name="IoConfigParameter" />
2984
                        </baseType>
2985
                      </pointer>
2986
                    </type>
2987
                  </variable>
2988
                  <variable name="udiResult">
2989
                    <type>
2990
                      <UDINT />
2991
                    </type>
2992
                  </variable>
2993
                </localVars>
2994
              </interface>
2995
              <body>
2996
                <ST>
2997
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.Initialize(wModuleType, dwInstance, pConnector);
2998
2999
pParam1 := ConfigGetParameter(_pConnector, 1);
3000
IF pParam1 &lt;&gt; 0 THEN
3001
    THIS^.Watchdog := IoStandard.ConfigGetParameterValueByte(pParam1, ADR(udiResult));
3002
END_IF
3003
3004
pParam10 := ConfigGetParameter(_pConnector, 10);
3005
IF pParam10 &lt;&gt; 0 THEN
3006
    THIS^.ControlByte8 := IoStandard.ConfigGetParameterValueByte(pParam10, ADR(udiResult));
3007
END_IF</xhtml>
3008
                </ST>
3009
              </body>
3010
              <addData />
3011
            </Method>
3012
          </data>
3013
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3014
            <Property name="Counter2Config">
3015
              <interface>
3016
                <returnType>
3017
                  <derived name="stCounter2Config" />
3018
                </returnType>
3019
                <documentation>
3020
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Get / Set configure COUNTER2</xhtml>
3021
                </documentation>
3022
              </interface>
3023
              <GetAccessor>
3024
                <interface>
3025
                  <localVars>
3026
                    <variable name="stConfig">
3027
                      <type>
3028
                        <derived name="stCounter2Config" />
3029
                      </type>
3030
                    </variable>
3031
                    <variable name="J">
3032
                      <type>
3033
                        <INT />
3034
                      </type>
3035
                    </variable>
3036
                    <variable name="awSrvAnwser">
3037
                      <type>
3038
                        <array>
3039
                          <dimension lower="1" upper="2" />
3040
                          <baseType>
3041
                            <WORD />
3042
                          </baseType>
3043
                        </array>
3044
                      </type>
3045
                    </variable>
3046
                    <variable name="uiMode">
3047
                      <type>
3048
                        <UINT />
3049
                      </type>
3050
                    </variable>
3051
                    <variable name="uiDirection">
3052
                      <type>
3053
                        <UINT />
3054
                      </type>
3055
                    </variable>
3056
                    <variable name="uiActiveEdge">
3057
                      <type>
3058
                        <UINT />
3059
                      </type>
3060
                    </variable>
3061
                    <variable name="uiCapture">
3062
                      <type>
3063
                        <UINT />
3064
                      </type>
3065
                    </variable>
3066
                  </localVars>
3067
                </interface>
3068
                <body>
3069
                  <ST>
3070
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3071
    eComStatus := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_CNT2MODE, xWrite := FALSE );
3072
    awSrvAnwser[J]   := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3073
END_FOR
3074
3075
/// COUNTER2 Configuration;
3076
///   Mode;
3077
///    * Off,
3078
///    * Pulse counting,
3079
///    * Quadrature encoder,
3080
///   Direction (only for pulse counting mode):
3081
///     * Up
3082
///     * [FUTURE] external control, low/high = up/down
3083
///   Active Edge (only for pulse counting mode):
3084
///     * Rising
3085
///     * Falling
3086
///     * Both
3087
///   CAPTURE function active edge:
3088
///     * Disabled
3089
///     * [FUTURE] rising
3090
///     * [FUTURE] falling
3091
///     * [FUTURE] both
3092
3093
uiMode := BOOL_TO_UINT(awSrvAnwser[2].0) + BOOL_TO_UINT(awSrvAnwser[2].1) + BOOL_TO_UINT(awSrvAnwser[2].2);
3094
CASE uiMode OF
3095
    eCounterMode.Off                    : stConfig.eMode := eCounterMode.Off;               //0x00                                                                  
3096
    eCounterMode.PulseCounting          : stConfig.eMode := eCounterMode.PulseCounting;     //0x01                                                              
3097
    eCounterMode.QuadratureEncoder      : stConfig.eMode := eCounterMode.QuadratureEncoder; //0x02
3098
ELSE
3099
    // Weird value returns?
3100
    stConfig.eMode := eCounterMode.Off;
3101
END_CASE
3102
3103
uiDirection := BOOL_TO_UINT(awSrvAnwser[2].3) + BOOL_TO_UINT(awSrvAnwser[2].4) + BOOL_TO_UINT(awSrvAnwser[2].5);
3104
CASE uiDirection OF
3105
    eCounterDirection.Up                : stConfig.eDirection := eCounterDirection.Up;                  //0x00
3106
    eCounterDirection.External_Control1 : stConfig.eDirection := eCounterDirection.External_Control1;   //0x01
3107
ELSE
3108
    // [FUTURE] or weird value's?
3109
    stConfig.eDirection := eCounterDirection.External_Control1;
3110
END_CASE
3111
3112
uiActiveEdge :=  BOOL_TO_UINT(awSrvAnwser[2].6) + BOOL_TO_UINT(awSrvAnwser[2].7);
3113
CASE uiActiveEdge OF
3114
    eCounterActiveEdge.Rising           : stConfig.eActiveEdge := eCounterActiveEdge.Rising;     //0x00
3115
    eCounterActiveEdge.Falling          : stConfig.eActiveEdge := eCounterActiveEdge.Falling; //0x01
3116
    eCounterActiveEdge.Both             : stConfig.eActiveEdge := eCounterActiveEdge.Both;    //0x02
3117
ELSE
3118
    // Weird value returns?
3119
    stConfig.eActiveEdge := eCounterActiveEdge.Rising;  //0x00      
3120
END_CASE
3121
3122
3123
uiCapture :=  BOOL_TO_UINT(awSrvAnwser[2].8) + BOOL_TO_UINT(awSrvAnwser[2].9);
3124
CASE uiCapture OF
3125
    eCounterCapture.Disabled            : stConfig.eCapture := eCounterCapture.Disabled;    //0x00
3126
    eCounterCapture.Rising              : stConfig.eCapture := eCounterCapture.Rising;  //0x01
3127
    eCounterCapture.Falling             : stConfig.eCapture := eCounterCapture.Falling;     //0x02
3128
    eCounterCapture.Both                : stConfig.eCapture := eCounterCapture.Both;    //0x02
3129
ELSE
3130
    // Weird value returns?
3131
    stConfig.eCapture := eCounterCapture.Disabled;  //0x00      
3132
END_CASE
3133
3134
Counter2Config := stConfig;</xhtml>
3135
                  </ST>
3136
                </body>
3137
                <addData />
3138
              </GetAccessor>
3139
              <SetAccessor>
3140
                <interface>
3141
                  <localVars>
3142
                    <variable name="stConfig">
3143
                      <type>
3144
                        <derived name="stCounter2Config" />
3145
                      </type>
3146
                    </variable>
3147
                    <variable name="wReq">
3148
                      <type>
3149
                        <WORD />
3150
                      </type>
3151
                    </variable>
3152
                  </localVars>
3153
                </interface>
3154
                <body>
3155
                  <ST>
3156
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">/// COUNTER1 Configuration;
3157
///   Mode;
3158
///    * Off,
3159
///    * Pulse counting,
3160
///    * Quadrature encoder,
3161
///   Direction (only for pulse counting mode):
3162
///     * Up
3163
///     * [FUTURE] external control, low/high = up/down
3164
///   Active Edge (only for pulse counting mode):
3165
///     * Rising
3166
///     * Falling
3167
///     * Both
3168
///   CAPTURE function active edge:
3169
///     * Disabled
3170
///     * [FUTURE] rising
3171
///     * [FUTURE] falling
3172
///     * [FUTURE] both
3173
3174
stConfig   := Counter2Config;
3175
CASE stConfig.eMode OF
3176
    eCounterMode.Off                    :   wReq.0 := FALSE;    //0x00
3177
                                            wReq.1 := FALSE;
3178
                                            wReq.2 := FALSE;
3179
                                        
3180
    eCounterMode.PulseCounting          :   wReq.0 := TRUE;     //0x01
3181
                                            wReq.1 := FALSE;
3182
                                            wReq.2 := FALSE;
3183
                                        
3184
    eCounterMode.QuadratureEncoder      :   wReq.0 := FALSE;    //0x02
3185
                                            wReq.1 := TRUE;
3186
                                            wReq.2 := FALSE;
3187
END_CASE
3188
3189
CASE stConfig.eDirection OF
3190
    eCounterDirection.up                :   wReq.3 := FALSE;    //0x00
3191
                                            wReq.4 := FALSE;
3192
                                            wReq.5 := FALSE;
3193
                                    
3194
    eCounterDirection.External_Control1 :   wReq.3 := TRUE;     //0x01  [FUTURE] external control, low/high = up/down
3195
                                            wReq.4 := FALSE;
3196
                                            wReq.5 := FALSE;
3197
END_CASE
3198
3199
CASE stConfig.eActiveEdge OF
3200
    eCounterActiveEdge.rising           :   wReq.6 := FALSE;    //0x00
3201
                                            wReq.7 := FALSE;
3202
                                            
3203
    eCounterActiveEdge.falling          :   wReq.6 := TRUE;     //0x01
3204
                                            wReq.7 := FALSE;
3205
                                            
3206
    eCounterActiveEdge.both             :   wReq.6 := FALSE;    //0x02
3207
                                            wReq.7 := TRUE;                         
3208
END_CASE
3209
3210
CASE stConfig.eCapture OF
3211
    eCounterCapture.Disabled            :   wReq.8 := FALSE;    //0x00
3212
                                            wReq.9 := FALSE;
3213
                                            
3214
    eCounterCapture.Rising              :   wReq.8 := TRUE;     //0x01 [FUTURE]
3215
                                            wReq.9 := FALSE;
3216
                                            
3217
    eCounterCapture.Falling             :   wReq.8 := FALSE;    //0x02 [FUTURE]
3218
                                            wReq.9 := TRUE;     
3219
                                            
3220
    eCounterCapture.Both                :   wReq.8 := TRUE;     //0x03 [FUTURE]
3221
                                            wReq.9 := TRUE;                         
3222
END_CASE
3223
3224
wReq.10 := FALSE;   // Mandatory
3225
wReq.11 := FALSE;   // Mandatory
3226
wReq.12 := FALSE;   // Mandatory
3227
wReq.13 := FALSE;   // Mandatory
3228
wReq.14 := FALSE;   // Mandatory
3229
wReq.15 := FALSE;   // Mandatory
3230
3231
eComStatus := THIS^.ServiceRequest( wValue := wReq, eCommand := eServiceCommand.SDC_FIXED_CNT2MODE, xWrite := TRUE );
3232
3233
stCounter2Config := stConfig;</xhtml>
3234
                  </ST>
3235
                </body>
3236
                <addData />
3237
              </SetAccessor>
3238
              <addData />
3239
            </Property>
3240
          </data>
3241
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3242
            <Property name="Counter1Config">
3243
              <interface>
3244
                <returnType>
3245
                  <derived name="stCounter1Config" />
3246
                </returnType>
3247
                <documentation>
3248
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Get / Set configure COUNTER1</xhtml>
3249
                </documentation>
3250
              </interface>
3251
              <SetAccessor>
3252
                <interface>
3253
                  <localVars>
3254
                    <variable name="stConfig">
3255
                      <type>
3256
                        <derived name="stCounter1Config" />
3257
                      </type>
3258
                    </variable>
3259
                    <variable name="wReq">
3260
                      <type>
3261
                        <WORD />
3262
                      </type>
3263
                    </variable>
3264
                  </localVars>
3265
                </interface>
3266
                <body>
3267
                  <ST>
3268
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">/// COUNTER1 Configuration;
3269
///   Mode;
3270
///    * Off,
3271
///    * Pulse counting,
3272
///    * Quadrature encoder,
3273
///   Direction (only for pulse counting mode):
3274
///     * Up
3275
///     * [FUTURE] external control, low/high = up/down
3276
///   Active Edge (only for pulse counting mode):
3277
///     * Rising
3278
///     * Falling
3279
///     * Both
3280
stConfig   := Counter1Config;
3281
CASE stConfig.eMode OF
3282
    eCounterMode.Off                    :   wReq.0 := FALSE;    //0x00
3283
                                            wReq.1 := FALSE;
3284
                                            wReq.2 := FALSE;
3285
                                        
3286
    eCounterMode.PulseCounting          :   wReq.0 := TRUE;     //0x01
3287
                                            wReq.1 := FALSE;
3288
                                            wReq.2 := FALSE;
3289
                                        
3290
    eCounterMode.QuadratureEncoder      :   wReq.0 := FALSE;    //0x02
3291
                                            wReq.1 := TRUE;
3292
                                            wReq.2 := FALSE;
3293
END_CASE
3294
3295
CASE stConfig.eDirection OF
3296
    eCounterDirection.up                :   wReq.3 := FALSE;    //0x00
3297
                                            wReq.4 := FALSE;
3298
                                            wReq.5 := FALSE;
3299
                                    
3300
    eCounterDirection.External_Control1 :   wReq.3 := TRUE;     //0x01  [FUTURE] external control, low/high = up/down
3301
                                            wReq.4 := FALSE;
3302
                                            wReq.5 := FALSE;
3303
END_CASE
3304
3305
CASE stConfig.eActiveEdge OF
3306
    eCounterActiveEdge.rising           :   wReq.6 := FALSE;    //0x00
3307
                                            wReq.7 := FALSE;
3308
                                            
3309
    eCounterActiveEdge.falling          :   wReq.6 := TRUE;     //0x01
3310
                                            wReq.7 := FALSE;
3311
                                            
3312
    eCounterActiveEdge.both             :   wReq.6 := FALSE;    //0x02
3313
                                            wReq.7 := TRUE;                         
3314
END_CASE
3315
3316
wReq.8 := FALSE;    // Mandatory
3317
wReq.9 := FALSE;    // Mandatory
3318
wReq.10 := FALSE;   // Mandatory
3319
wReq.11 := FALSE;   // Mandatory
3320
wReq.12 := FALSE;   // Mandatory
3321
wReq.13 := FALSE;   // Mandatory
3322
wReq.14 := FALSE;   // Mandatory
3323
wReq.15 := FALSE;   // Mandatory
3324
3325
eComStatus := THIS^.ServiceRequest( wValue := wReq, eCommand := eServiceCommand.SDC_FIXED_CNT1MODE, xWrite := TRUE );
3326
3327
// update classic status;
3328
stCounter1Config := stConfig;</xhtml>
3329
                  </ST>
3330
                </body>
3331
                <addData />
3332
              </SetAccessor>
3333
              <GetAccessor>
3334
                <interface>
3335
                  <localVars>
3336
                    <variable name="stConfig">
3337
                      <type>
3338
                        <derived name="stCounter1Config" />
3339
                      </type>
3340
                    </variable>
3341
                    <variable name="J">
3342
                      <type>
3343
                        <INT />
3344
                      </type>
3345
                    </variable>
3346
                    <variable name="awSrvAnwser">
3347
                      <type>
3348
                        <array>
3349
                          <dimension lower="1" upper="2" />
3350
                          <baseType>
3351
                            <WORD />
3352
                          </baseType>
3353
                        </array>
3354
                      </type>
3355
                    </variable>
3356
                    <variable name="uiMode">
3357
                      <type>
3358
                        <UINT />
3359
                      </type>
3360
                    </variable>
3361
                    <variable name="uiDirection">
3362
                      <type>
3363
                        <UINT />
3364
                      </type>
3365
                    </variable>
3366
                    <variable name="uiActiveEdge">
3367
                      <type>
3368
                        <UINT />
3369
                      </type>
3370
                    </variable>
3371
                  </localVars>
3372
                </interface>
3373
                <body>
3374
                  <ST>
3375
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3376
    eComStatus := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_CNT1MODE, xWrite := FALSE );
3377
    awSrvAnwser[J]   := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3378
END_FOR
3379
3380
/// COUNTER1 Configuration;
3381
///   Mode;
3382
///    * Off,
3383
///    * Pulse counting,
3384
///    * Quadrature encoder,
3385
///   Direction (only for pulse counting mode):
3386
///     * Up
3387
///     * [FUTURE] external control, low/high = up/down
3388
///   Active Edge (only for pulse counting mode):
3389
///     * Rising
3390
///     * Falling
3391
///     * Both
3392
3393
uiMode := BOOL_TO_UINT(awSrvAnwser[2].0) + BOOL_TO_UINT(awSrvAnwser[2].1) + BOOL_TO_UINT(awSrvAnwser[2].2);
3394
CASE uiMode OF
3395
    eCounterMode.Off                    : stConfig.eMode := eCounterMode.Off;               //0x00                                                                  
3396
    eCounterMode.PulseCounting          : stConfig.eMode := eCounterMode.PulseCounting;     //0x01                                                              
3397
    eCounterMode.QuadratureEncoder      : stConfig.eMode := eCounterMode.QuadratureEncoder; //0x02
3398
ELSE
3399
    // Weird value returns?
3400
    stConfig.eMode := eCounterMode.Off;
3401
END_CASE
3402
3403
uiDirection := BOOL_TO_UINT(awSrvAnwser[2].3) + BOOL_TO_UINT(awSrvAnwser[2].4) + BOOL_TO_UINT(awSrvAnwser[2].5);
3404
CASE uiDirection OF
3405
    eCounterDirection.Up                : stConfig.eDirection := eCounterDirection.Up;                  //0x00
3406
    eCounterDirection.External_Control1 : stConfig.eDirection := eCounterDirection.External_Control1;   //0x01
3407
ELSE
3408
    // [FUTURE] or weird value's?
3409
    stConfig.eDirection := eCounterDirection.External_Control1;
3410
END_CASE
3411
3412
uiActiveEdge :=  BOOL_TO_UINT(awSrvAnwser[2].6) + BOOL_TO_UINT(awSrvAnwser[2].7);
3413
CASE uiActiveEdge OF
3414
    eCounterActiveEdge.Rising           : stConfig.eActiveEdge := eCounterActiveEdge.Rising;    //0x00
3415
    eCounterActiveEdge.Falling          : stConfig.eActiveEdge := eCounterActiveEdge.Falling;   //0x01
3416
    eCounterActiveEdge.Both             : stConfig.eActiveEdge := eCounterActiveEdge.Both;      //0x02
3417
ELSE
3418
    // Weird value returns?
3419
    stConfig.eActiveEdge := eCounterActiveEdge.Rising;  //0x00      
3420
END_CASE
3421
3422
Counter1Config := stConfig;</xhtml>
3423
                  </ST>
3424
                </body>
3425
                <addData />
3426
              </GetAccessor>
3427
              <addData />
3428
            </Property>
3429
          </data>
3430
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3431
            <Property name="RS485Mode">
3432
              <interface>
3433
                <returnType>
3434
                  <derived name="stRS485Mode" />
3435
                </returnType>
3436
                <documentation>
3437
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Please refer to Monarco HAT SPI Protocol Reference Manual for more details!
3438
3439
 Read/ Write Host Baudrate in steps of 100 Baud.
3440
 The host side baudrate is configurable by service register 0x012, but it is usually *NOT* needed, as RS-485 side communication parameters are independant on Host side.
3441
3442
 Default communication parameters on Raspberry Pi (Host side) side are; 
3443
    * 115200 Baud, 
3444
    * 8 data bits, no parity, 
3445
        * 1 stop Bit/// 115200 Baud, 8 data bits, no parity, 1 stop BIT. 
3446
 Host side baudrate is configurable by service register 0x012, but it is usually *NOT* needed, 
3447
 as RS-485 side communication parameters are independant on Host side.
3448
3449
 Monarco HAT RS-485 side communication parameters can be fully configured by service registers 0x010 and 0x011. 
3450
 Default settings are: 9600 Baud, no parity, 1 stop bit (9k6, 8-N-1). 
3451
3452
 sets RS485 port to
3453
 * parity - 0: none, 1: even, 2: odd,
3454
 * data bits: 0: 5, 1: 6, 2: 7, 3: 8,
3455
 * stop bits: 0: half, 1: one, 2: one and half, 3: two.</xhtml>
3456
                </documentation>
3457
              </interface>
3458
              <GetAccessor>
3459
                <interface>
3460
                  <localVars>
3461
                    <variable name="stMode">
3462
                      <type>
3463
                        <derived name="stRS485Mode" />
3464
                      </type>
3465
                    </variable>
3466
                    <variable name="J">
3467
                      <type>
3468
                        <INT />
3469
                      </type>
3470
                    </variable>
3471
                    <variable name="awSrvAnwser">
3472
                      <type>
3473
                        <array>
3474
                          <dimension lower="1" upper="2" />
3475
                          <baseType>
3476
                            <WORD />
3477
                          </baseType>
3478
                        </array>
3479
                      </type>
3480
                    </variable>
3481
                    <variable name="uiParity">
3482
                      <type>
3483
                        <UINT />
3484
                      </type>
3485
                    </variable>
3486
                    <variable name="uiDatabits">
3487
                      <type>
3488
                        <UINT />
3489
                      </type>
3490
                    </variable>
3491
                    <variable name="uiStopbits">
3492
                      <type>
3493
                        <UINT />
3494
                      </type>
3495
                    </variable>
3496
                  </localVars>
3497
                </interface>
3498
                <body>
3499
                  <ST>
3500
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3501
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485MODE, xWrite := FALSE );
3502
    awSrvAnwser[J]  := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3503
END_FOR
3504
3505
//RS-485 Mode [RW]
3506
//  bit 00..02 - parity - 0: none, 1: even, 2: odd
3507
//  bit 03..04 - data bits: 0: 5, 1: 6, 2: 7, 3: 8
3508
//  bit 05..06 - stop bits: 0: half, 1: one, 2: one and half, 3: two
3509
//  bit 07..15 - RESERVED (write zeros)
3510
3511
uiParity            := BOOL_TO_UINT(awSrvAnwser[2].0) + BOOL_TO_UINT(awSrvAnwser[2].1) + BOOL_TO_UINT(awSrvAnwser[2].2);
3512
CASE uiParity OF
3513
    eRS485Parity.None           :   stMode.eParity := eRS485Parity.None;        //0x00                                                                  
3514
    eRS485Parity.Even           :   stMode.eParity := eRS485Parity.Even;        //0x01                                                              
3515
    eRS485Parity.Odd            :   stMode.eParity := eRS485Parity.Odd;     //0x02
3516
END_CASE
3517
3518
uiDatabits          := BOOL_TO_UINT(awSrvAnwser[2].3) + BOOL_TO_UINT(awSrvAnwser[2].4);
3519
CASE uiDatabits OF
3520
    eRS485Databits.Five         :   stMode.eDatabits := eRS485Databits.Five;    //0x00
3521
    eRS485Databits.Six          :   stMode.eDatabits := eRS485Databits.Six;     //0x01
3522
    eRS485Databits.Seven        :   stMode.eDatabits := eRS485Databits.Seven;   //0x02
3523
    eRS485Databits.Eight        :   stMode.eDatabits := eRS485Databits.Eight;   //0x03
3524
END_CASE
3525
3526
uiStopbits          := BOOL_TO_UINT(awSrvAnwser[2].5) + BOOL_TO_UINT(awSrvAnwser[2].6);
3527
CASE uiStopbits OF
3528
    eRS485Stopbits.Half         :   stMode.eStopbits := eRS485Stopbits.Half;    //0x00
3529
    eRS485Stopbits.One          :   stMode.eStopbits := eRS485Stopbits.One; //0x01
3530
    eRS485Stopbits.OneAndAHalf  :   stMode.eStopbits := eRS485Stopbits.OneAndAHalf; //0x02
3531
    eRS485Stopbits.Two          :   stMode.eStopbits := eRS485Stopbits.Two; //0x03
3532
END_CASE
3533
3534
RS485Mode := stMode;</xhtml>
3535
                  </ST>
3536
                </body>
3537
                <addData />
3538
              </GetAccessor>
3539
              <SetAccessor>
3540
                <interface>
3541
                  <localVars>
3542
                    <variable name="stMode">
3543
                      <type>
3544
                        <derived name="stRS485Mode" />
3545
                      </type>
3546
                    </variable>
3547
                    <variable name="wReq">
3548
                      <type>
3549
                        <WORD />
3550
                      </type>
3551
                    </variable>
3552
                  </localVars>
3553
                </interface>
3554
                <body>
3555
                  <ST>
3556
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">//RS-485 Mode [RW]
3557
//  bit 00..02 - parity - 0: none, 1: even, 2: odd
3558
//  bit 03..04 - data bits: 0: 5, 1: 6, 2: 7, 3: 8
3559
//  bit 05..06 - stop bits: 0: half, 1: one, 2: one and half, 3: two
3560
//  bit 07..15 - RESERVED (write zeros)
3561
//
3562
stMode   := RS485Mode;
3563
CASE stMode.eParity OF
3564
    eRS485Parity.none           :   wReq.0 := FALSE;    //0x00
3565
                                    wReq.1 := FALSE;
3566
                                    wReq.2 := FALSE;
3567
                                    
3568
    eRS485Parity.even           :   wReq.0 := TRUE;     //0x01
3569
                                    wReq.1 := FALSE;
3570
                                    wReq.2 := FALSE;
3571
                                    
3572
    eRS485Parity.odd            :   wReq.0 := FALSE;    //0x02
3573
                                    wReq.1 := TRUE;
3574
                                    wReq.2 := FALSE;
3575
END_CASE
3576
3577
CASE stMode.eDatabits OF
3578
    eRS485Databits.Five         :   wReq.3 := FALSE;    //0x00
3579
                                    wReq.4 := FALSE;
3580
                                    
3581
    eRS485Databits.Six          :   wReq.3 := TRUE;     //0x01
3582
                                    wReq.4 := FALSE;
3583
                                    
3584
    eRS485Databits.Seven        :   wReq.3 := FALSE;    //0x02
3585
                                    wReq.4 := TRUE;
3586
                                    
3587
    eRS485Databits.Eight        :   wReq.3 := TRUE;     //0x03
3588
                                    wReq.4 := TRUE;
3589
END_CASE
3590
3591
CASE stMode.eStopbits OF
3592
    eRS485Stopbits.Half         :   wReq.5 := FALSE;    //0x00
3593
                                    wReq.6 := FALSE;
3594
                                    
3595
    eRS485Stopbits.One          :   wReq.5 := TRUE;     //0x01
3596
                                    wReq.6 := FALSE;
3597
                                    
3598
    eRS485Stopbits.OneAndAHalf  :   wReq.5 := FALSE;    //0x02
3599
                                    wReq.6 := TRUE;
3600
                                    
3601
    eRS485Stopbits.Two          :   wReq.5 := TRUE;     //0x03
3602
                                    wReq.6 := TRUE;
3603
END_CASE
3604
3605
wReq.7 := FALSE;    // Mandatory
3606
wReq.8 := FALSE;    // Mandatory
3607
wReq.9 := FALSE;    // Mandatory
3608
wReq.10 := FALSE;   // Mandatory
3609
wReq.11 := FALSE;   // Mandatory
3610
wReq.12 := FALSE;   // Mandatory
3611
wReq.13 := FALSE;   // Mandatory
3612
wReq.14 := FALSE;   // Mandatory
3613
wReq.15 := FALSE;   // Mandatory
3614
3615
eComStatus := THIS^.ServiceRequest( wValue := wReq, eCommand := eServiceCommand.SDC_FIXED_RS485MODE, xWrite := TRUE );</xhtml>
3616
                  </ST>
3617
                </body>
3618
                <addData />
3619
              </SetAccessor>
3620
              <addData />
3621
            </Property>
3622
          </data>
3623
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3624
            <Property name="RS485Baudrate">
3625
              <interface>
3626
                <returnType>
3627
                  <UINT />
3628
                </returnType>
3629
                <documentation>
3630
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Get/Set Monarco HAT External RS-485 Baudrate in steps of 100 Baud, deafault 115
3631
 UART AMA0 should be set at 1152, 8, N, 1 via Linux side config!
3632
3633
    * Unit: 100 Bd, Min: 3 (300 Bd), Max 10000 (1 MegaBd)
3634
    12 = 1200 Bd, 
3635
    24 = 2400 Bd, 
3636
    48 = 4800 Bd,
3637
    96 = 9600 Bd,
3638
    192 = 19200 Bd, 
3639
    384 = 38400 Bd,
3640
    576 = 57600 Bd,
3641
    1152 = 115200 Bd (</xhtml>
3642
                </documentation>
3643
              </interface>
3644
              <GetAccessor>
3645
                <interface>
3646
                  <localVars>
3647
                    <variable name="J">
3648
                      <type>
3649
                        <INT />
3650
                      </type>
3651
                    </variable>
3652
                    <variable name="awSrvAnwser">
3653
                      <type>
3654
                        <array>
3655
                          <dimension lower="1" upper="2" />
3656
                          <baseType>
3657
                            <WORD />
3658
                          </baseType>
3659
                        </array>
3660
                      </type>
3661
                    </variable>
3662
                  </localVars>
3663
                </interface>
3664
                <body>
3665
                  <ST>
3666
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3667
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485BAUD, xWrite := FALSE  ) ;
3668
    awSrvAnwser[J]  := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3669
END_FOR
3670
3671
RS485Baudrate               := awSrvAnwser[2];</xhtml>
3672
                  </ST>
3673
                </body>
3674
                <addData />
3675
              </GetAccessor>
3676
              <SetAccessor>
3677
                <interface>
3678
                  <localVars>
3679
                    <variable name="uiRate">
3680
                      <type>
3681
                        <UINT />
3682
                      </type>
3683
                    </variable>
3684
                  </localVars>
3685
                </interface>
3686
                <body>
3687
                  <ST>
3688
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">uiRate := LIMIT( 3, RS485Baudrate, 10000 ); // limit baudrate within accepted range [300 .. 1000000]
3689
eComStatus := THIS^.ServiceRequest( wValue := uiRate, eCommand := eServiceCommand.SDC_FIXED_RS485BAUD, xWrite := TRUE ); </xhtml>
3690
                  </ST>
3691
                </body>
3692
                <addData />
3693
              </SetAccessor>
3694
              <addData />
3695
            </Property>
3696
          </data>
3697
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3698
            <Property name="ControlByte">
3699
              <interface>
3700
                <returnType>
3701
                  <derived name="stControlByte" />
3702
                </returnType>
3703
                <documentation>
3704
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read / write the control byte</xhtml>
3705
                </documentation>
3706
              </interface>
3707
              <SetAccessor>
3708
                <interface>
3709
                  <localVars>
3710
                    <variable name="eComStat">
3711
                      <type>
3712
                        <derived name="eMonarcoComStatus" />
3713
                      </type>
3714
                    </variable>
3715
                  </localVars>
3716
                </interface>
3717
                <body>
3718
                  <ST>
3719
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">THIS^._abyIntRxBuf[4].0 := ControlByte.xStatusLEDctrl;
3720
THIS^._abyIntRxBuf[4].1 := ControlByte.xStatusLEDvalue;
3721
THIS^._abyIntRxBuf[4].2 := ControlByte.xOneWireShutdown;
3722
THIS^._abyIntRxBuf[4].3 := FALSE;
3723
THIS^._abyIntRxBuf[4].4 := ControlByte.xCounter1Reset;
3724
THIS^._abyIntRxBuf[4].5 := ControlByte.xCounter2Reset;
3725
THIS^._abyIntRxBuf[4].6 := ControlByte.xSignOfLife0;
3726
THIS^._abyIntRxBuf[4].7 := ControlByte.xSignOfLife1;</xhtml>
3727
                  </ST>
3728
                </body>
3729
                <addData />
3730
              </SetAccessor>
3731
              <GetAccessor>
3732
                <interface>
3733
                  <localVars>
3734
                    <variable name="ctrlbyte">
3735
                      <type>
3736
                        <derived name="stControlByte" />
3737
                      </type>
3738
                    </variable>
3739
                  </localVars>
3740
                </interface>
3741
                <body>
3742
                  <ST>
3743
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">ctrlbyte.xStatusLEDctrl     := _abyIntRxBuf[4].0;
3744
ctrlbyte.xStatusLEDvalue    := _abyIntRxBuf[4].1;
3745
ctrlbyte.xOneWireShutdown   := _abyIntRxBuf[4].2;
3746
ctrlbyte.xReserved          := FALSE;               // Mandatory
3747
ctrlbyte.xCounter1Reset     := _abyIntRxBuf[4].4;
3748
ctrlbyte.xCounter2Reset     := _abyIntRxBuf[4].5;
3749
ctrlbyte.xSignOfLife0       := _abyIntRxBuf[4].6;
3750
ctrlbyte.xSignOfLife1       := _abyIntRxBuf[4].7;
3751
3752
// return the anwser
3753
ControlByte                 := ctrlbyte;
3754
</xhtml>
3755
                  </ST>
3756
                </body>
3757
                <addData />
3758
              </GetAccessor>
3759
              <addData />
3760
            </Property>
3761
          </data>
3762
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3763
            <Property name="getHwVersion">
3764
              <interface>
3765
                <returnType>
3766
                  <DWORD />
3767
                </returnType>
3768
                <documentation>
3769
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> reads the Monarco HAT Hardware Revision</xhtml>
3770
                </documentation>
3771
              </interface>
3772
              <GetAccessor>
3773
                <interface />
3774
                <body>
3775
                  <ST>
3776
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">GetHwVersion := stHATinfo.dwHwVersion;</xhtml>
3777
                  </ST>
3778
                </body>
3779
                <addData />
3780
              </GetAccessor>
3781
              <addData />
3782
            </Property>
3783
          </data>
3784
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3785
            <Property name="getFwVersion">
3786
              <interface>
3787
                <returnType>
3788
                  <DWORD />
3789
                </returnType>
3790
                <documentation>
3791
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Reads the Monarco HAT Firmware Version</xhtml>
3792
                </documentation>
3793
              </interface>
3794
              <GetAccessor>
3795
                <interface />
3796
                <body>
3797
                  <ST>
3798
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">GetFwVersion := stHATinfo.dwFwVersion;</xhtml>
3799
                  </ST>
3800
                </body>
3801
                <addData />
3802
              </GetAccessor>
3803
              <addData />
3804
            </Property>
3805
          </data>
3806
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3807
            <Property name="RS485FxC">
3808
              <interface>
3809
                <returnType>
3810
                  <UINT />
3811
                </returnType>
3812
                <documentation>
3813
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> RS-485 RX Framing Error Diagnostics Counter [R]</xhtml>
3814
                </documentation>
3815
              </interface>
3816
              <GetAccessor>
3817
                <interface>
3818
                  <localVars>
3819
                    <variable name="J">
3820
                      <type>
3821
                        <INT />
3822
                      </type>
3823
                    </variable>
3824
                    <variable name="awSrvAnwser">
3825
                      <type>
3826
                        <array>
3827
                          <dimension lower="1" upper="2" />
3828
                          <baseType>
3829
                            <WORD />
3830
                          </baseType>
3831
                        </array>
3832
                      </type>
3833
                    </variable>
3834
                  </localVars>
3835
                </interface>
3836
                <body>
3837
                  <ST>
3838
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3839
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485_FxC, xWrite := FALSE  ) ;
3840
    awSrvAnwser[J]  := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3841
END_FOR
3842
3843
RS485FxC                    := awSrvAnwser[2];</xhtml>
3844
                  </ST>
3845
                </body>
3846
                <addData />
3847
              </GetAccessor>
3848
              <addData />
3849
            </Property>
3850
          </data>
3851
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3852
            <Property name="RS485RxC">
3853
              <interface>
3854
                <returnType>
3855
                  <UINT />
3856
                </returnType>
3857
                <documentation>
3858
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> RS-485 Bytes Received Diagnostics Counter [R]</xhtml>
3859
                </documentation>
3860
              </interface>
3861
              <GetAccessor>
3862
                <interface>
3863
                  <localVars>
3864
                    <variable name="J">
3865
                      <type>
3866
                        <INT />
3867
                      </type>
3868
                    </variable>
3869
                    <variable name="awSrvAnwser">
3870
                      <type>
3871
                        <array>
3872
                          <dimension lower="1" upper="2" />
3873
                          <baseType>
3874
                            <WORD />
3875
                          </baseType>
3876
                        </array>
3877
                      </type>
3878
                    </variable>
3879
                  </localVars>
3880
                </interface>
3881
                <body>
3882
                  <ST>
3883
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3884
    eComStatus              := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485_RxC, xWrite := FALSE  ) ;
3885
    awSrvAnwser[J]          := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3886
END_FOR
3887
3888
RS485RxC                    := awSrvAnwser[2];</xhtml>
3889
                  </ST>
3890
                </body>
3891
                <addData />
3892
              </GetAccessor>
3893
              <addData />
3894
            </Property>
3895
          </data>
3896
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3897
            <Property name="RS485PxC">
3898
              <interface>
3899
                <returnType>
3900
                  <UINT />
3901
                </returnType>
3902
                <documentation>
3903
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">RS-485 RX Parity Error Diagnostics Counter [R]</xhtml>
3904
                </documentation>
3905
              </interface>
3906
              <GetAccessor>
3907
                <interface>
3908
                  <localVars>
3909
                    <variable name="J">
3910
                      <type>
3911
                        <INT />
3912
                      </type>
3913
                    </variable>
3914
                    <variable name="awSrvAnwser">
3915
                      <type>
3916
                        <array>
3917
                          <dimension lower="1" upper="2" />
3918
                          <baseType>
3919
                            <WORD />
3920
                          </baseType>
3921
                        </array>
3922
                      </type>
3923
                    </variable>
3924
                  </localVars>
3925
                </interface>
3926
                <body>
3927
                  <ST>
3928
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3929
    eComStatus              := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485_PxC, xWrite := FALSE  ) ;
3930
    awSrvAnwser[J]          := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3931
END_FOR
3932
3933
RS485PxC                    := awSrvAnwser[2];</xhtml>
3934
                  </ST>
3935
                </body>
3936
                <addData />
3937
              </GetAccessor>
3938
              <addData />
3939
            </Property>
3940
          </data>
3941
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3942
            <Property name="RS485TxC">
3943
              <interface>
3944
                <returnType>
3945
                  <UINT />
3946
                </returnType>
3947
                <documentation>
3948
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> RS-485 Bytes Transmitted Diagnostics Counter [R]</xhtml>
3949
                </documentation>
3950
              </interface>
3951
              <GetAccessor>
3952
                <interface>
3953
                  <localVars>
3954
                    <variable name="J">
3955
                      <type>
3956
                        <INT />
3957
                      </type>
3958
                    </variable>
3959
                    <variable name="awSrvAnwser">
3960
                      <type>
3961
                        <array>
3962
                          <dimension lower="1" upper="2" />
3963
                          <baseType>
3964
                            <WORD />
3965
                          </baseType>
3966
                        </array>
3967
                      </type>
3968
                    </variable>
3969
                  </localVars>
3970
                </interface>
3971
                <body>
3972
                  <ST>
3973
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
3974
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_RS485_TxC, xWrite := FALSE  ) ;
3975
    awSrvAnwser[J]          := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
3976
END_FOR
3977
3978
RS485TxC                    := awSrvAnwser[2];</xhtml>
3979
                  </ST>
3980
                </body>
3981
                <addData />
3982
              </GetAccessor>
3983
              <addData />
3984
            </Property>
3985
          </data>
3986
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
3987
            <Property name="HostBaudrate">
3988
              <interface>
3989
                <returnType>
3990
                  <UINT />
3991
                </returnType>
3992
                <documentation>
3993
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read/ Write Host (RPi) Baudrate in steps of 100 Baud.
3994
 Default Raspberry Pi (Host side) side are; 
3995
    * 115200 Baud, 
3996
    * 8 data bits, no parity, 
3997
        * 1 stop Bit
3998
3999
 The host side baudrate is configurable by service register 0x012, but it is usually *NOT* needed, as RS-485 side communication parameters are independant on Host side.
4000
    * Unit: 100 Bd, Min: 3 (300 Bd), Max 10000 (1 MegaBd)
4001
    12 = 1200 Bd, 
4002
    24 = 2400 Bd, 
4003
    48 = 4800 Bd,
4004
    96 = 9600 Bd,
4005
    192 = 19200 Bd, 
4006
    384 = 38400 Bd,
4007
    576 = 57600 Bd,
4008
    1152 = 115200 Bd</xhtml>
4009
                </documentation>
4010
              </interface>
4011
              <GetAccessor>
4012
                <interface>
4013
                  <localVars>
4014
                    <variable name="J">
4015
                      <type>
4016
                        <INT />
4017
                      </type>
4018
                    </variable>
4019
                    <variable name="awSrvAnwser">
4020
                      <type>
4021
                        <array>
4022
                          <dimension lower="1" upper="2" />
4023
                          <baseType>
4024
                            <WORD />
4025
                          </baseType>
4026
                        </array>
4027
                      </type>
4028
                    </variable>
4029
                  </localVars>
4030
                </interface>
4031
                <body>
4032
                  <ST>
4033
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
4034
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_HOST_UART, xWrite := FALSE  ) ;
4035
    awSrvAnwser[J]  := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
4036
END_FOR
4037
4038
HostBaudrate                := awSrvAnwser[2];</xhtml>
4039
                  </ST>
4040
                </body>
4041
                <addData />
4042
              </GetAccessor>
4043
              <SetAccessor>
4044
                <interface>
4045
                  <localVars>
4046
                    <variable name="uiRate">
4047
                      <type>
4048
                        <UINT />
4049
                      </type>
4050
                    </variable>
4051
                  </localVars>
4052
                </interface>
4053
                <body>
4054
                  <ST>
4055
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">uiRate      := LIMIT( 3, RS485Baudrate, 10000 ); // limit baudrate within accepted range [300 .. 1000000]
4056
eComStatus  := THIS^.ServiceRequest( wValue := uiRate, eCommand := eServiceCommand.SDC_FIXED_HOST_UART, xWrite := TRUE ); </xhtml>
4057
                  </ST>
4058
                </body>
4059
                <addData />
4060
              </SetAccessor>
4061
              <addData />
4062
            </Property>
4063
          </data>
4064
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4065
            <Property name="HWConfig1">
4066
              <interface>
4067
                <returnType>
4068
                  <derived name="stHWConfig1" />
4069
                </returnType>
4070
                <documentation>
4071
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Set the Analog outputs to Current Loop or Voltage
4072
 Set the RS485 shunt resistor</xhtml>
4073
                </documentation>
4074
              </interface>
4075
              <GetAccessor>
4076
                <interface>
4077
                  <localVars>
4078
                    <variable name="J">
4079
                      <type>
4080
                        <INT />
4081
                      </type>
4082
                    </variable>
4083
                    <variable name="awSrvAnwser">
4084
                      <type>
4085
                        <array>
4086
                          <dimension lower="1" upper="2" />
4087
                          <baseType>
4088
                            <WORD />
4089
                          </baseType>
4090
                        </array>
4091
                      </type>
4092
                    </variable>
4093
                    <variable name="stCfg1">
4094
                      <type>
4095
                        <derived name="stHWConfig1" />
4096
                      </type>
4097
                    </variable>
4098
                  </localVars>
4099
                </interface>
4100
                <body>
4101
                  <ST>
4102
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
4103
    eComStatus      := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_HWConfig1, xWrite := FALSE ) ;
4104
    awSrvAnwser[J]          := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
4105
END_FOR
4106
4107
stCfg1.xTerminated          := awSrvAnwser[2].0;
4108
stCfg1.xAIN1shunt           := awSrvAnwser[2].1;
4109
stCfg1.xAIN2shunt           := awSrvAnwser[2].2;
4110
4111
HWConfig1                   := stCfg1;</xhtml>
4112
                  </ST>
4113
                </body>
4114
                <addData />
4115
              </GetAccessor>
4116
              <SetAccessor>
4117
                <interface>
4118
                  <localVars>
4119
                    <variable name="Cfg1">
4120
                      <type>
4121
                        <derived name="stHWConfig1" />
4122
                      </type>
4123
                    </variable>
4124
                    <variable name="wReq">
4125
                      <type>
4126
                        <WORD />
4127
                      </type>
4128
                    </variable>
4129
                  </localVars>
4130
                </interface>
4131
                <body>
4132
                  <ST>
4133
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">Cfg1   := HWConfig1;
4134
wReq.0 := Cfg1.xTerminated;
4135
wReq.1 := Cfg1.xAIN1shunt;
4136
wReq.2 := Cfg1.xAIN2shunt;
4137
wReq.3 := FALSE;    // Mandatory
4138
wReq.4 := FALSE;    // Mandatory
4139
wReq.5 := FALSE;    // Mandatory
4140
wReq.6 := FALSE;    // Mandatory
4141
wReq.7 := FALSE;    // Mandatory
4142
wReq.8 := FALSE;    // Mandatory
4143
wReq.9 := FALSE;    // Mandatory
4144
wReq.10 := FALSE;   // Mandatory
4145
wReq.11 := FALSE;   // Mandatory
4146
wReq.12 := FALSE;   // Mandatory
4147
wReq.13 := FALSE;   // Mandatory
4148
wReq.14 := FALSE;   // Mandatory
4149
wReq.15 := FALSE;   // Mandatory
4150
4151
eComStatus := THIS^.ServiceRequest( wValue := wReq, eCommand := eServiceCommand.SDC_FIXED_HWConfig1, xWrite := TRUE ); </xhtml>
4152
                  </ST>
4153
                </body>
4154
                <addData />
4155
              </SetAccessor>
4156
              <addData />
4157
            </Property>
4158
          </data>
4159
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4160
            <Property name="Watchdog">
4161
              <interface>
4162
                <returnType>
4163
                  <UINT />
4164
                </returnType>
4165
                <documentation>
4166
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read / Write the Watchdog Timeout
4167
 Unit: 1 = 1 msec; 0 = watchdog disabled; default = 100msec.</xhtml>
4168
                </documentation>
4169
              </interface>
4170
              <SetAccessor>
4171
                <interface />
4172
                <body>
4173
                  <ST>
4174
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">eComStatus := THIS^.ServiceRequest( wValue := Watchdog, eCommand := eServiceCommand.SDC_FIXED_WATCHDOG, xWrite := TRUE ); </xhtml>
4175
                  </ST>
4176
                </body>
4177
                <addData />
4178
              </SetAccessor>
4179
              <GetAccessor>
4180
                <interface>
4181
                  <localVars>
4182
                    <variable name="J">
4183
                      <type>
4184
                        <INT />
4185
                      </type>
4186
                    </variable>
4187
                    <variable name="awSrvAnwser">
4188
                      <type>
4189
                        <array>
4190
                          <dimension lower="1" upper="2" />
4191
                          <baseType>
4192
                            <WORD />
4193
                          </baseType>
4194
                        </array>
4195
                      </type>
4196
                    </variable>
4197
                  </localVars>
4198
                </interface>
4199
                <body>
4200
                  <ST>
4201
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">FOR J := 1 TO 2 DO
4202
    eComStatus          := THIS^.ServiceRequest( wValue := 16#0000, eCommand := eServiceCommand.SDC_FIXED_WATCHDOG, xWrite := FALSE  ) ;
4203
    awSrvAnwser[J]      := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]);
4204
END_FOR
4205
4206
Watchdog                := awSrvAnwser[2];</xhtml>
4207
                  </ST>
4208
                </body>
4209
                <addData />
4210
              </GetAccessor>
4211
              <addData />
4212
            </Property>
4213
          </data>
4214
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4215
            <Property name="getCpuID">
4216
              <interface>
4217
                <returnType>
4218
                  <LWORD />
4219
                </returnType>
4220
                <documentation>
4221
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Reads the Monarco HAT CPU ID of the embedded microcontroller (MCU)</xhtml>
4222
                </documentation>
4223
              </interface>
4224
              <GetAccessor>
4225
                <interface />
4226
                <body>
4227
                  <ST>
4228
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">getCpuID := stHATinfo.lwCpuID;</xhtml>
4229
                  </ST>
4230
                </body>
4231
                <addData />
4232
              </GetAccessor>
4233
              <addData />
4234
            </Property>
4235
          </data>
4236
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4237
            <Property name="HATinfo">
4238
              <interface>
4239
                <returnType>
4240
                  <derived name="stHATinfo" />
4241
                </returnType>
4242
              </interface>
4243
              <GetAccessor>
4244
                <interface />
4245
                <body>
4246
                  <ST>
4247
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">HATinfo := THIS^.stHATinfo;</xhtml>
4248
                  </ST>
4249
                </body>
4250
                <addData />
4251
              </GetAccessor>
4252
              <addData />
4253
            </Property>
4254
          </data>
4255
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4256
            <Property name="Operational">
4257
              <interface>
4258
                <returnType>
4259
                  <BOOL />
4260
                </returnType>
4261
                <documentation>
4262
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> This property has to return TRUE, when the device is configured and running</xhtml>
4263
                </documentation>
4264
              </interface>
4265
              <GetAccessor>
4266
                <interface />
4267
                <body>
4268
                  <ST>
4269
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">Operational := xOperational;</xhtml>
4270
                  </ST>
4271
                </body>
4272
                <addData />
4273
              </GetAccessor>
4274
              <addData />
4275
            </Property>
4276
          </data>
4277
          <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation">
4278
            <Property name="ControlByte8">
4279
              <interface>
4280
                <returnType>
4281
                  <BYTE />
4282
                </returnType>
4283
                <documentation>
4284
                  <xhtml xmlns="http://www.w3.org/1999/xhtml"> Read / write the control byte</xhtml>
4285
                </documentation>
4286
              </interface>
4287
              <SetAccessor>
4288
                <interface>
4289
                  <localVars>
4290
                    <variable name="eComStat">
4291
                      <type>
4292
                        <derived name="eMonarcoComStatus" />
4293
                      </type>
4294
                    </variable>
4295
                  </localVars>
4296
                </interface>
4297
                <body>
4298
                  <ST>
4299
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">THIS^._abyIntRxBuf[4].0 := ControlByte8.0;
4300
THIS^._abyIntRxBuf[4].1 := ControlByte8.1;
4301
THIS^._abyIntRxBuf[4].2 := ControlByte8.2;
4302
THIS^._abyIntRxBuf[4].3 := FALSE;
4303
THIS^._abyIntRxBuf[4].4 := ControlByte8.4;
4304
THIS^._abyIntRxBuf[4].5 := ControlByte8.5;
4305
THIS^._abyIntRxBuf[4].6 := ControlByte8.6;
4306
THIS^._abyIntRxBuf[4].7 := ControlByte8.7;</xhtml>
4307
                  </ST>
4308
                </body>
4309
                <addData />
4310
              </SetAccessor>
4311
              <GetAccessor>
4312
                <interface>
4313
                  <localVars>
4314
                    <variable name="ctrlbyte">
4315
                      <type>
4316
                        <BYTE />
4317
                      </type>
4318
                    </variable>
4319
                  </localVars>
4320
                </interface>
4321
                <body>
4322
                  <ST>
4323
                    <xhtml xmlns="http://www.w3.org/1999/xhtml">ctrlbyte.0  := _abyIntRxBuf[4].0;
4324
ctrlbyte.1  := _abyIntRxBuf[4].1;
4325
ctrlbyte.2  := _abyIntRxBuf[4].2;
4326
ctrlbyte.3  := FALSE;               // Mandatory
4327
ctrlbyte.4  := _abyIntRxBuf[4].4;
4328
ctrlbyte.5  := _abyIntRxBuf[4].5;
4329
ctrlbyte.6  := _abyIntRxBuf[4].6;
4330
ctrlbyte.7  := _abyIntRxBuf[4].7;
4331
4332
// return the anwser
4333
ControlByte8 := ctrlbyte;
4334
</xhtml>
4335
                  </ST>
4336
                </body>
4337
                <addData />
4338
              </GetAccessor>
4339
              <addData />
4340
            </Property>
4341
          </data>
4342
        </addData>
4343
      </pou>
4344
    </pous>
4345
  </types>
4346
  <instances>
4347
    <configurations />
4348
  </instances>
4349
  <addData>
4350
    <data name="http://www.3s-software.com/plcopenxml/globalvars" handleUnknown="implementation">
4351
      <globalVars name="ParamList" constant="true">
4352
        <variable name="MONARCO_STRUCT_SIZE">
4353
          <type>
4354
            <UINT />
4355
          </type>
4356
          <initialValue>
4357
            <simpleValue value="26" />
4358
          </initialValue>
4359
        </variable>
4360
        <variable name="MONARCO_SERVICE_STATUS_OK">
4361
          <type>
4362
            <WORD />
4363
          </type>
4364
          <initialValue>
4365
            <simpleValue value="16#ABCD" />
4366
          </initialValue>
4367
        </variable>
4368
        <variable name="MONARCO_SERVICE_ERROR_UNKNOWN_REG">
4369
          <type>
4370
            <WORD />
4371
          </type>
4372
          <initialValue>
4373
            <simpleValue value="16#FFFF" />
4374
          </initialValue>
4375
        </variable>
4376
        <variable name="MONARCO_SERVICE_ERROR_CRC">
4377
          <type>
4378
            <WORD />
4379
          </type>
4380
          <initialValue>
4381
            <simpleValue value="16#CCCC" />
4382
          </initialValue>
4383
        </variable>
4384
        <variable name="SDC_ADDRESS_MASK">
4385
          <type>
4386
            <WORD />
4387
          </type>
4388
          <initialValue>
4389
            <simpleValue value="16#FFF" />
4390
          </initialValue>
4391
        </variable>
4392
        <variable name="MONARCO_ADC_RANGE_MAX">
4393
          <type>
4394
            <WORD />
4395
          </type>
4396
          <initialValue>
4397
            <simpleValue value="16#4095" />
4398
          </initialValue>
4399
        </variable>
4400
        <addData>
4401
          <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
4402
            <Attributes>
4403
              <Attribute Name="parameterlist" Value="" />
4404
              <Attribute Name="qualified_only" Value="" />
4405
            </Attributes>
4406
          </data>
4407
        </addData>
4408
      </globalVars>
4409
    </data>
4410
    <data name="http://www.3s-software.com/plcopenxml/libraries" handleUnknown="implementation">
4411
      <Libraries>
4412
        <Library Name="#Raspberry Pi Peripherals" Namespace="RasPi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" />
4413
        <Library Name="#IoStandard" Namespace="IoStandard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoStandard, * (System)" />
4414
        <Library Name="#CAA Memory" Namespace="MEM" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CAA Memory, * (CAA Technical Workgroup)" />
4415
        <Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" />
4416
        <Library Name="#CAA RTCLK" Namespace="RTCLK" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CAA Real Time Clock Extern, * (CAA Technical Workgroup)" />
4417
        <Library Name="#CAA SerialCom" Namespace="COM" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CAA SerialCom, * (CAA Technical Workgroup)" />
4418
        <Library Name="#IoDrvBase" Namespace="IoDrvBase" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoDrvBase, * (System)" />
4419
        <Library Name="CmpErrors Interfaces, * (System)" Namespace="CmpErrors" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
4420
        <Library Name="IoDriver Interfaces, * (System)" Namespace="IIoDrv" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
4421
        <Library Name="IoDriver Parameter Interfaces, * (System)" Namespace="IIoDrvParameter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
4422
        <Library Name="SysTypes Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
4423
        <Library Name="#SysCpuHandling" Namespace="SysCpuHandling" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysCpuHandling, * (System)" />
4424
        <Library Name="Base Interfaces, * (System)" Namespace="IBaseLibrary" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
4425
        <Library Name="#System_VisuElems" Namespace="VisuElems" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElems, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4426
        <Library Name="#System_VisuElemMeter" Namespace="VisuElemMeter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemMeter, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4427
        <Library Name="#System_VisuElemsSpecialControls" Namespace="VisuElemsSpecialControls" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemsSpecialControls, 3.5.11.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4428
        <Library Name="#System_VisuElemsWinControls" Namespace="VisuElemsWinControls" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemsWinControls, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4429
        <Library Name="#System_VisuElemTextEditor" Namespace="VisuElemTextEditor" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemTextEditor, 3.5.11.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4430
        <Library Name="#System_VisuElemTrace" Namespace="VisuElemTrace" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemTrace, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4431
        <Library Name="#System_VisuNativeControl" Namespace="VisuNativeControl" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuNativeControl, 3.5.11.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4432
        <Library Name="#System_VisuElemsAlarm" Namespace="VisuElemsAlarm" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemsAlarm, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4433
        <Library Name="#System_VisuElemCamDisplayer" Namespace="VisuElemCamDisplayer" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemCamDisplayer, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4434
        <Library Name="#System_VisuElem3DPath" Namespace="VisuElem3DPath" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElem3DPath, 3.5.10.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4435
        <Library Name="#System_VisuElemsDateTime" Namespace="VisuElemsDateTime" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemsDateTime, 3.5.11.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4436
        <Library Name="#System_VisuElemXYChart" Namespace="VisuElemXYChart" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="VisuElemXYChart, 3.5.12.0 (System)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4437
        <Library Name="#system_visuinputs" Namespace="visuinputs" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="true" LinkAllContent="false" DefaultResolution="visuinputs, 3.5.12.0 (system)" ResolverGuid="2717eb6a-dd07-4c66-8d8d-cacebd7b18ae" />
4438
        <addData />
4439
      </Libraries>
4440
    </data>
4441
  </addData>
4442
</project>