Vweber Posted October 11, 2016 Share Posted October 11, 2016 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 More sharing options...
AzeoTech Posted October 12, 2016 Share Posted October 12, 2016 First, you forgot a delay() in the loop. Always have some sort of delay. But otherwise what you had should have worked. Is P1 an output channel with a Timing of 0? Link to comment Share on other sites More sharing options...
Vweber Posted October 12, 2016 Author Share Posted October 12, 2016 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 More sharing options...
AzeoTech Posted October 12, 2016 Share Posted October 12, 2016 I think I'd need to see the whole document. Can you post your .ctl? Or email us it? Link to comment Share on other sites More sharing options...
Vweber Posted October 12, 2016 Author Share Posted October 12, 2016 Will do so when I get back to my system tomorrow. Thanks so far for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.