首页 > 解决方案 > 使用软件 panel builder 600 在 ABB HMI 中显示查询

问题描述

我正在使用 ABB HMI 并在 panel builder 600 上对其进行编程。我使用仪表来显示角度并将比例设置为 -100 到 +100。我在显示角度方面取得了成功,但问题是角度变化非常频繁,仪表的指针失控。例如:角度是5度,然后突然增加到10度,然后在很短的时间内又减小到3度,我的显示仪表中的指针失控了。我应该怎么做才能解决这个问题?我正在使用 ABB plc 并用 CFC 语言在 codesys 中编写我的代码。等待有用的回复 TIA

标签: displayplccfccodesysmeter

解决方案


降低采样率

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没关系,除非您在每个周期都计算数千个平均值)。您还可以更改平均大小:它越大,值越平滑,但对变化的反应也更慢。尽量不要太大


推荐阅读