Jump to content

Recommended Posts

Posted

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

 

  • MVP 2023
Posted

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.

Posted

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?

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.