'ver 1.2 of a program for the Basic Smart A/C Controller 'uses a Picaxe-28x1 MCU, '2-74HC595 that drive two 7-segment com anode LED displays 'thermostat can be set from 35f to 85f 'to set thermostat, press up or down buttons display will flash at .5 htz 'use up down button to set--display returns to normal mode after 10 seconds 'compressor 5 minute off protection 'mode switch allows airflow to be displayed in .5f differential 'leds show compressor on, low airflow, ice on evaporator 'low airflow cutoff can be set by first putting mode switch in airflow 'position (pin 6 low) and MODE=0,AIRFLOW will then be displayed 'next, press up or down buttons and display will flash, then set airflow 'cutoff point. when done, display will stop flashing and airflow cutoff 'point will be set, mode switch can then be returned to normal 'normal comp off=5 minutes: with jumper at j6 it is 3 min '6/23/2008 symbol compon=7 symbol lowairflow=6 symbol iceonevap=5 symbol up=pin6 symbol down=pin5 symbol mode=pin7 'if airflow switch on mode=0, otherwise mode=1 symbol rcklatch=0 'setup out0(21) to 595 rck pin 12--latch symbol sckclk=1 'setup out1(22) to 595 sck pin 11--clock symbol ser=2 'setup out2(23) to 595 ser pin 14--ser in symbol number=w13 symbol sum=w12 symbol adc10tempdata=w11 symbol RawTempData=w10 symbol AvgTemp=w9 symbol settemp=w8 symbol evapuhtmp=w7 symbol evaphtmp=w6 symbol airflow=w5 symbol setair=w4 symbol N=b0 symbol bitcounter=b1 symbol outbyte=b2 symbol outnible=b3 symbol whichsensor=b4 symbol room=0 symbol evap=1 symbol hevap=2 symbol tempscale=pin0 'dipsw1 pos 1 off deg F, on (pin0=0)deg C symbol celsius=0 EEPROM 0,(18) EEPROM 2,(45) #picaxe 28x1 start:disablebod low compon 'make sure compressor is off low lowairflow 'shut off law airflow LED low iceonevap 'shut off Ice On Evaporator LED pause 2000 'wait two seconds high lowairflow 'turn on low airflow LED for test pause 2000 low lowairflow 'turn off lowairflow LED-test over high iceonevap 'turn on Ice On Evap LED for init test pause 2000 low iceonevap 'turn off Ice on Evap LED-init test over 'settemp=45 'setair=18 If tempscale=celsius then goto mainC 'check celsius of fahrenheit 'if fahrenheit continue otherwise restart at mainC ' Nextdisplay room temperature mainF:disablebod read 0, WORD setair read 2, WORD settemp pause 100 if mode=0 then low compon gosub disairflow endif whichsensor=room 'choose room to take temp gosub taketemp 'take room temperature number = AvgTemp/2 min 0 max 99 'number now has room temp in whole degf gosub displnum 'display room temperature gosub evapsnsrs if up=0 or down=0 then gosub settherm whichsensor=room gosub taketemp number=AvgTemp/2if number > settemp and airflow < setair and evapuhtmp > 64 then high compon 'then send signal to turn on comp else 'else turn of compressor or low compon 'make sure it is off endif if airflow>=setair then high lowairflow else low lowairflow endif if evapuhtmp<=64 then high iceonevap else low iceonevap endif goto mainF mainC: number=$FE gosub displnum pause 1000 read 0, WORD setair read 2, WORD settemp pause 200 if mode=0 then low compon gosub disairflow endif whichsensor=room 'choose room to take temp gosub taketemp 'take room temperature number = AvgTemp/2 min 0 max 99 'number now has room temp in whole degf gosub displnum 'display room temperature pause 2000 gosub evapsnsrs if up=0 or down=0 then gosub settherm whichsensor=room gosub taketemp number=AvgTemp/2 sum=0 For N=1 to 64 readadc10 evap, RawTempData sum=sum + RawTempData Next N AvgTemp=Sum/64 min 0 max 198 if number > settemp and airflow < setair and AvgTemp > 155 then high compon 'then send signal to turn on comp else 'else turn of compressor or low compon 'make sure it is off endif if airflow>=setair then high lowairflow else low lowairflow endif if AvgTemp<=155 then high iceonevap else low iceonevap endif goto mainC '*********************************** '**subroutine to set the low airflow cutoff point setairflow: read 0, WORD setair number=setair 'the next 6 lines 'flash the airflow setting for N = 1 to 20 number=setair 'the next 6 lines gosub displnum pause 125 number=$FF 'shuts off gosub displnum 'display for pause 125 'half second if up = 0 then inc setair pause 50 N = 1 elseif down=0 then dec setair pause 50 N = 1 endif next N write 0, WORD setair pause 500 read 0, WORD setair return '************************************* '**subroutine**Take 10 bit temperature data and store it in AvgTemp... 'whichsensor stores the info on which sensor is beign used 'the variable RawTempData stores the info--in .5F resolution 'thus if RawTempData=150 then the actual temp is 75F taketemp: sum=0 For N=1 to 64 readadc10 whichsensor, RawTempData sum=sum + RawTempData Next N AvgTemp=Sum/64 min 0 max 198 If tempscale=celsius then AvgTemp=AvgTemp-64*5/9 endif return '*************************************** 'this modified subroutine skips the celsius conversion 'so airflow subroutine works better taketempC: sum=0 For N=1 to 64 readadc10 whichsensor, RawTempData sum=sum + RawTempData Next N AvgTemp=Sum/64 min 0 max 198 return '**subroutine**displays the data in "number" in decimal displnum: if number = $FF then 'display 2 blanks if number =$FF outnible = 10 gosub outdigit outnible = 10 gosub outdigit pulsout rcklatch, 1 return endif if number = $FE then 'display blank C" if number = $FE outnible = 11 gosub outdigit outnible = 10 gosub outdigit pulsout rcklatch, 1 return endif outnible=number % 10 'outnible now has lsd gosub outdigit 'send lsd outnible=number / 10 'outnible now has msd gosub outdigit pause 200 pulsout rcklatch, 1 return 'next is outdigit routine outdigit: ' 0 1 2 3 4 5 6 7 8 9 blank C lookup outnible, ($C0, $F9, $A4, $B0, $99, $92, $83, $F8, $80, $90, $FF, $46), outbyte for bitcounter = 0 to 7 if outbyte>=128 then outhi low ser goto clkout outhi: high ser clkout: pulsout sckclk, 1 outbyte=outbyte*2 next bitcounter return '********************************************** 'the following subroutine displays the settemp and then flashes it 'it also prepares for the set temperature to be changed with the 'use of the up and down buttons settherm: read 2, WORD settemp number=settemp 'the next 6 lines 'flash the thermostat setting for N = 1 to 20 number=settemp 'the next 6 lines 'if tempscale=celsius then 'number=number-64*5/9 'endif gosub displnum pause 125 number=$FF 'shuts off gosub displnum 'display for pause 125 'half second if up = 0 then inc settemp pause 50 N = 1 elseif down=0 then dec settemp pause 50 N = 1 endif next N write 2, WORD settemp pause 500 read 2, WORD settemp return '******************************************* 'the following subroutine will display the 'difference between the evaporator's 'heated and unheated sensors 'this difference will be in half degrees 'example if the display shows 20 this means 'there is 10F degrees difference between sensors disairflow: do gosub evapsnsrs number=airflow gosub displnum pause 100 if up=0 or down=0 then gosub setairflow loop until mode = 1 return '******************************************** 'subroutine takes tmp of both evap sensors (heated and unheated) 'and stores then in evaphtmps and evapuhtmp evapsnsrs: whichsensor=evap 'first take the temp of unheated sensor gosub taketempC 'get data in AvgTemp evapuhtmp=AvgTemp whichsensor=hevap gosub taketempC evaphtmp=AvgTemp airflow=evaphtmp-evapuhtmp min 2 max 95 return