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 OscillatorOsctune=b'111110''works from 111000 to 000011'Set the pin directionsdirportA.0In'Cold pin 17dirportA.1In'Hot pin 18dirportA.2In'Ambient Temp pin 1dirportA.3Out'Heater pin 2dirportA.4Out'Pump pin 3dirportB.0In'New Snow signal pin 6 Tied to pin 8dirportB.1In'Manual Heat mode pin 7dirportB.2In'Snow pin 8dirPortB.3Out'Test port Pin 9dirportB.4In'Manual Circulate Mode Pin 10dirportB.5Out'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 dimAmbientTasintegerdimWaterinTasintegerdimWateroutTasintegerdimAmbientTempasworddimE_timeminasworddimDeltaTasworddimDisplayAmbTasworddimDisplayinTasworddimDisplayoutTasworddimWaterinTempasworddimWateroutTempasworddimMeltTime_sasworddimMeltTime_masworddimMeltTime_Lasword'Set inital parametersInitSer1,r2400,1,8,1,none,invert'LCD interface Positive going Standby bit 2400 baudSetLCD=On'Init LCDwait200msOption_reg.7=off'Enable WPUMeltTime_s=0'Zero Melt timesMeltTime_m=0MeltTime_L=0E_timesec=0'Zero Elapsed timesE_timemin=0E_timehrs=0Tons=0OnInterruptExtInt0CallSnowCheckStandby:SetPump=Off'Turn system OffSetHeater=On'Keep heater on to defrostE_timesec=0'Zero Elapsed timesE_timemin=0Ambient=ReadAD(Temp)'Read Ambient air sensorReadTableTconvert,Ambient,AmbientTemp'Look up temeperature valueAmbientT=AmbientTemp-80'Correct for lack of negiative numbers in tablecallReadWater'Check Water TempcallStandbyDisplay'Refresh display Count=0'Zero Write counter for EEprom writerIfManualMode=OffandManualCirc=OnthenGotoManual'Goto manual modeIfManualCirc=OffandManualMode=OnthenGotoCirc'Goto circulate modeIfManualMode=OnandManualCirc=Onthennop'Prevent going to neverlandIfManualMode=OffandManualCirc=Offthennop'Prevent going to neverlandIfAmbientT>-25thenGotoStandby'Bypass fluid measurementSetHeater=OffSetPump=On'Circulate water to measure WaterinTwait30sSetPump=OffSetHeater=OncallReadWater`'Read water temperatureIfAmbientT<-25andWaterinT<-15thenGotoWarm'Keep unit off for as long as possibleWait1h'Do hourlyGotoStandby'SubsManual:'Turn on system Checked 10-19-11CallTurnOnsSetPump=OnSetHeater=OnPWMOff'Turn on heater on snow sensorIfSnow=OnthenMeltTime_s+=1'record melt timeMeltTime_m=MeltTime_s/60EPWrite255,MeltTime_m'Record melt timecallElapsed_time'Measure on timecallReadWater'Read water temperaturecallManualDisplay'Refresh displaycallWrite'Measure DeltaT in 10 min intervals and write to EEpromIfManualMode=OnthenGotoStandbyWait673msGotoManualCirc:'Checked 10-19-11SetPump=OnSetHeater=OffcallElapsed_time'Measure on timecallReadWater'Read water temperaturecallCircDisplay'Refresh displayIfManualCirc=OnthenGotoStandbyWait713msGotoCircHeat:'Checked 10-19-11CallTurnOnsSetPump=On'Turn on systemSetHeater=OnPWMOff'Turn on heater on snow sensorIfSnow=OnthenMeltTime_s+=1'record melt timeMeltTime_m=MeltTime_s/60EPWrite255,MeltTime_m'Record melt timecallElapsed_time'Measure on timecallReadWater'Read water temperaturecallHeatDisplay'Refresh displaycallWrite'Measure DeltaT in 10 min intervals and write to EEprom IfSnow=Offthen'Clear snow and wait 30 min.Wait30mgotoStandbyEndIfWait685msGotoHeatWarm:'Checked 10-19-11PulseOutTest,1msSetPump=On'Turn on systemSetHeater=OncallReadWater'Read water temperaturecallWarmDisplay'Refresh displayifWaterinT>100thengotoStandby'Warm up water then turn offWait703msGotoWarmSubSnowCheckwait1500msIfSnow=Onthengotoheat'Test for sensor failIfSnow=OffThencallFailDisplayReturnSubManualDisplaycallClearserprint1,"Mode:"serprint1,"Man"serprint1," T"MeltTime_m=MeltTime_s/60Serprint1,MeltTime_mSerprint1,"m"callCommonDisplayReturnSubCircDisplaycallClearserprint1,"Mode:"serprint1,"Circ"callCommonDisplayReturnSubStandbyDisplaycallClearserprint1,"Mode:"serprint1,"Sby"EPRead255,MeltTime_LSerprint1," MTime:"'Read melt timeSerprint1,MeltTime_LcallCommonDisplayWait1sReturnSubWarmDisplaycallClearcallFirstserprint1,"Mode:"serprint1,"Warm"callCommonDisplayReturnSubHeatDisplaycallClearcallFirstserprint1,"Mode:"serprint1,"Heat"callCommonDisplayReturnFailDisplay:callClearcallFirstserprint1,"Mode:"serprint1,"SENSOR FAILURE"callCommonDisplayGotoFailDisplaySubCommonDisplaycallsecondcallElapsed_time'Measure on timeserprint1,"Ambient:"IfAmbientT_H.7=OnthenDisplayAmbT=65536-AmbientTElseDisplayAmbT=AmbientTEndIfIfAmbientT_H.7=Onthenserprint1,"-"serprint1,DisplayAmbTElseserprint1,DisplayAmbTEndIfserprint1," ET:"serprint1,E_timeminserprint1,"m"callThirdIfWaterin<52thenDisplayinT=65536-WaterinTElseDisplayinT=WaterinTEndIfserprint1,"WIn:"IfWaterIn<52thenserprint1,"-"serprint1,DisplayinTElseserprint1,DisplayinTEndIfcallFourthserprint1,"WOut:"IfWaterout<52thenDisplayoutT=65536-WateroutTElseDisplayoutT=WateroutTEndIfIfWaterout<52thenserprint1,"-"serprint1,DisplayoutTElseserprint1,DisplayoutTEndIfEPRead254,Tonsserprint1," Tons:"serprint1,Tons'wait 1 sReturnSubReadWaterWaterin=ReadAD(cold)ReadTableTconvert,Waterin,WaterinTempWaterinT=WaterinTemp-80Waterout=ReadAD(hot)ReadTableTconvert,Waterout,WateroutTempWateroutT=WateroutTemp-80ReturnSubElapsed_timeE_timesec+=1'SecondsIfE_timesec=60thenE_timesec=0E_timemin+=1'MinutesendifReturnSubWriteDeltaT=WateroutT-WaterinTEPWrite0,DeltaT'Store first Delta T measurementIfE_timemin%10=0then'Measure DeltaT in 10 min intervals and write to EEprom Count+=1EPWriteCount,DeltaTEndIfReturnSubTurnOnsTurnOn+=1EPWrite254,TurnOnReturnSubTestDisplayCallClearserprint1,"First line"CallsecondSerprint1,"Second line"CallThirdSerprint1,"Third line"CallfourthSerprint1,"Fourth line"wait1sReturn'NewHaven Display utilitiesSubClearsersend1,254'start CMDsersend1,81'clear screenReturnSubFirstsersend1,254'start CMDsersend1,69'First linesersend1,0ReturnSubSecondsersend1,254'start CMDsersend1,69'second linesersend1,64ReturnSubThirdsersend1,254'start CMDsersend1,69'Third linesersend1,20ReturnSubFourthsersend1,254'start CMDsersend1,69'Fourth linesersend1,84ReturnSubBaud'1=300, 2=1200, 3=2400, 4=9600, 5=14.4k. 6=19.2k, 7=57.6k, 8=115.2ksersend1,254'start CMDsersend1,97'baud selectsersend1,4'9600-wait100usReturn/code]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh, this is the second time I have post about this problem. The first time it was necessary to comment out the HPWM command to make the error go away. This time tying to comment out the PWMOff comment brings the error. There is definitely something going on with the HPWM code!
BTW, I really love GCB! It is a very useful and powerful tool . This project is a controller for the hot water system I had put under the driveway this summer. I hope I can get it finished before the snow flies. When you get around to it it would be great to have a serprint command for Integer variables. Thanks, Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have a look at the LST file and see if GCB is leaving a large gap at the page boundary ie 07FF-0800.
Ive had this problem before where the code needs more than 1 page and it gets worse with chips with multiple pages like 16F88 and worse again with 16F886 / 887 .
The problem seems to be that GCB calculates the program size incorrectly and concludes that all the code wont fit.
Try adding some NOP instructions in the vicinity of the code thats causing the problem, ie near the HPWM commands and then see if the error dissapears.
You may need to add a lot , sometimes Ive needed 64 or more.
Add them in lots of 8.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mauried, I think you are correct! I added some new features to the code and increased the code size from 2830 bytes to 3396 and the problem went away! There is definitely a bug in there somewhere. Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ed, If your heater control ends up needing extra PWM resolution, the 18f1330 can give you up to 14 bits to play with. Drop in replacement for the 16f88, 3 hardware PWM's, and no paging issues that I'm aware of. I could post some PWM manual setup code if you go down that road, it's a totally different beast.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Kent, I think I will take you up on your offer, There is an article in Circuit Cellar this month on a high accuracy voltage reference using an LT 1236 reference regulator. A 14 bit PWM would be great. Please post your code. Thanks, Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ed, no problem. Here is the hardware PWM code that exercises a Futaba servo motor. The Fpwm and PTPER will be different for a standard PWM. Hope the comments will make sense when comparing to the datasheet. Let me know if something is amiss, it's been awhile since I did this.
If you need a better voltage referance then a Microchip MCP1541 is the answer.
Its a high precision 4.096 V referance intended for 10 bit A/D apps.
The 4.096 V allows easy math to display voltages as 1 bit = exactly 4 mv.
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:
Hugh, this is the second time I have post about this problem. The first time it was necessary to comment out the HPWM command to make the error go away. This time tying to comment out the PWMOff comment brings the error. There is definitely something going on with the HPWM code!
BTW, I really love GCB! It is a very useful and powerful tool . This project is a controller for the hot water system I had put under the driveway this summer. I hope I can get it finished before the snow flies. When you get around to it it would be great to have a serprint command for Integer variables. Thanks, Ed.
Have a look at the LST file and see if GCB is leaving a large gap at the page boundary ie 07FF-0800.
Ive had this problem before where the code needs more than 1 page and it gets worse with chips with multiple pages like 16F88 and worse again with 16F886 / 887 .
The problem seems to be that GCB calculates the program size incorrectly and concludes that all the code wont fit.
Try adding some NOP instructions in the vicinity of the code thats causing the problem, ie near the HPWM commands and then see if the error dissapears.
You may need to add a lot , sometimes Ive needed 64 or more.
Add them in lots of 8.
Mauried, I think you are correct! I added some new features to the code and increased the code size from 2830 bytes to 3396 and the problem went away! There is definitely a bug in there somewhere. Ed.
Ed, If your heater control ends up needing extra PWM resolution, the 18f1330 can give you up to 14 bits to play with. Drop in replacement for the 16f88, 3 hardware PWM's, and no paging issues that I'm aware of. I could post some PWM manual setup code if you go down that road, it's a totally different beast.
Kent, Thanks for the tip. I have changed the design so that I no longer need the PWM. Ed.
Kent, I think I will take you up on your offer, There is an article in Circuit Cellar this month on a high accuracy voltage reference using an LT 1236 reference regulator. A 14 bit PWM would be great. Please post your code. Thanks, Ed.
Ed, no problem. Here is the hardware PWM code that exercises a Futaba servo motor. The Fpwm and PTPER will be different for a standard PWM. Hope the comments will make sense when comparing to the datasheet. Let me know if something is amiss, it's been awhile since I did this.
If you need a better voltage referance then a Microchip MCP1541 is the answer.
Its a high precision 4.096 V referance intended for 10 bit A/D apps.
The 4.096 V allows easy math to display voltages as 1 bit = exactly 4 mv.