feeding the clock of a microcontroller from the output of a TCXO or GPSDO - Page 1
Forum section: electronics / projects

author: djacobow
author_rank: Super Contributor
timestamp: March 15, 2021, 02:26:35 am
content: A friend would like to feed the input clock of a microcontroller directly from the output of a high-quality oscillator. This should allow him to build some very interesting timing applications. I think we understand some of the implications of doing this, like that we probably want to disable the PLL to avoid the jitter it would introduce.One of the sources available to us is a GPSDO that puts out a (suspected 50 ohm) 0.85V 10 MHz sinewave (1.7V p-p) centered on ground.The uC input pin ideally requires a 3.3V signal centered on Vcc/2. It can also be a sinewave. I believe that in external clock mode the controller just puts it through a schmitt trigger.We'd like to come up with a circuit to condition the GPSO signal to 3.3V for the uC.I built the following in LTspice using 2n3904's and it appeared to "work", and in fact, when I built it on a breadboard it did "work" except for a fair amount of distortion (probably doesn't matter in this app) and I had to tweak the resistor values. This is the effort of someone who was never good at analog and hasn't improved much in the last 25 years.What is the "right" way to do this? Opamps seem to slow generally and probably overkill. What I basically need is a little bit of voltage gain, and positive clamping, not much more. The circuit pictured does not clamp, but instead just has an offset built in. But we could also just do a simple gain stage AC coupled to a passive clamp.Bonus question: The 2.2k load was totally a guess. I could not really find much on what the impedance of a microcontroller clock pin would look like at 10 MHz. It certainly was not in the stm32gxx datasheet I was looking at.

author: Mecanix
author_rank: Frequent Contributor
timestamp: March 15, 2021, 02:54:18 am
content: Innovative idea! I wouldn't know how to answer the question(s) but have to let you know (in case you didn't know) that some of the STM32 parts does have pretty spectacular built-in DAC already. Coupled with a half-decent NDK crystal they will output pre-scaled (or not) sines and pretty much anything else you need it to generate (square/saw/cats&dogs/etc).

author: SilverSolder
author_rank: Super Contributor
timestamp: March 15, 2021, 03:15:49 am
content: I think a comparator might be what we are looking for here, to generate a good square from a sine?

author: djacobow
author_rank: Super Contributor
timestamp: March 15, 2021, 03:35:57 am
content: Quote from: SilverSolder on March 15, 2021, 03:15:49 amPerhaps. That's actually where we started, but simple experiments generated extreme generator. It probably didn't help that the input signal is negative-going. So a DC restorer first would help, but that didn't work too well either.Maybe we need a better comparator.But actually, the stm32g oscin pin is just fine with a sinusoid input. That is, after all, what it has to deal with when it is driving its own xtal.

author: AlienRelics
author_rank: Unknown
timestamp: March 15, 2021, 05:29:14 am
content: Capacitor followed by a shottky clamping diode, fed to the input of a schmidt trigger inverter. Or probably even just a 4049 inverter. The capacitor and clamping diode shift the voltage.In fact, I think instead I'd use a capacitor followed by a resistor divider, to shift the signal without losing a diode drop. Fed into a 4049 or a 4093 if the 4049 doesn't provide a clean enough signal. A 4049 is basically a linear amplifier with a TON of gain that should be driven into saturation with a 1.7V signal.Power it with 3.3V. Done.

author: DaJMasta
author_rank: Super Contributor
timestamp: March 15, 2021, 05:50:59 am
content: Is this a genuine clock pin, or crystal pins? If it's a crystal, you just need to get the oscillator signal to the right level, AC couple and allow the chip to DC bias as needed (or do it with resistors if that's required), and filter it down to be just a sinewave, ideally. That means either some bandpass filter simulation or some trial and error, then you apply the filtered output to both crystal pins.If you're actually driving a clock pin, something like a comparator is fine... but so would be a schmitt trigger (with appropriate DC bias on its input) or just a very high gain amplifier. A way to sort of square up a sine wave is just amplify it like crazy and let it clip to the rail and ground.

author: djacobow
author_rank: Super Contributor
timestamp: March 15, 2021, 06:07:45 am
content: Thanks guys, I am moving in this direction.Here's a version essentially doing the decouple than bias, then "digify" approach. In this case, I'm using an LT1719 comparator. There's a long time constant RC filter for one of the comparator inputs, the other just gets the biased signal.Comparator could be replaced with a schmitt trigger only and I can lose the RC midpoint detector.My friend tried something like this and got a ton of jitter, but I can't think of why he should have. I think it might have been a setup problem.

author: bob91343
author_rank: Super Contributor
timestamp: March 15, 2021, 06:13:25 am
content: The problem with all these approaches is the lack of precision. Slight variations in supply voltage or temperature or input amplitude or shape or noise will cause phase noise. This may or may not be significant depending on the system requirements. Even the slight shift of resistance of the components due to temperature will cause corresponding drifts in performance.The real question is, how accurate must it be? Certainly working from GPS makes for great long term stability, but how about the short term?

author: fourfathom
author_rank: Super Contributor
timestamp: March 15, 2021, 06:19:22 am
content: Since you don't need a square wave into the uC, you might consider a common-base amplifier. I don't know if that 0.85V output of the GPSDO is loaded or unloaded, so I assumed unloaded. The input Z of this common-base amp is about 113 Ohms (100 Ohms plus the Re of the transistor) so if you need to load the clock with 50 Ohms just add a shunt resistor. Adjust the gain with the 100 Ohm input resistor, adjust the duty-cycle with the base bias resistors. This doesn't swing full power supply, but should hit the levels you need for reliable operation. That 5pF cap at the output represents input capacitance of the uC pin -- just a guess.One caveat: This amplifier duty-cycle and general waveform is sensitive to input amplitude. If your input level is known then it's not a bad solution.

author: MIS42N
author_rank: Frequent Contributor
timestamp: March 15, 2021, 09:32:26 am
content: I don't know what GPS module you are using, but some of them synthesize their output from an internal oscillator that is not synchronised to the output - hence not always a 50/50 duty cycle and has jitter. I have made two GPSDOs that use the controlled OCXO as the clock source for the uP. One has an HCMOS square wave output and I coupled this to the uP with a 22pF capacitor, nothing else. It is still a work in progress, I posted some info herehttps://www.eevblog.com/forum/projects/budget-gpsdo-a-work-in-progress/msg3481886/#msg3481886. The other had an output into 50 ohm, somewhat similar to what you are dealing with. I just used a spare gate on a 74LS04 to generate a square wave, a resistor chain to bias the input to about 1V with an average 2.4V output (about 50/50). The uP did not like a lop sided duty cycle (like 70/30). I posted the circuit herehttps://www.eevblog.com/forum/projects/lars-diy-gpsdo-with-arduino-and-1ns-resolution-tic/msg3354018/#msg3354018

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: March 15, 2021, 02:32:46 pm
content: The LTC6957 is meant for such applications.The rise time of a sine wave at 10 MHz is going to be poor, and one can expect there to be jitter added as a result. That said, jitter added by the uC's clock tree is likely going to dominate any such effects.

author: mino-fm
author_rank: Regular Contributor
timestamp: March 15, 2021, 02:56:40 pm
content: A simple inverter will do all you need.For STM32Fxxx (e.g.) configure OSC-pins for ext. crystal/resonator so you don't need an inverter.

author: fourfathom
author_rank: Super Contributor
timestamp: March 15, 2021, 03:13:16 pm
content: The TLV3501 is a good comparator, probably with more phase noise than the LTC6957, but less expensive. It has reasonable input offset and a useful amount of hysteresis. Just running the GPSDO into a 3.3V Schmitt trigger buffer such as the NL27WZ17 (AC-coupled, resistor divider bias) will work with strong inputs, but the input hysteresis is too large to work with attenuated clocks that you get if (for example) you use a resistive splitter to distribute your reference clocks.

author: djacobow
author_rank: Super Contributor
timestamp: March 15, 2021, 05:23:29 pm
content: I think what you guys may be missing is that the swing of the oscillator source is not really high enough to drive the oscin pin of a controller supplied with 3.3v.If I feed it into an inverter powered with 3.3, then the 0.85 positive volts or so is not a reliable 1, and the -0.85 volts is going to be outside the electrical specs of the inverter.If I use a passive dc restorer (ie, capacitor and diode), then I can maybe 1.7 V, which is also not a reliable cmos 1 for a 3.3v system, especially if there is noise.Hence, the original approach to use an amplifier to get a 0-3.3v sine that can be fed into oscin configured to work with analog sine.An alternate approach is to use a comparator or other digitizing device to get a 0-3.3v cmos digital signal to feed into oscin configured to take an external digital clock.Quote from: mino-fm on March 15, 2021, 02:56:40 pm

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: March 15, 2021, 06:06:37 pm
content: Quote from: djacobow on March 15, 2021, 05:23:29 pmThe LTC6957 will accept between 0.2 and 2 Vpp (0.8Vpp typical), and has a self-biasing AC-coupled input. The -3 and -4 versions have CMOS outputs suitable to drive the uC clock input.

author: floobydust
author_rank: Super Contributor
timestamp: March 15, 2021, 06:22:52 pm
content: I ended up using a SN74LVC1G14 SOT-23 Schmitt triggerpost #11in relevant thread:https://www.eevblog.com/forum/projects/level-translate-the-output-of-a-tcxo-crystal-oscillator-module/One issue is to not load down (AC or DC) the oscillator module and degrade it's performance. The model I had was 3.0V power and has an internal O/P coupling capacitor.

author: djacobow
author_rank: Super Contributor
timestamp: March 15, 2021, 07:50:11 pm
content: Quote from: radar_macgyver on March 15, 2021, 06:06:37 pmThanks! This looks very promising!

author: nctnico
author_rank: Super Contributor
timestamp: March 15, 2021, 10:08:23 pm
content: LTC6957 is a good choice to convert a since wave to a square wave. But starting with an OCXO which has a square wave output is easier. The uBlox LEA-M8F GPS receiver module can discipline an external OCXO (using several different frequencies) for example so you can maximise the clock rate of the microcontroller without needing the internal PLL.

author: eb4eqa
author_rank: Regular Contributor
timestamp: March 16, 2021, 11:24:34 am
content: Probably too quick & dirty for some people but a simple 74HC86 worked for me inhttps://rbarrios.com/projects/10kgpsdo/Roberto EB4EQA

author: David Hess
author_rank: Super Contributor
timestamp: March 16, 2021, 01:09:22 pm
content: If the source is a sine wave, then I would use a comparator configured as a data slicer to force the output to a 50% duty cycle. With a square wave source, I would use a limiting amplifier like that found in a frequency counter. Either can be made with a differential pair.

author: djacobow
author_rank: Super Contributor
timestamp: March 16, 2021, 04:22:39 pm
content: Quote from: David Hess on March 16, 2021, 01:09:22 pmI had to Google what a data slicer, but I believe that is precisely what I had posted as my second try: input is split in two, one is strong low-pass filtered and then both are fed to a comparator.

author: David Hess
author_rank: Super Contributor
timestamp: March 16, 2021, 04:39:15 pm
content: Quote from: djacobow on March 16, 2021, 04:22:39 pmYes, what you posted is known as a data slicer.