Anyway the program is simple, check the input (its a relay contact) when it calls, do X wait 5 min and loop.
The problem is it wont work, I get it doing crazy things, running in reverse firing out of turn ect.
Whats even more frustrating is that If i write the program long hand it works fine with an occasional out of turn. I suspect it could be the controllers fault, occasional faulty signal (need to write it in a way to check it multiple times) short hand the thing goes nuts. Yet if you do a simple test program a basic switch it works fine so how can it be hardware?. I was told I probably need an offamp that makes no sense, its either on or off its not that complicated. Maybe the analog pins are more stable IDK
this runs nuts
public static void Method_6() { while((method_state_6) && (!phcontroller.Read())) //phcontroller is just a relay that closes when needed { ph.Write(false); Thread.Sleep(2000); ph.Write(true); Thread.Sleep(5 * MinuteMs); } }
this is almost fine
public static void Method_6() { bool phState = true; while (method_state_6 == true) { phState = phcontroller.Read(); if (phState == false) { ph.Write(false); Thread.Sleep(2000); ph.Write(true); Thread.Sleep(5 * MinuteMs); } else Thread.Sleep(1000); } }