Measuring phase difference with 4046B phase comparator II - Page 1
Forum section: electronics / projects

author: saint
author_rank: Contributor
timestamp: July 17, 2014, 04:32:20 pm
content: Hi, in my project i have two sin waves (few Hz to about 2kHz) that are 90 deg out of phase (TLL levels). What I need to do is determine if wave A is currently leading or trailing wave B so naturally after using LM393 I wanted to use 4046B and its Phase Comparator II output. Wave A goes to pin 14, and B to pin 3 of 4046. At pin 13 i put resistor divider (1M + 2k/2k) as suggestedherebut I'm pretty sure it should be the other way around eg. 10k + 1M/1M) so that the 1M can actually pull the output close to VCC or GND.But no matter what I do thePC2 doesn't stay an VCC/2 when Wave A & B are at VCC/2 (DC), sometimes PC2 sticks to VCC sometimes to GND and occasionally I see VCC/2 (on PC2) when generating Wave A & B.What am I doing wrong?Resistor divider used for measurments is 10k + 1M/1M.SIG (ch. 1) and COMP (ch. 2)From separate measurment, PCP (1), PC2 (2)One more thing is thatPCP is Low when SIG & COMP are VCC/2, according to the datasheet (pageit should be High. Any ideas why?Everything was tested with my Rigol oscilloscope (only 2-ch. :-() and the singnals on pin 3 & 14 are clean (not exactly 50% duty but this doesn't matter for PC2 as far as I know).Do I need to connect C1, C2, R1,R2, RS, looking at thedatasheet(page 4, fig. 2) I don'tthink I'm using any of them.What should one do with unused pins on 4046, leave them floating?

author: w2aew
author_rank: Super Contributor
timestamp: July 17, 2014, 11:08:48 pm
content: Not sure if this will be helpful, but you may want to view my video (or parts of it) that reviews PLLs in general, and uses the 4046 as the example. I discuss and demonstrate each circuit block, including the phase detectors. For my test, I simply connected the signal generator outputs (0-5V square waves) directly to the phase detector inputs. Phase Detector II starts at about 10:15 in the video:

author: moffy
author_rank: Super Contributor
timestamp: July 18, 2014, 02:22:02 am
content: Use a D type flip flop. One signal goes to the D input the other is the clock. The output HIGH or LOW will tell which signal is leading which.

author: saint
author_rank: Contributor
timestamp: July 18, 2014, 10:26:01 am
content: Quote from: moffy on July 18, 2014, 02:22:02 amThank's got the same suggestion elsewhere plus a XOR for determining if there is a lag (basilly PCP output circuit).I'd swing by a local shop a bought a few parts (CD4013B, 74LS86).I've used my sniffer. Wave A goes to input D of flip-flop, B goes to CLK.#1#2#3Any ideas how to make XOR only work on leading edge.

author: moffy
author_rank: Super Contributor
timestamp: July 20, 2014, 05:55:42 am
content: What is a PCP output circuit? Never heard of it before.

author: saint
author_rank: Contributor
timestamp: July 20, 2014, 06:00:42 am
content: Quote from: moffy on July 20, 2014, 05:55:42 amSorry my bad, I was thinking about Phase Pulse (Terminal 1) and looked at the PC1 (XOR) in the datasheet.Anyway what type of filter would get rid of this 1/4 pi low state on the XOR output?

author: mikerj
author_rank: Super Contributor
timestamp: July 20, 2014, 07:44:20 am
content: Quote from: saint on July 17, 2014, 04:32:20 pmI'm probably missing something, but that link shows a schematic with 20k +2k/2k, which someone rightly pointed out is functionally equivalent to two 42k resistors. Using a 1M resistor is going to give a very high output impedance, possibly whatever you are driving into is loading it down.

author: moffy
author_rank: Super Contributor
timestamp: July 22, 2014, 12:10:48 am
content: Could you please describe in words what you are trying to accomplish? I don't understand the final objective.

author: saint
author_rank: Contributor
timestamp: July 22, 2014, 05:31:12 am
content: Quote from: moffy on July 22, 2014, 12:10:48 am1) I have a module (doppler radar) with two outputs, let's call them A, B. They are bias at VCC/2, when the module detects a moving object A and B start outputting a sine wave proportional in amplitude to object size/distance and frequency is proportional to its speed.2) The module offsets A, B waves exactly 90 deg., if object is approaching wave A is leading if receding B is leading.3) So after passing A, B through op amps and simple comparators I get a nice clean square wave (GND or VCC) but the duty of square wave is proportional to the amplitude of the sine wave.4) Using a D flip-flop A goes to input D of flip-flop, B goes to CLK, Q tells me with one is leading.5) a XOR from A, B square waves should tell me if the A, B are actually producing any sine waves or just idle (bias at VCC/2).The problem is that gain of op amps is fixed but as the object approaches the amplitude of of A/B increases so does the duty from comparator(s). When the duty is small (<25%) the XOR produces a pair of pulses but only the first one is valid (the Q from D flip-flop is valid at that time).

author: moffy
author_rank: Super Contributor
timestamp: July 23, 2014, 12:09:15 am
content: Is the duty cycle problem when the signal is small or large, not quite sure? Could you divide both A and B by 2 and do your phase detection on that?

author: saint
author_rank: Contributor
timestamp: July 23, 2014, 05:06:20 am
content: Quote from: moffy on July 23, 2014, 12:09:15 amThe problem is that there has to be a time when both A and B are high as in 4046datasheet fig. 6so higher duty would helpQuote from: moffy on July 23, 2014, 12:09:15 amIt could but it might also produce some error as the comparator aren't perfect (extra pulses on A or B square wave).Quote from: wilfred on July 23, 2014, 02:02:27 amThanks but I'm not sure if this does give me a lead/lag information that I'm after. It just says 0V output for 90 deg, at <90 deg it'll give a negative voltage and positive for >90 deg. Won't it just give 0V on matter which wave is leading?I've also found an old National chipMM54C932/MM74C932but it looks like it's just a part of 4046 nowadays.Ok I feel like am stuck on this one. Any brilliant ideas, maybe there is a better way to get the lead/lag information? Analog gurus I'm counting on you.