I2C and Voltages

tjetson

Senior Member
So, I have a project where my Picaxe needs to run from 3 NiMH batteries, so 3.6 volts. I need to use the DS1307 with this project, but the clock unfortunately only runs between 4.5 and 5.5 volts. Anything lower and the backup battery automatically kicks in and you can't read or write to the clock's chip.

My question is, will the 3.6 volt Picaxe be able to talk via i2c with the 5 volt DS1307 chip? If not, what steps can I take to remedy this unfortunate predicament?
 

westaust55

Moderator
You cannot directly connect different i2c devices that have different Vcc reference.


A couple of options are:

1 use a DS1338 RTC drop in replacement for DS1307 which is suitable for lower operating voltages and by perchance can also operate at 400kHz (i2cfast keyword) - but beware of the changed backup battery voltage requirements as well

2. Use a couple of FETs (eg 2N27000) as a level shifter for the i2c clock and data lines which I have done and posted here about in the past.

http://www.picaxeforum.co.uk/showthread.php?t=14265
See the link I give to the NXP (ex Philips) website in post 4.
 
Last edited:

slimplynth

Senior Member
I got my DS1307 chips a couple of weeks ago but have only just taken them out of the bag for breadboarding. Was reading the datasheet on Friday...

http://www.sparkfun.com/datasheets/Components/DS1307.pdf

...from this...

OPERATION
The DS1307 operates as a slave device on the serial bus. Access is obtained by implementing a START condition and providing a device identification code followed by a register address. Subsequent registers can be accessed sequentially until a STOP condition is executed. When VCC falls below 1.25 x VBAT the device terminates an access in progress and resets the device address counter. Inputs to the device will not be recognized at this time to prevent erroneous data from being written to the device from an out of tolerance system. When VCC falls below VBAT the device switches into a low-current battery backup mode. Upon power-up, the device switches from battery to VCC when VCC is greater than VBAT + 0.2V and recognizes inputs when VCC is greater than 1.25 x VBAT. The block diagram in Figure 1 shows the main elements of the serial RTC.
and further down...

VBAT – Battery input for any standard 3V lithium cell or other energy source. Battery voltage must be held between 2.0V and 3.5V for proper operation.
If you can supply VBAT with 2V then the minium operational voltage would be 2 * 1.25 = 2.5V

The 3.6V supply would be adequate? Well that's how I read it.. that it's the relative voltage that matters.. would you use a potential divider to get the 2 volts or would a diode provide enough of a voltage drop? (or too much?)
 
Last edited:

westaust55

Moderator
Where tjetson is coming from is the Vcc ratings for the DS1307. Namely (datasheet page 9):

PARAMETER___SYMBOL MIN TYP MAX UNITS NOTES
Supply Voltage__VCC___4.5_5.0_5.5___V

So operation at 3/3.3V is questionable
 

Dippy

Moderator
Slimmy, always read the Min-Max and Operational paramters for a device rather than trying to work backwards. Some data sheets can be ambiguous, but this one (as highlighted by Westy) is very clear - nice try though :)

So, back to the plot....
 

slimplynth

Senior Member
yeah, thanks for the constructive critism (honestly).

I couldn't help but finish the breadboard and have a try.

using 3.6 volts (3 x AA NiMH) - measures 3.84 the clock gives an ok output. when I connected a diode from V+ of the axe090 power rail to the VBAT, all values in the debug screen goto FF.

The voltage measured from the VBAT to ground was 3.5V.

gonna have another look after a swim.
 

hippy

Ex-Staff (retired)
using 3.6 volts (3 x AA NiMH) - measures 3.84 the clock gives an ok output. when I connected a diode from V+ of the axe090 power rail to the VBAT, all values in the debug screen goto FF.

The voltage measured from the VBAT to ground was 3.5V.
From earlier quotes from the datasheets, it seems VCC must be 1.25 x VBAT to operate correctly. With VBAT at 3.5V you need VCC at 4.275V minimum. With VCC at 3.6V the VBAT must be no greater than 2.88V.

The diode is only dropping 0.3V or so, you need to drop a lot more. No idea if you can get this to work as I haven't looked at the datasheet for these situations. This where one or two variable power supplies come in useful.
 

hippy

Ex-Staff (retired)
Do you need the battery backup ?

With a 20X2 and DS1307 with VBAT disconnected that seems to start up and run okay down to 2.8V. No idea what time accuracy would be when operated out of spec would be though.
 

slimplynth

Senior Member
well after a good swim...

... used 4 x 1N4001 diodes connected in series off the axe090 VCC rail; This gives a voltage at VBAT of 2.5V... still the debug screen shows FF for b0 to b7.

however touching any of the diode legs with a finger populates the debug screen with the correct values and continues counting correctly. Any ideas why this might be?
 

MartinM57

Moderator
The DS1307 data sheet I have (from the Maxim web site) says (my bold'ing)

Backup Supply Input for Any Standard 3V Lithium Cell or Other Energy Source. Battery
voltage must be held between the minimum and maximum limits for proper operation.
Diodes in series between the battery and the VBAT pin may prevent proper operation. If a
backup supply is not required, VBAT must be grounded. The nominal power-fail trip point
(VPF) voltage at which access to the RTC and user RAM is denied is set by the internal
circuitry as 1.25 x VBAT nominal. A lithium battery with 48mAhr or greater will back up
the DS1307 for more than 10 years in the absence of power at +25°C.
UL recognized to ensure against reverse charging current when used with a lithium
battery.
..and you [EDIT:] essentially appear to be doing just that ;)
 
Last edited:

slimplynth

Senior Member
Nothing ventured...

Cheers Martin :D perhaps I should edit my first post to say
...Friday (but not really taking it all in)
:D

Though not perfect it does show that 4V isn't the minimum although as Hippy said, It might not be accurate or reliable.
 

hippy

Ex-Staff (retired)
Using an 20X2 and DS1307 with VBAT to 0V, that seems to work down to 2.1V, same caveat on time keeping acciracy.
 

slimplynth

Senior Member
Managed to do it after getting home for different resistors, using a 100 ohm and a 47 ohm resistor as a potential divider.

this gives 2.57V @ VBAT... seems to be working fine.

Update: If it's less than a second lost/gained in a week, I'll live with that (for the time being) ;)
 
Last edited:

MartinM57

Moderator
I'n not really concentrating on what you're trying to do here - but you seem to be running the DS1307 at 3V6 with a (power hungry) potential divider from Vcc to give you a 2V57 Vbat??

So the DS1307 is running severely out of spec and so you're completely on your own regards timekeeping accuracy (and a second a week is a very big ask of a DS1307 when operating fully in spec - get hold of a copy of Maxim App Note 58 to see the care needed with crystal selection and circuit layout) - and when Vcc disappears so does Vbat as well - so timekeeping is completely lost?
 

slimplynth

Senior Member
28X2 >>> DS1307 >>> Minimum Supply

Evenin' All

I set it up as below, planning on leaving it running for a while unsupervised - appreciate any comments - good or bad, cheers.

Will try the FETs for my second DS1307.

Used:

28X2
3X AA (1.2V NiMH 2300mAh) 'ACTIV ENERGY' batteries - from Aldi

Pinched the code from Picaxe Manual 2...

pg.59: hi2cout - with symbol declarations

Code:
; Example of how to use DS1307 Time Clock
; Note the data is sent/received in BCD format.
; Note that seconds, mins etc are variables that need
; defining e.g. symbol seconds = b0 etc.
' set PICAXE as master and DS1307 slave address

hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
'write time and date e.g. to 11:59:00 on Thurs 25/12/03

symbol seconds = b0
symbol mins = b1
symbol hour = b2
symbol day = b3
symbol date = b4
symbol month = b5
symbol year = b6
symbol control = b7



start_clock:
let seconds = $00 ' 00 Note all BCD format
let mins = $59 ' 59 Note all BCD format
let hour = $11 ' 11 Note all BCD format
let day = $03 ' 03 Note all BCD format
let date = $25 ' 25 Note all BCD format
let month = $12 ' 12 Note all BCD format
let year = $03 ' 03 Note all BCD format
let control = $10' Enable output at 1Hz
hi2cout 0,(seconds,mins,hour,day,date,month,year,control)
high 0
end
and pg. 58: hi2cin - with blinking status LED on Output 0
Code:
; Example of how to use DS1307 Time Clock
; Note the data is sent/received in BCD format.
' set PICAXE as master and DS1307 slave address

hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte

' read time and date and debug display
main:
low 0 'Turns off LED, If it's blinking then picaxe ok. 
hi2cin 0,(b0,b1,b2,b3,b4,b5,b6,b7)
debug b1
high 0
pause 2000
goto main
The breadboard ended up a little hairy so here's the PEBBLE layout....

PEBBLE:

Code:
IC||337|210|2|DS1307|U?|||DIP8|IC||DIP8_2
Miscell||400|174|1||XX?||1|4|32.768 kHz||misc_4
Wire||292|180|11||11|#FF0000|3|11||10|
Resistor|47|284|47|2|Resistor|R?||3||IC||
Resistor|100|284|212|2|Resistor|R?||3||IC||
Wire||372|42|11||11|#000000|10|11||10|
Wire||344|44|21||11|#000000|2|11||10|
Wire||453|454|11||11|#FF0000|7|11||10|
Resistor|4700|340|405|2|Resistor|R?||1||IC||
Resistor|4700|366|405|2|Resistor|R?||1||IC||
Wire||424|402|21||11|#FF0000|2|11||10|
Note||270|422|2||||1||SDA||NOTEPAD_12
Note||383|420|1||||1||SCL||NOTEPAD_11
BREADBOARDSTYLE=BB5
SHOWTHETOPAREA=false
Hopefully not made any mistakes after tyding up the layout online.


Pic: - Too much time on my hands tonight :D



 
Last edited:

slimplynth

Senior Member
No worries, I'll summise...

Yes I thought the potential divider would be a waste of energy and as hinted in the picture title, i kind of know it's a waste of time (no pun intended). How long would a coin cell last under a similar set up?

I just wanted to know if the DS1307 would give any results using a 3.6V supply. Which I think was the thread's original question, that it's minimum voltage is stated as 4.5V in data sheet but the explanation given hints that VCC must be 1.25 times VBAT for correct operation.

It's Sunday, a day of rest (or tinkering), the only point (for me) is that I used a new IC and it didn't turn into magic smoke (yet :)).

I can think of reasons for wanting to use 3.6V... perhaps a 3V 28X2.. yup I got one of those doing nothing too...
 

MartinM57

Moderator
appreciate any comments - good or bad, cheers.

Will try the FETs for my second DS1307.
I don't think you should be (perhaps you aren't) claiming that you have found a successful way (for others) to run a DS1307 at 3.x volts - and the fact that it doesn't keep time when Vcc goes away would seem a bit of a limitation to most people.

I look forward to the test results of how accurately it keeps the time.

The proper solution is to run the DS1307 within its voltage specs and use logic level shifters - a pain, yes, but that's the proper way.

Not sure what your second point is about, but note that you can't put two DS1307's on the same i2c bus as their i2c addresses are hardcoded into the chip (as opposed to pin selectable) and so you will get a clash.
 

MartinM57

Moderator
How long would a coin cell last under a similar set up?
It's in the datasheet - "A lithium battery with 48mAhr or greater will back up
the DS1307 for more than 10 years in the absence of power at +25°C."

...but the explanation given hints that VCC must be 1.25 times VBAT for correct operation.
But the data sheet explicitly says that Vcc must be between 4V5 and 5V5 and I'm sure that if the DS1307 worked perfectly at 3.6v with a <3v standby battery, Maxim would be claiming that all over their data sheet.

Also read the data sheet more carefully - "The nominal power-fail trip point (VPF) voltage at which access to the RTC and user RAM is denied is set by the internal circuitry as 1.25 x VBAT nominal"..and then search for VPF in the rest of it - it shows:

Power-Fail Voltage (VBAT = 3.0V) VPF (min) 1.216 xVBAT (typ) 1.25 xVBAT (max)1.284 xVBAT
i.e. those values are only valid when VBAT is 3V

Anyway, enough of this - it's a good Sunday night experiment when you've too much time on your hands and I look forward to the time-keeping accuracy results
 
Last edited:

slimplynth

Senior Member
@ Martin: Cheers for the comments, will (have) taken them on board.

Re. the coin cell.. if VBAT is at 3.0V and VCC is at 3.6 (ish) then the output defaults to FF for variables B0 thru B7. VBAT needs to be 1.25 * lower than VCC.

If I were to set up with a coin cell, as provided by Rev-ed, then I'd need a different potential divider; my assumption being that as long as it supplied 2.5(ish) to VBAT it would work.

But given that its wasting energy the coin cell wouldn't last 10yrs.
 
Last edited:

tjetson

Senior Member
Thank you for the enormous number of replies :)

Do you need the battery backup ?
If I always keep the clock running from the Ni-Mh batteries (which is a possibility) then probably not.

Some of you posted information about boost converters and such. I had actually looked at such a device. I seem to have 2 or 3 devices I want to use that won't like 3.6 volts (sigh), so I will use a boost converter to power those. My problem is I need them to be able to talk to each other. The idea about the FETs seems like it would work. I will look at it further. Thank you again
 

Dippy

Moderator
Ah, 2 or 3 devices now....
Maybe you should post a rough schematic of your system and include component types and any appropriate links to Data. Then people can suggest where level shifting is needed or appropriate.
 

tjetson

Senior Member
Upon closer inspection of the parts I want to use, it turns out that the 1307 is the only i2c part which isn't 3.6 volt-capable. The only other device is an LCD, for which I can use a boost converter or something. If a diagram is required, I will have to upload something tomorrow.

The LCD is one of P Anderson's devices.
 

westaust55

Moderator
The idea about the FETs seems like it would work. I will look at it further. Thank you again
Definitely will work.
I am using it on the clock and data lines in a circuit with EEPROM, RTC and PICAXE at 5V and some HOPERF sensors at 3.0/3.3V
 
Top