BradenBurton
New Member
Hi all,
I Know - another Battery Charger
I thought I would give a Solar Charger/Controller a go and here are the results.
This is the first time using a micro controller (unless you count the couple of hours with a Basic Stamp 5 Years ago).
This is a VERY BASIC Charger only. All seems to work as a charger. Trying to minimize component count and cost
Calibration/Setup (08M)
Note: Batt+ (I) and Batt+ (II) are actually the same connection but on setup treat them as seperate - they are NOT Connected (there will be a jumper in the final solution)
This only has 1 stage - float, but will disconnect if greater than 13.8V and reconnect at below 13.7V.
There should probably be some protection diode at Pin3 to Gnd to stop higher than 5V put on pin.
The LED Bar Connector connects to a 10LED array/LED Driver - SW1 will also actually connect power to this aswell - if it always connected it sucks power like anything.
Just a few Questions:
Please tell me im using the MOSFET correctly in respect with the PICAXE (I know this is a pet peve of some people - and rightly so).
I've been looking at the Solar Panel power curves (IV). I'm not sure about the Voltage Reg as a voltage source (I know better results would come from a switched reg, but that is the next step). Will the panel give as much current it can at the set voltage and drop the V it to give more current, or is it just a set current at a set voltage. If anyone could please point me in the right direction - I can't seem to find it anywhere.
When the battery gets to about 13V (Using a 9Ah SLA for testing) it really slows down its charge (more than I would expect). With no battery connected, point Batt+(II) is set at 14.5V (Cycle Charge Voltage). With battery connected, about 40mA flowing into battery - seems not to go much higher than 13V.
Also any pointers on the code would be useful aswell - but I am hoping that it is ok (246 out of 256 full).
Thanks to all on this forum - I have been watching it for a while now and learning a lot, I only hope I can be of help to others. This is a hobby for me so I have only learn't electronics off the web - I'll create a post with some of the resources I have used - they are really good.
Braden
PS: Sorry about the hand drawn diagram - I havn't found a quick designer yet thats free - I find it a lot quicker by hand (tried Eagle, but too slow for really simple diagrams)
Disclaimer: I am not a Electrical Engineer, this is just a sample circuit - use at your own risk
.
I Know - another Battery Charger
I thought I would give a Solar Charger/Controller a go and here are the results.
This is the first time using a micro controller (unless you count the couple of hours with a Basic Stamp 5 Years ago).
This is a VERY BASIC Charger only. All seems to work as a charger. Trying to minimize component count and cost
Calibration/Setup (08M)
Note: Batt+ (I) and Batt+ (II) are actually the same connection but on setup treat them as seperate - they are NOT Connected (there will be a jumper in the final solution)
- Put 14V on Batt+(I) while holding down SW1 and then release it once it starts blinking.
- Adjust R1 until both LEDs are off (about 4.6V on Pin 3 PICAXE)
- Press and release SW1 again - Green LED Should Light (after Red blink)
- Put 16-18V on PV+
- Adjust R2 until Batt+(II) reads the Float voltage for the battery (add 0.1-0.2V to this reading)
- Disconnect Test Voltage supplies and connect to PV and Battery
This only has 1 stage - float, but will disconnect if greater than 13.8V and reconnect at below 13.7V.
There should probably be some protection diode at Pin3 to Gnd to stop higher than 5V put on pin.
The LED Bar Connector connects to a 10LED array/LED Driver - SW1 will also actually connect power to this aswell - if it always connected it sucks power like anything.
Just a few Questions:
Please tell me im using the MOSFET correctly in respect with the PICAXE (I know this is a pet peve of some people - and rightly so).
I've been looking at the Solar Panel power curves (IV). I'm not sure about the Voltage Reg as a voltage source (I know better results would come from a switched reg, but that is the next step). Will the panel give as much current it can at the set voltage and drop the V it to give more current, or is it just a set current at a set voltage. If anyone could please point me in the right direction - I can't seem to find it anywhere.
When the battery gets to about 13V (Using a 9Ah SLA for testing) it really slows down its charge (more than I would expect). With no battery connected, point Batt+(II) is set at 14.5V (Cycle Charge Voltage). With battery connected, about 40mA flowing into battery - seems not to go much higher than 13V.
Also any pointers on the code would be useful aswell - but I am hoping that it is ok (246 out of 256 full).
Code:
'' BATTERY CHARGER
'' POWERED BY SOLAR POWER
'' m_ = memory, c_ = constant, i_ = input, o_ = output, p_ = parameter (passed to functions)
'' i, j = general counters for loops
''''' MEMORY
' bit0 - bit7
symbol m_Charging = bit6 ' There seems to be feedback on ADC when PWM
symbol m_PwmInProgress = bit7 ' There seems to be feedback on ADC when PWM
symbol m_SetupInProgress = bit5 ' Set when the ShowVoltage is Pressed when startup
symbol m_BatteryActuallyCharging = bit4 ' There may not be enough sun
Symbol tmpBit = bit0 ' Holds Temp Vars
' b1 - b5
symbol i = b1
symbol m_TimeCounter = b2 ' used for timing (seconds)
symbol p_ledBlinkCount = b4
symbol tmpB = b5 ' just holds tmp vars - 1 to 2 lines code max scope
' w3 - w6
symbol m_VoltagePrev = w3
symbol m_Voltage = w4 ' Contains input Voltage ADC [c_VoltageMinADC-c_VoltageMaxADC]
symbol m_LedBars = w5 ' Contains output Percentage ADC [0-600] -> [0V-3V]
symbol tmpW = w6 ' just holds tmp vars - 1 to 2 lines code max scope
''''' CONSTANTS
symbol c_VoltageOffset = 727 ' Taken odd ADC reading to
symbol c_SleepProcessor = 2 ' x * 2.3sec
symbol c_LedBarShowTime = 2000 ' How long to display the LED Bar
symbol c_VoltageReferenceADC = 942 ' 14.0V -> 4.60V - ADC Value = 942 - USED FOR SETUP
symbol c_VoltageLedMaxADC = 851 ' 12.65V -> 4.18V
symbol c_VoltageLedMinADC = 760 ' 11.3V -> 3.70V
symbol c_VoltageLedThreshold = 855 ' The threshold where it shows the overcharged battery
symbol c_VoltageLedMinADC_O = 841 ' 12.5V
symbol c_VoltageLedMaxADC_O = 929 ' 13.8V
symbol c_SlowPulseCharge = 0 ' Turn the Charger on and off - not overheat the regulaturs
symbol c_ChargerOn = 922 ' Lowest Float Charge - turn charger on - 13.7V
symbol c_ChargerOff = 929 ' Highest Float Charge [MUST BE BELOW ACTUAL FLOAT CHARGE] - turn charger off- 13.8V
''''' INPUTS
symbol i_Voltage = 4
symbol i_ShowVoltage = pin3
''''' OUTPUTS
symbol o_LedGeneral = 0 ' Just a LED for information to the programmer
symbol o_ChargeSwitch = 1 ' Turns the charger on and off
symbol o_PwmVoltage = 2 ' Pin 5 but pwm 2
symbol o_SetupRed = 0 ' Startup Led
symbol o_SetupGreen = 1 ' Charger LED - Is INVERSE
''''' BOOTING
Initalize:
' Clear Stuff
let pins = %00000000
pwmout 2, off
' Check in Setup Mode
' If Turned on with Show Voltage Button Pressed - go into Setup Mode
if i_ShowVoltage = 1 then
gosub FlashLed
goto SetupMode ' Infinate Loop
endif
' Show Normal Boot Sequence
let p_ledBlinkCount = 6
gosub FlashLed
' Show Initial Voltage Display
readadc10 i_Voltage, m_Voltage
gosub Calculate
gosub SetLEDVoltageDisplay
''''' MAIN EVENT LOOP
MainEventLoop:
' Indicate a loop start
let p_ledBlinkCount = 1
gosub FlashLed
'pause 1000
' Load Battery Voltage
readadc10 i_Voltage, m_Voltage
' Run Calculations
gosub Calculate
' Setup interrupt - Show LED Meter - Sleep ignores it - The interrupt itself does NOT reset it
if i_ShowVoltage = 1 then ' Change to 0 when using interrupt
gosub SetLEDVoltageDisplay
'setint %00001000, %000001000 ' Pin 3
endif
' Turn Charger On/Off
gosub Charger
'disablebod
pause 3000 ' c_SleepProcessor
goto MainEventLoop
''''' MAIN FUNCTIONS
Calculate:
' Calculate LEDBar Value in percentage of 5V - 0V-3V [0-600] actual output
' Show Normal Battery Charge - Below 12.65V
if m_Voltage < c_VoltageLedThreshold then
m_BatteryActuallyCharging = 0
let tmpW = c_VoltageLedMaxADC - c_VoltageLedMinADC ' Get delta
let m_LedBars = m_Voltage - c_VoltageLedMinADC * 100 / tmpW * 6 ' The *100 and *6 make it fit within 16bits
else ' Show Charger Battery Voltage - Up to 13.8
m_BatteryActuallyCharging = 1
let tmpW = c_VoltageLedMaxADC_O - c_VoltageLedMinADC_O ' Get delta
let m_LedBars = m_Voltage - c_VoltageLedMinADC_O * 100 / tmpW * 6 ' The *100 and *6 make it fit within 16bits
endif
let tmpW = m_LedBars
let m_LedBars = m_LedBars MAX 650
let m_LedBars = m_LedBars MIN 80
debug
return
Charger:
if m_Voltage <= c_ChargerOn then
let m_Charging = 1
low o_ChargeSwitch
let tmpBit = c_SlowPulseCharge
if tmpBit = 1 then
pause 5000
high o_ChargeSwitch
endif
endif
if m_Voltage >= c_ChargerOff then
let m_Charging = 0
high o_ChargeSwitch
endif
return
SetLEDVoltageDisplay:
Interrupt:
let m_PwmInProgress = 1
if m_BatteryActuallyCharging = 1 then
high o_LedGeneral
endif
pwmout 2 , 249, m_LedBars ' 0V-3V
pause c_LedBarShowTime
pwmout 2, off
if m_BatteryActuallyCharging = 1 then
low o_LedGeneral
endif
let m_PwmInProgress = 0
return ' Reset in Main Loop
''''' UTILITY FUNCTIONS
SetupMode:
' Set Main Voltage to 14.0V - Turn until both leds are off
' Red - Decreade Voltage R1
' Green - Increase Voltage R1
' NOTE One of the LEDS is Revesed so Low is ON - (Charge Led)
do while i_ShowVoltage = 1 ' Debounce
high o_LedGeneral
pause 100
low o_LedGeneral
pause 100
loop
pause 100
readadc10 i_Voltage, m_Voltage
if m_Voltage > c_VoltageReferenceADC then high o_SetupRed
else low o_SetupRed
endif
if m_Voltage < c_VoltageReferenceADC then low o_SetupGreen
else high o_SetupGreen
endif
if i_ShowVoltage = 1 then
let p_ledBlinkCount = 4
gosub FlashLed
low o_ChargeSwitch
stop
endif
goto SetupMode
return
FlashLed:
for i = 1 to p_ledBlinkCount
high o_LedGeneral
pause 100
low o_LedGeneral
pause 100
next
return
Braden
PS: Sorry about the hand drawn diagram - I havn't found a quick designer yet thats free - I find it a lot quicker by hand (tried Eagle, but too slow for really simple diagrams)
Disclaimer: I am not a Electrical Engineer, this is just a sample circuit - use at your own risk
.
Attachments
-
96.4 KB Views: 157
Last edited: