IO的数据集使用案例

1. 用AQ2ST和AI4ST做回环测试,主要是验证AQ2和AI4手册上的DS数据集

2. DS参数写入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
REGION params input
IF NOT #In_SelectedChannel THEN
#params_AQ2ST.RDREC.index := 64;
#params_AQ2ST.WRREC.index := 64;
#params_AI4ST.RDREC.index := 0;
#params_AI4ST.WRREC.index := 0;

ELSE
#params_AQ2ST.RDREC.index := 65;
#params_AQ2ST.WRREC.index := 65;
#params_AI4ST.RDREC.index := 1;
#params_AI4ST.WRREC.index := 1;
END_IF;
#params_AQ2ST.RDREC.id := #In_AQhwio;
#params_AI4ST.RDREC.id := #In_AIhwio;
#params_AQ2ST.WRREC.id := #In_AQhwio;
#params_AI4ST.WRREC.id := #In_AIhwio;

END_REGION

3. 通道类型切换选择

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
REGION type choice
CASE #In_TypeChoic OF
11:
#params_AQ2ST.recorddata[2] := 2#00000001;//voltage
#params_AQ2ST.recorddata[3] := 2#00000000;//-10.0v-10.0v
#params_AQ2ST.recorddata[4] := 2#11000101;//voltage diagnotic
#params_AI4ST.recorddata[2] := 2#00000001;//voltage
#params_AI4ST.recorddata[3] := 2#00001001;//-10.0v-10.0v
12:
#params_AQ2ST.recorddata[2] := 2#00000001;//voltage
#params_AQ2ST.recorddata[3] := 2#00000010;//0.0v-10.0v
#params_AQ2ST.recorddata[4] := 2#11000101;//voltage diagnotic
#params_AI4ST.recorddata[2] := 2#00000001;//voltage
#params_AI4ST.recorddata[3] := 2#00001001;//-10.0v-10.0v(no 0.0to10.0v)
13:
#params_AQ2ST.recorddata[2] := 2#00000001;//voltage
#params_AQ2ST.recorddata[3] := 2#00000011;//1.0v-5.0v
#params_AQ2ST.recorddata[4] := 2#11000101;//voltage diagnotic
#params_AI4ST.recorddata[2] := 2#00000001;//voltage
#params_AI4ST.recorddata[3] := 2#00001010;//1.0v-5.0v
21:
#params_AQ2ST.recorddata[2] := 2#00000010;//current
#params_AQ2ST.recorddata[3] := 2#00000000;//-20.0mato20.0ma
#params_AQ2ST.recorddata[4] := 2#11010001;//current diagnotic
#params_AI4ST.recorddata[2] := 2#00000010;//current(4-wire)
#params_AI4ST.recorddata[3] := 2#00000100;//-20.0mato20.0ma
22:
#params_AQ2ST.recorddata[2] := 2#00000010;//current
#params_AQ2ST.recorddata[3] := 2#00000001;//0.0mato20.0ma
#params_AQ2ST.recorddata[4] := 2#11010001;//current diagnotic
#params_AI4ST.recorddata[2] := 2#00000010;//current(4-wire)
#params_AI4ST.recorddata[3] := 2#00000010;//0.0mato20.0ma
23:
#params_AQ2ST.recorddata[2] := 2#00000010;//current
#params_AQ2ST.recorddata[3] := 2#00000010;//4.0mato20.0ma
#params_AQ2ST.recorddata[4] := 2#11010001;//current diagnotic
#params_AI4ST.recorddata[2] := 2#00000010;//current(4-wire)
#params_AI4ST.recorddata[3] := 2#00000011;//4.0mato20.0ma
ELSE
//default voltage
#params_AQ2ST.recorddata[2] := 2#00000001;//voltage
#params_AQ2ST.recorddata[3] := 2#00000000;//-10.0v-10.0v
#params_AQ2ST.recorddata[4] := 2#00000000;//no diagnostic
#params_AI4ST.recorddata[2] := 2#00000001;//voltage
#params_AI4ST.recorddata[3] := 2#00001001;//-10.0v-10.0v
END_CASE;

END_REGION

4. 切换使能

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
REGION Operate enable
IF #In_OperateEnable AND NOT #paluse_bool THEN
#stepInt := 10;
END_IF;
#paluse_bool := #In_OperateEnable;

CASE #stepInt OF
10:
//read AQ2
#params_AQ2ST.RDREC.req := true;
IF #params_AQ2ST.RDREC.valid THEN
#stepInt := 20;
ELSIF #params_AQ2ST.RDREC.error THEN
#Status_Error := true;
END_IF;
20:
//read AI4
#params_AQ2ST.RDREC.req := FALSE;
#params_AI4ST.RDREC.req := true;
IF #params_AI4ST.RDREC.valid THEN
#stepInt := 30;
ELSIF #params_AI4ST.RDREC.error THEN
#Status_Error := true;
END_IF;
30:
//write AQ2
#params_AI4ST.RDREC.req := FALSE;
#params_AQ2ST.WRREC.req := TRUE;
IF #params_AQ2ST.WRREC.done THEN
#stepInt := 40;
ELSIF #params_AQ2ST.WRREC.error THEN
#Status_Error := true;
END_IF;
40:
//write ai4
#params_AQ2ST.WRREC.req := FALSE;
#params_AI4ST.WRREC.req := TRUE;
IF #params_AI4ST.WRREC.done THEN
#stepInt := 50;
ELSIF #params_AI4ST.WRREC.error THEN
#Status_Error := true;
END_IF;
50:
//write finish
#Status_Done := true;
#params_AQ2ST.RDREC.req := false;
#params_AQ2ST.WRREC.req := false;
#params_AI4ST.RDREC.req := false;
#params_AI4ST.WRREC.req := false;
#stepInt := 0;
END_CASE;

IF NOT #In_OperateEnable THEN
#Status_Done := false;
#Status_Error := false;
#params_AQ2ST.RDREC.req := false;
#params_AQ2ST.WRREC.req := false;
#params_AI4ST.RDREC.req := false;
#params_AI4ST.WRREC.req := false;
#stepInt := 0;
END_IF;

END_REGION

5. 执行

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
REGION execute 
//AQ2ST
#RdrecControl_AQ2ST(REQ := #params_AQ2ST.RDREC.req,
ID := #params_AQ2ST.RDREC.id,
INDEX := #params_AQ2ST.RDREC.index,
VALID => #params_AQ2ST.RDREC.valid,
ERROR => #params_AQ2ST.RDREC.error,
LEN => #params_AQ2ST.RDREC.len,
RECORD := #params_AQ2ST.recorddata);

#WrrecControl_AQ2ST(REQ := #params_AQ2ST.WRREC.req,
ID := #params_AQ2ST.WRREC.id,
INDEX := #params_AQ2ST.WRREC.index,
LEN := 8,
DONE => #params_AQ2ST.WRREC.done,
ERROR => #params_AQ2ST.WRREC.error,
RECORD := #params_AQ2ST.recorddata);
//AI4ST
#RdrecControl_AI4ST(REQ := #params_AI4ST.RDREC.req,
ID := #params_AI4ST.RDREC.id,
INDEX := #params_AI4ST.RDREC.index,
VALID => #params_AI4ST.RDREC.valid,
ERROR => #params_AI4ST.RDREC.error,
LEN => #params_AI4ST.RDREC.len,
RECORD := #params_AI4ST.recorddata);

#WrrecControl_AI4ST(REQ := #params_AI4ST.WRREC.req,
ID := #params_AI4ST.WRREC.id,
INDEX := #params_AI4ST.WRREC.index,
LEN := 28,
DONE => #params_AI4ST.WRREC.done,
ERROR => #params_AI4ST.WRREC.error,
RECORD := #params_AI4ST.recorddata);
END_REGION

6. 输出

1
2
3
4
5
REGION output
#Out_Status_Error := #Status_Error;
#Out_Status_Done := #Status_Done;

END_REGION

IO的数据集使用案例
http://example.com/2024/07/21/IO的数据集使用案例/
作者
xiao cuncun
发布于
2024年7月21日
许可协议