Showing posts with label pic16f88. Show all posts
Showing posts with label pic16f88. Show all posts
Monday, October 24, 2016
MPPT Circuit using PIC16F88 with 3 Level Charging
MPPT Circuit using PIC16F88 with 3 Level Charging
An MPPT as we all know refers to maximum power point tracking which is typically associated with solar panels for optimizing their outputs with maximum efficiency. In this post we learn how to make a PIC16F88 microcontroller based MPPT circuit with a 3-stage charging.
This data was donated by: Mr. hisham bahaa-aldeen (hisham2630@gmail.com)
The optimized output from MPPT circuits is primarily used for charging batteries with maximum efficiency from the available sunshine.
New hobbyists normally find the concept to difficult and get confused with the many parameters associated with MPPT, such as the maximum power point, "knee" of the I/V graph etc.
Actually theres nothing so complex about this concept, because a solar panel is nothing but just a form of power supply.
Optimizing this power supply becomes necessary because typically solar panels lack current, but posses excess voltage, this abnormal specs of a solar panel tends to get incompatible with standard loads such as 6V, 12V batteries which carry higher AH rating and lower voltage rating compared to the panel specs, and furthermore the ever-varying sunshine makes the device extremely inconsistent with its V and I parameters.
And thats why we require an intermediate device such as an MPPT which can "understand" these variations and churn out the most desirable output from a connected solar panel.
You might have already studied this simple IC 555 based MPPT circuit which is exclusively researched and designed by me and provides an excellent example of a working MPPT circuit.
The basic idea behind all MPPTs is to drop or trim down the excess voltage from the panel according to the load specs making sure that the deducted amount of voltage is converted into an equivalent amount of current, thus balancing the I x V magnitude across the input and the output always up to the mark...we cannot expect anything more than this from this useful gadget, do we?
In this post we study an MPPT circuit which is quite similar to the IC 555 design, the only difference being the use of a microcontroller PIC16F88 and an enhanced 3-level charging circuit.

The basic function of the various stages can be understood with the help of the following description:
1) The panel output is tracked by extracting a couple of information from it through the associated potential divider networks.
2) One opamp from IC2 is configured as a voltage follower and it tracks the instantaneous voltage output from the panel through a potential divider at its pin3, and feeds the info to the relevant sensing pin of the PIC.
3) The second opamp from IC2 becomes responsible for tracking and monitoring the varying current from the panel and feeds the same to another sensing input of the PIC.
4) These two inputs are processed internally by the MCU for developing a correspondingly tailored PWM for the buck converter stage associated with its pin#9.
5) The PWM out from the PIC is buffered by Q2, Q3 for triggering the switching P-mosfet safely. The associated diode protects the mosfet gate from overvolatges.
6) The mosfet switches in accordance with the switching PWMs and modulates the buck converter stage formed by the inductor L1 and D2.
7) The above procedures produce the most appropriate output from the buck converter which is lower in voltage as per the battery, but rich in current.
8) The output from the buck is constantly tweaked and appropriately adjusted by the IC with reference to the sent info from the two opamps associated with the solar panel.
9) In addition to the above MPPT regulation, the PIC is also programmed to monitor the battery charging through 3 discrete levels, which are normally specified as the bulk mode, absorption mode, an the float mode.
10) The MCU "keeps an eye" on the rising battery voltage and adjusts the buck current accordingly maintaining the correct Ampere levels during the 3 levels of charging procedure. This is done in conjunction with the MPPT control, thats like handling two situations at a time for delivering the most favorable results for the battery.
11) The PIC itself is supplied with a precision regulated voltage at its Vdd pinout through the IC TL499, any other suitable voltage regulator could be replaced here for rendering the same.
12) A thermistor can be also seen in the design this may be optional but can be effectively configured for monitoring the battery temperature and feeding the info to the PIC, which effortlessly processes this third information for tailoring the buck output making sure that the battery temperature never rises above unsafe levels.
13) The LED indicators associated with the PIC indicate the various charging states for the battery which allows the user to get an up-to-date information regarding the charging condition of the battery throughout the day.
14) The proposed MPPT Circuit using PIC16F88 with 3-Level Charging supports 12V battery charging as well as 24V battery charging without any change in the circuit, except the values shown in parenthesis and VR3 setting which needs to be adjusted to allow the output to be 14.4V at the onset for a 12V battery and 29V for a 24V battery.
The next article gives the access to the entire source code for the above discussed MPPT circuit using PIC16F88
This data was donated by: Mr. hisham bahaa-aldeen (hisham2630@gmail.com)
The optimized output from MPPT circuits is primarily used for charging batteries with maximum efficiency from the available sunshine.
New hobbyists normally find the concept to difficult and get confused with the many parameters associated with MPPT, such as the maximum power point, "knee" of the I/V graph etc.
Actually theres nothing so complex about this concept, because a solar panel is nothing but just a form of power supply.
Optimizing this power supply becomes necessary because typically solar panels lack current, but posses excess voltage, this abnormal specs of a solar panel tends to get incompatible with standard loads such as 6V, 12V batteries which carry higher AH rating and lower voltage rating compared to the panel specs, and furthermore the ever-varying sunshine makes the device extremely inconsistent with its V and I parameters.
And thats why we require an intermediate device such as an MPPT which can "understand" these variations and churn out the most desirable output from a connected solar panel.
You might have already studied this simple IC 555 based MPPT circuit which is exclusively researched and designed by me and provides an excellent example of a working MPPT circuit.
The basic idea behind all MPPTs is to drop or trim down the excess voltage from the panel according to the load specs making sure that the deducted amount of voltage is converted into an equivalent amount of current, thus balancing the I x V magnitude across the input and the output always up to the mark...we cannot expect anything more than this from this useful gadget, do we?
The above automatic tracking and appropriately converting the parameters efficiently is implemented using a PWM tracker stage and a buck converter stage, or sometimes a buck-boost converter stage, although a solitary buck converter gives better results and is simpler to implement.
In this post we study an MPPT circuit which is quite similar to the IC 555 design, the only difference being the use of a microcontroller PIC16F88 and an enhanced 3-level charging circuit.

The basic function of the various stages can be understood with the help of the following description:
1) The panel output is tracked by extracting a couple of information from it through the associated potential divider networks.
2) One opamp from IC2 is configured as a voltage follower and it tracks the instantaneous voltage output from the panel through a potential divider at its pin3, and feeds the info to the relevant sensing pin of the PIC.
3) The second opamp from IC2 becomes responsible for tracking and monitoring the varying current from the panel and feeds the same to another sensing input of the PIC.
4) These two inputs are processed internally by the MCU for developing a correspondingly tailored PWM for the buck converter stage associated with its pin#9.
5) The PWM out from the PIC is buffered by Q2, Q3 for triggering the switching P-mosfet safely. The associated diode protects the mosfet gate from overvolatges.
6) The mosfet switches in accordance with the switching PWMs and modulates the buck converter stage formed by the inductor L1 and D2.
7) The above procedures produce the most appropriate output from the buck converter which is lower in voltage as per the battery, but rich in current.
8) The output from the buck is constantly tweaked and appropriately adjusted by the IC with reference to the sent info from the two opamps associated with the solar panel.
9) In addition to the above MPPT regulation, the PIC is also programmed to monitor the battery charging through 3 discrete levels, which are normally specified as the bulk mode, absorption mode, an the float mode.
10) The MCU "keeps an eye" on the rising battery voltage and adjusts the buck current accordingly maintaining the correct Ampere levels during the 3 levels of charging procedure. This is done in conjunction with the MPPT control, thats like handling two situations at a time for delivering the most favorable results for the battery.
11) The PIC itself is supplied with a precision regulated voltage at its Vdd pinout through the IC TL499, any other suitable voltage regulator could be replaced here for rendering the same.
12) A thermistor can be also seen in the design this may be optional but can be effectively configured for monitoring the battery temperature and feeding the info to the PIC, which effortlessly processes this third information for tailoring the buck output making sure that the battery temperature never rises above unsafe levels.
13) The LED indicators associated with the PIC indicate the various charging states for the battery which allows the user to get an up-to-date information regarding the charging condition of the battery throughout the day.
14) The proposed MPPT Circuit using PIC16F88 with 3-Level Charging supports 12V battery charging as well as 24V battery charging without any change in the circuit, except the values shown in parenthesis and VR3 setting which needs to be adjusted to allow the output to be 14.4V at the onset for a 12V battery and 29V for a 24V battery.
The next article gives the access to the entire source code for the above discussed MPPT circuit using PIC16F88
Available link for download
Saturday, September 3, 2016
MPPT Circuit using PIC16F88 Code and HEX
MPPT Circuit using PIC16F88 Code and HEX
The earlier article comprehensively described the circuit details of an MPPT using PIC16F88 microcontroller, here we get the access to the source code for programming the PIC and the HEX file format for the same.
This data was donated by: Mr. hisham bahaa-aldeen (hisham2630@gmail.com)
Programming source code for the proposed 12V/24V solar MPPT circuit using PIC16F88
; 100W Solar Charger
; upgraded with a supplementary bulk charge restart feature after a 4hr break when sunlight returns to panel
; Option set when RB0 low
; Supplementary bulk restart anytime power demanded for float charging. Option set when RB1 low
; Added switch to float mode if bulk charging takes less than 60s. ie if the battery is fully charged
list P=16F88
#include p16f88.inc
ERRORLEVEL -302
ERRORLEVEL -306
;Program Configuration Register 1
__CONFIG _CONFIG1, _CP_ALL & _CCP1_RB3 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_ON & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
;Program Configuration Register 2
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
; Bank 0 RAM
DIGITAL equ H20 ; storage
FIRST equ H21 ; first run
CUT_M equ H22 ; cutout voltage high byte
CUT_L equ H23 ; cutout voltage low byte
FLOAT_H equ H24 ; float voltage high byte
FLOAT_L equ H25 ; float voltage low byte
COMP equ H26 ; compensation (temperature)
BATT_HI equ H27 ; battery volts high byte
BATT_LO equ H28 ; battery low byte
DELCNT equ H29 ; delay counter
FLASHER equ H2A ; LED flasher timer
TEMPERATURE equ H2B ; temperature reading deg C
THERMISTOR equ H2C ; thermistor flag for LED
CUT_COMP_M equ H2D ; cutout temp. compensated voltage high byte
CUT_COMP_L equ H2E ; cutout temp. compensated voltage low byte
FLOAT_COMP_M equ H2F ; float temp. compensated voltage high byte
FLOAT_COMP_L equ H30 ; float temp. compensated voltage low byte
NEGATIVE equ H31 ; subtract negative flag
VALUE_1 equ H32 ; delay counter
VALUE_2 equ H33 ; delay counter
HOUR0 equ H34 ; hour counter
HOUR1 equ H35 ; 14 seconds counter for hour counter (256 x 14s=1hour)
SENSOR_COUNT equ H36 ; sensor counter for periodic checking
SENSOR_COUNT1 equ H37 ; sensor counter for periodic checking
CELL_LO equ H38 ; solar cell voltage ls byte
CELL_HI equ H39 ; solar cell voltage ms byte
CELL_I_LO equ H3A ; solar cell current ls byte
CELL_I_HI equ H3B ; solar cell current ms byte
CHARGE_STATE equ H3C ; 0 charge, 1 float
CHARGE_FLAG equ H3D ; flag for charge
CHRG_RATE equ H3E ; charge change rate
CELL_V equ H3F ; solar cell voltage 8-bit
CELL_I equ H40 ; solar cell current 8-bit
PERIOD equ H41 ; power calculation rate
CCPR1_STORE equ H42 ; CCPR1L storage value
POWERH equ H43 ; power ms byte
POWERL equ H44 ; power ls byte
VALUE1 equ H45 ; temporary value
VALUE2 equ H46 ; temporary value
VALUE3 equ H47 ; temporary value
VALUE4 equ H48 ; temporary value
EQ_FLAG equ H49 ; equalisation flag
EQ_LO equ H4A ; ls byte EQ battery voltage
EQ_HI equ H4B ; ms byte EQ battery voltage
EQ_LO_COMP equ H4C ; ls byte temp. compensated EQ battery voltage
EQ_HI_COMP equ H4D ; ms byte temp. compensated EQ battery voltage
EQ_LEVEL equ H4E ; equalisation input (RB4) level store
BATT_IND equ H4F ; battery indicator flag when error
BURST_FLG equ H50 ; burst flag
HOUR3 equ H51 ; 4 hour counter
HOUR2 equ H52 ; 56 seconds counter for hour counter (256 x 56s=1hour)
BULK_TIMER equ H53 ; bulk charge timer (60s)
BULK_TIMER_END equ H54 ; bulk timer ended flag
; math routines
TEMP1 equ H5C
TEMPB0 equ H5D
TEMPB1 equ H5E
TEMPB2 equ H5F
TEMP equ H60
REMB3 equ H61
REMB2 equ H62
REMB1 equ H63
REMB0 equ H64
AARGB5 equ H65
AARGB4 equ H66
AARGB3 equ H67
AARGB2 equ H68
AARGB1 equ H69
AARGB0 equ H6A ; most significant byte of argument A
BARGB3 equ H6B
BARGB2 equ H6C
BARGB1 equ H6D
BARGB0 equ H6E ; most significant byte of argument B
LOOPCOUNT equ H6F ; division counter
; All Banks RAM
; Interrupt store registers
W_TMP equ H70 ; storage of w before interrupt
STATUS_TMP equ H71 ; status storage before interrupt
; start at memory 0
org 0
goto SETUP
org 4
goto INTERRUPT
; position the lookup table at start to avoid a 256 bit boundary
TEMP_CONV ; convert A/D values to deg C based on thermistor R=Ae**(B/T) where (T is in K ie deg C plus 273)
; A =0.01058 and B is 4100
addwf PCL,f ; add value to program counter
; 60 deg C max
retlw D60 ; 60deg C for A/D D49 (8-bit)
retlw D59 ; deg C for A/D D50(8-bit)
retlw D58 ; deg C for A/D D51(8-bit)
retlw D58 ; deg C for A/D D52(8-bit)
retlw D57 ; deg C for A/D D53(8-bit)
retlw D57 ; deg C for A/D D54(8-bit)
retlw D56 ; deg C for A/D D55(8-bit)
retlw D56 ; deg C for A/D D56(8-bit)
retlw D55 ; deg C for A/D D57(8-bit)
retlw D54 ; deg C for A/D D58(8-bit)
retlw D54 ; 54 deg C for A/D D59(8-bit)
retlw D53 ; deg C for A/D D60(8-bit)
retlw D53 ; deg C for A/D D61(8-bit)
retlw D52 ; deg C for A/D D62(8-bit)
retlw D52 ; deg C for A/D D63(8-bit)
retlw D51 ; deg C for A/D D64(8-bit)
retlw D50 ; deg C for A/D D65(8-bit)
retlw D50 ; deg C for A/D D66(8-bit)
retlw D50 ; deg C for A/D D67(8-bit)
retlw D49 ; deg C for A/D D68(8-bit)
retlw D49 ; deg C for A/D D69(8-bit)
retlw D48 ; 48 deg C for A/D D70(8-bit)
retlw D48 ; deg C for A/D D71(8-bit)
retlw D47 ; deg C for A/D D72(8-bit)
retlw D47 ; deg C for A/D D73(8-bit)
retlw D46 ; deg C for A/D D74(8-bit)
retlw D46 ; deg C for A/D D75(8-bit)
retlw D45 ; deg C for A/D D76(8-bit)
retlw D45 ; deg C for A/D D77(8-bit)
retlw D44 ; deg C for A/D D78(8-bit)
retlw D44 ; deg C for A/D D79(8-bit)
retlw D43 ; deg C for A/D D80(8-bit)
retlw D43 ; deg C for A/D D81(8-bit)
retlw D43 ; deg C for A/D D82(8-bit)
retlw D42 ; deg C for A/D D83(8-bit)
retlw D42 ; deg C for A/D D84(8-bit)
retlw D41 ; deg C for A/D D85(8-bit)
retlw D41 ; deg C for A/D D86(8-bit)
retlw D40 ; deg C for A/D D87(8-bit)
retlw D40 ; deg C for A/D D88(8-bit)
retlw D40 ; 40 deg C for A/D D89(8-bit)
retlw D39 ; deg C for A/D D90(8-bit)
retlw D39 ; deg C for A/D D91(8-bit)
retlw D38 ; deg C for A/D D92(8-bit)
retlw D38 ; deg C for A/D D93(8-bit)
retlw D38 ; deg C for A/D D94(8-bit)
retlw D37 ; deg C for A/D D95(8-bit)
retlw D37 ; deg C for A/D D96(8-bit)
retlw D36 ; deg C for A/D D97(8-bit)
retlw D36 ; deg C for A/D D98(8-bit)
retlw D36 ; deg C for A/D D99(8-bit)
retlw D35 ; deg C for A/D D100(8-bit)
retlw D35 ; deg C for A/D D101(8-bit)
retlw D34 ; deg C for A/D D102(8-bit)
retlw D34 ; deg C for A/D D103(8-bit)
retlw D34 ; deg C for A/D D104(8-bit)
retlw D33 ; deg C for A/D D105(8-bit)
retlw D33 ; deg C for A/D D106(8-bit)
retlw D33 ; deg C for A/D D107(8-bit)
retlw D32 ; deg C for A/D D108(8-bit)
retlw D32 ; 32 deg C for A/D D109(8-bit)
retlw D32 ; deg C for A/D D110(8-bit)
retlw D31 ; deg C for A/D D111(8-bit)
retlw D31 ; deg C for A/D D112(8-bit)
retlw D30 ; deg C for A/D D113(8-bit)
retlw D30 ; deg C for A/D D114(8-bit)
retlw D30 ; deg C for A/D D115(8-bit)
retlw D29 ; deg C for A/D D116(8-bit)
retlw D29 ; deg C for A/D D117(8-bit)
retlw D29 ; deg C for A/D D118(8-bit)
retlw D28 ; deg C for A/D D119(8-bit)
retlw D28 ; deg C for A/D D120(8-bit)
retlw D28 ; deg C for A/D D121(8-bit)
retlw D27 ; deg C for A/D D122(8-bit)
retlw D27 ; deg C for A/D D123(8-bit)
retlw D27 ; deg C for A/D D124(8-bit)
retlw D26 ; deg C for A/D D125(8-bit)
retlw D26 ; deg C for A/D D126(8-bit)
retlw D26 ; deg C for A/D D127(8-bit)
retlw D25 ; deg C for A/D D128(8-bit)
retlw D25 ; deg C for A/D D129(8-bit)
retlw D24 ; deg C for A/D D130(8-bit)
retlw D24 ; deg C for A/D D131(8-bit)
retlw D24 ; deg C for A/D D132(8-bit)
retlw D24 ; deg C for A/D D133(8-bit)
retlw D23 ; deg C for A/D D134(8-bit)
retlw D23 ; deg C for A/D D135(8-bit)
retlw D23 ; deg C for A/D D136(8-bit)
retlw D22 ; deg C for A/D D137(8-bit)
retlw D22 ; deg C for A/D D138(8-bit)
retlw D22 ; deg C for A/D D139(8-bit)
retlw D21 ; deg C for A/D D140(8-bit)
retlw D21 ; deg C for A/D D141(8-bit)
retlw D21 ; deg C for A/D D142(8-bit)
retlw D20 ; deg C for A/D D143(8-bit)
retlw D20 ; deg C for A/D D144(8-bit)
retlw D20 ; deg C for A/D D145(8-bit)
retlw D19 ; deg C for A/D D146(8-bit)
retlw D19 ; deg C for A/D D147(8-bit)
retlw D19 ; deg C for A/D D148(8-bit)
retlw D18 ; deg C for A/D D149(8-bit)
retlw D18 ; deg C for A/D D150(8-bit)
retlw D18 ; deg C for A/D D151(8-bit)
retlw D17 ; deg C for A/D D152(8-bit)
retlw D17 ; deg C for A/D D153(8-bit)
retlw D17 ; deg C for A/D D154(8-bit)
retlw D16 ; deg C for A/D D155(8-bit)
retlw D16 ; deg C for A/D D156(8-bit)
retlw D16 ; deg C for A/D D157(8-bit)
retlw D15 ; deg C for A/D D158(8-bit)
retlw D15 ; deg C for A/D D159(8-bit)
retlw D15 ; deg C for A/D D160(8-bit)
retlw D14 ; deg C for A/D D161(8-bit)
retlw D14 ; deg C for A/D D162(8-bit)
retlw D14 ; deg C for A/D D163(8-bit)
retlw D13 ; deg C for A/D D164(8-bit)
retlw D13 ; deg C for A/D D165(8-bit)
retlw D13 ; deg C for A/D D166(8-bit)
retlw D12 ; deg C for A/D D167(8-bit)
retlw D12 ; deg C for A/D D168(8-bit)
retlw D12 ; deg C for A/D D169(8-bit)
retlw D11 ; deg C for A/D D170(8-bit)
retlw D11 ; deg C for A/D D171(8-bit)
retlw D11 ; deg C for A/D D172(8-bit)
retlw D10 ; deg C fo
Read more »
This data was donated by: Mr. hisham bahaa-aldeen (hisham2630@gmail.com)
Programming source code for the proposed 12V/24V solar MPPT circuit using PIC16F88
; 100W Solar Charger
; upgraded with a supplementary bulk charge restart feature after a 4hr break when sunlight returns to panel
; Option set when RB0 low
; Supplementary bulk restart anytime power demanded for float charging. Option set when RB1 low
; Added switch to float mode if bulk charging takes less than 60s. ie if the battery is fully charged
list P=16F88
#include p16f88.inc
ERRORLEVEL -302
ERRORLEVEL -306
;Program Configuration Register 1
__CONFIG _CONFIG1, _CP_ALL & _CCP1_RB3 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_ON & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
;Program Configuration Register 2
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
; Bank 0 RAM
DIGITAL equ H20 ; storage
FIRST equ H21 ; first run
CUT_M equ H22 ; cutout voltage high byte
CUT_L equ H23 ; cutout voltage low byte
FLOAT_H equ H24 ; float voltage high byte
FLOAT_L equ H25 ; float voltage low byte
COMP equ H26 ; compensation (temperature)
BATT_HI equ H27 ; battery volts high byte
BATT_LO equ H28 ; battery low byte
DELCNT equ H29 ; delay counter
FLASHER equ H2A ; LED flasher timer
TEMPERATURE equ H2B ; temperature reading deg C
THERMISTOR equ H2C ; thermistor flag for LED
CUT_COMP_M equ H2D ; cutout temp. compensated voltage high byte
CUT_COMP_L equ H2E ; cutout temp. compensated voltage low byte
FLOAT_COMP_M equ H2F ; float temp. compensated voltage high byte
FLOAT_COMP_L equ H30 ; float temp. compensated voltage low byte
NEGATIVE equ H31 ; subtract negative flag
VALUE_1 equ H32 ; delay counter
VALUE_2 equ H33 ; delay counter
HOUR0 equ H34 ; hour counter
HOUR1 equ H35 ; 14 seconds counter for hour counter (256 x 14s=1hour)
SENSOR_COUNT equ H36 ; sensor counter for periodic checking
SENSOR_COUNT1 equ H37 ; sensor counter for periodic checking
CELL_LO equ H38 ; solar cell voltage ls byte
CELL_HI equ H39 ; solar cell voltage ms byte
CELL_I_LO equ H3A ; solar cell current ls byte
CELL_I_HI equ H3B ; solar cell current ms byte
CHARGE_STATE equ H3C ; 0 charge, 1 float
CHARGE_FLAG equ H3D ; flag for charge
CHRG_RATE equ H3E ; charge change rate
CELL_V equ H3F ; solar cell voltage 8-bit
CELL_I equ H40 ; solar cell current 8-bit
PERIOD equ H41 ; power calculation rate
CCPR1_STORE equ H42 ; CCPR1L storage value
POWERH equ H43 ; power ms byte
POWERL equ H44 ; power ls byte
VALUE1 equ H45 ; temporary value
VALUE2 equ H46 ; temporary value
VALUE3 equ H47 ; temporary value
VALUE4 equ H48 ; temporary value
EQ_FLAG equ H49 ; equalisation flag
EQ_LO equ H4A ; ls byte EQ battery voltage
EQ_HI equ H4B ; ms byte EQ battery voltage
EQ_LO_COMP equ H4C ; ls byte temp. compensated EQ battery voltage
EQ_HI_COMP equ H4D ; ms byte temp. compensated EQ battery voltage
EQ_LEVEL equ H4E ; equalisation input (RB4) level store
BATT_IND equ H4F ; battery indicator flag when error
BURST_FLG equ H50 ; burst flag
HOUR3 equ H51 ; 4 hour counter
HOUR2 equ H52 ; 56 seconds counter for hour counter (256 x 56s=1hour)
BULK_TIMER equ H53 ; bulk charge timer (60s)
BULK_TIMER_END equ H54 ; bulk timer ended flag
; math routines
TEMP1 equ H5C
TEMPB0 equ H5D
TEMPB1 equ H5E
TEMPB2 equ H5F
TEMP equ H60
REMB3 equ H61
REMB2 equ H62
REMB1 equ H63
REMB0 equ H64
AARGB5 equ H65
AARGB4 equ H66
AARGB3 equ H67
AARGB2 equ H68
AARGB1 equ H69
AARGB0 equ H6A ; most significant byte of argument A
BARGB3 equ H6B
BARGB2 equ H6C
BARGB1 equ H6D
BARGB0 equ H6E ; most significant byte of argument B
LOOPCOUNT equ H6F ; division counter
; All Banks RAM
; Interrupt store registers
W_TMP equ H70 ; storage of w before interrupt
STATUS_TMP equ H71 ; status storage before interrupt
; start at memory 0
org 0
goto SETUP
org 4
goto INTERRUPT
; position the lookup table at start to avoid a 256 bit boundary
TEMP_CONV ; convert A/D values to deg C based on thermistor R=Ae**(B/T) where (T is in K ie deg C plus 273)
; A =0.01058 and B is 4100
addwf PCL,f ; add value to program counter
; 60 deg C max
retlw D60 ; 60deg C for A/D D49 (8-bit)
retlw D59 ; deg C for A/D D50(8-bit)
retlw D58 ; deg C for A/D D51(8-bit)
retlw D58 ; deg C for A/D D52(8-bit)
retlw D57 ; deg C for A/D D53(8-bit)
retlw D57 ; deg C for A/D D54(8-bit)
retlw D56 ; deg C for A/D D55(8-bit)
retlw D56 ; deg C for A/D D56(8-bit)
retlw D55 ; deg C for A/D D57(8-bit)
retlw D54 ; deg C for A/D D58(8-bit)
retlw D54 ; 54 deg C for A/D D59(8-bit)
retlw D53 ; deg C for A/D D60(8-bit)
retlw D53 ; deg C for A/D D61(8-bit)
retlw D52 ; deg C for A/D D62(8-bit)
retlw D52 ; deg C for A/D D63(8-bit)
retlw D51 ; deg C for A/D D64(8-bit)
retlw D50 ; deg C for A/D D65(8-bit)
retlw D50 ; deg C for A/D D66(8-bit)
retlw D50 ; deg C for A/D D67(8-bit)
retlw D49 ; deg C for A/D D68(8-bit)
retlw D49 ; deg C for A/D D69(8-bit)
retlw D48 ; 48 deg C for A/D D70(8-bit)
retlw D48 ; deg C for A/D D71(8-bit)
retlw D47 ; deg C for A/D D72(8-bit)
retlw D47 ; deg C for A/D D73(8-bit)
retlw D46 ; deg C for A/D D74(8-bit)
retlw D46 ; deg C for A/D D75(8-bit)
retlw D45 ; deg C for A/D D76(8-bit)
retlw D45 ; deg C for A/D D77(8-bit)
retlw D44 ; deg C for A/D D78(8-bit)
retlw D44 ; deg C for A/D D79(8-bit)
retlw D43 ; deg C for A/D D80(8-bit)
retlw D43 ; deg C for A/D D81(8-bit)
retlw D43 ; deg C for A/D D82(8-bit)
retlw D42 ; deg C for A/D D83(8-bit)
retlw D42 ; deg C for A/D D84(8-bit)
retlw D41 ; deg C for A/D D85(8-bit)
retlw D41 ; deg C for A/D D86(8-bit)
retlw D40 ; deg C for A/D D87(8-bit)
retlw D40 ; deg C for A/D D88(8-bit)
retlw D40 ; 40 deg C for A/D D89(8-bit)
retlw D39 ; deg C for A/D D90(8-bit)
retlw D39 ; deg C for A/D D91(8-bit)
retlw D38 ; deg C for A/D D92(8-bit)
retlw D38 ; deg C for A/D D93(8-bit)
retlw D38 ; deg C for A/D D94(8-bit)
retlw D37 ; deg C for A/D D95(8-bit)
retlw D37 ; deg C for A/D D96(8-bit)
retlw D36 ; deg C for A/D D97(8-bit)
retlw D36 ; deg C for A/D D98(8-bit)
retlw D36 ; deg C for A/D D99(8-bit)
retlw D35 ; deg C for A/D D100(8-bit)
retlw D35 ; deg C for A/D D101(8-bit)
retlw D34 ; deg C for A/D D102(8-bit)
retlw D34 ; deg C for A/D D103(8-bit)
retlw D34 ; deg C for A/D D104(8-bit)
retlw D33 ; deg C for A/D D105(8-bit)
retlw D33 ; deg C for A/D D106(8-bit)
retlw D33 ; deg C for A/D D107(8-bit)
retlw D32 ; deg C for A/D D108(8-bit)
retlw D32 ; 32 deg C for A/D D109(8-bit)
retlw D32 ; deg C for A/D D110(8-bit)
retlw D31 ; deg C for A/D D111(8-bit)
retlw D31 ; deg C for A/D D112(8-bit)
retlw D30 ; deg C for A/D D113(8-bit)
retlw D30 ; deg C for A/D D114(8-bit)
retlw D30 ; deg C for A/D D115(8-bit)
retlw D29 ; deg C for A/D D116(8-bit)
retlw D29 ; deg C for A/D D117(8-bit)
retlw D29 ; deg C for A/D D118(8-bit)
retlw D28 ; deg C for A/D D119(8-bit)
retlw D28 ; deg C for A/D D120(8-bit)
retlw D28 ; deg C for A/D D121(8-bit)
retlw D27 ; deg C for A/D D122(8-bit)
retlw D27 ; deg C for A/D D123(8-bit)
retlw D27 ; deg C for A/D D124(8-bit)
retlw D26 ; deg C for A/D D125(8-bit)
retlw D26 ; deg C for A/D D126(8-bit)
retlw D26 ; deg C for A/D D127(8-bit)
retlw D25 ; deg C for A/D D128(8-bit)
retlw D25 ; deg C for A/D D129(8-bit)
retlw D24 ; deg C for A/D D130(8-bit)
retlw D24 ; deg C for A/D D131(8-bit)
retlw D24 ; deg C for A/D D132(8-bit)
retlw D24 ; deg C for A/D D133(8-bit)
retlw D23 ; deg C for A/D D134(8-bit)
retlw D23 ; deg C for A/D D135(8-bit)
retlw D23 ; deg C for A/D D136(8-bit)
retlw D22 ; deg C for A/D D137(8-bit)
retlw D22 ; deg C for A/D D138(8-bit)
retlw D22 ; deg C for A/D D139(8-bit)
retlw D21 ; deg C for A/D D140(8-bit)
retlw D21 ; deg C for A/D D141(8-bit)
retlw D21 ; deg C for A/D D142(8-bit)
retlw D20 ; deg C for A/D D143(8-bit)
retlw D20 ; deg C for A/D D144(8-bit)
retlw D20 ; deg C for A/D D145(8-bit)
retlw D19 ; deg C for A/D D146(8-bit)
retlw D19 ; deg C for A/D D147(8-bit)
retlw D19 ; deg C for A/D D148(8-bit)
retlw D18 ; deg C for A/D D149(8-bit)
retlw D18 ; deg C for A/D D150(8-bit)
retlw D18 ; deg C for A/D D151(8-bit)
retlw D17 ; deg C for A/D D152(8-bit)
retlw D17 ; deg C for A/D D153(8-bit)
retlw D17 ; deg C for A/D D154(8-bit)
retlw D16 ; deg C for A/D D155(8-bit)
retlw D16 ; deg C for A/D D156(8-bit)
retlw D16 ; deg C for A/D D157(8-bit)
retlw D15 ; deg C for A/D D158(8-bit)
retlw D15 ; deg C for A/D D159(8-bit)
retlw D15 ; deg C for A/D D160(8-bit)
retlw D14 ; deg C for A/D D161(8-bit)
retlw D14 ; deg C for A/D D162(8-bit)
retlw D14 ; deg C for A/D D163(8-bit)
retlw D13 ; deg C for A/D D164(8-bit)
retlw D13 ; deg C for A/D D165(8-bit)
retlw D13 ; deg C for A/D D166(8-bit)
retlw D12 ; deg C for A/D D167(8-bit)
retlw D12 ; deg C for A/D D168(8-bit)
retlw D12 ; deg C for A/D D169(8-bit)
retlw D11 ; deg C for A/D D170(8-bit)
retlw D11 ; deg C for A/D D171(8-bit)
retlw D11 ; deg C for A/D D172(8-bit)
retlw D10 ; deg C fo
Available link for download
Subscribe to:
Posts (Atom)