RTC Library using LSE

User avatar
ahull
Posts: 1528
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: RTC Library using LSE

Post by ahull » Mon Oct 26, 2015 10:01 am

j-zero wrote:Hello,

thanks for all the answers. The crystals I tried to use didn't work. I just desolders one from an DS1307 RTC module which I used with an Arduino and it worked immediately. Those are 12.5pF crytals and I attached them with 18pF caps to ground. So it seems not that important.
Interestingly the crystals that didn't work on the Maple Mini clone are working on the DS1307 modules.

Thanks for help

j-zero
I thought the crystal was the most likely source of the issue. They are relatively delicate devices, and might suffer/fail if overheated while de-soldering or re-soldering.

The values of those caps, *may* affect the accuracy of the crystal, other than that, they are not particularly critical. As stated before, the accuracy of the oscillator depends to a large degree also on the type of crystal used (and obviously the quality control of the manufacturer). You can also tweak things within certain limits, with the RTC calibration registers.

For the sort of accuracy that is acceptable in a hobby project, somewhere between zero and 20pf will probably allow most watch type crystal to oscillate. If you know spec. of the crystal however, you can make a more educated choice.
- Andy Hull -

ag123
Posts: 663
Joined: Thu Jul 21, 2016 4:24 pm

Re: RTC Library using LSE

Post by ag123 » Tue May 02, 2017 11:53 pm

this is a very old thread, i go one big round googling on the internet and eventually end up here :lol:
yup, i'm also looking to use those 'cheap china' 32768 hz crystals and run into stm's onerous declaration that

page 13 section 2.2 LSE OSC clock
http://www.st.com/content/ccc/resource/ ... 164185.pdf
“External clock” figure: To avoid exceeding the maximum value of CL1 and CL2 (15 pF) it is strongly recommended to use a resonator with a load capacitance CL≤ 7 pF. Never use a resonator with a load capacitance of 12.5 pF
then i run into yet another article (in chinese) in which this person describes his encounter with a crystal that *don't oscillate*
http://www.eeworld.com.cn/mcu/article_2 ... 25498.html
the google translate is accordingly here:
https://translate.google.com/translate? ... edit-text=

the fun parts of the comments are like
STM32 RTC crystal often can not afford to start the problem, which is already "industry consensus". The The Many people in a variety of electronic forums to help similar to "seeking expert guidance! RTC crystal can not afford to do vibration," the problem, and the answer can be summarized as "the master cannot help you" :lol:

More conspiracy theorists made a ridiculous explanation - STM32 RTC crystal can not afford to ST and crystal manufacturers collusion deliberately engage in out, the purpose is to improve a crystal oscillator manufacturers high-end crystal sales.

Recently made a few boards also used the STM32 RTC, before and after the two versions made a total of about 6, fortunately, did not encounter the crystal can not vibrate the phenomenon. And I used a 3 cents a common crystal, did not use the legendary low-load high-precision crystal. Later in another piece of experimental nature of the board for the first time encountered a crystal that does not oscillates which makes me aware of the seriousness of this problem.

From the above phenomenon, I think the biggest effect on the RTC crystal oscillator should be the PCB wiring. But when the problem is usually PCB has been done, and even have done hundreds of pieces, it is too late to turn back. So we are more concerned about the problem seems to be "how to remedy" the. Search online, you will find the world is so beautiful! Everyone's experience and advice are not the same, or even the opposite! This phenomenon tells us that, in addition to PCB wiring, the biggest effect on the crystal vibration does not seem to be electrical parameters, but another factor can not be ignored - workmanship!

Various contradictory experiences also tell us that the cause of the crystal can not be vibrated is varied, but also because of "people" are different. Perhaps we can not find an absolutely effective experience to solve the headache problem of the STM32 RTC crystal in one fell swoop, but we can find some clues from the various experiences and provide some help for finding out the solution that suits your own board And tips.

If the crystal can not start, especially if you have used the legendary Epson 6pF crystal or not, maybe you should try to arrange the following aspects of the combination, find the board for you, more likely to start the way.

The following list of factors that may affect the RTC crystal oscillator
1. Crystal brand and load capacitance We seem to know that you want to use 6pF crystal, but I found that in fact 12.5pF can also be used. We all said that KDS Japan's original good, my 3 cents that made the domestic crystal looks like nothing big problem.

2. Crystal external matching capacitor Some people say that 6pF crystal with 6pF capacitor. But the empirical formula that the capacitor should be the value of the crystal itself is twice the load capacitance, 6pF crystal should be equipped with 10pF matching capacitor, of course, 12.5pF should be equipped with 20pF or 22pF capacitance ~ capacitance does not match may cause crystal Can not stand vibration Even more amazing is that it was pointed out that removing the external matching capacitor will make the crystal vibrate! This seems nothing to make sense, but on my board, there is only this program is feasible!

3. Crystal in parallel with the feedback resistor crystal can be connected in parallel with a high resistance of the resistance, it is said that it is easier to start the vibration. The The The resistance of some resistance that is 1MΩ, it was said to be 5MΩ, it was also said that 10MΩ ,,, of course, some people can not say that this resistor can be connected in parallel, but not vibration

4. XTALout to the crystal series resistance This approach is the official application note pointed out, and gives the resistance of the formula. The need for this resistance is also different opinions, there are two contradictory argument, that must have this resistance, or not vibration. There is a saying that can not have this resistance, or not vibration. The The From the official application notes, the main role of this resistor is to protect the crystal, to prevent crystal vibration. It seems that this resistance does not seem to affect the main factors of crystal vibration, and even may make the crystal more difficult to start.

5. Crystal shell of the ground is not necessary to say it. The The Crystal shell is a metal, do the packaging can be made when the pad of mechanical pad and floating, can also be made into electrical pads, and then connected to the GND. This argument is also controversial, it was said that the shell must be grounded, some people say that after the ground but not vibration.

6. Improve the power quality of the Vbat pin This argument is justified, because the RTC part is powered by Vbat. Some people say that Vbat pin on the power quality requirements are relatively high, if the larger ripple may affect the crystal vibration. Some people say that they need some noise, encourage the crystal to produce positive feedback to smooth the vibration (I said Oh). The The But in any case, to improve the quality of power for everyone is a good thing ~

7. The environment around the crystal It was pointed out that the circuit around the RTC crystal should be carefully cleaned, or even sealed with epoxy resin. This argument has been some people's support, it seems there is a considerable number of factual basis.

8. Reduce the time of heating when the crystal welding Some people think that long-term heating crystal oscillator will have an impact on the crystal itself, but not completely damage the crystal, so that the crystal is not easy to start vibration. The The I have not verified this argument, personally expressed doubts.

9. Welding the amount of solder this kind of feeling even more do not fly, but really someone in the crystal pin on the point of the solder crystal can be more vibration. In principle, the addition of solder does change the parasitic parameters between the crystal and the PCB, but I feel the impact is minimal. The The It may have been wandering in the edge of the threshold, and this approach will play a little role.

10. Use *active crystal
Personally think that this is once and for all can not solve the problem of vibration can not afford the only way! Some people on the STM32 RTC crystal vibration is not easy to start the reason to do an explanation that, for low power consumption considerations, STM32 crystal drive power is relatively low, the so-called "good drum without heavy hammer", some poor crystal need more High drive power, so it is not easy to start vibration. I think that this explanation is justified. The use of active crystal does not exist the problem of driving power, if the problem is indeed due to the driving power caused by the use of active crystal no doubt can completely solve the problem. And now the Internet has not seen that the active crystal can not afford to help. But active crystal is usually more expensive, even more expensive than an external RTC chip. As for the choice of this issue, it is necessary to see you see their own ideas.
it would seem that the onerous specs by ST may be to try to 'play it safe', e.g. use those ultra thin, high precision elaborate state-of-the-art featherweight crystals that vibrates more easily (perhaps those may be the 6pf ones?)

according to wikipedia
https://en.wikipedia.org/wiki/Crystal_oscillator
you have high quality 'tuning fork' precision cut crystals possibly with *gold electrodes* sealed in *vacuum*, perhaps which looks like this
https://en.wikipedia.org/wiki/File:Insi ... ngfork.jpg

then you have possibly the 'cheap china' version that maybe looks like this (and forget about vacuum, maybe it's just air in there enclosed in a can - this could make a huge difference in the Q factor)
https://en.wikipedia.org/wiki/File:Insi ... leType.jpg
^^^ it would apparently seem that such a flat fat piece of crystal may be much harder to vibrate that that sophisticated 'tuning fork' state-of-the-art crystal. And even then the workmanship for each piece is not yet accounted for (e.g. one piece may work while the others don't !)

my thoughts are, i'm going to try the 3c flat fat cheap crystal first hand until the options run out, e.g. try the different pieces till one which works, if u are lucky may be they just works (vibrates/oscillates). i.e. an expensive crystal offers little assurance that it'd after all work
:lol:
Last edited by ag123 on Wed May 03, 2017 6:47 am, edited 3 times in total.

ag123
Posts: 663
Joined: Thu Jul 21, 2016 4:24 pm

Re: RTC Library using LSE

Post by ag123 » Wed May 03, 2017 12:09 am

the expensive crystals e.g. perhaps from japan? are possibly those high precision elaborate 'tuning fork' stuff (maybe with gold electrodes) and sealed in a vacuum. but there's that additional likelihood that the expensive crystals are individually tested before it reaches you. my guess is all that efforts is too expensive to built into a 3 cents crystal :lol:

as it turns out sophisticated crystals are nothing short of being at the forefront of technology
this programmable crystal from epson seiko only started production in 2016
http://global.epson.com/newsroom/2016/n ... 60316.html

User avatar
ahull
Posts: 1528
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: RTC Library using LSE

Post by ahull » Wed May 03, 2017 9:40 am

With crystals, as with most things, you get what you pay for, and if you pay next to nothing, then you can expect that quality control will be minimal.

That said, I've used a bunch of different crystals, mainly the cheapest if the cheap twenty for a dollar unbranded Chinese ones, and even a couple salvage from old junk items and not yet found one that didn't work. Whether grounding the can of the device will have any effect (good or bad) depend on the construction of the device, and for that you would either need to check the datasheet, or in the case of the cheapo ones which are unlikely to have any meaningful datasheet, try it and see.

When you get 100 for $3.40, or 3.4 cents each then you might expect them to be lower quality than the Epson ones at 54 cents each.

If I were building for production, rather than messing around for my own amusement, and wanted repeatable, accurate frequency results, I would go for a known source branded device, and pay the extra to avoid production headaches and customer returns. :? Having said that, if I want a precise time source, I wouldn't base it on a 32kHz crystal, I would opt for GPS or NTP.

ST's datasheet is correct in the sense that if you want the best possible results, then you should follow their guidelines and stump up the cost of a quality device, however in this quality is optional world, you don't have to follow that advice. :lol:
- Andy Hull -

User avatar
Pito
Posts: 1245
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: RTC Library using LSE

Post by Pito » Wed May 03, 2017 10:05 am

Basically it does not matter what kind of 32kHz resonator you use - it matters how you tune the frequency exactly.
The difference 12.5pF vs. 6pF mostly affects the frequency (because the oscillator inside the chip assumes a specific capacity of the resonator). These ceramic fork 32kHz resonators are made such they have the temperature coef zero around wrist temperature.
In each case you have to tune - the best way is to use a gimmick capacitor (about 3-5mm of twisted 0.2mm magnet wire) at the input side of the oscillator against the ground (wired in parallel to the ceramic capacitor). By selecting the right ceramic cap and cutting off the gimmick wire (by tenths of mm) you can tune the frequency precisely.
1cm of gimmick cap is about 10pF.
1pF makes a difference of seconds/month.
The shorter the gimmick cap the faster the clock.
Gimmick cap.JPG
Gimmick cap.JPG (16.06 KiB) Viewed 266 times
Not to scale!
:)
Last edited by Pito on Wed May 03, 2017 10:42 am, edited 3 times in total.
Pukao Hats Cleaning Services Ltd.

ag123
Posts: 663
Joined: Thu Jul 21, 2016 4:24 pm

Re: RTC Library using LSE

Post by ag123 » Wed May 03, 2017 10:19 am

+1 for this hack & +1 for ahull's comments :D
i'd think other than accuracy my guess is that for other practical reasons (e.g. no connectivity etc, time sync may be difficult) as well as for frequency stability/sensitivity say to battery voltages declining, crystals may still be a necessary solution

i'd think one of the 'headaches' is to have a crystal that *doesn't oscillate* let alone accuracy and maybe a cheap fat crystal encased in air (not vacuum) would have a hard time starting up and need higher pf load cap & driving currents etc just to make it oscillate
presumably the 6pf 'legendary' Epson ones pretty much oscillate with 'feather weight' excitation with its much better construction :lol:

found another link about those 32k 12.5pf crystals usage for RTC
http://www.e-devices.ricoh.co.jp/en/pro ... 25pf-e.pdf
but it is still all about tuning the accuracy, doesn't really fix the crystal doesn't oscillate problem :lol:

User avatar
ahull
Posts: 1528
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: RTC Library using LSE

Post by ahull » Wed May 03, 2017 12:47 pm

ag123 wrote:+1 for this hack & +1 for ahull's comments :D
i'd think other than accuracy my guess is that for other practical reasons (e.g. no connectivity etc, time sync may be difficult) as well as for frequency stability/sensitivity say to battery voltages declining, crystals may still be a necessary solution

i'd think one of the 'headaches' is to have a crystal that *doesn't oscillate* let alone accuracy and maybe a cheap fat crystal encased in air (not vacuum) would have a hard time starting up and need higher pf load cap & driving currents etc just to make it oscillate
presumably the 6pf 'legendary' Epson ones pretty much oscillate with 'feather weight' excitation with its much better construction :lol:

found another link about those 32k 12.5pf crystals usage for RTC
http://www.e-devices.ricoh.co.jp/en/pro ... 25pf-e.pdf
but it is still all about tuning the accuracy, doesn't really fix the crystal doesn't oscillate problem :lol:
I suspect the "doesn't oscillate" problem will only reliably be fixed by using a different, marginally better made crystal, so perhaps the 3.5 cents each one with the rudimentary data sheet in Chinglish rather then the 3.4 cents each ones with the obvious cosmetic defects, and the dirt and dust from being "recovered" from the Shenzhen electronics market's waste bins. :twisted:
- Andy Hull -

ag123
Posts: 663
Joined: Thu Jul 21, 2016 4:24 pm

Re: RTC Library using LSE

Post by ag123 » Wed May 03, 2017 2:06 pm

lol, the trouble with internet these days is the picture is always perfect, u'd only get to see the dirt and dust and maybe the fleas when it arrives :lol:

oh btw, these days the 'top tier' premium oscillators/resonators manufacturers has gone so far ahead of the competition

i've been searching and looking at the pictures looking for those 'tin cans' for a sign that they at least put a legitimate crystal
http://www.ebay.com/itm/Mini-core-board ... 2309828654
i can't see any 'tin cans' on this ^^^ board and only see 'black oscillator' modules, initially i'm thinking they must be cheapo ceramic resonators (e.g. PZT)

only later after a lot of googling that i see something similar to the 'black oscillator' modules
http://www5.epsondevice.com/en/products ... 030jf.html
^^^
initially i couldn't figure out what's all that difference in making the crystals black?
only today did i scroll down on the Seiko Epson product web only to see a complete block diagram of an oscillator, the crystals, the caps, the whole pierce oscillator electronics + output fet is embedded in that 1 'black oscillator' module, the output is pure square wave & u'd only need to feed that to the oscillator in pin on the mcu
but then there are also literal crystal units made into 'black oscillator' module
http://www5.epsondevice.com/en/products ... mc306.html
the 'legendary' 6pf epson 'black crystal' resonators, it is hardly surprising they cost perhaps 20c - 50c each on ebay
http://www.ebay.com/sch/i.html?_from=R4 ... 06&_sop=15

it is no longer possible to tell looking at it if that resonator module is simply a crystal or a complete oscillator module or something else, i'm truly outdated, but my guess is with these premium resonators, u'd get as accurate a crystal RTC as u'd (ever) get :lol:

the other of epson seiko resonator products are here
http://www5.epsondevice.com/en/products/
the other one i run into during my google searches is NDK
http://www.ndk.com/en/products/index.html

User avatar
ddrown
Posts: 128
Joined: Sat Jan 09, 2016 4:49 am

Re: RTC Library using LSE

Post by ddrown » Wed May 03, 2017 6:28 pm

I've been experimenting with a LSE and I have some data:

Image

At the peak you can see it's around 78.8ppm off (around 7 seconds per day day drift).

After setting the RTC's calibration, I'm getting around 70ms per day (around 0.8ppm)

Image

More data: https://blog.dan.drown.org/tcxo-rtc-hats-initial-data/
ahull wrote:Having said that, if I want a precise time source, I wouldn't base it on a 32kHz crystal, I would opt for GPS or NTP
I agree, GPS and NTP would both be better if they're an option.

ag123
Posts: 663
Joined: Thu Jul 21, 2016 4:24 pm

Re: RTC Library using LSE

Post by ag123 » Wed May 03, 2017 7:03 pm

+10 to ddrown
thanks much for sharing the charts, incredible precision of the measurements! :D

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest