• {{item.name}}
SIMATIC WinCC {{item.name}}
{{item2.name}}
更多
常问问题

如何在 WinCC SCADA (V7)的 IO 域中实现线性缩放

star star star star star
5.0 分
文档编号:109780723| 文档类型:常问问题| 发布时间:2025年08月14日
  • 0
  • 117
  • 0
在实际应用中,很多时候都需要在 WinCC Runtime 中对不同单位参数进行数据转换,例如:“克--千克”,通过 VB 脚本可以快速的实现数据的转换。 本FAQ 中详细描述了如何实现输入值和输出值的线性缩放。

问题

用户无法直接在 IO 域中输入缩放参数值,例如,将 IO 域中的值按比例(例如 1000)进行缩放。


解决方案

为了实现相应功能,需要对一个 IO 域创建两个 VB 脚本。

在 IO 域的 “输入值” 属性的 “事件-->变化时执行” 中添加下列脚本:


Code block

'Reading the PLC variable "Integer"

Dim IntegerScal

Set IntegerScal = HMIRuntime.Tags("Integer")

'Assigning the value of the IO field

item.OutputValue = value

'Scaling the value with your chosen scaling factor

IntegerScal.Value = item.OutputValue * Scaling factor

'Writing the variable

IntegerScal.Write


下图中显示了相关设置(如图1)。

image.png
图. 1

用户同时需要在“过程值”属性中添加 VB 脚本。

首先需要读取 PLC 中的变量值,将其除以一个比例因子(例如 1000),然后将结果传送给过程值。


Code block

'Reading the PLC variable "Integer"

Dim IntegerScal

Set IntegerScal = HMIRuntime.Tags("Integer")

IntegerScal.Read

'Scaling the process value by the scaling factor

OutputValue_Trigger = IntegerScal.Value / Scaling factor

为了正确的触发上述脚本,需要把 PLC 变量 “Integer” 的扫描模式设置为“有变化时”(如图2)。

image.png
图. 2

  • 评论
更多
  • 分享

    手机扫码分享文档(需在手机端重新登录账号)

提示
您即将前往“全球技术资源库”。
“全球技术资源库”的用户名与本地支持中心(下载中心、技术论坛、找答案、1847工业学习平台)的用户名不通用。如果需要在全球技术资源库下载文档,您需要重新登录或注册。
确定
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。