summaryrefslogtreecommitdiffstats
path: root/tests/700-hardware/pixtend/pixtend2-iotest.awlpro
blob: ca06b1e59f3f5947794c52e60cc3b3c41e57d483 (plain)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Awlsim project file generated by awlsim-0.63-pre -->
<awlsim_project date_create="2016-03-16 00:00:00.000000"
                date_modify="2018-04-12 18:56:35.898016"
                format_version="1">
	<!-- CPU core configuration -->
	<cpu>
		<!-- CPU core feature specification -->
		<specs nr_accus="2"
		       nr_counters="256"
		       nr_flags="2048"
		       nr_inputs="128"
		       nr_localbytes="1024"
		       nr_outputs="128"
		       nr_timers="256" />

		<!-- CPU core configuration -->
		<config clock_memory_byte="102"
		        ext_insns_enable="1"
		        mnemonics="2"
		        ob_startinfo_enable="0" />
	</cpu>

	<!-- AWL/STL language configuration -->
	<language_awl>
		<!-- AWL/STL source code -->
		<source enabled="1"
		        name="source"
		        type="0"><![CDATA[
// Digital input (DI) / output (DO) tests.
// PiXtend DIs are wired to EB 1
// PiXtend DOs are wired to AB 1
FUNCTION FC 1 : VOID
BEGIN
	// Calculate the expected EB 1 from AB 1.
	// The fake PiXtend spidev module wires DI do DO in the following way:
	// EB1 := ((AB1 & 0x0F) | (((AB1 ^ 0x0F) & 0x0F) << 4))
	L		AB 1
	UW		W#16#0F
	L		AB 1
	XOW		W#16#0F
	UW		W#16#0F
	SLW		4
	OW
	T		MB 10

	// Compare the actual EB 1 to the expected EB 1 (MB 10)
	L		EB 1
	L		MB 10
	__ASSERT==	__ACCU 1,	__ACCU 2

	// Increment the EB 1 / AB 1 test pattern by one
	L		AB 1
	+		1
	T		AB 1
END_FUNCTION


// GPIO tests
// PiXtend GPIO 0 is wired to E 2.0
// PiXtend GPIO 1 is wired to A 2.0
FUNCTION FC 2 : VOID
BEGIN
	// Calculate the expected E 2.0 from A 2.0
	// The fake PiXtend spidev module wires GPIO 1 to GPIO 0
	L		AB 2
	UW		W#16#01
	T		MB 20

	// Compare the actual EB 1 to the expected EB 1 (MB 20)
	L		EB 2
	L		MB 20
	__ASSERT==	__ACCU 1,	__ACCU 2

	// Increment the EB 2 / AB 2 test pattern by one
	L		AB 2
	+		1
	T		AB 2
END_FUNCTION


// Analog input tests
FUNCTION FC 3 : VOID
BEGIN
	// Check AI0
	// The fake PiXtend spidev module always reports 1 V
	L		EW 10
	L		2754
	__ASSERT==	__ACCU 1,	__ACCU 2

	// Check AI1
	// The fake PiXtend spidev module always reports 2 V
	L		EW 12
	L		5535
	__ASSERT==	__ACCU 1,	__ACCU 2
END_FUNCTION


// Analog output tests
FUNCTION FC 4 : VOID
BEGIN
	// Check DAC_A
	// The magic value is checked by the fake PiXtend-Spidev module
	L		27648
	T		AW 10
	
	// Check DAC_B
	// The magic value is checked by the fake PiXtend-Spidev module
	L		2764
	T		AW 12
END_FUNCTION


// PWM output tests
FUNCTION FC 5 : VOID
BEGIN
	// Set PWM0
	// The magic value is checked by the fake PiXtend-Spidev module
	L		W#16#1234
	T		AW 20
	
	// Set PWM1
	// The magic value is checked by the fake PiXtend-Spidev module
	L		W#16#4321
	T		AW 22
END_FUNCTION


ORGANIZATION_BLOCK OB 1
BEGIN
	// This test only works with the fake PiXtend-Spidev module
	
	CALL		FC 1	// Test DI/DO
	CALL		FC 2	// Test GPIOs
	CALL		FC 3	// Test analog inputs
	CALL		FC 4	// Test analog outputs
	CALL		FC 5	// Test PWMs
	
	// If we ran 50 test cycles then exit.
	L		MW 100
	+		1
	T		MW 100
	L		50
	<I
	BEB
	CALL		SFC 46 // Exit test; Stop CPU.
END_ORGANIZATION_BLOCK


ORGANIZATION_BLOCK OB 100
BEGIN
	L		0
	T		AB 1
	T		AB 2
	T		MW 100
	CALL		FC 4	// Init analog outputs
	CALL		FC 5	// Init PWMs
END_ORGANIZATION_BLOCK

]]></source>
	</language_awl>

	<!-- Symbol table configuration -->
	<symbols>
		<!-- symbol table source code -->
		<source enabled="1"
		        name="Main table"
		        type="3"><![CDATA[

]]></source>
	</symbols>

	<!-- Core server link configuration -->
	<core_link>
		<!-- Locally spawned core server -->
		<spawn_local enable="1"
		             interpreters="$DEFAULT"
		             port_range_begin="4183"
		             port_range_end="8278" />

		<!-- Remote server connection -->
		<connect host="localhost"
		         port="4151"
		         timeout_ms="3000" />

		<!-- Transport tunnel -->
		<tunnel local_port="-1"
		        type="0">
			<ssh executable="ssh"
			     port="22"
			     user="pi" />
		</tunnel>
	</core_link>

	<!-- Hardware modules configuration -->
	<hardware>
		<!-- Loaded hardware module -->
		<module name="pixtend">
			<params>
				<param name="analogIn0_10V"
				       value="True" />
				<param name="analogIn0_addr"
				       value="IW 10" />
				<param name="analogIn0_nos"
				       value="10" />
				<param name="analogIn1_10V"
				       value="True" />
				<param name="analogIn1_addr"
				       value="IW 12" />
				<param name="analogIn1_nos"
				       value="10" />
				<param name="analogIn2_addr" />
				<param name="analogIn2_nos"
				       value="10" />
				<param name="analogIn3_addr" />
				<param name="analogIn3_nos"
				       value="10" />
				<param name="analogIn_kHz"
				       value="125" />
				<param name="analogOut0_addr"
				       value="AW 10" />
				<param name="analogOut1_addr"
				       value="AW 12" />
				<param name="boardType"
				       value="v2.x" />
				<param name="digitalIn0_addr"
				       value="I 1.0" />
				<param name="digitalIn1_addr"
				       value="I 1.1" />
				<param name="digitalIn2_addr"
				       value="I 1.2" />
				<param name="digitalIn3_addr"
				       value="I 1.3" />
				<param name="digitalIn4_addr"
				       value="I 1.4" />
				<param name="digitalIn5_addr"
				       value="I 1.5" />
				<param name="digitalIn6_addr"
				       value="I 1.6" />
				<param name="digitalIn7_addr"
				       value="I 1.7" />
				<param name="digitalOut0_addr"
				       value="Q1.0" />
				<param name="digitalOut1_addr"
				       value="Q1.1" />
				<param name="digitalOut2_addr"
				       value="Q1.2" />
				<param name="digitalOut3_addr"
				       value="Q1.3" />
				<param name="digitalOut4_addr" />
				<param name="digitalOut5_addr" />
				<param name="enabled"
				       value="True" />
				<param name="gpio0_addr"
				       value="I 2.0" />
				<param name="gpio0_hum_addr" />
				<param name="gpio0_mode"
				       value="GPIO" />
				<param name="gpio0_pullup"
				       value="False" />
				<param name="gpio0_temp_addr" />
				<param name="gpio1_addr"
				       value="Q 2.0" />
				<param name="gpio1_hum_addr" />
				<param name="gpio1_mode"
				       value="GPIO" />
				<param name="gpio1_pullup"
				       value="False" />
				<param name="gpio1_temp_addr" />
				<param name="gpio2_addr" />
				<param name="gpio2_hum_addr" />
				<param name="gpio2_mode"
				       value="GPIO" />
				<param name="gpio2_pullup"
				       value="False" />
				<param name="gpio2_temp_addr" />
				<param name="gpio3_addr" />
				<param name="gpio3_hum_addr" />
				<param name="gpio3_mode"
				       value="GPIO" />
				<param name="gpio3_pullup"
				       value="False" />
				<param name="gpio3_temp_addr" />
				<param name="inputAddressBase"
				       value="0" />
				<param name="outputAddressBase"
				       value="0" />
				<param name="pollIntMs"
				       value="2.5" />
				<param name="pwm0A_addr"
				       value="AW 20" />
				<param name="pwm0B_addr"
				       value="AW 22" />
				<param name="pwm0_baseFreqHz"
				       value="16000000" />
				<param name="pwm0_mode"
				       value="dutycycle" />
				<param name="pwm0_period"
				       value="65000" />
				<param name="pwm1A_addr" />
				<param name="pwm1B_addr" />
				<param name="pwm1_baseFreqHz"
				       value="0" />
				<param name="pwm1_mode"
				       value="dutycycle" />
				<param name="pwm1_period" />
				<param name="relay0_addr"
				       value="Q 0.0" />
				<param name="relay1_addr"
				       value="Q 0.1" />
				<param name="relay2_addr"
				       value="Q 0.2" />
				<param name="relay3_addr"
				       value="Q 0.3" />
				<param name="rs485"
				       value="False" />
				<param name="testMode"
				       value="True" />
			</params>
		</module>
	</hardware>

	<!-- Graphical user interface configuration -->
	<gui>
		<editor autoindent="1"
		        paste_autoindent="1"
		        validation="1" />
	</gui>
</awlsim_project>
bues.ch cgit interface