display - 使用软件 panel builder 600 在 ABB HMI 中显示查询
问题描述
我正在使用 ABB HMI 并在 panel builder 600 上对其进行编程。我使用仪表来显示角度并将比例设置为 -100 到 +100。我在显示角度方面取得了成功,但问题是角度变化非常频繁,仪表的指针失控。例如:角度是5度,然后突然增加到10度,然后在很短的时间内又减小到3度,我的显示仪表中的指针失控了。我应该怎么做才能解决这个问题?我正在使用 ABB plc 并用 CFC 语言在 codesys 中编写我的代码。等待有用的回复 TIA
解决方案
降低采样率
VAR
plcValue: INT; // this value changes a lot
hmiValue: INT := plcValue; // this value is sent to the HMI to be displayed
sampleRate: TIME := T#2S; // hmiValue will change every 2 seconds
timer: TON; // the timer
END_VAR
timer(IN := TRUE, PT := sampleRate);
IF (timer.Q) THEN
hmiValue := plcValue;
timer(IN := FALSE, PT := sampleRate); // reset
END_IF
移动平均线
VAR CONSTANT
SIZE: INT := 100; // the number of values to average
END_VAR
VAR
plcValue: INT; // this value changes a lot
hmiValue: INT := plcValue; // this value is sent to the HMI to be displayed
movingAverage: ARRAY [0..SIZE] OF INT; // last SIZE number of values of plcValue
maIndex: INT := 0;
maFilled: BOOL;
sum: REAL;
i: INT;
END_VAR
movingAverage[maIndex] := plcValue;
sum := 0;
IF (maFilled) THEN
FOR i := 0 TO SIZE DO
sum := sum + movingAverage[i];
END_FOR
hmiValue := REAL_TO_INT(sum / SIZE);
ELSE
FOR i := 0 TO maIndex DO
sum := sum + movingAverage[i];
END_FOR
hmiValue := REAL_TO_INT(sum / (maIndex + 1));
END_IF
IF (maIndex = SIZE) THEN
maIndex := 0;
maFilled := TRUE;
ELSE
maIndex := maIndex + 1;
END_IF
比较
运行此代码:
IF (plcValue = 5) THEN
plcValue := 10;
ELSIF (plcValue = 10) THEN
plcValue := 3;
ELSE
plcValue := 5;
END_IF
降低采样率导致hmiValue
仍然每 2 秒跳跃一次(或任何设置),而sampleRate
移动平均线停留在6
没关系,除非您在每个周期都计算数千个平均值)。您还可以更改平均大小:它越大,值越平滑,但对变化的反应也更慢。尽量不要太大
推荐阅读
- swashbuckle - 为什么 Swashbuckle 会妨碍每次通话?
- php - 电子邮件中的类以某些代码为前缀
- typescript - 从其他属性中确定属性类型
- python-3.x - 如何使用 python 和 amazon-textract 在 PDF 中检索表单数据(键值对)?
- ios - 是否可以告诉 Apple TV 启动应用程序或从 iOS 手机应用程序打开商店?
- excel - 更改工作簿名称的一部分并将文件另存为新名称
- mysql - SQL:比较 2 个表并返回任何不匹配的记录
- python - 如何将自然对数应用于矩阵并在矩阵条目为零时获得零
- node.js - 如何正确列出 node.js 中的所有弹性搜索索引
- php - ThePHPLeague OAuth2 Client `getAccessToken()` 抛出“遇到不包含 JSON 正文的 OAuth 服务器错误”错误