DS1307 RTC All In One Reader & Programmer.

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

DS1307 RTC All In One Reader & Programmer.

Post by medelec35 »

I have just Purchased a few RTC modules from 4tronix for £3.20 each:
RTC DS1307.png
(96.26 KiB) Downloaded 7810 times
DS1307 Datasheet
Only took a couple of days to arrive and shop owner does answer any queries you have very quickly indeed!
You can purchase at a cheaper price from china, but I did not want to complicate things with additional charges like import TAX!
So stuck with UK.
Modules include rechargeable battery which when charged can allow RTC to keep time with no external power from 9 to 17 years!
So I thought I would create an all in one RTC reader and programmer.
All that's required are:
Two Momentary switches (using EB007 Eblock),
Microcontoller (using EB006 V9 Eblock)
LCD (using EB005 Eblock)
A suitable power supply
Either 2.54 mm Headers (usually male & min of 2 single Rows of 4 if not using square wave o/p) or 4 wires.
The connections are:
GND
Vcc = +5V (supply range is 4.5 to 5.5V)
SDA = Serial DAta = Port C5 with attached flowchart.
SCL = Serial CLock = Port C4 with attached flowchart.
Only using the above settings so USBEE Eblock can decode I2C signals.
When Hardware is first powered up, If DS1307 is correctly programmed you should see the following format:
DS1307 time1.jpg
DS1307 time1.jpg (20.97 KiB) Viewed 9513 times
None of the three modules I purchased was correctly programmed so the time was not running at all.
If you want to set a new time and date then press switch on A0 (Enter function).
you should then see the abbreviation SUN Flashing:
DS1307 Set time1.jpg
DS1307 Set time1.jpg (19.46 KiB) Viewed 9513 times
Any values flashing is enabled for adjustment up (switch connected to A1).
Every time you press A1 then Day will increment: SUN MON TUE WED THU FRI SAT SUN MON etc.
When correct day is set, press enter switch to start next char flashing.
Again pressing adjustment up switch (A1) to increment tens, of Date.
Pressing enter will cause units of dates to flash etc.
If you realise after enter you have made a mistake, then long pressing enter (for a second or more) should make the previous car flash again for adjustment.
When the last char is flashing (second units) as soon as enter is short pressed the RTC should be updated with new time and date:
Settings updated.jpg
Settings updated.jpg (18.67 KiB) Viewed 9513 times
Flowchart is the first version, so may not be perfect.
I have added some error catches.
For example if you don't increment date and still shows DD then it should not allow you to short press enter and go to MM.

Caution:
If connections to RTC module are nor correct or only GND is removed for example then registers will be corrupt.
This will force the time to be invalid and seconds will stop altogether.
Only solution is to program with correct valid time.

Martin
Attachments
DS1307 RTC Tester & Programmer V1.fcfx
(67.4 KiB) Downloaded 866 times
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DS1307 RTC All In One Reader & Programmer.

Post by medelec35 »

Update:
I have tried this RTC Module:
DS3231 RTC.png
(83.31 KiB) Downloaded 7755 times
I purchased 3 of them for £3.19 each (including rechargeable battery) from a UK supplier.
They arrived next day and no Flowchart modifications are required as they are 100% compatible with DS1307.
Reason for purchase is unlike DS1307 the DS3231 has built in crystal osc with temperature compensation.
The manufactures state:
]DS3231
Extremely Accurate I²C-Integrated RTC/TCXO/Crystal

From the datasheet:
The DS3231 is a serial RTC driven by a temperaturecompensated
32kHz crystal oscillator. The TCXO provides
a stable and accurate reference clock, and maintains the
RTC to within ±2 minutes per year accuracy from -40°C
to +85°C.
Here are the key features:
Highly Accurate RTC Completely Manages All Timekeeping Functions
Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year, with Leap-Year Compensation Valid Up to 2100
Accuracy ±2ppm from 0°C to +40°C
Accuracy ±3.5ppm from -40°C to +85°C
Digital Temp Sensor Output: ±3°C Accuracy
Register for Aging Trim
Active-Low RST Output/Pushbutton Reset Debounce Input
Two Time-of-Day Alarms
Programmable Square-Wave Output Signal
Simple Serial Interface Connects to Most Microcontrollers
Fast (400kHz) I2C Interface
Battery-Backup Input for Continuous Timekeeping
Low Power Operation Extends Battery-Backup Run Time
3.3V Operation
Operating Temperature Ranges: Commercial (0°C to +70°C) and Industrial (-40°C to +85°C)
Martin

Post Reply