行家帮忙看看程序,提提意见----关于模拟量采集的程序(含有带参数的子程序)

已锁定

Huskier

  • 帖子

    2
  • 精华

    0
  • 被关注

    0

论坛等级:新手

注册时间:2006-11-15

普通 普通 如何晋级?

行家帮忙看看程序,提提意见----关于模拟量采集的程序(含有带参数的子程序)

577

5

2006-11-28 14:27:00

PLC程序
在这儿帖程序格式实在不好,读起来有点别扭,我用google的Docs & Spreadsheets把这个程序一并出版到网上了,看起来比这儿舒服一些。链接
http://docs.google.com/View?docid=ah8d9gdg98n5_87ch3gk4
本程序主要编写了一个带参数子程序ScaleAnalogValue用于换算工程量。其中用到了VD100地址4个字节的空间来传递换算结果,调用之后把换算结果保存到另外的地方,然后进行再一次的调用。子程序的调用格式:
CALL ScaleAnalogValue:SBR0, Iv, Isl, Ish, Osl, Osh
VW500地址处一个字节的数据用于模拟口输出,这个值由上位机的组态软件给定。
M区地址0处的位0用于控制线圈Q0.0的输出,这个值也由上位机的组态软件给定。
TITLE=程序注释
Network 1 // 网络标题
// Load special memory bit SM0.0 to process this network every scan cycle.
LD SM0.0 // Load SM0.0.
CALL SBR0, AIW0, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1000
CALL SBR0, AIW2, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1004
CALL SBR0, AIW4, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1008
CALL SBR0, AIW6, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1012
CALL SBR0, AIW8, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1016
CALL SBR0, AIW10, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1020
CALL SBR0, AIW12, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1024
CALL SBR0, AIW14, 0.0, 32000.0, -20.0, 80.0
MOVR VD100, VD1028
MOVW VW500, AQW0 //把VW500一个字的数据转化成模拟电压输出
LD M0.0 //根据M0.0的数值控制Q0.0的通断
= Q0.0
关于子程序变量的图像不能显示,放到了下面的链接
http://docs.google.com/View?docid=ah8d9gdg98n5_87ch3gk4
TITLE=子程序注释
Network 1 // 网络标题
// This program reads an analog value from one of the analog input
// channels on the S7-200 CPU and supplies the output value XQ into
// an area scaled by the user. All required parameters must be provided
// with values in the initialization segment of the program. The
// following variables are pertinent to the scaling formula:
// Ov = scaled output value
// Iv = analog input value
// Osh = high limit of the scale for the scaled output value
// Osl = low limit of the scale for the scaled output value
// Ish = high limit of the scale for the analog input value
// Isl = low limit of the scale for the analog input value
//
// The following formula for calculating the scaled value can be
// derived from the diagram (shown in the online Help file):
//
// Ov = [(Osh - Osl) * (Iv - Isl) / (Ish - Isl)] + Osl
LD SM0.0 // Load SM0.0.
MOVR LD14, AC1 //AC1 = Osh - Osl
-R LD10, AC1
MOVR LD6, AC2 //AC2 = Ish - Isl
-R LD2, AC2

MOVD +0, AC3 //AC3 = Iv - Isl
MOVW LW0, AC3
DTR AC3, LD18 //不知道这个地方有没有更简单的实现方法?
MOVR LD18, AC3
-R LD2, AC3

Network 2
LD SM0.0 // Load SM0.0.
/R AC2, AC3 //(Iv - Isl) / (Ish - Isl)
*R AC1, AC3 //(Iv - Isl) / (Ish - Isl) * (Osh - Osl)
+R LD10, AC3 //(Iv - Isl) / (Ish - Isl) * (Osh - Osl) + Osl
MOVR AC3, VD100
行家帮忙看看程序,提提意见----关于模拟量采集的程序(含有带参数的子程序) 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-200

共有33274条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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