Jump to content

How to monitor a value change


Recommended Posts

Hello!

I am tracking some values in my application thru MQTT and would like to trigger a publish event if for example a value changes for a fixed amount or percentage. What I am using right now is periodic transfer but would like to save some bandwidth if data isn't changing much. Also, I need some kind of general solution to implement it on 50 values.

Let me give you an example: we are monitoring an outside temperature. The sensor is quite unstable and changes in tenths every few seconds. It's value table at 10am might look like this:

10:00:01    102 = 10,2 degrees C
10:00:02    102
10:00:03    103
10:00:04    104
10:00:05    104
10:00:06    103
10:00:06    103

...  You get the idea. Now, I do not need to transfer these minor changes to my broker every second or on every change. I would like to detect a change of 5 tenths and only then send the data to my server. And periodically every hour for example to have records with timestamps.

What are the possible solutions with UniLogic to achieve this kind of reaction with hysteresis?

Regards,

Ales

 

Link to comment
Share on other sites

  • MVP 2023

Store the value in a temporary location immediately after transferring it. Compare the new value to the stored value (+/-5). When the new value is greater than stored value +5 or less than the stored value -5, then send the new value and store it again to the temporary location.

Link to comment
Share on other sites

Thanks, I am sure it works that way, but I was hoping for some kind of advanced functionality included with Unilogic, like observers or onChange events to not having to add those compare statements for every variable. What I would love to see is having a table of observed variables and set boundaries on them (either fixed or relative) and they would change a "state" of a variable (low-low, low, normal, high, over-the-moon or up-5-percent, down-5-percent)  which you could also use for styling the display on HMI. Right now I am struggling with that too.

Ok, now I am ranting, but thanks for your time and suggestion. Many things can be done in a such a "manual" way, but I am always looking for more automation. That's our business, right?

Link to comment
Share on other sites

You could create a data table with a row for each sensor, and columns for current and stored values, and sensitivity criteria. You then write a loop to process the table at some suitable frequency, reading into the table the current value from the sensor and performing the same comparison calculation each time, but with custom values for each sensor. You can implement loops in ladder code using the Jump to Region function.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...