View previous topic :: View next topic |
Author |
Message |
JamesW
Joined: 23 Apr 2007 Posts: 91 Location: Rochester, England
|
RTC on PIC 24FJ64GA306 drifting |
Posted: Mon Dec 19, 2016 12:38 pm |
|
|
Hi folks,
Very quick question - I'm running the internal RTC on a PIC24FJ64GA306 and it's drifting badly. I set the time at 1pm and it is now running 50 minutes slow (@ 7pm)
I'm running it on a bog standard watch crystal (uk.farnell.com part 1652573 )
With a couple of 15pF caps across it - it stops completely, but by removing them it does run - albeit slowly.
Can anyone offer any pointers - the datasheet doesn't give any concrete values to use, and I'm not sure if I'm able to tune/trim it in code.
Thanks in advance.
James |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon Dec 19, 2016 1:00 pm |
|
|
slow... I'd say too much cap.... also check PCB. It MUST be CLEAN, use qtip and alcohol to clean ANY solder residue.
I'd have thought Microchip would specify xtal/cap specs 'somewhere' in teh 500-600 pages though.....
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Dec 19, 2016 2:27 pm |
|
|
Layout and the crystal caps are big issues. The one time I had to implement a RTC I managed to get a clock accuracy of about +/- 3 seconds over a weekend, or about 1 second per day with nearby circuitry active/running. With that circuitry off and the RTC operating from a backup battery I got about +/- 2 seconds per week. ....At room temperature.
It was one of those instances of ehhh, good enough. |
|
|
JamesW
Joined: 23 Apr 2007 Posts: 91 Location: Rochester, England
|
|
Posted: Tue Dec 20, 2016 6:34 am |
|
|
Thanks guys,
The problem appears to be a lot better - albeit I wouldn't say it is solved.
I've fitted a different crystal, and ended up with 33pF rather than 22pF caps. With 22pF the clock still wouldn't run.
It's been on now for 3 hours and has lost about 4 seconds. (Which is a definite improvement over the 30 minutes it would have been previously.
I will order in a crystal with and ESR of 50K, and see if this makes things even better.
James |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Dec 20, 2016 7:03 am |
|
|
I went through the same 'exercise',got very frustrated and ended up using a discrete RTC chip/battery combination ( DS1307). While it's a few pennies more than xtal/caps it works very,very well. Also has a bit of backedup RAM and 1HZ interrupt.
Perhaps an option, at least look into the 'specs and space' for it.
Jay |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Tue Dec 20, 2016 7:55 am |
|
|
Are you using the low power or high power mode? High power mode would be preferred for better stability and accuracy.
Are you using the I/O pin adjacent to the SOSC pins? Any switching on this pin can inject noise into the clock.
It can also at times help to add a series resistor into the oscillator circuit. |
|
|
JamesW
Joined: 23 Apr 2007 Posts: 91 Location: Rochester, England
|
|
Posted: Tue Dec 20, 2016 8:37 am |
|
|
That is a very interesting question. How do I know what mode the oscillator is running in?
I currently have
|
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Tue Dec 20, 2016 9:53 am |
|
|
Section 9.5.2 of DS39996F discussed CW3<9:8> determining operation and power mode.
Section 9.5.2 of DS39996G has the low power section omitted and only defines one bit CW3<8>
It appears I was looking at an older version data sheet... |
|
|
JamesW
Joined: 23 Apr 2007 Posts: 91 Location: Rochester, England
|
|
Posted: Tue Dec 20, 2016 12:55 pm |
|
|
Ordered one of these 2064057 from Farnell.
Allegedly it's 50K ohm - so will try it tomorrow and see what happens.
After 8 hours of settings - its about 30 seconds behind.
Thanks for all the help
James |
|
|
|