Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Questions and Problems by DS1307 RTC

Saeedk9574

Member level 3
Member level 3
Joined
Nov 6, 2023
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
484
Hi Everyone,
It has been a few days that I have been struggling with DS1307 RTC and I have some questions and problems. I should mention I had tested a library for ds1307 on its prepared module, then I decided to make the circuit separately with its components. These are the ds1307 module pic and its circuit diagram. In addition I attached ds1307 and its module datasheet here. However, there was not appropriate datasheet for its module.
ds1307-module-500x500.jpg
DS1307-RTC-Module-Schematic.png


1. Based on the datasheet ds1307 has 56B nvSRAM, so my first question is what is the usage of eeprom in this module? is it necessary to use eeprom on my board or not?

2. Second, I have a very big problem. After creating this circuit on PCB, it works correctly when the board is fixed o its place. But sometimes by a simple movement of board the timer gets stuck and sometimes it works well. My first guess was the crystal oscillator stops working by moving the board. But then I decided to touch crystal by my hand to test it and it was OK. I do not know where is the problem.

3. I should mention the only difference between the module and my circuit is the type of eeprom. Module has a 32K eeprom (24c32), but I used a 1k eeprom (24AA01). Can this difference affect the performance. I still do not know the usage of eeprom here.
 

Attachments

  • DS1307-1513036.pdf
    214.7 KB · Views: 157
  • tiny_rtc.pdf
    806 KB · Views: 166
1. you can ignore the EEPROM if you don't need it. Just don't use its I2C address.
2. This is almost certainly a connection problem, if the power/ground breaks even for a moment, you have to reinitialize the IC.
3. I2C EEDPROM have diferent internal addresses and sometimes different commands but most are very similar. If you change the address to 24C32 it will probably work just the same but with 32 times more storage!

Brian.
 
1. you can ignore the EEPROM if you don't need it. Just don't use its I2C address.
2. This is almost certainly a connection problem, if the power/ground breaks even for a moment, you have to reinitialize the IC.
3. I2C EEDPROM have diferent internal addresses and sometimes different commands but most are very similar. If you change the address to 24C32 it will probably work just the same but with 32 times more storage!

Brian.
Thanks for replying. Do you have any idea how I can use an eeprom in this RTC?
 
Treat it as an EEPROM that is not on the board. The SDA and SCL lines are shared with the RTC but the I2C protocol states the communication with a device starts by putting its address on the bus so using address B'1101000x' will communicate with the DS1307 and address B'1010AAAx' will communicate with the AT24C32.
In both examples, 'x' is the read/write bit (I2C uses adjacent addresses to read or write to a device) and in the case of the AT24C32, 'AAA' is the bit pattern on pins A2,A1,A0. As these pins seem to be permanently grounded on the PCB you can treat them as all zero.

For the specifics of how to use the 24C32 you have to refer to its data sheet but it is a very easy device to use.

Brian.
 
Treat it as an EEPROM that is not on the board. The SDA and SCL lines are shared with the RTC but the I2C protocol states the communication with a device starts by putting its address on the bus so using address B'1101000x' will communicate with the DS1307 and address B'1010AAAx' will communicate with the AT24C32.
In both examples, 'x' is the read/write bit (I2C uses adjacent addresses to read or write to a device) and in the case of the AT24C32, 'AAA' is the bit pattern on pins A2,A1,A0. As these pins seem to be permanently grounded on the PCB you can treat them as all zero.

For the specifics of how to use the 24C32 you have to refer to its data sheet but it is a very easy device to use.

Brian.
Thanks a lot for sharing this information.
 
It says WARNING
Negative undershoots below -0.3V while the part is in battery-backed mode may cause loss of data



Imagine how the Vbat can be used to save the time of day for a few seconds or minute to save the date, hour and minute while the battery is being changed and the capacitor gets discharged too much. Why do you think they sense the battery voltage using 1.5/2.1 Meg or 71% and if they rely on the input logic level at 50% or 1.3V for 74HCTxx thresholds when should they save date & time into EEPROM first before it stops? Or maybe it is still powered up with 5V and the battery is dead what parameters should it use to update Date & time into EE?

Do you think it should have a cap on the Vbat? Maybe not if Vbat drops below Vcc and (if it) causes SCR shutdown when Vcc comes back up and Vbat exceeds Vcc by the do not exceed rating. Or maybe that port's high impedance is affected by stray E-fields in your cable from high CM grid fields and has exceeded the Not to Exceed thresholds into the 0.5 Meg Vbat port

Std 3.0V Li battery...."
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 48mAh or greater will back up the
DS1307 for more than 10 years in the absence of power at +25°C"

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.

Try 1nF on Vbat port.

Use shielded or twisted wires to suppress CM E-fields.

use a magnifying lens on all solder joints.
--- Updated ---

24C32 4.5 to 55V won't work on power fail using 3V

1705095839442.png
 
Last edited:
It says WARNING
Negative undershoots below -0.3V while the part is in battery-backed mode may cause loss of data



Imagine how the Vbat can be used to save the time of day for a few seconds or minute to save the date, hour and minute while the battery is being changed and the capacitor gets discharged too much. Why do you think they sense the battery voltage using 1.5/2.1 Meg or 71% and if they rely on the input logic level at 50% or 1.3V for 74HCTxx thresholds when should they save date & time into EEPROM first before it stops? Or maybe it is still powered up with 5V and the battery is dead what parameters should it use to update Date & time into EE?

Do you think it should have a cap on the Vbat? Maybe not if Vbat drops below Vcc and (if it) causes SCR shutdown when Vcc comes back up and Vbat exceeds Vcc by the do not exceed rating. Or maybe that port's high impedance is affected by stray E-fields in your cable from high CM grid fields and has exceeded the Not to Exceed thresholds into the 0.5 Meg Vbat port

Std 3.0V Li battery...."
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 48mAh or greater will back up the
DS1307 for more than 10 years in the absence of power at +25°C"

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.

Try 1nF on Vbat port.

Use shielded or twisted wires to suppress CM E-fields.

use a magnifying lens on all solder joints.
--- Updated ---

24C32 4.5 to 55V won't work on power fail using 3V

View attachment 187838
Thank you for such a perfect answer.
As far as I understood, absence of battery cause the disconnection of timer.
I have used cr2032 for this DS1307,but It does not work with this battery. I do not know the 510k resistor prevent battery to run ds1307 or I have to use other types of batteries.
 
The topic of these little boards has come up before. They are not well designed and the advertising is misleading.

The purpose of D1 and R5 is to provide a charging current to a RECHARGEABLE coin cell. They do nothing if a normal CR2023 cell is fitted, in fact there is a tiny risk of the cell being damaged although it is unlikely and shouldn't be dangerous.

R2 and R1 are to drop the voltage at the VBAT pin to a safe level if the battery isn't fitted or can't sink enough current, otherwise it could rise to around (5V - Vf of D1) = 4.4V.

A more sensible design would omit D1, R1,R2 and R5 altogether and just rely on a battery being fitted for backup. Someone somewhere designed this without really thinking through the consequences or at least explaining how it was supposed to be used. They didn't follow the data sheet.

Brian.
 
The topic of these little boards has come up before. They are not well designed and the advertising is misleading.

The purpose of D1 and R5 is to provide a charging current to a RECHARGEABLE coin cell. They do nothing if a normal CR2023 cell is fitted, in fact there is a tiny risk of the cell being damaged although it is unlikely and shouldn't be dangerous.

R2 and R1 are to drop the voltage at the VBAT pin to a safe level if the battery isn't fitted or can't sink enough current, otherwise it could rise to around (5V - Vf of D1) = 4.4V.

A more sensible design would omit D1, R1,R2 and R5 altogether and just rely on a battery being fitted for backup. Someone somewhere designed this without really thinking through the consequences or at least explaining how it was supposed to be used. They didn't follow the data sheet.

Brian.
I omitted the R2, R1 and D1 and I connected cr2032 directly to ds1307. The result was when I disconnect Vcc from ds1307 it can save the time correctly but it can not show it on serial terminal.
 
That is how it is supposed to work.
The cell is only there to keep the clock operating when VCC is removed, otherwise without any power it would forget all the register contents. VCC is still needed for the I2C interface to work.

Brian.
 
That is how it is supposed to work.
The cell is only there to keep the clock operating when VCC is removed, otherwise without any power it would forget all the register contents. VCC is still needed for the I2C interface to work.

Brian.
To test this I disconnected VCC from ds1307 but I made pullup I2C pins to an external VCC by same ground. I expected besides saving time it could show the time on serial terminal. Unfortunately it just saved the time. Have I tested in a wrong way? If so, I2c pins of ds1307 do not work with VBAT, Am I Right?
 
Hi,

I´m not surprised, because I believe in datasheet informations like:
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 ..


Klaus
 
There is a marginal EMC problem with your long wires, but as I pointed out if the power fail depends your EE memory still working at 3V, your 24C32 is the wrong type.

The real test is it should retain the correct time of day when you replace the battery with no Vcc in less than a minute.
 
Hi,

When OP says he disconnects VCC .. this does not mean VCC is zero. I guess the OP did not measure VCC voltage.

When the RTC datasheet says it´s allowed to pull up SCL and SDA while the RTC_VCC is down ... just says there is no diode from SCL/SDA to RTC_VCC installed.
The same is not true for the EEPROM. Thus it´s likely the EEPROM internal protetion diodes use the pull up current to lift EEPROM_VCC to an unknown level.
Now on the circuit EEPROM_VCC is connected to RTC_VCC ... thus the RTC may be "supplied" from SDA/SCL pull up current via EEPROM_ESD_Diodes.

--> just saying "VCC is disconnected" means nothing. One has to verify (=measure) theRTC_VCC level to be able to make the right decisions.

Klaus
 
Hi,

I´m not surprised, because I believe in datasheet informations like:
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 ..


Klaus
By this explanation I won't be able to use the time during the absence of VCC. it can just save the time, if I am not mistaken.
 
If VCC is absent how does the controller read the data anyway? Normally it would share the same VCC supply.
VBAT is just an alternative power input that keeps the timekeeping part running so the clock updates normally but you can't actually read or write the time/date unless VCC is also present.

Brian.
 
If VCC is absent how does the controller read the data anyway? Normally it would share the same VCC supply.
VBAT is just an alternative power input that keeps the timekeeping part running so the clock updates normally but you can't actually read or write the time/date unless VCC is also present.

Brian.
What I mean is I just disconnected VCC from ds1307, not from microcontroller, meanwhile microcontroller is connected to VCC. I did this to see if RTC can work with Vbat or not. Accordingly, I realized ds1307 can save time with Vbat but can not communicate with microcontroller by I2C. If I concluded wrongly let me know?
 
Module has a 32K eeprom (24c32), but I used a 1k eeprom (24AA01)
Hi Everyone,
It has been a few days that I have been struggling with DS1307 RTC and I have some questions and problems. I should mention I had tested a library for ds1307 on its prepared module, then I decided to make the circuit separately with its components. These are the ds1307 module pic and its circuit diagram. In addition I attached ds1307 and its module datasheet here. However, there was not appropriate datasheet for its module.
View attachment 187789View attachment 187790

1. Based on the datasheet ds1307 has 56B nvSRAM, so my first question is what is the usage of eeprom in this module? is it necessary to use eeprom on my board or not?

2. Second, I have a very big problem. After creating this circuit on PCB, it works correctly when the board is fixed o its place. But sometimes by a simple movement of board the timer gets stuck and sometimes it works well. My first guess was the crystal oscillator stops working by moving the board. But then I decided to touch crystal by my hand to test it and it was OK. I do not know where is the problem.

3. I should mention the only difference between the module and my circuit is the type of eeprom. Module has a 32K eeprom (24c32), but I used a 1k eeprom (24AA01). Can this difference affect the performance. I still do not know the usage of eeprom here.
You are experiencing mechanical & EMC issues. If you squeeze a 10:1 probe tip without touching ground clip floating, you ought to easily get >> 50Vpp.

if you rattle the board & connections while one hand is grounded to 0V and PE gnd., it should not fail. If so, minimize by tapping the faulty connection.


Regarding EEPROM , here are some examples.

Here are a few more examples of how external EEPROM and an RTC (Real-Time Clock) like the DS1307, along with the 24C32 EEPROM, might be used in embedded systems or electronic projects:

  1. Data Logging:
    • Scenario: You have a data logging project where you want to record sensor readings at specific intervals.
    • Implementation: Use the RTC to timestamp each sensor reading, and store the data in the external EEPROM. This allows you to log data with a time reference.
  2. Configuration Storage:
    • Scenario: Your device has user-configurable settings that need to be retained even when the power is turned off.
    • Implementation: Store configuration parameters (e.g., user preferences, calibration data) in the external EEPROM. The RTC can be used to timestamp when the configuration was last modified.
  3. Event Logging:
    • Scenario: You want to log specific events or occurrences in your system.
    • Implementation: When an event occurs, use the RTC to timestamp the event and store relevant details in the external EEPROM. This can be useful for debugging or system monitoring.
  4. Security System:
    • Scenario: Building a security system where you want to log access attempts.
    • Implementation: Use the RTC to timestamp each access attempt and store information in the external EEPROM. This can include details such as the user ID, access point, and result of the attempt.
  5. Energy Monitoring:
    • Scenario: Designing a system to monitor energy consumption over time.
    • Implementation: Store periodic energy consumption readings in the external EEPROM with timestamps from the RTC. This allows you to analyze energy usage patterns.
  6. Temperature Data Storage:
    • Scenario: You are building a temperature monitoring system.
    • Implementation: Use the RTC to timestamp temperature readings and store the data in the external EEPROM. This provides a historical record of temperature changes over time.
  7. Alarming System:
    • Scenario: Implementing an alarm system with programmable alarms.
    • Implementation: Store alarm settings and trigger conditions in the external EEPROM. The RTC can be used to manage time-related aspects of the alarms.
  8. Firmware Update Tracking:
    • Scenario: Keeping track of when firmware updates occurred.
    • Implementation: Store firmware update timestamps and version information in the external EEPROM using the RTC. This helps in monitoring the history of firmware updates.
These examples showcase the versatility of combining an RTC with external EEPROM to enhance the functionality of embedded systems and electronic projects. Always refer to the datasheets of the specific components you are using for detailed information and guidelines.

Thanks to GPT3.5 and my prompts.
 
You are experiencing mechanical & EMC issues. If you squeeze a 10:1 probe tip without touching ground clip floating, you ought to easily get >> 50Vpp.

if you rattle the board & connections while one hand is grounded to 0V and PE gnd., it should not fail. If so, minimize by tapping the faulty connection.


Regarding EEPROM , here are some examples.

Here are a few more examples of how external EEPROM and an RTC (Real-Time Clock) like the DS1307, along with the 24C32 EEPROM, might be used in embedded systems or electronic projects:

  1. Data Logging:
    • Scenario: You have a data logging project where you want to record sensor readings at specific intervals.
    • Implementation: Use the RTC to timestamp each sensor reading, and store the data in the external EEPROM. This allows you to log data with a time reference.
  2. Configuration Storage:
    • Scenario: Your device has user-configurable settings that need to be retained even when the power is turned off.
    • Implementation: Store configuration parameters (e.g., user preferences, calibration data) in the external EEPROM. The RTC can be used to timestamp when the configuration was last modified.
  3. Event Logging:
    • Scenario: You want to log specific events or occurrences in your system.
    • Implementation: When an event occurs, use the RTC to timestamp the event and store relevant details in the external EEPROM. This can be useful for debugging or system monitoring.
  4. Security System:
    • Scenario: Building a security system where you want to log access attempts.
    • Implementation: Use the RTC to timestamp each access attempt and store information in the external EEPROM. This can include details such as the user ID, access point, and result of the attempt.
  5. Energy Monitoring:
    • Scenario: Designing a system to monitor energy consumption over time.
    • Implementation: Store periodic energy consumption readings in the external EEPROM with timestamps from the RTC. This allows you to analyze energy usage patterns.
  6. Temperature Data Storage:
    • Scenario: You are building a temperature monitoring system.
    • Implementation: Use the RTC to timestamp temperature readings and store the data in the external EEPROM. This provides a historical record of temperature changes over time.
  7. Alarming System:
    • Scenario: Implementing an alarm system with programmable alarms.
    • Implementation: Store alarm settings and trigger conditions in the external EEPROM. The RTC can be used to manage time-related aspects of the alarms.
  8. Firmware Update Tracking:
    • Scenario: Keeping track of when firmware updates occurred.
    • Implementation: Store firmware update timestamps and version information in the external EEPROM using the RTC. This helps in monitoring the history of firmware updates.
These examples showcase the versatility of combining an RTC with external EEPROM to enhance the functionality of embedded systems and electronic projects. Always refer to the datasheets of the specific components you are using for detailed information and guidelines.

Thanks to GPT3.5 and my prompts.
Thanks for providing this information.
Ds1307 itself has 56B nvSRam, do you know how can I use this memory?
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top