[r1]: / trunk / legacy / Libraries / I2C_SRF02.library.xml  Maximize  Restore  History

Download this file

203 lines (199 with data), 7.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://www.plcopen.org/xml/tc6_0200">
<fileHeader companyName="" productName="CODESYS" productVersion="CODESYS V3.5 SP11" creationDateTime="2018-07-16T11:54:04.7350592" />
<contentHeader name="Raspberry I2C SRF02" version="1.1.0.0" modificationDateTime="2015-11-24T04:28:44" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH">
<Comment>Library containing device support for SRF02 under Raspberry Pi</Comment>
<coordinateInfo>
<fbd>
<scaling x="1" y="1" />
</fbd>
<ld>
<scaling x="1" y="1" />
</ld>
<sfc>
<scaling x="1" y="1" />
</sfc>
</coordinateInfo>
<addData>
<data name="http://www.3s-software.com/plcopenxml/projectinformation" handleUnknown="implementation">
<ProjectInformation>
<property name="Author" type="string">3S - Smart Software Solutions GmbH</property>
<property name="Company" type="string">3S - Smart Software Solutions GmbH</property>
<property name="DefaultNamespace" type="string">SRF02</property>
<property name="Description" type="string">Library containing device support for SRF02 under Raspberry Pi</property>
<property name="Placeholder" type="string">PlaceholderTemplate</property>
<property name="Project" type="string">I2C_SRF02</property>
<property name="Released" type="boolean">false</property>
<property name="Title" type="string">Raspberry I2C SRF02</property>
<property name="Version" type="version">1.1.0.0</property>
<property name="library-category-list" type="library-category-list" />
</ProjectInformation>
</data>
</addData>
</contentHeader>
<types>
<dataTypes />
<pous>
<pou name="SRF02_Supersonic" pouType="functionBlock">
<interface>
<inputVars>
<variable name="lrMinDistance">
<type>
<LREAL />
</type>
<initialValue>
<simpleValue value="0.15" />
</initialValue>
</variable>
<variable name="lrMaxDistance">
<type>
<LREAL />
</type>
<initialValue>
<simpleValue value="16" />
</initialValue>
</variable>
</inputVars>
<outputVars>
<variable name="lrDistance">
<type>
<LREAL />
</type>
<initialValue>
<simpleValue value="-1" />
</initialValue>
</variable>
<variable name="xValid">
<type>
<BOOL />
</type>
</variable>
<variable name="xNewMeasurement">
<type>
<BOOL />
</type>
</variable>
</outputVars>
<localVars>
<variable name="timer">
<type>
<derived name="TON" />
</type>
<initialValue>
<structValue>
<value member="IN">
<simpleValue value="TRUE" />
</value>
</structValue>
</initialValue>
</variable>
</localVars>
<addData>
<data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
<Inheritance>
<Extends>i2c</Extends>
</Inheritance>
</data>
</addData>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">xNewMeasurement := FALSE;
SUPER^();
CASE _iState OF
0:
IF usiAddress = 0 THEN
usiAddress := 16#70;
END_IF
IF SUPER^.init() THEN
_iState := 5;
END_IF
5:
Timer.pt := T#70MS;
_iState := 10;
xValid := FALSE;
END_CASE</xhtml>
</ST>
</body>
<addData>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="AfterReadInputs">
<interface>
<returnType>
<INT />
</returnType>
<localVars>
<variable name="Buffer">
<type>
<array>
<dimension lower="0" upper="3" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
<variable name="len">
<type>
<DINT />
</type>
</variable>
</localVars>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs();
IF _iState = 10 THEN
timer(IN:=TRUE);
IF timer.Q THEN
len := Read(ADR(Buffer), 4);
IF len = 4 THEN
lrDistance := BYTE_TO_LREAL(Buffer[2])*0.01 + BYTE_TO_LREAL(Buffer[3]) * 2.56;
xValid := (lrDistance &gt;= lrMinDistance AND lrDistance &lt;= lrMaxDistance);
xNewMeasurement := TRUE;
ELSE
xValid := FALSE;
END_IF
Write8(0, 16#51); //new measurement
timer(IN:=FALSE);
END_IF
END_IF</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="BeforeWriteOutputs">
<interface>
<returnType>
<INT />
</returnType>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.BeforeWriteOutputs();
</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
</addData>
</pou>
</pous>
</types>
<instances>
<configurations />
</instances>
<addData>
<data name="http://www.3s-software.com/plcopenxml/libraries" handleUnknown="implementation">
<Libraries>
<Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" />
<Library Name="#IoStandard" Namespace="IoStandard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoStandard, * (System)" />
<Library Name="#Raspberry Pi Peripherals" Namespace="Raspi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" />
<addData />
</Libraries>
</data>
</addData>
</project>