Analog question - single rail zero cross? - Page 1
Forum section: electronics / projects

author: Dubbie
author_rank: Unknown
timestamp: October 05, 2018, 03:14:24 am
content: Hi,I am making a device that needs to read LTC timecode into a microcontroller.It is carried as audio at ~2Khz. It's a squarish wave centered on zero. it's Manchester encoded Biphase Mark.I don't want to read it with the ADC. I'd rather condition the signal to 0-3.3V digital square waves before it hits the microcontroller.My initial circuit was a little differential opamp thing to offset and amplify the signal so it just clipped the top and bottom of my 3.3v rail.That works fine.Problem is, my test circuit worked with 200mV PP audio.I'd like it to work with everything between 200mV PP to 3V PP with no adjustmentI'm wondering if some sort of zero cross detector is what I want.Does anyone have any clever (or even not so clever) analog ideas to do this?Thanks!R

author: ajb
author_rank: Super Contributor
timestamp: October 05, 2018, 03:19:38 am
content: If you ac-couple the input and bias it to mid-rail, then wouldn't a simple comparator do the job? One side gets the input signal, the other is simply tied to mid-rail, same as the bias. Maybe a bit of hysteresis.

author: Dubbie
author_rank: Unknown
timestamp: October 05, 2018, 03:48:15 am
content: How do I bias it to mid rail if the amplitude could be different? hrmm, I've tried a few circuits, and I can't seem to precisely bias an arbitrary AC signal to exactly 1/2 rail. This seems to work. I'll build it and check it works reliably with real data.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 05, 2018, 01:37:27 pm
content: If it's Manchester encoded and thus should be DC-balanced AFAIR, you could use a bit slicer which is much less dependent on amplitude.The attached schematic should work fine under all conditions @2 kbit/s, has added input protection and is very low power (~10 µA).

author: Dubbie
author_rank: Unknown
timestamp: October 05, 2018, 04:27:17 pm
content: I like it!Hadn’t come across that circuit before. Thanks, I’ll give it a try.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 05, 2018, 04:35:57 pm
content: Here's the LTSpice file so you can check for yourself and try different comparators, although the one I chose here (LMV7271) is a good fit and draws very little power.One thing to consider with this kind of bit slicers (also called data slicers) is that they need an initial period to settle. With the values given, at 2 kHz it needs approx one period to settle - meaning the very first bit should be discarded. This is why transmitters using this kind of setup usually need "preambles" in their data frames (dummy bits).

author: Dubbie
author_rank: Unknown
timestamp: October 05, 2018, 11:43:48 pm
content: I ordered the parts. The ones you chose seemed reasonable. I don’t seem to have any schottkys lying around that I can find, so will have to wait till Monday to test.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 05, 2018, 11:59:25 pm
content: Quote from: Dubbie on October 05, 2018, 11:43:48 pmThe Schottky diodes are just there for clamping in case of overvoltage. They are not necessary to make it work, and given the series resistor, it's probably already protected enough for your application.

author: Dubbie
author_rank: Unknown
timestamp: October 06, 2018, 06:10:03 am
content: I made up a little test circuit. I was just using the app on my phone to generate the TimeCode signal. It’s amazing how much the square wave rings when you only have up to 20khz! Turns out I might be a bit optimistic getting down to 200mV. Below about 500mV PP, I get very noisy transitions, even after adding some hysteresis. Oh well, I guess 500mV is my lower bound on acceptable input levels.Besides that it works very well.

author: StillTrying
author_rank: Super Contributor
timestamp: October 06, 2018, 12:45:48 pm
content: I thinkthere's a vital component missing from SW's schem. - to keep the amp or comparator's inputs biased into their high impedance linear CM range.Minimum input for 960Hz is going to be about 80mVpp.

author: David Hess
author_rank: Super Contributor
timestamp: October 07, 2018, 02:01:39 am
content: This seems like a perfect application for a single comparator data slicer as shown. A limiting amplifier could also be used.

author: coppercone2
author_rank: Super Contributor
timestamp: October 07, 2018, 12:45:29 pm
content: You can use fast clipping circuits and elevate the sine wave so any significant signal looks like a sine wave that has the top and bottom clipped to a voltage level thats fine for your circuit so that you have a squarish wave offset by a DC voltage, the idea being that you stay outside of any nonlinear hard to recover from regions in the precision electronics and use fast electronics to condition the signal, your not worried about anything but the region near the zero cross as far as useful information, so you can blank it out. to avoid operation where some parts of the op-amp are entering saturation

author: donmr
author_rank: Regular Contributor
timestamp: October 07, 2018, 02:10:43 pm
content: Without R4 which StillTrying adds below the 2 diodes are the source/sink of current to keep their shared node at about 1/2 Vdd.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 07, 2018, 06:07:01 pm
content: Quote from: StillTrying on October 06, 2018, 12:45:48 pmIt's not vital IMO. Actually the leakage current of the Schottky diodes will be much higher than the input bias current of the comparator. Given the very low input bias current, even just a very small unbalance of the input signal should be enough (and it will never be perfectly balanced).With the added R4, the drawback is that it increases the settling time of the data slicer tremendously.Edit: apart from the biasing which shouldn't be an issue IMO, there's still something I've overlooked. Due to the AC coupling (capacitive), by not offsetting the input voltage (it will get some offset due to the leakage current of the clamping diodes but it will not be controlled and will all depend on the individual diodes and temperature...), the average value of the signal (at the '-' input of the comparator) which is the reference voltage of the comparator will be too close to ground. Even though it's a rail-to-rail comparator, it may indeed generate spurious toggling especially at lower amplitudes.So I still suggest adding a pull-up (at the R4 position as ST suggested) to offset the signal enough. It doesn't have to sit at half-VDD. So I suggest a lower offset by using a greater value for R4, which will actually improve the settling time compared to a higher offset. For instance a 470k resistor will give you an offset of approx 500 mV which seems ok to me.You may also increase R1 or C1 to lower the cutoff frequency of the averager which should also limit the spurious toggling.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 07, 2018, 06:09:04 pm
content: Quote from: Dubbie on October 06, 2018, 06:10:03 amWould be interesting to take a look at your signals. Do you have screenshots of your scope?The given comparator is pretty fast even though it's very low power, so you may improve things by filtering the input signal maybe?

author: Dubbie
author_rank: Unknown
timestamp: October 07, 2018, 11:04:52 pm
content: I'll post a pic in a bit once I am back at the bench.I was using a different comparator to test while I waited for the other to arrive.I was using a MAX9010EXT+T - still pretty fast!I think some filtering may be a good idea. I'll put the footprints in my final board layout to be safe.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 07, 2018, 11:20:46 pm
content: The MAX9010 as far as I've seen is specified for a 4.5V-5.5V single supply. Not 3.3V. It's probably going to have degraded performance in possibly unexpected ways at 3.3V. It's also much more power-hungry and probably way too fast for your application (5 ns!), which will make it too sensitive to parasitic transients IMO. Filtering could then definitely help. But really it doesn't seem like the right comparator here and again you're using it out of spec if you power it at 3.3V. So it may show some problems that you wouldn't have with a more appropriate part.As suggested, you could also try to add the pull-up we mentioned to see if it improves the low-amplitude condition.

author: Dubbie
author_rank: Unknown
timestamp: October 08, 2018, 04:26:58 am
content: I rebuilt the circuit this time on a soldered protoboard with smd components, I included the suggested 470K pullup and switched out the comparator for an LMV331 that I found lying around.This time it worked absolutely perfectly. I can go down to about 15mV PP before things fall apart. Everything above that is perfectly clean edges.Thanks very much for everyone who helped, Especially SiliconWizard. I really appreciate it. I feel like I've learnt a bunch with this little exercise.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 08, 2018, 01:35:01 pm
content: Good to hear!