Loop with two variables requiring hysteris


Vweber

Recommended Posts

I need a script that turns on pump, P1 when atemperature sensor T1 is 10 degrees greator than temperature sensor T2 and keeps P1 running until temperature sensor T1 is less than 5 degrees greator than T2.

 

i have tried:

while (1)

 if ((T1[0] - T2[0] >= 10) && (T1[1] -T2[1] >= 10))

 P1 = 1

 endif

 if ((T1[0] - T2[0] <= 5 ) && (T1[1] -T2[1] <= 5))

 P1 = 0

 endif

endwhile

 

this just turns the pump on and off once per second or so while 10 degree threshold is met.

 

have tried a few other iterations, but it justdoes not seem to like the variable sum on readings taken every second.

 

any help is appreciated!

 

vic

Link to comment
Share on other sites

I did have a delay in the script I tried forgot to list it here.  Delay (1) after second endif.  P1 is digital output channel timing is 1 sec.

when I write a simpler script such as 

while (1)

 if T1 [0] > 80

 P1 = 1

endif

Delay (0)

endwhole

 

The pump turns on and remains on once T1 exceeds 80.  So channel appears to work.

 

Link to comment
Share on other sites

Archived

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