Thanks it resolved one issue of date not getting populating.
What we can do for if rtc time get struck at particular time.and how we do that in code
afremont:
You need to send weekDay when you set the clock. You are not sending it, causing the following fields to get wrong data. In my first post in this thread, I have some code that will set the clock. I have also fixed my code that reads the clock. I haven't tested it yet.
tempaddr = 0x68;
Wire.beginTransmission(tempaddr);
Wire.write(0x00); // set address to 0
Wire.write(0x00); // seconds in BCD
Wire.write(0x19); // minutes in BCD
Wire.write(0x15); // hours in BCD
Wire.write(0x06); // day of week DONT FORGET THIS
Wire.write(0x15); // date
Wire.write(0x02); // month
Wire.write(0x13); // year
Wire.write(0x10); // sq wave out 1HZ
Wire.endTransmission();
for struck of date and time,i think like this way
i need function that will execute for every 1 minute. parameter it take time (hour:min:second).
for every 1 minute it check whether hour.min.sec has changed or not.
if hour.min.sec is changing
continue;
else
add 1 minute and write to RTC
how we can write in arduino platform.i dont want to use delay and miilis function.using counter how can we do that
You shouldn't have to do anything like that. When the clock is not advancing, you should see bit CH (Bit 7) set in the SECONDS register. That is the only problem I have ever encountered, and it may have been because I didn't have correct code when I accessed the clock. As Nick says, the clock should work reliably for months if not years without issue.
I just tested the code changes I made for reading the clock and my clock was only 10 seconds fast. It was last set on 15 Feb. I have modified the program to read the clock approx 30 times per second. I will let this run and see if it randomly stops advancing again. I don't expect it to since I used the same clock module on a PIC project where it ran for many months without issue.
@OP: Have you read my first reply? Did you check the voltages? DS1307 are known for striking if the power supply is not stable. I think you should check for that and correct it first and not try to tinker some pseudo solutions. The RTC should keep the time while the Arduino is not running. Theoretically you can read the time at startup and you don't need to bother with the RTC again till the next reset.
That's interesting pylon, could you tell more about what the problem is? I would think that with a backup battery, the chip should handle pretty much anything you throw at it, as far as messing with the power. Is it that it doesn't like a bunch of sharp glitches close together? Maybe just adding a big cap to the power pin to slow down the voltage changes?
I never had the problem myself but we've seen it a few times on this forum. When it happened a stabilization of the power supply solved it.
From the datasheet:
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.
A new battery gives about 3.5V so if the supply voltage drops below ca. 4.4V you might see such behavior.
Ok, well that sounds like predictable and designed in behavior even if it's not the nicest thing. I've had the CH bit get set for no apparent reason when the only code was to read from the clock chip. I know it wasn't writing arbitrary trash to the seconds register because the clock kept good time as long as it was running. Anything writing to the seconds register on a regular basis would cause horrible timekeeping so I'm pretty confident of that. I did have an error and I have changed it to see if the problem occurs again. I set the program up to read the clock about 30 times per second as that's what seemed to trigger it before.
The clock will keep running on the battery backup, but the I2C communication, which requires 4.5V to 5V, may be erratic if the power supply is erratic. The default library is known to hang if it doesn't get an interrupt it is expecting.
ya checked it properly. They are working seem properly during operation. But they get disturbed when voltage level are different
pylon: @OP: Have you read my first reply? Did you check the voltages? DS1307 are known for striking if the power supply is not stable. I think you should check for that and correct it first and not try to tinker some pseudo solutions. The RTC should keep the time while the Arduino is not running. Theoretically you can read the time at startup and you don't need to bother with the RTC again till the next reset.
Is it possible to check code whther RTC running for every 1 min,If data is varying within 1 min continue process. else write new rtc time with l minute add to previous time. How to do this
Here i have written code that execute for every predefined second, If RTC stopped working for more predefine time , it rewrite the rtc time with previous time
You are totally fixing the wrong thing here. It's like saying "oh my fuse keeps blowing, but no matter, I've got a robot installed that pulls out the blown fuse and puts in a new one".
You have to fix the problem, not put a bandage over it.
Can you able to give me the solution.How can avoid my fuse(ds1307) keep blowing. I wanna diagnostic output so that i should come to know RTC got damaged.
what is other kind of fuse(ds1307) i can use . which can take of voltage fluctuation and having internal crystal oscillator.