Jump to content

Started trying to figure out Variables, lost in translation...


EagleAye

Recommended Posts

Here is the situation. I have a Autelis Pool Control that inputs State Variables to ISY.

I was trying to figure out a way to create a differential temp value variable from 2 temp inputs in State tab. I am able to easily have the 2 State variables update 2 Interger variables I created (and don't even know if this is needed, but playing).

Basically, I am trying to set up a differential variable from 2 temp readings. If the differential variable is greater than 3 or 4 (degrees) then I would trigger a program to run (increase flow with pump, which currently works as programmed).

Is there an easy way to take 2 Interger or State variables and subtract the two to create a differential variable, and then program that variable to start a program when the total is 3 or 4 (or x) differential? All I am seeing is +-< etc.

If I can get this simple one going, it will open up huge amounts of things I could implement with everything else (solar, power, weather, Lux, etc).

What am I missing?

And Thanks for ANY input!

Link to comment

Yes.

In the first program create conditions that will always be true to catch when the values change.  I'll use State1, State2, State3 in this example.  we also need a temporay integer variable for math.

IF

    State1 > 0      (something always true)

or state2 > 0      (also always true)

then

    Integer_temp = State1

    Integer_temp -= State2

    State3 = Integer_temp

--- anytime either state1 or state2 change in value state3 will be computed.

in a second program:

If

    State3 > 4

then

   (increase flow)

in the third program

If

   State3 < 2

then

   (decrease flow)

 

anytime state3 is updated by the first program, programs 2 and 3 will be evaluated.

Link to comment

Thank You, Thank You.

I will play with this shortly. Is there a good primer that I could refer to in order to increase my ignorance on this instead of shooting in the dark blindly? I have looked, but found nothing definitive as of yet. The way I get by is seeing what other people happen to post, and gathering bits and pieces to attempt something workable.

It is tough when starting out. Rather steep learning curve when fumbling around with no guidance.

Link to comment
57 minutes ago, EagleAye said:

Thank You, Thank You.

I will play with this shortly. Is there a good primer that I could refer to in order to increase my ignorance on this instead of shooting in the dark blindly? I have looked, but found nothing definitive as of yet. The way I get by is seeing what other people happen to post, and gathering bits and pieces to attempt something workable.

It is tough when starting out. Rather steep learning curve when fumbling around with no guidance.

there is the ISY Cookbook

but then again asking questions to get pointed in the right direction is pretty simple too.   The most important things to grasp are how event based IF statements work, and the difference between State and Integer variables.   When a state variables value changes it causes programs whose IF statements contain them to be run.  When run the entire IF statement is evaluated down to a single True or False.   If True the THEN statements are executed, If False the ELSE statements are executed. 

You must be careful because something like IF STATE_A > 3 AND STATE_B < 99  AND STATE_C = 100 AND TIME IS 3:00PM means that the THEN block will ONLY run at 3pm when all 3 of the other conditions are ALL true.   On the other hand if this program has an ELSE statement it will get run anytime A, B, or C changes and at 3pm.   the ELSE portion often bites unsuspecting people in the butt....  because the ELSE lines run way more often than they expect them too.

Integer variables on the other hand, when used in an IF statement will not cause the program to run, but might be used to change the outcome.   For example:

IF INTEGER_A > 100 THEN .... ELSE.... will never be triggered.  Integer variables don't have the magic property that State variables have that trigger IF statements.  An Integer variable could be used in conjunction with something else in an IF statement tho to change the outcome.

IF STATE_A > 100 AND INTEGER_C = 5 THEN... ELSE.... in that case anytime STATE_A changes the IF will be evaluated, INTEGER_C can change millions of times and nothing will happen tho.    BUT when STATE_A changes the value of INTEGER_C is important because if it's 5 AND STATE_A > 100 then the THEN clause will run, but if STATE_A <= 100 or INTEGER_C is anything but 5 then the ELSE is going to run.

In conclusion, a change to a State variables can be used to trigger things happening, Integer variables don't trigger things but instead can change the outcome when the trigger occurred by another event.

 

Confused yet?   feel free to ask questions until you understand things....

Link to comment

That works. I needed to swap a couple of things to show a positive instead of a negative variable, but I have the basic idea of how it is working. You just opened up a whole new can of worms to play with.

Once you see the basics working real-time, then the examples and cookbook become dangerous!

Thanks again for the quick reply, and probably NOT the last time I will need a (simple) question answered!

Link to comment
13 hours ago, EagleAye said:

That works. I needed to swap a couple of things to show a positive instead of a negative variable, but I have the basic idea of how it is working. You just opened up a whole new can of worms to play with.

Once you see the basics working real-time, then the examples and cookbook become dangerous!

Thanks again for the quick reply, and probably NOT the last time I will need a (simple) question answered!

Used as an inline "If" construct, this can negate any variable

Repeat While $variable > 0
    $variable *= -1
Repeat 1 times

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...