I have an air compressor in an enclosed space, to keep noise down. This means that I need ventilation to prevent it from overheating. What I am trying to do is write a program that will 1) monitor a thermistor in the box, 2) operate a relay that controls a vent fan when the temp reaches a set limit, and 3) shut the whole thing down if the fan runs too long without bringing temps back down. My intention is to protect the compressor in the event that the fan fails, or is unable to cool properly in hot weather.
Here's my code so far, it does 1) and 2), but I need help with 3).
For testing purposes, I'm using 10 seconds as my run-time limit, though in reality it'll be more like 20 minutes. I'm also doing the same thing with the temperature limit, so I can trip the sensor with my hand for testing. Cycling the fan on and off is working fine, but I'd like to know what the most reasonable way is to shut the program down if the RUNTIMETHRESH is exceeded. RELAYPIN connects to a large contactor relay that controls mains power to the compressor. I want the error mode to switch off the relay, and blink FANLEDPIN continuously- meaning the only way to reset the control is to unplug/replug the Arduino.
So, in between the **** lines, I need to find a way to keep the program looping the LED on and off, without going back to the beginning and turning the relay back on. Is "while" the right tool for this job?
Rather than making your sketch effectively die, I would have thought it made more sense to bring the fans in if the temperature exceeded a set point, and shut the compressor off if the temperature exceeded another, higher temperature - and turn the compressor on and the fan off as the temperature dropped. That way you can arrange for it to all reset itself automatically when things have cooled down again.
For a simple solution, consider line-voltage thermostats for sale in the USA that are designed for electric baseboards. Fairly cheap, can handle high loads (though the inductive kickback of a compressor may present a problem for any device interrupting its line service). Once the temperature setpoint is exceeded, the thermostat will 'open' the line, no microprocessor needed. This way you can directly interface the compressor with the thermostat. Single-pole versions are good for low-hp, 120V compressors, while the dual-pole versions can be used for 230V service. A quick google scan indicates unit prices ranging from about $15-26 for manual versions.
A downside of a manual thermostat is the (usually limited) temperature range. 80F may be below your cutout temperature. On the other hand, I'm not sure it's a good idea to run a compressor within a space with a very hot air supply (i.e. much above 90F).
Now, if you want to insist on micro-processor solution, one additional option is a watchdog timer that automatically resets the microprocessor unless the microprocessor program is running normally (and updating the values that the watchdog timer is accumulating). Several GPRS shield solutions use such watchdog timers since sometimes the gears get gummed up and the microprocessor hangs.
The fun of look, I didn't have to over-engineer and over-budget something simple?
A car radiator valve has more muscle but needs a lot of heat to open.
Thing is, it can open the vent hatch with the fan switch attached.
Downside, they cost more new than a bi-metal coil from a junk yard and I wouldn't trust an old one.
If you want to get creative, make something that uses waste heat to power the fan(s).
Or maybe a stovepipe with baffles would just draw the hot air out without too much noise,
when a vent does open it's going to get loud anyway.
PeterH:
Rather than making your sketch effectively die, I would have thought it made more sense to bring the fans in if the temperature exceeded a set point, and shut the compressor off if the temperature exceeded another, higher temperature - and turn the compressor on and the fan off as the temperature dropped. That way you can arrange for it to all reset itself automatically when things have cooled down again.
Thought of that, but I prefer the idea of forcing human interaction so that it doesn't go unnoticed. Nothing wrong with your idea, but I prefer mine.
The fun of look, I didn't have to over-engineer and over-budget something simple?
A car radiator valve has more muscle but needs a lot of heat to open.
Thing is, it can open the vent hatch with the fan switch attached.
Downside, they cost more new than a bi-metal coil from a junk yard and I wouldn't trust an old one.
If you want to get creative, make something that uses waste heat to power the fan(s).
Or maybe a stovepipe with baffles would just draw the hot air out without too much noise,
when a vent does open it's going to get loud anyway.
And I'm the one who's over-engineering? What exactly do you think a "radiator valve" is, anyway?
Look, this is a question about programming. I even posted in the "Programming Questions" board. A couple people have pointed out two ways of doing what I want. I'm not trying to change the world with my automatic fan starter-upper, I'm trying to make a program do something useful. This is what I want it to do. The rules say "post your code", so I posted it. Until NASA calls and asks me to design something for the Mars Rover, I'm going to stick with things that I can use around the house- even if they're not 100% necessary. Is that really a problem for you? What do you do with your Arduino?
( Oh, I forgot to mention, the conversion of tempreading to a resistance value is one step that adafruit.com uses in their tutorial so that I can get a *F value, which I would like to send to an LCD screen at some point. That's not in the program yet, I'm trying to eat this elephant one bite at a time. So, yeah, right now it's useless.)
tsmi243:
I'm trying to make a program do something useful. This is what I want it to do.
There's nothing wrong with doing a project just because you want to, but if you're pursuing a solution which is not the simplest or most straight forward way to do what you've said you want, and you haven't made it clear that you're doing this for the fun of it, then don't be surprised if people recommend options that you seem to be overlooking.
The fun of look, I didn't have to over-engineer and over-budget something simple?
A car radiator valve has more muscle but needs a lot of heat to open.
Thing is, it can open the vent hatch with the fan switch attached.
Downside, they cost more new than a bi-metal coil from a junk yard and I wouldn't trust an old one.
If you want to get creative, make something that uses waste heat to power the fan(s).
Or maybe a stovepipe with baffles would just draw the hot air out without too much noise,
when a vent does open it's going to get loud anyway.
And I'm the one who's over-engineering? What exactly do you think a "radiator valve" is, anyway?
From back before there were microprocessors a car radiator valve was mainly two layers of different metals fused together in a housing with valve flaps. They had no power connections yet were strong enough to hold against pump pressure, more than strong enough to flip a switch and off the shelf solidly automotive-standard reliable.
Please understand that I'm more concerned about the expensive piece of machinery that are trying to protect.
You might even look at an analog temperature sensor wired to an Arduino-compatible relay through a resistor and transistor. The relay triggers, on goes vent opener and fan.
GoForSmoke:
From back before there were microprocessors a car radiator valve was mainly two layers of different metals fused together in a housing with valve flaps. They had no power connections yet were strong enough to hold against pump pressure, more than strong enough to flip a switch and off the shelf solidly automotive-standard reliable.
I've never seen a thermostatic valve like that.
Almost all thermostatic valves are operated by a cannister full of wax which expands with heat and drives a pin out - the pin is mechanically connected to a flap to seal/divert the coolant. A heavy spring keeps the wax under pressure and pushes the pin back as the wax cools and contracts. On some modern cars the cannister includes an electrical heating element so that the operating point can be varied by an electronic controller.
The bimetallic device you describe sounds like what is often called an 'otter switch' and is simply used to make/break an electrical circuit to operate the fans - it does not generate any significant mechanical force and doesn't directly operate anything mechanical. These have largely been phased out in favour of simple relays driven directly from an ECU.
What is being proposed here could be implemented trivially easily using a couple of otter switches, but I gather the OP wants to use a microcontroller.