Forum Home › Forums › Development and Integration › Hysteresis on input channel…
- This topic has 4 replies, 3 voices, and was last updated 5 years, 6 months ago by manjey73.
-
AuthorPosts
-
September 21, 2018 at 11:46 am #4293josef.novotnyParticipant
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
September 21, 2018 at 12:44 pm #4294manjey73ParticipantIn 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)
September 21, 2018 at 6:12 pm #4297MikhailModeratorHi 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.
October 3, 2018 at 10:32 pm #4336josef.novotnyParticipantWhen 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 5 years, 6 months ago by josef.novotny.
October 4, 2018 at 7:29 am #4338manjey73ParticipantSorry, 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
-
AuthorPosts
- You must be logged in to reply to this topic.