PDA

View Full Version : DS1302 Back-up Battery Charger



Nick Waldvogel
03-04-2010, 04:16 AM
I have been working with a DS1302 and I can't seen to get the coding right to turn off the charging output. I read the data sheet and it states that the output is off by default. However, I somehow got it turned on because I have a output voltage of 1.20v on the back-up pin. I want to be able to turn it off so that I don't have trouble with non-rechargeable batteries. I just need a shove in the right direction. Thanks for any input.

Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

sam_sam_sam
03-04-2010, 07:26 AM
Here is the table that you need

'------- Trickle Charge values ---------------------------------------------
Tric····· CON %10010000
OFF······ CON %11110000 'turns off trickle charge
D1R1····· CON %10100101 '1 diode 1 resistor 0.7v 2k ohms
D1R2····· CON %10100110 '1 diode 2 resistor 0.7v 4k ohms
D1R3····· CON %10100111 '1 diode 3 resistor 0.7v 8k ohms
D2R1····· CON %10101001 '2 diode 1 resistor 1.4v 2k ohms
D2R2····· CON %10101010 '2 diode 2 resistor 1.4v 4k ohms
D2R3····· CON %10101011 '2 diode 3 resistor 1.4v 8k ohms
Temp = D2R3············ ' *** Edit this variable ***
RTCCmd = TRIC



How ever you would be better off to us a ONE FARD Supper Cap work much better I have used both

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Nick Waldvogel
03-04-2010, 10:08 AM
Thanks for the reply Sam

I have tried to use te values you provided. I still can't get it to work. Maybe I'm testing it wrong? I'm testing with a DVM from Vss to pin #8 of the DS1302 with the battery not installed. I thought I was getting 1.20v but as I test more and more I find that the voltage is moving around..... I have seen voltage as high as 4.20v and the lowest I can get now is 1.7 volts. I have stripped the code down to what I believe is the bare minimum to get it to change the charger settings.



' {$STAMP BS2}
' {$PBASIC 2.5}

'------- Trickle Charge values ---------------------------------------------
Tric CON %10010000
OFF CON %00001111 'turns off trickle charge
D1R1 CON %10100101 '1 diode 1 resistor 0.7v 2k ohms
D1R2 CON %10100110 '1 diode 2 resistor 0.7v 4k ohms
D1R3 CON %10100111 '1 diode 3 resistor 0.7v 8k ohms
D2R1 CON %10101001 '2 diode 1 resistor 1.4v 2k ohms
D2R2 CON %10101010 '2 diode 2 resistor 1.4v 4k ohms
D2R3 CON %10101011 '2 diode 3 resistor 1.4v 8k ohms
Temp = D2R2 ' *** Edit this variable ***
RTCCmd = TRIC



' -----[ I/O Definitions ]-------------------------------------------------

DataIO PIN 0 ' DS1302.6
Clock PIN 1 ' DS1302.7
CS1302 PIN 2 ' DS1302.5


' -----[ Constants ]-------------------------------------------------------

CWPr CON $8E ' Write Protect Register
WPr1 CON $80 ' Set Write Protect
WPr0 CON $00 ' Clear Write Protect


' -----[ Variables ]-------------------------------------------------------

reg VAR Byte ' Read/Write Address
ioByte VAR Byte ' Data To/From DS1302


Temp VAR Byte
RTCCmd VAR Byte


reg = CWPr ' Initialize DS1302
ioByte = WPr0 ' Clear Write Protect
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [reg, ioByte]
LOW CS1302 ' Deselect DS1302
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [%10010000, %00001111]
LOW CS1302 ' Deselect DS1302


STOP



Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Nick Waldvogel
03-04-2010, 10:25 AM
I now relize that when I change the value highlighted I get a voltage change on pin #8. I get 4.10v with a value of %10101011 and 1.60v with %10101011.

I'm concerned that even with a value of %00001111 it should turn off the charging output but I still get a voltage above 1 volt. Maybe it's nothing to be worried about?



HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [reg, ioByte]
LOW CS1302 ' Deselect DS1302
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [$90, %10101011]
LOW CS1302 ' Deselect DS1302




Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Nick Waldvogel
03-04-2010, 10:56 AM
With even more testing I found that the mA are changing as they should, based on the formula provided on the data sheet, with a battery installed. I believe that the battery needs to be low on voltage to see the voltage change. Everything seems to be falling into place.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

sam_sam_sam
03-05-2010, 05:26 AM
Make sure that you only use about 100 millamp hour batterys if the millamps are more than that··they may not charge all the way up

The ones that a cordless phone battery pack this is what I would

That why I was saying that I use supper caps


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 3/4/2010 10:33:20 PM GMT