In my project two arduinos are communicating with each other using xbee's. I would like to have a real-time clock in the program which has to track the time at which information is being recieved at the arduinos. Could any one guide me in doing this.
A real time clock is a piece of hardware. Do you need help choosing the right hardware?
Or, do you need help in connecting the hardware to the Arduino? Which one - the sender, the receiver, or both?
Or, do you need help with the code to set/get the time on the RTC? There are libraries that make this trivial.
For what purpose are you keeping track of the time? How are you going to store the time? For how long? What difference does the time make? What are you attempting to learn/improve by know specific times versus relative times.
It's not that we're not willing to help, but some more information would reduce the possibility of us overwhelming you with information that is only tangentially relevant.
If your question is about a RTC hardware solution
then take a look at the schematic in my NB1A datasheet.
I use the DS1337 and power it from a coincell.
I also have a software library.
I am trying to watch the time at which data has recieved and store them in a file, and by using these time values and recieved data, i would like to plot the graphs. And i wish them to run for a long time say 1-2hrs. This relates my project work to analyse the convergence of an algorithm. And one more thing i don't want to use any hardware. Can't we set a clock in the program?
Thanks for taking time in looking into my problem.
There is a Time library that you can use. The Arduino keeps track of relative time. The Time library provides a mechanism to assign an "absolute" time and date to a given relative time. You can get a new "absolute" time and date at any time. The "absolute" date will be incremented as the relative time changes.
Without external hardware to persist the "absolute" time, the "absolute" time will need to be set every time the Arduino restarts.
Once you have the "absolute" time, you can format it however you need to, and store it in the file, along with the other data. I presume you know how to do that.