滤波程序 问题在哪

已锁定

hane

  • 帖子

    101
  • 精华

    0
  • 被关注

    6

论坛等级:游侠

注册时间:2011-02-04

普通 普通 如何晋级?

滤波程序 问题在哪

1094

4

2012-12-16 09:23:49

IN
DB_no Int
DB_addr_begin int
Degree int
Piw_addr int
Time_base bool

out
Average int

inout
Mid int
result dint


temp
temp1 word
temp2 dword
temp3 dword
temp4 dint
temp5 dint
temp6 word
temp7 dword
temp8 word
temp9 dword
temp10 int
temp11 dword
temp12 dint
//平均值结果为result为Dint
//Time_base采用CPU clock Memory,时间越长,平均值结果越慢,控制的实时性越慢。
//采样资料Degree次数越多,平均值结果越慢,控制的实时性越慢。


L #DB_no //打开DB块
OPN DB [#temp1]
L #DB_addr_begin //找到DB块存储区的开始
SLD 3
T #temp2
A #Time_base //时基到,采集数据
JCN end
L #Mid
L 1
+I
T #Mid
L #Mid
L #Degree
>=I
JC a1 //采集次数未到,继续采集;采集完成,程序跳转到a1
L #Mid
L 4
*I
SLD 3
L #temp2
+D
T #temp3
L #Piw_addr
ITD
T DBD [#temp3]
JU end
a1: L #temp2 // 求最大值
LAR1
L DBD [AR1,P#0.0]
T #temp4
L #Degree
max: T #temp6
L #Degree
L #temp6
-I
L 4
*I
SLD 3
L #temp2
+D
T #temp7
L #temp4
L DBD [#temp7]
>D
JC a2
L DBD [#temp7]
T #temp4
a2: L #temp6
LOOP max
L #temp2 //求最小值
LAR1
L DBD [AR1,P#0.0]
T #temp5
min: T #temp8
L #Degree
L #temp8
-I
L 4
*I
SLD 3
L #temp2
+D
T #temp9
L DBD [#temp9]
L #temp5
>D
JC a3
L DBD [#temp9]
T #temp5
a3: L #temp8
LOOP min //求和
L 0
T #temp12
L #Degree
sum: T #temp10
L #Degree
L #temp10
L 4
*I
SLD 3
L #temp2
+D
T #temp11
L #temp12
L DBD [#temp11]
+D
T #temp12
L #temp10
LOOP sum
L #temp12
L #temp4 //减去最大值
-D
T #temp12
L #temp12
L #temp5 //减去最小值
-D
T #temp12
L #temp12
L #Degree
DEC 1
DEC 1
ITD
/D
T #result
L #result
T #Average //输出平均值结果
L -1
T #Mid
L #Degree
init: T #temp10 //初始化
L #Degree
L #temp10
-I
L 4
*I
SLD 3
L #temp2
+D
T #temp11
L #temp12
L DBD [#temp11]
+D
T #temp12
L #temp10
LOOP init
end: NOP 0



如上一份资料里的程序,输入后不正常。谢谢大家指点!!
滤波程序 问题在哪 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54617条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。