Shop OBEX P1 Docs P2 Docs Learn Events
DS1307 Real Time Clock Engine — Parallax Forums

DS1307 Real Time Clock Engine

pusinkpusink Posts: 68
edited 2013-04-04 15:09 in Propeller 1
anybody have a sample spin code to use DS1307 Real Time Clock Engine v.1.4 by Kwabena W. Agyeman.
tq.

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-10-19 19:03
    I posted this reply recently. I modified Kye's object to allow for 12 hour mode -http://forums.parallax.com/showpost.php?p=945279&postcount=7
  • KyeKye Posts: 2,200
    edited 2010-10-20 05:55
    It has an included demo... What more do you need?
  • pusinkpusink Posts: 68
    edited 2010-10-21 23:53
    Nyamekye,

    i'm new in propeller chip dan *.spin. When i see your demo, it's hard for me to understand..you have any other sample program using your v1.4 to display time and date via parallax serial terminal..

    Tq..for helping me...
  • KyeKye Posts: 2,200
    edited 2010-10-22 05:39
    There is no easier way... Displaying the time and date requires string processing and setting the time and date requires string processing.

    You gotta bite the bullet and dive in. Only way to learn. In particular look at the private funtion called "ProgramDate" this function is the one that actually generates the date output to the serial terminal.

    I'm sorry the function is so complicated, but unless you want to just see numbers for the time and date it has to be complex.

    You can however do stuff like... (using fullduplexserial.spin)

    rtc.readTime
    serial.dec(rtc.checkSeconds)
    serial.tx(13)
    serial.dec(rtc.checkMinutes)
    serial.tx(13)
    serial.dec(rtc.checkHours)
    serial.tx(13)
    serial.dec(rtc.checkDate)
    serial.tx(13)
    serial.dec(rtc.checkDay)
    serial.tx(13)
    serial.dec(rtc.checkMonth)
    serial.tx(13)
    serial.dec(rtc.checkYear)
    serial.tx(13)
  • pusinkpusink Posts: 68
    edited 2010-10-22 06:53
    Nyamekye,
    it's working properly....tq very much...but i have another question...now my clock is 24h format...how to change 12h format...

    tq again...
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-22 06:56
    Hi Kye,

    I am not sure whether I am the only one experiencing this peculiar thing with your v1.4 driver.

    The first time I call rtc.readTime, it returns failure.
    The second time I call rtc.readtime, it returns success but all the values I got are 165.

    Only after the 3rd and subsequent call of rtc.readtime do i get the correct date and time values.

    I share the same I2c bus with the boot eeprom.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-10-22 07:51
    pusink,
    Kye's object provides methods to return 12 hour values,
    clockMeridiemHour and clockMeridiemTime, but it does not accomodate using the chip's built-in 12 hour format.

    That is why I tweaked his object to allow 12 or 24 hour mode since I move my modules between the propellers, basic stamps and arduinos where my code expects the 12 hour format.

    My version is here
    http://forums.parallax.com/showpost.php?p=945279&postcount=7
    - Ron
  • pusinkpusink Posts: 68
    edited 2010-10-22 08:05
    ron czapala,

    tq very much....i will try first...
  • KyeKye Posts: 2,200
    edited 2010-10-22 08:11
    @william chan - The code I wrote always accesses the I2C bus the same way, meaning that it should work every time, every call.

    You may be experiencing problems related to another piece of I2C code running or electrical problems. I have never had any problems using sparkfun's DS1307 module.

    If you weren't getting this problem before its probably because all the accesses weren't group together before. So, maybe previously a few of the calls to "getSecond" or "getMinutes", etc may have failed but you didn't notice.

    I assure you that the new code works much better than the previous code and is well tested.
  • phil kennyphil kenny Posts: 233
    edited 2012-09-11 17:09
    Kye wrote: »

    I'm sorry the function is so complicated, but unless you want to just see numbers for the time and date it has to be complex.

    You can however do stuff like... (using fullduplexserial.spin)

    rtc.readTime
    serial.dec(rtc.checkSeconds)
    serial.tx(13)
    serial.dec(rtc.checkMinutes)
    serial.tx(13)
    serial.dec(rtc.checkHours)
    serial.tx(13)
    serial.dec(rtc.checkDate)
    serial.tx(13)
    serial.dec(rtc.checkDay)
    serial.tx(13)
    serial.dec(rtc.checkMonth)
    serial.tx(13)
    serial.dec(rtc.checkYear)
    serial.tx(13)

    Kye,

    When I attempted to use the above commands, I got "Error expected a subroutine name" on each line with the methods rtc.ckeck.xxx

    In your excellent DS1307 RTCEngine.spin I can't find these methods, except inside of comment fields under PUB ReadTime.

    Am I missing something?

    phil kenny
  • KyeKye Posts: 2,200
    edited 2012-09-11 19:08
    It looks like the names changed from "check" to "clock".

    I haven't updated that code in a while. Sorry about that.

    Thanks,
  • phil kennyphil kenny Posts: 233
    edited 2012-09-11 23:24
    Found my bug(s). Please ignore this post.

    phil
  • ShaliniShalini Posts: 59
    edited 2013-04-04 10:37
    Kye wrote: »
    There is no easier way... Displaying the time and date requires string processing and setting the time and date requires string processing.

    You gotta bite the bullet and dive in. Only way to learn. In particular look at the private funtion called "ProgramDate" this function is the one that actually generates the date output to the serial terminal.

    I'm sorry the function is so complicated, but unless you want to just see numbers for the time and date it has to be complex.

    You can however do stuff like... (using fullduplexserial.spin)

    rtc.readTime
    serial.dec(rtc.checkSeconds)
    serial.tx(13)
    serial.dec(rtc.checkMinutes)
    serial.tx(13)
    serial.dec(rtc.checkHours)
    serial.tx(13)
    serial.dec(rtc.checkDate)
    serial.tx(13)
    serial.dec(rtc.checkDay)
    serial.tx(13)
    serial.dec(rtc.checkMonth)
    serial.tx(13)
    serial.dec(rtc.checkYear)
    serial.tx(13)

    Because ur indicating serial there in the code the data is displayed on the serial terminal. But how can i get the time and date to display on a JHD162A 16x2 LCD with HD44780 Driver. What do I need to change in the LCD RTC Demo code??
  • KyeKye Posts: 2,200
    edited 2013-04-04 15:06
    I suppose you just take the code you quoted and pass those values to the LCD function print statements.
  • ShaliniShalini Posts: 59
    edited 2013-04-04 15:09
    Kye wrote: »
    I suppose you just take the code you quoted and pass those values to the LCD function print statements.

    So,something like this???
    PUB Update_time

    I2C.read_page(I2C#RTC,Seconds,@buffer,7)
    LCD.clear
    LCD.hex(buffer[date],2) ' display time and date as dd/mm/yy hh:mm:ss
    LCD.send("/")
    LCD.hex(buffer[month],2)
    LCD.send("/")
    LCD.hex(buffer[year],2)
    LCD.move(2,0)
    LCD.send(" ")
    LCD.hex(buffer[hours],2)
    LCD.send(":")
    LCD.hex(buffer[minutes],2)
    LCD.send(":")
    LCD.hex(buffer[seconds],2)
Sign In or Register to comment.