DS 1302 - Gaining Time
SEL
Posts: 80
I have bread boarded the DS 1302 chip with the recommended crystal from Parallax.
I am using DS1302_Full Object based on Daniel Robert's DS 1302 Object. The last revision on this object was Mar 28 2010 to fix a bug that caused the seconds to be reset in the config method. I am out putting, to a LCD display, the date and time.
The Problem: The chip is gaining time. ( about 10 seconds in 12 Hrs. )
On the pin layout connection to the Propeller I followed the schematic from DS1302_Full Object.
Does anyone know why the chip is gaining time? I have the crystal standing straight up. Do I need to bend it over away from the Chip? I have the crystal plugged in next to the x1 and x0 connections.
My bread board platform is the Propeller Demo Board.
Any advise would be appreciated!
I am using DS1302_Full Object based on Daniel Robert's DS 1302 Object. The last revision on this object was Mar 28 2010 to fix a bug that caused the seconds to be reset in the config method. I am out putting, to a LCD display, the date and time.
The Problem: The chip is gaining time. ( about 10 seconds in 12 Hrs. )
On the pin layout connection to the Propeller I followed the schematic from DS1302_Full Object.
Does anyone know why the chip is gaining time? I have the crystal standing straight up. Do I need to bend it over away from the Chip? I have the crystal plugged in next to the x1 and x0 connections.
My bread board platform is the Propeller Demo Board.
Any advise would be appreciated!
Comments
Just to ask the question, what are you using for a time reference when you compare? Hopefully something like this:
http://tycho.usno.navy.mil/simpletime.html
I ordered a 1 farad supercap today. I will connect that to Vcc2 when it arrives
Since I asked for help I've created a new cog for the ReadTime and readDate methods. I display the date and time using an LCD.
Thanks for helping. I look forward to your report later.
The GetDateTime method runs in it's own cod.
Here is the code:
PUB GetDateTime
rtc.readTime( @hour, @minute, @second ) 'read time from DS1302
rtc.readDate( @day, @month, @year, @dow ) 'read date from DS1302
Lcd.gotoxy(1,0)
Lcd.str(tempDOW)
Lcd.str(string(": "))
Lcd.decx(month,2)
Lcd.str(string("-"))
Lcd.decx(day,2)
Lcd.str(string("-"))
Lcd.decx(year,2)
Lcd.gotoxy(0,1)
Lcd.str(string("Time: "))
Lcd.decx(hour,2)
Lcd.str(string(":"))
Lcd.decx(minute,2)
Lcd.str(string(":"))
Lcd.decx(second,2)
waitcnt( clkfreq + cnt )
if (hour == 00 and minute == 0) or tempDow < 1
tempDOW := GetDow(dow)
PRI GetDOW(__dow)
case __dow
1:
return @_dow[noparse][[/noparse]0]
2:
return @_dow
3:
return @_dow[noparse][[/noparse]8]
4:
return @_dow[noparse][[/noparse]16]
5:
return @_dow[noparse][[/noparse]32]
6:
return @_dow[noparse][[/noparse]64]
7:
return @_dow[noparse][[/noparse]128]
other:
return @NA
DAT
_dow byte "Sun",0,"Mon",0,"Tue",0,"Wed",0,"Thu",0,"Fri",0,"Sat",0,"UKN",0
NA byte "N/A",0
As you can see I am new to spin. I know there has to be betters ways, but one has to start somewhere.
It sounds like you got a crystal with the wrong load capacitance. Parallax even received some wrong units once and this is in bulk, so even if it came from us it may be the wrong load capacitance. It must be 6pF or you will gain / lose time depending on yours.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
I just received the crystal from Parallax, I believe, about a week ago.
If I can't get the timing to behave like it should I'll call and see if there is something I am doing wrong.
I have taken the chip (ds1302 ) and mounted it on the Propeller Professional Development Board. I will run it for a while and see if anything changes for the better.
Maybe we have to replace the crystal?
Oh, this may be important. I had pin 8 floating before. I have grounded it. I am waiting for a super cap ( 1 Farad ) to arrive in a few days.
Could Pin 8 floating have caused the crystal time gain?
Thanks!
SEL
Most likely you simply got the wrong crystal. I'm not sure if we purged our stock on these or not to get rid of the mix-up. I think there were like 1500+ crystals last time I checked. The other possibility, although difficult to test is the added capacitance of running this from the bread board. To solve this some people have soldered the crystal directly to the pins on the DS1302. This is not something I recommend if you're not comfortable doing it. A little too much heat and the crystal (and possibly the DS1302) could be damaged. A known good crystal can be gotten from Digi-Key as part number SER3205-ND. If you're still having the same issue after that then it is simply the bread board causing the issue. Dallas/Maxim has a AppNote that defines the proper layout and ground routing to ensure the crystal stays within its specifications. Remember temperature can also cause problems. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
Good practice to use Crystal's on Breadboard are to CUT 2 pins from one Machine-pins IC holder and stuck in breadboard AND XTal in it.
It not help to have smaller Capacitance BUT give good connection that give reliable working IC's oscillator.
As many inaccurate frequencies on Breadboard come from BAD connection rather as from little differences in capacitance.
Regards
Christoffer J
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
It would seem that BR has been able to use the Prop Demo Board and make the crystal work.
I will backup and start over. Every failure is a good learning experience.
My lack of programming experience in this area is the limiting factor, it would seem.
Thanks again to ALL!
PS: Special thank you to Chris Savage!
Parallax Website and .PDF file for the 32.768 crystal shows a load Cap. of 12.5 cl. I just received 100 from Mouser with these spec., I want to make sure of this before I start setting up my kits. I have not tested any of these parts this time.
Please let me know.
Thanks
Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
I am trying another object. I was using DS1302_Full. I will now use DS1302.
If the chip still will not keep proper time I will call Parallax and request they send another crystal.
As Chris Savage said: I might have gone bad crystal.
SEL
Sapieha, yes, that is why my focus has been on the crystal. I too have used the breadboard and with solid connections have not experienced issue, however the time I did the crystal turned out to be the wrong spec, and I expect that is what is the case here. But if the Parallax crystal is 12.5pF then it won't work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
I will get with Parallax and request a new crystal. I received this crystal from Parallax about a week ago.
when I ordered the DS1302 there was a link on that page to the crystal. It was supposed be rated at 6pf.
Of course, I could have just gotten the right crystal that was defective.
Many thanks to you all.
Chris, I know we all feel good knowing that you are looking out for we newbees!!
SEL
P.S.: Chris, last year ( 2/2009 ) you said on this forum that you were looking at the DS3234. That chip would solve the crystal problem.
How far did you get with your investigation? I am just in the bread board stage and would change if you had an object for this chip!
page 5 of the datasheet below under CLOCK ACCURACY ... "External circuit noise coupled into the oscillator circuit may result in the clock running fast." ... do you have a decoupling capacitor across the power supply to the DS1302?
With the wrong crystal (i.e. more load capacitance) my intuition would lead me to believe that the clock speed would be slower. Because this does not seem to be the case, I would start focusing on potential noise issues in the immediate environment of the DS1302.
Reference DataSheet:
pdfserv.maxim-ic.com/en/ds/DS1302.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thanks for the info and advice.
I have a bread board setup at the moment.
After your response I took a closer look and found I had a wire looping over the crystal. This might induce some emf that would effect the crystal.
I do not seem to have any situation that the app note makes reference to, except as stated above.
BR, was able to use a Propeller Demo Board and has no problem with the crystal! This lead me down the path of maybe, if the over the crystal wire is not the problem, that I may need to replace the crystal.
But as you say: 'the crystal would be slower'.
Have you done any coding for the DS3234? Chris S. was going to look into this in Feb of last year.
Thank you very much.
SEL
Fast Clocks - The following are the most common scenarios that cause a crystal-based RTC to run fast.
Slow Clocks - The following are the most common scenarios that cause a crystal-based RTC to run slow.
Stray capacitance. Stray capacitance between the crystal pins and/or to ground can slow an RTC down. Therefore, care must be taken when designing the PC board layout to ensure the stray capacitance is kept to a minimum.
Temperature. The further the operating temperature is from the crystal turnover temperature, the slower the crystal oscillates. See Figures 3 and 4.
Clock Does Not Run - The following are the most common scenarios that cause a RTC to not run.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Post Edited (Chris Savage (Parallax)) : 7/8/2010 9:21:44 PM GMT
"But as you say: 'the crystal would be slower'." - I said that intuitively it would make me think that the crystal would run slower.
let me ask you this, Are you using the solderless bread-board with the crystal (i.e. sharing the same pins with the bread board) ... If so, and if a higher capacitance causes the DS1302 to run faster, then THAT is the culprit. The solderless bread board contributes a considerable amount of parasitic capacitance between pins, this being the case, it would cause your DS1302 to run faster.
"Have you done any coding for the DS3234?" - I personally have not
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 7/8/2010 9:28:12 PM GMT
Thank you so much for taking the time to explain so much to me. I now that this takes a great amount of energy over the course of a day!
I have looked at the reference material that you stated. Of course, not being an electrical engineer it takes time to adapt to reading data sheets.
It is easy to miss or dismiss what you do not understand.
Have you mad progress on the DS3234 chip?
With respect,
Stan
I installed a decoupling cap, 0.1ufd, on the power supply side and now the DS1302 is running slower.
This supports what Chris S. said below that the wrong crystal would cause the clock to run slower. It has lost 15 seconds in about 24 hrs.
Before the gain was about 40 seconds in 24 hours.
Of course, this is just one 24 period, but it has always gained time. The decoupling cap must be the difference.
The crystal I ordered, about two weeks ago, from Parallax was rated with CL of 6pfs.
I have been in touch with Tech Support and they have told me that Chris is testing a new batch of crystals and will have the results soon.
I hope these helps.
SEL