I've made a very simple heater controller with my Arduino and incorporated some hysteresis in software like so:
if (temperature < (setTemp - HYSTERESIS)) digitalWrite(TRIAC_PIN, HIGH);
if (temperature > (setTemp + HYSTERESIS)) digitalWrite(TRIAC_PIN, LOW);
That's the core of the temperature controller. It works fine. (Well, my simulation using the built-in LED works fine, but I haven't connected the heating element yet.) Anyway, I see that when we are in the no man's land between the high and low borders of the hysteresis loop, the state of the TRIAC_PIN stays whatever it was previously. When I think about it, I see no problem with this. The system will leave that area at some point and the controller will take charge again. But considering we're dealing with 120VAC and a heating element here, I want to make sure there is no logic error there that can allow some sort of runaway condition.For that matter, can anyone refer me to some information on programming for safety?
In my day job I do this sort of thing with relay logic all the time. But programming, though similar, is a different story. I'm not using pointers or passing arrays to functions, so I don't think I have to worry about memory leaks. What else should I look out for?
Thanks a lot for your help.