Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3, 4  Next
DS1302 Real Time Clock Module (HCMODU0035) 
Author Message

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
it is the sketch from page one wired on an uno to pins 234 as per sketch
I GET IT IS THURDAY 02.03.2005TIME IS 010085 on first line
then it is FRIDAY 07 11 2014 TIME IS 13 :00 :2014 on second line
then back to thursday on 3rd line then back to friday 4th line and so on
have tried it on my mega as well same result disconnected the battery hoping it will rest something now prints xxxxxxxxx 11.25.2007 time is 18 36 85 the a line of correst time and date then the xxxx as before alternating between the 2


Fri Nov 07, 2014 12:08 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
That defiantly shouldn't happen. Have you made any modifications to the original sketch? If so can you post your code. Do the two times increment or stay the same?

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri Nov 07, 2014 1:56 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
no the sketch is not modified except for the the date and todays time i copied the sketch from the first page of this ds1302 but here it is:=
/* FILE: ARD_1302_RTC_Example_Sketch_HCMODU0035
DATE: 03/09/13
VERSION: 0.1

REVISIONS:

20/09/13 Created version 0.1

This is an example of how to use the Hobby Components 1302 Real Time Clock
module (HCMODU0035). This example uses the RTC library written by Henning Karlsen
(http://www.henningkarlsen.com/electronics/). This example sketch demonstrates
how to read and write to the RTC module. To connect the module to your Arduino
please see the following pinout:

PINOUT:

MODULE ARDUINO
GND GND
VCC +5V
SCK D4
I/O D3
RST(CS) D2


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */

/* Define the DIO pins used for the RTC module */
#define SCK_PIN 4
#define IO_PIN 3
#define RST_PIN 2

/* Include the DS1302 library */
#include <DS1302.h>

/* Initialise the DS1302 library */
DS1302 rtc(RST_PIN, IO_PIN, SCK_PIN);

void setup()
{
/* Clear the 1302's halt flag */
rtc.halt(false);
/* And disable write protection */
rtc.writeProtect(false);

/* Initialise the serial port */
Serial.begin(9600);
}

/* Main program */
void loop()
{

/* Set the time and date to 16:30 on the 3rd of September 2013 */
rtc.setDOW(MONDAY);
rtc.setTime(16,30,0);
rtc.setDate(3, 9, 2013);

/* Read the time and date once every second */
while(1)
{
Serial.print("It is ");
Serial.print(rtc.getDOWStr());
Serial.print(" ");
Serial.print(rtc.getDateStr());
Serial.print(" ");
Serial.print("and the time is: ");
Serial.println(rtc.getTimeStr());

/* Wait before reading again */
delay (1000);
}
}


Last edited by kenco on Fri Nov 07, 2014 2:25 pm, edited 2 times in total.



Fri Nov 07, 2014 2:13 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
the time is incrementing on the new date by 2 secs but on the line with xxxxxxxxx for the day it isnt just tried it on my laptop which runs win 8.1 same as on my other comp which runs xp


Fri Nov 07, 2014 2:17 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
The cause of the problem is not jumping out at me at the moment. The RTC is only storing one time so you shouldn't be able to read two different times back out of it. Also there's no way the example sletch should be displaying two different times and dates. This leads me to suspect that the data transfer is getting corrupted for some reason. I think it's worth double checking your connections and making sure they are the same as in the comments of the sketch. In particular make sure your ground and 5V power connections are good. If you can't find anything wrong with the connections can you post a section of the output from the serial terminal.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri Nov 07, 2014 5:10 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
:D hi andrew yes as i ve tried it with 2 diff computers and a uno and a mega i also thought it could be a faulty connection so i metered all the wires but tono joy so i thought maybe a bad joint on the board so i reran all the soldered joints and vola problem solved now counting as should with only 1 setof time and dates. many thnks for your help ken


Fri Nov 07, 2014 6:59 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
That's great, a bad connection makes sense.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Sat Nov 08, 2014 11:45 am
Profile

Joined: Wed Oct 01, 2014 5:40 pm
Posts: 15
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
I am building a clock/calender using the DS1302 RTC, a I2C 7-Segment display for the time and a 16x2 LCD for Month/week/date display. However I have encountered a problem whilst pre-testing the RTC with the 7-Seg display. Basicly the RTC runs fine with sample sketch on this forum but when I test it with my code the clock gives correct times for about 3-4minutes when accessed every 4 seconds then for the next 3-4minutes it produces a fixed rubbish value. These alternations repeats regularly. I know that the sketch is running Ok because my code flashes the semi-colon on the 7 Seg very second and is visible. I have tried this with three different samples of This RTC with the same result. It would seem to me to be a timing problem in accessing the RTC. Would this rubbish occur if the RTC is changing its registers at the time it is accessed.??


Sun Nov 16, 2014 8:00 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
I believe the device has additional buffers that effectively take a snapshot of the time and date when you initiate a read so that there is no chance of the time changing whilst it is being read. You'd also see this when using the example sketch. Going back the the example sketch is a good first step as it helps to rule out the possibility of a bad connection etc. I don't why it would be on a 3-4 minute cycle but there is probably a clue hiding in that.

If possible can you try to cut out any unnecessary code to see if it fixes the problem. Even cutting out the seven segment display code if necessary and outputting the date time to the serial port instead. If this fixes it you can then start adding your additional code back to see where it breaks. Alternatively if your code is based on the example sketch you can just start with that again and cut and past your code a bit at a time into it.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Tue Nov 18, 2014 10:38 am
Profile

Joined: Tue Oct 13, 2015 12:52 pm
Posts: 3
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
Hello

I'm using an Arduino Mega with the DS1302 RTC module. I'm uploading the exact same code as in the first post, but my RTC does not give me the correct time back.
This is the code again:
Code:
/* FILE:    ARD_1302_RTC_Example_Sketch_HCMODU0035
   DATE:    03/09/13
   VERSION: 0.1
   
REVISIONS:

20/09/13 Created version 0.1

This is an example of how to use the Hobby Components 1302 Real Time Clock
module (HCMODU0035). This example uses the RTC library written by Henning Karlsen
(http://www.henningkarlsen.com/electronics/). This example sketch demonstrates
how to read and write to the RTC module. To connect the module to your Arduino
please see the following pinout:

PINOUT:

MODULE    ARDUINO
GND       GND             
VCC       +5V             
SCK       D4
I/O       D3
RST(CS)   D2


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */

/* Define the DIO pins used for the RTC module */
#define SCK_PIN 4
#define IO_PIN 3
#define RST_PIN 2

/* Include the DS1302 library */
#include <DS1302.h>

/* Initialise the DS1302 library */
DS1302 rtc(RST_PIN, IO_PIN, SCK_PIN);

void setup()
{
  /* Clear the 1302's halt flag */
  rtc.halt(false);
  /* And disable write protection */
  rtc.writeProtect(false);
   /* Set the time and date to 16:30 on the 3rd of September 2013 */
  rtc.setDOW(MONDAY);
  rtc.setTime(16,30,0);
  rtc.setDate(21,11,2015);
 
  /* Initialise the serial port */
  Serial.begin(9600);
}

/* Main program */
void loop()
{
 
  /* Read the time and date once every second */
  while(1)
  {
    Serial.print("It is ");
    Serial.print(rtc.getDOWStr());
    Serial.print(" ");
    Serial.print(rtc.getDateStr());
    Serial.print(" ");
    Serial.print("and the time is: ");
    Serial.println(rtc.getTimeStr());

    /* Wait before reading again */
    delay (1000);
  }
}


And my readout says: It is Monday 21.01.2018 and the time is: 00:05:40
So my date and time are not correct. What can be the issue here?

Thanks in advance!


Sat Nov 21, 2015 10:43 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 35 posts ]  Go to page Previous  1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD