GroveStreams
micl78 private msg quote post Address this user
Hi,
I need to edge trigger an event t achieve hysteresis on a signal and i cant see an easy way to do it. My scenario is quite common i think, so i hope someone can get me looking in the right place. I have an oil tank and i measure the level (and calculate remaining volume). when the volume goes below 700 litres I want to send an event 'Time to top up'. I thin want to disarm this event until the tank fills up beyond 800 litres. Because of temperature changes, the volume measurement fluctuates about +-10 litres and i currently get many triggers. I don't just want a time delay here as that is not suitable, The cycle is in the order of 8 months.
Thank you
Michael.


Post 1 IP   flag post
MikeMills private msg quote post Address this user
Create a "Tank State" regular derived stream and make it a value type of String and have an event monitor the value of that stream:

* Edit your component and create a Regular stream
* Name it whatever (i.e. Tank State)
* Give it a value type of String
* Make its default rollup Last
* Click on the Derivation tab and select From Expression
* Set the effective date to a very early date - earlier than the Volume stream
* Toggle the Drag and Drop button at the top and then drag the Volume stream onto the dependents grid. var1 below will be the value of the Volumne stream.
* Set the Expression to:

if(isNull(LAST_VALUE), "Normal", 
   if (LAST_VALUE == "Normal" && var1 < 700, "Low", 
      if (LAST_VALUE == "Low" && var1 >= 800, "Normal", NULL)
   ) 
)


* Un-toggle the drag and drop button
* Create an event that monitors the State stream
value == "Low"
* Save the component

When the volume drops below 700, the start action package will be executed. When it gets back above 800, the stop action package will be executed.

The isNull checks to see if it is the first run and there is no previous State Sample. If so, just set the state to Normal and the next Volume sample used in derivation will do the proper state check. I think two states : Normal and Low are good enough.

The second if will only add a new State sample if the current state is Normal and the Volume dropped below 700.
The third if resets the state to Normal after the tank is filled.
The last if will return NULL if the state should not change. Returning Null implies to not derive a sample for current run.

You could use Point streams for the 700 and 800 amounts and create a dashboard with a Stream Form to allow those numbers to be easily configurable per tank or on-the-fly.

Disclosure: I didn't actually set this scenario up so there may be issues with the expression or something I haven't thought of.

Derivation Example Page
Post 2 IP   flag post
MikeMills private msg quote post Address this user
@micl78 - I submitted a bit early and have edited the above post.
Post 3 IP   flag post
2965 3 3
Log in or sign up to compose a reply.