It's not that you didn't ask nicely enough, it's just that this is a busy time of year, even for geeks and other engineering types! Plus your requirements will take a little thought, and after all of the eggnog floating around, well......
I have given requisite thought to developing a thermostat to supplement a project that I have been playing with for a while, so here goes;
Your setpoints, the temperature at which you will energize your relays to bring on the heating and air-conditioning, can fit in a byte sized variable, provided we are using the thermostat for comfort heating and cooling, as opposed to process control. Herein lies the first dilemma, will you allow settings in Fahrenheit, Celcius, or both? I will assume for now that you will allow settings to be in either. We can use a flag in picbasic to check for degrees F. or degrees C. I like to use a variable that is byte sized, and call it something silly and obscure, like, I don't know, Flags, or something. So let's try it.
'following line is an actual picbasic pro command;
Flags var byte 'variable to hold up to eight flags.
I didn't pay attention, but don't your selected temperature sensors output a voltage based upon a change in degrees Fahrenheit? So if we want the setpoint to be in degrees F. we just set the Flags.f = 1, and if we decide to change to degrees C. at some point then we just change the Flags.f = 0. So now when we test the flag using the pic basic command;
'following line is an actual picbasic pro command;
IF Flags.f true then
' this is where any code goes to accept Fahrenheit data.
Now, this is important, because you have to decide, will you test to ensure that if the Flags.f bit is a 1, or true, that your Pic won't accept any setpoints below 55 degrees, or over 95 degrees? If you are expecting F. setpoints, and your cousin from Quebec comes in over your serial port and sees a heating setpoint setting, he will of course enter something sane, like 21 degrees. This is a comfortable setting for our friends to the far north, but here in Pennsylvania most of us would put in a 71 or so setpoint. So we can do something like,
get_setpoint:
serin2 [setpoint]
If Flags.f = 1 and dec setpoint < 55 or dec setpoint > 95 then
lcdout $fe,1,"Setpoint out of range, please try again"
gosub get_setpoint 'go back and try again.
next we can set a flag for heating or cooling
if Flags.h = 1 then 'we are set for heating mode
so when we read our temperature in the controlled space we can compare it
to see if we need to turn on the heat.
I'll assume that you have the adc reading the lm34 temp sensors, and that you have stored the value in a variable called temperature.
if Flags.h = 1 and temperature < setpoint then gosub turn_the_heat_on
if Flags.h = 1 and temperature >= setpoint then gosub turn_the_heat_off
if Flags.h = 0 and temperature > setpoint then gosub turn_on_the_air-conditioning
if Flags.h = 0 and temperature <= setpoint then gosub turn_off_the_air-conditioning
You will also need a fan switch. Usually you can set fan on, off, or auto.
The fan must be turned on anytime that the air conditioning system is running, or you will freeze your indoor(evaporator) coil. If you are using this on a heat pump, then the fan must also be turned on immediately. If you are heating with a fossil fuel, such as a gas furnace, then you want to select let the air in the plenum come up to tempature first, then energize the fan, this way you don't blow cold air into the conditioned space. So, if the Auto flag is set, we will call for heat, and let a bonnet switch, or something similar, bring the fan on when the plenum temperature reaches at least ninety degrees or so F.
Let's us set two flags, Flags.auto and Flags.off
turn_the_heat_on:
if flags.auto = 1 then 'set the pin high to energize your heat relay.
ensure that the furnace will bring a blower on when the plenum temperature rises. This switch is usually located in the front control panel on the furnace.
Oops, Santa's helper says that I have to leave now. I'll try to get back to
finish this up over the next few days. I know a lot about thermostats and heating and air conditioning systems, so I can get you started with coming up with an anticiaptor, and other things.
Have a Merry Christmas,
Jerry




Bookmarks