I am getting a strange error message associated with the PWMoff command. If I try to comment out line 103 or 129 I get this message:
Error: Program is too large, cannot fit all subroutines into available program memory
Here is the code:
'Snow melt V 3.0 08-23-11
'Tried to remobe PWM for Snow Sensor
'Copyright E.V. LaBudde 2011
'Tested all modes 08-09-11
'Chip model
#chip 16F88, 8 'Pic model and clock MHz
#config INTRC_IO 'Use internal Oscillator
Osctune = b'111110' 'works from 111000 to 000011
'Set the pin directions
dir portA.0 In 'Cold pin 17
dir portA.1 In 'Hot pin 18
dir portA.2 In 'Ambient Temp pin 1
dir portA.3 Out 'Heater pin 2
dir portA.4 Out 'Pump pin 3
dir portB.0 In 'New Snow signal pin 6 Tied to pin 8
dir portB.1 In 'Manual Heat mode pin 7
dir portB.2 In 'Snow pin 8
dir PortB.3 Out 'Test port Pin 9
dir portB.4 In 'Manual Circulate Mode Pin 10
dir portB.5 Out 'LCD pin 11
'set defines
#define SendAHigh Set PORTB.5 Off 'Note Polarity for 4X20 Newhaven display
#define SendALow Set PORTB.5 On
#define Cold An0
#define Hot An1
#define Temp An2
#define Heater PortA.3
#define Pump PortA.4
#define ManualMode PortB.1
#define Snow PortB.2
#define Test PortB.3
#define ManualCirc PortB.4
#define LCD PortB.5
dim AmbientT as integer
dim WaterinT as integer
dim WateroutT as integer
dim AmbientTemp as word
dim E_timemin as word
dim DeltaT as word
dim DisplayAmbT as word
dim DisplayinT as word
dim DisplayoutT as word
dim WaterinTemp as word
dim WateroutTemp as word
dim MeltTime_s as word
dim MeltTime_m as word
dim MeltTime_L as word
'Set inital parameters
InitSer 1, r2400, 1, 8, 1, none, invert 'LCD interface Positive going Standby bit 2400 baud
Set LCD = On 'Init LCD
wait 200 ms
Option_reg.7 = off 'Enable WPU
MeltTime_s = 0 'Zero Melt times
MeltTime_m = 0
MeltTime_L = 0
E_timesec = 0 'Zero Elapsed times
E_timemin = 0
E_timehrs = 0
Tons = 0
On Interrupt ExtInt0 Call SnowCheck
Standby:
Set Pump = Off 'Turn system Off
Set Heater = On 'Keep heater on to defrost
E_timesec = 0 'Zero Elapsed times
E_timemin = 0
Ambient = ReadAD(Temp) 'Read Ambient air sensor
ReadTable Tconvert, Ambient, AmbientTemp 'Look up temeperature value
AmbientT = AmbientTemp - 80 'Correct for lack of negiative numbers in table
call ReadWater 'Check Water Temp
call StandbyDisplay 'Refresh display
Count = 0 'Zero Write counter for EEprom writer
If ManualMode = Off and ManualCirc = On then Goto Manual 'Goto manual mode
If ManualCirc = Off and ManualMode = On then Goto Circ 'Goto circulate mode
If ManualMode = On and ManualCirc = On then nop 'Prevent going to neverland
If ManualMode = Off and ManualCirc = Off then nop 'Prevent going to neverland
If AmbientT > -25 then Goto Standby 'Bypass fluid measurement
Set Heater = Off
Set Pump = On 'Circulate water to measure WaterinT
wait 30 s
Set Pump = Off
Set Heater = On
call ReadWater ` 'Read water temperature
If AmbientT < -25 and WaterinT < -15 then Goto Warm 'Keep unit off for as long as possible
Wait 1 h 'Do hourly
Goto Standby
'Subs
Manual: 'Turn on system Checked 10-19-11
Call TurnOns
Set Pump = On
Set Heater = On
PWMOff 'Turn on heater on snow sensor
If Snow = On then MeltTime_s += 1 'record melt time
MeltTime_m = MeltTime_s/60
EPWrite 255, MeltTime_m 'Record melt time
call Elapsed_time 'Measure on time
call ReadWater 'Read water temperature
call ManualDisplay 'Refresh display
call Write 'Measure DeltaT in 10 min intervals and write to EEprom
If ManualMode = On then Goto Standby
Wait 673 ms
Goto Manual
Circ: 'Checked 10-19-11
Set Pump = On
Set Heater = Off
call Elapsed_time 'Measure on time
call ReadWater 'Read water temperature
call CircDisplay 'Refresh display
If ManualCirc = On then Goto Standby
Wait 713 ms
Goto Circ
Heat: 'Checked 10-19-11
Call TurnOns
Set Pump = On 'Turn on system
Set Heater = On
PWMOff 'Turn on heater on snow sensor
If Snow = On then MeltTime_s += 1 'record melt time
MeltTime_m = MeltTime_s/60
EPWrite 255, MeltTime_m 'Record melt time
call Elapsed_time 'Measure on time
call ReadWater 'Read water temperature
call HeatDisplay 'Refresh display
call Write 'Measure DeltaT in 10 min intervals and write to EEprom
If Snow = Off then 'Clear snow and wait 30 min.
Wait 30 m
goto Standby
End If
Wait 685 ms
Goto Heat
Warm: 'Checked 10-19-11
PulseOut Test, 1 ms
Set Pump = On 'Turn on system
Set Heater = On
call ReadWater 'Read water temperature
call WarmDisplay 'Refresh display
if WaterinT > 100 then goto Standby 'Warm up water then turn off
Wait 703 ms
Goto Warm
Sub SnowCheck
wait 1500 ms
If Snow = On then goto heat 'Test for sensor fail
If Snow = Off Then call FailDisplay
Return
Sub ManualDisplay
call Clear
serprint 1, "Mode:"
serprint 1, "Man"
serprint 1, " T"
MeltTime_m = MeltTime_s/60
Serprint 1, MeltTime_m
Serprint 1, "m"
call CommonDisplay
Return
Sub CircDisplay
call Clear
serprint 1, "Mode:"
serprint 1, "Circ"
call CommonDisplay
Return
Sub StandbyDisplay
call Clear
serprint 1, "Mode:"
serprint 1, "Sby"
EPRead 255, MeltTime_L
Serprint 1, " MTime:" 'Read melt time
Serprint 1, MeltTime_L
call CommonDisplay
Wait 1 s
Return
Sub WarmDisplay
call Clear
call First
serprint 1, "Mode:"
serprint 1, "Warm"
call CommonDisplay
Return
Sub HeatDisplay
call Clear
call First
serprint 1, "Mode:"
serprint 1, "Heat"
call CommonDisplay
Return
FailDisplay:
call Clear
call First
serprint 1, "Mode:"
serprint 1, "SENSOR FAILURE"
call CommonDisplay
Goto FailDisplay
Sub CommonDisplay
call second
call Elapsed_time 'Measure on time
serprint 1, "Ambient:"
If AmbientT_H.7 = On then
DisplayAmbT = 65536 - AmbientT
Else
DisplayAmbT = AmbientT
End If
If AmbientT_H.7 = On then
serprint 1, "-"
serprint 1, DisplayAmbT
Else
serprint 1, DisplayAmbT
End If
serprint 1, " ET:"
serprint 1, E_timemin
serprint 1, "m"
call Third
If Waterin < 52 then
DisplayinT = 65536 - WaterinT
Else
DisplayinT = WaterinT
End If
serprint 1, "WIn:"
If WaterIn < 52 then
serprint 1, "-"
serprint 1, DisplayinT
Else
serprint 1, DisplayinT
End If
call Fourth
serprint 1, "WOut:"
If Waterout < 52 then
DisplayoutT = 65536 - WateroutT
Else
DisplayoutT = WateroutT
End If
If Waterout < 52 then
serprint 1, "-"
serprint 1, DisplayoutT
Else
serprint 1, DisplayoutT
End If
EPRead 254, Tons
serprint 1, " Tons:"
serprint 1, Tons
'wait 1 s
Return
Sub ReadWater
Waterin = ReadAD (cold)
ReadTable Tconvert, Waterin, WaterinTemp
WaterinT = WaterinTemp - 80
Waterout = ReadAD (hot)
ReadTable Tconvert, Waterout, WateroutTemp
WateroutT = WateroutTemp - 80
Return
Sub Elapsed_time
E_timesec += 1 'Seconds
If E_timesec = 60 then
E_timesec = 0
E_timemin += 1 'Minutes
end if
Return
Sub Write
DeltaT = WateroutT - WaterinT
EPWrite 0, DeltaT 'Store first Delta T measurement
If E_timemin % 10 = 0 then 'Measure DeltaT in 10 min intervals and write to EEprom
Count += 1
EPWrite Count, DeltaT
End If
Return
Sub TurnOns
TurnOn +=1
EPWrite 254, TurnOn
Return
Sub TestDisplay
Call Clear
serprint 1, "First line"
Call second
Serprint 1, "Second line"
Call Third
Serprint 1, "Third line"
Call fourth
Serprint 1, "Fourth line"
wait 1 s
Return
'NewHaven Display utilities
Sub Clear
sersend 1, 254 'start CMD
sersend 1, 81 'clear screen
Return
Sub First
sersend 1, 254 'start CMD
sersend 1, 69 'First line
sersend 1, 0
Return
Sub Second
sersend 1, 254 'start CMD
sersend 1, 69 'second line
sersend 1, 64
Return
Sub Third
sersend 1, 254 'start CMD
sersend 1, 69 'Third line
sersend 1, 20
Return
Sub Fourth
sersend 1, 254 'start CMD
sersend 1, 69 'Fourth line
sersend 1, 84
Return
Sub Baud
'1=300, 2=1200, 3=2400, 4=9600, 5=14.4k. 6=19.2k, 7=57.6k, 8=115.2k
sersend 1, 254 'start CMD
sersend 1, 97 'baud select
sersend 1, 4 '9600-
wait 100 us
Return
/code]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am getting a strange error message associated with the PWMoff command. If I try to comment out line 103 or 129 I get this message:
Error: Program is too large, cannot fit all subroutines into available program memory
Here is the code: