一段曲线程序

已锁定

Smatic.simens

  • 帖子

    8
  • 精华

    0
  • 被关注

    2

论坛等级:新手

注册时间:2009-10-03

普通 普通 如何晋级?

一段曲线程序

351

0

2010-01-02 22:50:28

--- This block scales input between two points ( X1, Y1 ) and
( X2, Y2 ). The points are stored in the doublewords of X- and Y-tables ( DBs ).

First the block searches the two points, so that X1 < Input <= X2.

The line between those two points ( X1,Y1 and X2,Y2 ) is y = k*x + b.
So gain ( k ) can be calculated
Y1 = Gain * X1 + b
Y2 = Gain * X2 + b
=>
Y2 = Gain * X2 + Y1 - Gain * X1
= Gain * ( X2 - X1 ) + Y1
=>
Gain = ( Y2 - Y1 ) / ( X2 - X1 )

So Output is Output = Gain * Input + b
= Gain * Input + Y1 - Gain * X1
= Gain * ( Input - X1 ) + Y1

Limiting:
If Input <= first X-point: Output = first Y-point
If Input > last X-point: Output = last Y-point
If number of points < 2: Output is not updated

L #No_of_points
L 2
BEC // if there is not enough points

LAR1 P##X_table
L W [AR1,P#0.0]
T #XDBno // DB-number of X-points
L D [AR1,P#2.0]
T #Xpointer // X-table pointer

LAR1 P##Y_table
L W [AR1,P#0.0]
T #YDBno // DB-number of Y-points
L D [AR1,P#2.0]
T #Ypointer // Y-table pointer

OPN DB [#YDBno] // Opening of the Y-point DB
L DBD [#Ypointer]
T #Y1 // First Y-point

OPN DB [#XDBno] // Opening of the X-point DB
L DBD [#Xpointer]
T #X1 // First X-point

L #Input
>=R // If first X-point >= Input
L #Y1 // Output = first Y-point
JC OUT

L 2
T #Point_counter

LOOP: L #Ypointer
L P#4.0
+D // Increment the Y-pointer
T #Ypointer
OPN DB [#YDBno] // Opening of the Y-point DB
L DBD [#Ypointer]
T #Y2 // Second Y-point

L #Xpointer
L P#4.0
+D // Increment the X-pointer
T #Xpointer
OPN DB [#XDBno] // Opening of the X-point DB
L DBD [#Xpointer]
T #X2 // Second X-point

L #Input
>=R // If second X-point >= Input
JC EXIT // calculate the Output

L #X2 // Update first points
T #X1
L #Y2
T #Y1

L #Point_counter
INC 1 // Increment loop counter
T #Point_counter

L #No_of_points
<=I
JC LOOP // Next loop
L #Y2 // Input > last X-point
JU OUT // => Output = last Y-point
EXIT: L #X2
L #X1
-R
T #X_difference // X2 - X1
L #Y2
L #Y1
-R // Y2 - Y1
L #X_difference
/R
T #Gain
L #Input
L #X1
-R
L #Gain
*R
L #Y1
+R // Output = Gain * ( Input - X1 ) + Y1
OUT: T #Output
上面有程序的说明,在调用这个FB时,#No_of_points为15,输入
X_table为100.200...1500.
问题:当 #Input逐渐增加时(大概是100到800),为什么
L #Input
>=R // If second X-point >= Input
JC EXIT // calculate the Output
(其中>=R监视的时候此RLO一直为0,怎么回事啊?找不到这个点??程序肯定没问题,是正在使用的项目。另外,当输入大于200时,在此FB里面监视时也看不到OUT: T #Output输出值,调用此FB的FC里面能看见输出变化的。
一段曲线程序 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54616条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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