Hysteresis on input channel…

Forum Home Forums Development and Integration Hysteresis on input channel…

This topic contains 4 replies, has 3 voices, and was last updated by  manjey73 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4293

    josef.novotny
    Participant

    Hello, we monitoring some machines via MODBUS protocol, all work OK.
    We want set hysteresis on some input channels.
    Example…
    Input Channel state “1”
    When channel state “0”, we want wait (hysteresis) 20 seconds, after 20 seconds change status machine on dashboard to “0”.
    When machine change state to “1” between 20 seconds, then no action (reset hysteresis). Machine state “1” all time.

    We want use hysteresis only for state from 1 on 0.
    Not use from 0 on 1 state.

    Josef

    #4294

    manjey73
    Participant

    In this case, you do not need a hysteresis and just a timer with a delay off. TOF with time of 20 seconds.

    int[] TofNum = new int[1];
    long[] TofST = new long[1];
    bool[] TofFlag = new bool[1];
    public double Tof(double TofIn, double TofPT)
    {
    long ET = 0L;
    long tof_pt = Convert.ToInt64(TofPT);
    bool q = Val(CnlNum) > 0;
    bool tof_in = TofIn > 0;
    
    int res = Array.IndexOf(TofNum, CnlNum);
    if (res == -1)
    {
    res = TofNum.Length;
    Array.Resize(ref TofNum,  res+1);
    Array.Resize(ref TofST,   res+1);
    Array.Resize(ref TofFlag, res+1);
    TofNum[res] = CnlNum;
    }
    
    if (tof_in)
    {
    q = true;
    TofFlag[res] = true;
    TofST[res] = 0L;
    ET = 0L;
    }
    else
    {
    if (TofFlag[res])
    {
    TofFlag[res] = false;
    TofST[res] = Ticks();
    ET = 0L;
    }
     else
     {
       if (q) ET = Ticks() - TofST[res];
     }
     if (ET >= tof_pt) q = false;
    }
    return Convert.ToDouble(q);
    }

    Add in the Formula of the Administrator

    Configure the calculated channel formula – Tof(controlled channel, 20000)

    #4297
    Mikhail
    Mikhail
    Moderator

    Hi Josef,

    Other approach that may be easy to understand:
    1. Install Automatic Control Module and create triggers that will raise commands on your conditions. There are delays and deadbands available.

    2. Create an output channel and use SetVal() function to change a corresponding input channel.

    #4336

    josef.novotny
    Participant

    When i created new folmula by manjey73.
    Then I `apply and restart scada service.
    Scada server not running.
    In log…

    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> ScadaServerService 5.1.0.4 is started
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Module is loaded from the file C:\SCADA\ScadaServer\Mod\ModAutoControl.dll
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Module is loaded from the file C:\SCADA\ScadaServer\Mod\ModDBExport.dll
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Check the existence of the data directories is completed successfully
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Check the existence of the configuration database files is completed successfully
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Input channels are read from the configuration database. Active channel count: 114
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Ouput channels are read from the configuration database
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Users are read from the configuration database
    2018-10-04 00:27:46 <WRK-SCADA-V01><SYSTEM><ACT> Formulas are read from the configuration database
    2018-10-04 00:27:47 <WRK-SCADA-V01><SYSTEM><ERR> Error compiling the source code of the formulas: 
    Line 543, column 14: error CS0103: The name Ticks does not exist in the current context.
    Line 548, column 16: error CS0103: The name Ticks does not exist in the current context.
    See the file C:\SCADA\ScadaServer\Log\CalcEngine.cs with the source code
    2018-10-04 00:27:47 <WRK-SCADA-V01><SYSTEM><ERR> Normal program execution is impossible.

    After delete new “Tof” formula. All ok again.

    • This reply was modified 3 months, 3 weeks ago by  josef.novotny.
    #4338

    manjey73
    Participant

    Sorry, all timer formulas still need Tiсks formula to work

    public static long Ticks()
    {
    DateTime now = DateTime.Now;
    long time = now.Ticks/10000;
    return time;
    }

    Without this formula, all timers will give an error, and since the formula timers are different, but use the same calculation of the difference, the Ticks made a separate formula

    • This reply was modified 3 months, 2 weeks ago by  manjey73.
    • This reply was modified 3 months, 2 weeks ago by  manjey73.
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.