发一个老外写的【处理模拟量输入】的程序,供大家讨论

已锁定

*静 水*

  • 帖子

    526
  • 精华

    1
  • 被关注

    14

论坛等级:侠客

注册时间:2006-05-10

普通 普通 如何晋级?

发一个老外写的【处理模拟量输入】的程序,供大家讨论

2851

22

2011-02-15 09:29:40

我觉得对有干扰的场合还是蛮有用的。
Network 1 // Divide the calculation result (VD0) by 99, store it in AC0 .
// This routine produces a rolling average of the last 100 scans worth of an analog input.
//
// VD0 holds the average of the last 100 scans of the analog input AIW0. VD0 is multiplied by 99 in preparation
// to be added to the new analog value.
//
//
LD SM0.0
MOVR 0.0, AC0
MOVR VD0, AC0
*R 99.0, AC0

Network 2 // Convert the raw analog value (AIW0) to a real number, add it to the calculation result (AC0), divide by 100, move to VD0.
// The analog input AIW0 is converted to a real number, added to the calculation result in the rung above,
// divided by 100 and moved to VD0.
//
LD SM0.0
MOVD +0, AC1
MOVW AIW0, AC1
DTR AC1, AC1
+R AC0, AC1
/R 100.0, AC1
MOVR AC1, VD0

Network 3 // Truncate the calculation result, move it to VD4, move the higher order word (VW6) to VW8.
// The result VD0 which is a 32 bit real number is truncated to extract the 16 bit integer value
// which is held in VW6 and is moved to VW8. Use VW8 in any other part of your program as the
// analog average.
//
// the response time of the value is dependant upon the scan time.
//
LD SM0.0
TRUNC VD0, VD4
MOVW VW6, VW8

Network 4
// MEND
//

点击此处查看附件
发一个老外写的【处理模拟量输入】的程序,供大家讨论 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-200

共有33290条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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