using a RTC in SF basic

MrDEB

Well-Known Member
I have a DS-1302 RTC module but how to use it?
I recall Jon Chandler made a vu meter clock but what he used for timing?
Am planning on a clock that has no hands, just LEDs but precision would be nice.
 
The DS-1302 is not a chip that will be easy to use in a standalone configuration. The time keeping function is based on a 32.768 kHz quartz crystal. The remining pins provide a serial interface to a micro controller. The choice of a microcontroller is largely irrelevant.

Googling SF basic, the #1 hit is a San Francisco Ski Injury Clinic. I'm guessing that your reference is to something else. Isn't AI marvelous?
 
Against my better judgement.....

First, I suggest using a DS3231 module instead of the DS-1302 module or DS-1307 modules. The accuracy of the DS3231 is much better than the DS-1302 or DS-1307. There is a DS-1307 Swordfish include module, which I have very slightly modified for the DS3231. There isn't a DS-1302 include module, so I suggest forgetting about the DS1302.

Next point - The DS3231, as are almost all RTC modules, uses the I2C interface. I2C interfaces are complex, and must be done in the correct way; there is ZERO room for random changes.

There are many steps to making a clock. You need a mechanism to set the time and date. You have to read separate registers for hours, minutes and seconds and then do the math to display the results. My code is going to take more explanation than I am willing to provide, with much of it dedicated to the display, which won't apply to what you're doing.

I've attached the DS3231 include module. I suggest downloading the DS3231 datasheet and taking a look at the task you're trying to do.
 

Attachments

  • ds3231.bas
    10.7 KB · Views: 1
There may be an easier way for you to accomplish this. The attached pdfs discuss what I did for the servo clock. The method used is basically counting seconds, and converting that count into hours and minutes. Maybe this will help.

This is based on Soft RTC - 4 Methods For A Precision PIC Time Clock from the Swordfish Basic website.
 

Attachments

  • A Clock for Geeks.pdf
    2.9 MB · Views: 1
  • clock controller.pdf
    40.8 KB · Views: 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…