Heat Pump controller project

mlaymance

New Member
I am trying this new project using a picaxe.

I have a heat pump in my boat that I can no longer get a control board for,
so I am left with replacing the unit (Meggabucks) or fabricating my own controller.

I am familiar with control circuits so that portion is a no brainer for me. The Picaxe portion is where I am having a time.

I wrote the code for a 20M chip, as attached. The problem i am having is in the defrost section of the program. There are plenty of notes in the programming so the explanation of the steps should be pretty good.

I am asking for some programming assistance for that section and also constructive criticizm on the programming as a whole.

I am fairly new to the picaxe, but am willing to give it a try and am open to suggestions.
 

Attachments

eclectic

Moderator
First quick look

Code:
defrost:
			'defrost sequence-
			'when heat operates for continuous 40 minutes,
			'compressor and all fans stop, wait 3 minutes,
			'for compressor delay, turn compressor on for
			'5 minutes to defrost outdoor coil, then restart
	goto main	'heat sequence, and reset 40 minute timer.

eheat:
	pause 3000	'compressor delay should be 3 minutes to prevent short-cycle
	high valve	'reversing valve on
	high compres	'turn compressor on
	high outfan	'turn on outdoor fan
	pause 5000	'pause for 3 minutes while indoor coil heats up
	high infan	'turn on indoor fan
     	gosub defrost	'start defrost control
     	goto main
You need RETURN at the end of defrost, not
goto main

Then, please have a look at your Pause values,
they don't match your required minutes values.

e
 
Last edited:

kevrus

New Member
Just a quick look, I noticed that these two lines are the same
Code:
If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then heat
If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then eheat
so I can't see how it will get to 'eheat'
should it be

Code:
If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then heat
If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=1 then eheat
might be my eyes though...
 

eclectic

Moderator
A few more

Main:
Code:
#rem
	If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then fan
	If Pin0=0 and pin1=0 and pin2=1 and pin3=1 and pin4=0 then cool
	If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then heat
	If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then eheat
	If Pin0=0 and pin1=0 and pin2=0 and pin3=0 and pin4=0 then systemoff
	If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then systemoff
	If Pin0=0 and pin1=0 and pin2=1 and pin3=0 and pin4=0 then systemoff
#endrem	
if pins = %00001000 then fan
if pins = %00001100 then cool
if pins = %00001110 then heat	
; query  How will you get to eheat????
if pins = %00000000 OR  pins = %00001000 OR  pins = %00000100 then systemoff
	goto main
e

editadd post crossed with Kevrus
 

kevrus

New Member
also
Code:
If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then fan
is the same as
Code:
If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then systemoff
 

kevrus

New Member
Eclectic, try these...:)

Mlaymance,
another quick observation is that every time the 'cool' routine loops, the compressor will stop and go through its start delay don't think you will actually get any cooling
 

Attachments

kevrus

New Member
Not sure what the 'eheat' routine is for...
see if this does what you want, it may be a little untidy but you could work on that

Code:
'heatpump controller using 20M

'defrost sequence-
'when heat operates for continuous 40 minutes,compressor and all fans stop, waits 3 minutes for compressor delay, then turn compressor on for	5 minutes to defrost outdoor coil, then returns to 'heat' routine




                	'inputs from Standard Thermostat                		
                	'w lead is input 3
                	'g lead is input 2
               	'y lead is input 1
               	'o lead is input 0
               		
               		
   	'If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then fan
	'If Pin0=0 and pin1=0 and pin2=1 and pin3=1 and pin4=0 then cool
	'If Pin0=0 and pin1=1 and pin2=1 and pin3=1 and pin4=0 then heat
	'If Pin0=0 and pin1=0 and pin2=0 and pin3=0 and pin4=0 then systemoff
	'If Pin0=0 and pin1=0 and pin2=0 and pin3=1 and pin4=0 then systemoff
	'If Pin0=0 and pin1=0 and pin2=1 and pin3=0 and pin4=0 then systemoff            		
               		
               		
               		
Symbol infan=0
Symbol compres=1    
Symbol outfan=2
Symbol valve=3
Symbol coolLED=4
Symbol heatLED=5
Symbol delay_timer=w2
Symbol defrost_timer=w3           		
               		
               		
               		
systemoff:


let outpins=0			'makes all outputs low
pause 30000				'wait 30secs for everything to stop and gas 					 pressures to equalise in cooling circuit before 				     	 proceeding with next operation

Main:
 
	let b0=pins and %00011111 
	if b0=8 then fan
	if b0=12 then cool
	if b0=14 then heat
	if b0=0 OR b0=2 OR b0=4 then systemoff
	goto main
	
'OR USE ECLECTICS 'MAIN' CODE AS THAT MAY BE EASIER TO FOLLOW
	
	
Fan:
    	high infan 			'fan only mode when fan on is selected on stat
    	do
   	gosub stat_check		'check for stat changes
    	if b0=8 then loop		'system stays in fan mode until input change
    	end if
   	goto main			'loop back to check pin status
     
Cool:
     	high coolLED     		'Cool mode indicator on
     	low heatLED      		'make sure that heat indicator is off
     	high infan       		'turn on indoor fan
     	low valve        		'make sure that reversing valve is in cool mode
     	gosub start_delay		'delay before starting compressor
     	high outfan     	     	'outdoor fan on
     	high compres		'compressor on
     	
     	do 
     	gosub stat_check		'check for stat changes
     	if b0=12 then loop	'system stays in cool mode until input change
     	end if
     	goto systemoff
     	
     	
Heat:
	low coolLed			'turn off cool indicator
	high heatLED		'turn on heat indicator
	high valve			'reversing valve on

	gosub start_delay		'delay before starting compressor

	high compres		'turn compressor on
	high outfan			'turn on outdoor fan
	
	gosub start_delay		'delay before starting indoor fan
	
	high infan			'turn on indoor fan
	
	do 
	inc defrost_timer		'40min timer before defrosting
	pause 30			'only set to '30mS' to allow for 10mS delay in 					 stat_check routine
     	gosub stat_check		'loop to check status of inputs
     	if defrost_timer=60000 then goto defrost'jumps to defrost  
     	if b0=14 then loop	'system stays in heat mode until input change
     	end if
     	goto systemoff
	
	   	
defrost:
	let outpins=0		'makes all outputs low
	gosub start_delay		'waits 3mins before starting
	high compres		'starts compressor
	
	for delay_timer=0 to 60000'60000 mS delay (can be adjusted here) 
     	pause 5  			'(or here) each additional '1' here will increase 					 delay by one min...currently 5mins    	
     	next delay_timer
     	defrost_timer=0		'resets defrost timer before exiting 'defrost' 					 routine and going back to 'heat' routine
	goto heat

	
start_delay:			'compressor start delay (currently 3 mins)
   	for delay_timer=0 to 60000'60000 mS delay (can be adjusted here)
     	pause 3 			'(or here) each additional '1' here will increase 					 delay by one min...currently 3mins    	 	 
     	next delay_timer
     	delay_timer=0		'resets timer in readiness for next time
     	return
     	
          	
stat_check:
     	let b0=pins and %00011111
     	pause 10			'short delay to allow contacts to settle
     	return
 
Last edited:

eclectic

Moderator
@Michael

Now that Kev has lent me his magnificent Lego-Specs,
let's have a look at the problem again.

First, read what Kev has said.
What, exactly, do you want to achieve?

You have four (?) inputs.
So, you have, 16 choices:
%00000000 to %00001111
What will each one do?
Where will each input send the program to?

You need timers. How accurate do they need to be?
Pause works in milliseconds.
Wait works in seconds. It only counts up to 65. (Man 2, p.190)
Minute counts? No probs., just loop in multiples of 60.

You need counters. Kev has provided a solution.

And, finally, for the moment, look at post #6 in
http://www.picaxeforum.co.uk/showthread.php?t=11249

Over to you.

e
 

mlaymance

New Member
I realized that I made some mistakes during the programming. For some reason the simulator didn't pick them up.

I am going through them as I write this and making corrections.


Here is the skinny on this project:

A standard wall thermostat provides 4 outputs
1. G= Fan (indoor fan)
2. y=Compressor
3. O= reversing valve position
4. W= Emergency heat
These are my four inputs to the pic chip.

If there is a "call for cool" then the thermostat provides a signal on the G and Y terminal. When this happens there needs to be 3 outputs (compressor, Outdoor fan, and indoor fan)

If there is a "call for heat" then the thermostat provides outputs Y, G, and O. These inputs then should provide an output of Outdoor fan, compressor, reversing valve, and indoor fan (after delay).

Here's where the tricky part comes in:
After the unit has been running continuous for more that 40 minutes, the processor should change to defrost mode (compressor only) for 5 minutes.
after this proccess it should return to normal operation.

If the thermostat is turned up for more that 3 degrees above room temperature, a supplimental heat strip will be turned on typically, but in this case, when the thermostat is set 3 degrees above the room temperature the Heat LED will flash to let the user know that the heat is running but cannot keep up with the demand. (this output could also be used to control a relay for some supplimental heat).

I will read through the posts and correct as necessary.

The timing (pauses) were set low for testing purposes. After the final programming is completed, those values will be corrected prior to loading on the PIC.

Thanks for the help......

Michael
 

RexLan

Senior Member
Not to discourage the project but all of that function is found in a $35 thermostat with the exception of the defrost cycle that only requires a simple timer board. And, the thermostats are generally set at 2 degrees (not 3) before it turns on the aux heat.
 
Top