Design of a 1MHz phase detector circuit - Page 1
Forum section: electronics / rf-microwave

author: snoozy
author_rank: Contributor
timestamp: October 15, 2020, 03:35:45 pm
content: Hey guys and girls,I try to design a circuit that can detect the phase difference in a oscillating circuit. In the final application there will be an inductance that is variable (L2). The circuit should give out a PWM signal depending on the change of the inductance of L2.What I did is creating a 1 MHz clapp oszillator that stimulates the oscillator consisting of C4,C7,C8,C9 and L2.I give that on two comperators and than on an XOR.In the simulation it works, but I think it is not perfect and there will be problems with the real circuit.The problems I see now:1. The voltage at the oszillator is very low, because of the voltage devider R6 and L2/C4. A high amplifing is necessary (U3,U4).2. The slew rate of U2 and U5 might not be high enogh.3. I'm not sure about, which op-amps and what XOR to use4. There is probably a better circuit for this job, that I couldn't find in my books. Phase detector ICs are two expensive in my case.5. The clapp oszillator might need optimazation, too.Thaks for helping me out and kicking me in the right direction.

author: Yansi
author_rank: Super Contributor
timestamp: October 15, 2020, 03:52:22 pm
content: Since when is a HC4046 or equivalent an expensive IC?

author: snoozy
author_rank: Contributor
timestamp: October 15, 2020, 04:10:41 pm
content: true, I checked on mouser before and found IC in the range of 8 €.I will have a look at this oneEdit: I had a look and the HC4046 could replace / is an XOR.I still need to prepare the signals to TTL level, which left me again with my problems 1,2,4 and 5

author: Yansi
author_rank: Super Contributor
timestamp: October 15, 2020, 05:22:45 pm
content: Read the datasheet again, carefully.There are several phase detectors available and you do not need TTL levels.//EDIT: Added what you have likely missed and is easy to overlook.

author: snoozy
author_rank: Contributor
timestamp: October 17, 2020, 01:19:27 pm
content: Thanks for the tipp. I might come back to the IC, it seems to be available for LTspice, but needs a bit of effort to include it in the simulation (at least for me).I changed the circuit a bit, to get higher voltage at the oscillator (sensor circuit).Now I want to compare the sensor circuit C4 and L2 with the Clapp oszillator.But now I have problems to get the simulation running. It is super slow and there seems to be something wrong (the log says: Direct Newton iteration failed to find .op point. (Use ".option noopiter" to skip.)).It would be great, if somebody could have a look. The problems started, when I added the comparators.EDIT: I tried to add the 74HC4046 to my circuit from the LTSpicePlus library. It works on its own, but as soon as I combine my circuit with it I get this Error:Fatal Error: Analysis: Time step too small; initial timepoint: trouble with u1:dzslewp-instance d:u1:zslewpI don't know, but this drives me crazy

author: Yansi
author_rank: Super Contributor
timestamp: October 17, 2020, 03:19:17 pm
content: Why don't you breadboard it? It is a simple 10-piece circuit and you would get some real world "simulation". That way you would also easily find your 6 uF - 3.8 nH craziness would not be even remotely possible to do. (4nH is the inductance of about 4 mm (1/8th of an inch) of wire).ADA4981 is not a comparator to begin with. Also, in real world, those 5x inverting amplifiers it would not really work well at 1 MHz, due to the rather large impedances used. Downsize them at least 10 times. (1k, 5k6). ... again, breadboard it and test it! Block by block. Sims won't tell you everything.Also, U4 and U5 is missing a path for input bias current to flow (at their inverting input). You can't just capacitively couple into an opamp input. The node is high impedance, sure, but its bias current (however small it is) must still flow somewhere. (note your R11 for U1, same way you need one for U4, U5. So for example remove C8 and add an resistor for U4 inverting input).Sims can be very confusing for beginners due to giving false results. Sims are as good as are their input data. Breadboarding is I'd say still the preferred method to learn the real stuff.

author: snoozy
author_rank: Contributor
timestamp: October 17, 2020, 04:33:09 pm
content: Thanks a lot for helping. I don't have the parts yet and I can't order so often. Therefore I simulate and try to get the concept working.The 3 nF inductance is a 2 winding high current coil actually. Probably not the best choise, but is given by the task right now. But that is probably something that needs to be changed to a range of 10uH to 50uH as I saw in other applications.I had some troubles to find an Op amp in the list of available ones in LTspice. I will try to find one with a high slew rate later.I changed the resistor size and added a path for the bias current. The simulation is still not really working (very slow). I tried to bypass the couple C's with a 1Meg resistor, but it doesn't help. There must be a numeric problem.So, I could order some parts to figure out how to get it working, but I also need the simulation for analysis reasons later. :-/The task says to compare simulations with the real circuit.Well I keed trying for now.

author: Yansi
author_rank: Super Contributor
timestamp: October 17, 2020, 05:37:52 pm
content: Well, another obvious issue you have there is trying to drive a 6uF load at 1MHz. As an exercise, calculate the required current to do so, for example at any sensible amplitude (say 100 mV across it). Not to mention, that opamps do not like capacitive loading, unless special precautions taken.

author: coppercone2
author_rank: Super Contributor
timestamp: October 17, 2020, 07:38:15 pm
content: I have breadboard a phase detector out of transistors to a high frequency, if I recall when you swept the frequency it worked to 10+MHz. The waveforms start to look bad but it does work. Don't be too scared of the breadboard here. Make the wires neat and optimize it for length. This was a discrete XOR based one IIRC, but it was more then 5 years ago.. Still tells you something though because if XOR IC expanded to transistors all over a breadboard worked to 10MHz (limits of equipment), breadboards are not that bad. I mean it looked nasty but you can figure out what it was doing despite all the ringing. But I did fold the wires nicely and trim them down a bit and lifted everything off the board to rewire it when I saw the thing I made was not really positioned the best.I also got good performance on a 16bit SAR adc on a breadboard with alot of precision op amps and stuff. You don't need to go strait to a prototype PCB alot of the time, or even use solder, thankfully, for the first step. But you do need a breadboard that is not fucked up from putting TO220 parts in it (they are the biggest breadboard killers I know because it almost feels right to put one in there).I also do wonder if spraying a breadboard down with deoxit is a good idea, I used them before deoxit became an affordable commodity for me. Now I don't want to use the breadboards I have because I messed them up being lazy with TO220 and they have problems.The other problem you might have is cheap resistors that have leads which are too thin, they will trick you into thinking you have signal rate problems but infact its just crappy connections. And be careful to wipe the leads down with alcohol if you remove them from glue-paper strip packaging, it soils the breadboard. You kind of need fine scotch brite also if you use old components.Actually I am curious enough to maybe try to put a old breadboard into the ultrasonic cleaner with clean water and see how much gunk comes out of it lol. 10 year old breadboard should say it all.1 trap I see in your testing is the coils, if you wind them yourself you need to make sure the wire you leave touching the breadboard is the right diameter and stiff enough, you might need to solder it to a PCB with proper 'pins' on it.

author: bob91343
author_rank: Super Contributor
timestamp: October 17, 2020, 10:13:22 pm
content: It takes a lot of nerve and faith to specify an inductance to five figures. And the batch of parallel capacitors implies very close tolerances as well.All well and good theoretically but totally impractical. And with so much gain, the oscillator frequency stability will most certainly make the detector fly through its window.What is the purpose of this circuit?

author: coppercone2
author_rank: Super Contributor
timestamp: October 17, 2020, 11:00:54 pm
content: I think you would need an air capacitor trim bank to get that kind of resolution

author: snoozy
author_rank: Contributor
timestamp: October 18, 2020, 05:58:18 am
content: Thanks guys for your words. I will go to everything in detail.The circuit should be for inductive distance measurement. There are different coils, that were chosen by a group that worked before on the project. As well as the basic idea of the circuit.Actually a change of the inductance should lead to a phase change and this should be detected and transformed into a 0...10V signal.As I mentioned before, I need a point to start. If I don't know what components and what circuit could work, I can't order them for trying on a breadboard. I would prefer to have at least a concept that makes sense in the simulations, than create a protoype PCB and test. These PCBs are cheap today and I can use SMD components, that will be in the final application, too.Or, I could solder it together on these other kind of breadboards for soldering. Thats what I usually do.But anyway. I could make a list of components and order them, to do the breadboard. I will try that today.@Yansi current seems to be super high: Xc = 1 / (2*pi*f*C) = 1 / (2*pi*1MHz*6uF) = 0,027 OhmI = 100 mV / 0,027 Ohm = 3,7 AAs you maybe see, I'm a bit lost trying to find a working and realistic concept for this task. My electronic experience comes more from the digital world of microcontrollers. But I try my best to understand and solve the problems.I would start over with a total new concept, if there is any more popular, or easy and stable for a task like that. I saw also, that some people use a analog switch driven by a microcontroller to create a rectangle to drive the oszillator. But this should be a circuit without uC.

author: snoozy
author_rank: Contributor
timestamp: October 18, 2020, 05:48:24 pm
content: I just wanted to give a little update:The problem is called Bias currents, as mentioned before. By adding a resistor between the inputs, I could get the simulation running again!Also, by using a propper op amp, I could get the comparator function running!Thanks so muchNext step is the XOR, and then I will try to order parts to proceed.

author: snoozy
author_rank: Contributor
timestamp: October 25, 2020, 04:37:27 pm
content: Hey guys,I added now an XOR and changed the OP's.I hope that make sense, I will order the parts and try.

author: Yansi
author_rank: Super Contributor
timestamp: October 25, 2020, 05:11:52 pm
content: Why is the HC4046 still not used?Last time:Your sensor coil certainly can not have 5 nH of inductance!That is a nonsense.

author: snoozy
author_rank: Contributor
timestamp: October 25, 2020, 07:49:46 pm
content: Sorry for the monolg, but maybe someone will be interested.I will add a HC4046 to the test board, too.I finally got it working in the simulations, too. The trick was to set the tick at "Skip initial operating point solution" for the simulation command.Now I'm questioning myself if I'm using the IC correct. I don't need the VCO, so the connection is quite simple

author: Yansi
author_rank: Super Contributor
timestamp: October 25, 2020, 08:42:36 pm
content: Again, what are those two amps for there? What is up with the 10 pF coupling caps? Their impedance at 1 MHz is still quite large. Make them much bigger! The HC4046 should be able to pickup quite small voltages. If the voltage on the detector is too small to work, then it probably is too small and unlikely to even work in reality.Why wouldn't you use the VCO? Use it instead of your LC Clapp oscillator.Or even better, use your sensor coil in an oscillator and follow its frequency with the PLL to obtain a DC voltage proportional to the frequency.But still, you need to make sure to understand well, that your sensor coil does NOT have 5 nH inductance. That is about an equivalent of couple mm of wire. Sorry, not happening. Even the self-inductance of your 6 uF will be order of magnitude larger. You are even not counting the ESR of the cap (and the coil).As I've said: Simulation is as good as are its input data. In this case, I still see significant flaws in the simulation. Hence why I always try to explain, that people with less experience should not use simulators, but a soldering iron instead. Only that way you can get some realistic view of the world and then match it in your simulation. Only if the simulation matches real behavior of the circuit, is the simulation good enough. Otherwise, it lets you believe in false results.//EVEN better, you could just measure the frequency of the sense coil oscillator with a microcontroller, linearize the value using a suitable function/table/whatever and output required voltage using a DAC//

author: snoozy
author_rank: Contributor
timestamp: October 27, 2020, 02:12:05 pm
content: Those two amps supposed to adjust the voltage of the sensor circuit in case the HC4046 can not detect the voltage. It will be possible to bridge them.Ah well, it's true the 10 pF at 1 Mhz have a high impedance (ca. 160 kOhm). I could change them to 1 µF maybe.I was thinking, I will need the Clapp for driving the sensor circuit. Since I have the Clapp, I don't need the VCO."Or even better, use your sensor coil in an oscillator and follow its frequency with the PLL to obtain a DC voltage proportional to the frequency."That would be a different concept. I mean, probably it is more easy to detect the frequency change, than the phase difference.What kind of oszillator would you suggest? Could I stay with my Clapp or would a OP amp driven one better?Yes, I understand about the low inductance and relevance of the capacitance. I will change that, promiseIt is just still there, because I need to search for other inductances for the test circuit. I was thinking about creating them with some wire and measure them with an LCR.My next step will be ordering parts and the PCB. will create it in a way, that I can do changes as on a bread board. I have quite experience with that.My worries for now is only, that nothing will work without a working concept in the simulations. Therefore I'm asking for help here.I have a scope, solder iron and so on. I should be able to test and improve.I like the idea about using a µC. It would be helpful to do linearization or calibration, too. For now, this is an analog project. I could discuss if a µC could be used.I saw a concept, where the Oszillation was driven and controlled by the µC, too. The used an analog switch to drive the sensor coil.For now I'm thinking about your suggestion, to create an oszillator that uses the sensor coil and give the signal to the HC4046. Seems to be a way with low number of components. Mostly less complicated concepts are the best.

author: snoozy
author_rank: Contributor
timestamp: October 28, 2020, 09:05:02 pm
content: I'm about to calculate the values for operating the 4046. actually I found out, that there is the CD4046, HC4046 and HCT4046.I have a spice model for the CD4046 and it is running at 15 V which is nice.But the maximum frequency is 1.2 MHz and I wanted to run the circuit at 1 MHz.I could reduce the frequency a bit, so I'm not running it at the limits or switch to the more advanced HCT4046.What do you think, can I just use the CD4046 or should I go for the HC or HCT?

author: Kleinstein
author_rank: Super Contributor
timestamp: October 29, 2020, 08:52:56 am
content: The HC version of the 4046 is quite a bit faster, but it also needs a lower voltage. The HCT version is only for a quite narrow supply range and rarely needed.I would prefer the HC4046 over the need for 15 V to get enough speed from the CD4046.The whole concept is not clear. If it is about measuring the sensor inductance there are two possible concepts:One is having a fixed frequency and measure the phase shift from a LC (or similar) combination - so not oscillator at the sensor, but a separate oscillator (likely crystal based) and amplifier for the sensor signal.The other concept would be to build an oscillator with the sensor coil and than measure the frequency - no phase detector needed in this case. Frequency measurement would than be more like a thing for a µC.It makes not sense to make a PCB before the concept is OK and the central part of the circuit works in the simulation. The first tests can be done on a bread board or maybe dead bug in a piece of full copper board.

author: snoozy
author_rank: Contributor
timestamp: October 29, 2020, 10:06:55 am
content: Thanks for your reply Kleinstein.I will go for the HC4046 I think. I mean I have the 15 V supply per definition, but it is no problem to create a 5 V supply for it.There are the two concepts. My first concept is as you described the measurement of the phase shift. You can see my simulations. It is working in principle, but it needs the XOR and some OP amps. Maybe it is not the best solution.Concept two is to put the sensor coil into the oszillator and measure the frequency. This seems to be a better soultion. I'm about to create a concept for that solution. Therefore I need to calculate the C's and R's of the HC4046 and think about the sensor coil.I think I will need to add a fixed coil to the sensor coil, to keep the C in my clapp oszillator small. But that's something to think about.The PCB will be my breadboard. For me it doesn't make such a difference if I have it on a PCB where I can cut tracks and wire them up again or do everything on a breadboard (which I don't have anyway).So my plan is to do the concept in LTspice, create the PCB, test it and create the final circuit.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 29, 2020, 10:30:51 am
content: If using the oscillator and phase shift way, there is not need to use the discrete made LC oscillator, a ready made crystal oscillator is much easier and more stable. The driving side would also need some series element, like a relatively small capacitor. A 0 ohms resistor is not a good option there.In the simulation would should also include some loss terms for the sensor and maybe caps, the damping of the resonance can make a big difference.With the sensor coil as part of the oscillator, there is not need for the 4046. Just the oscillator, likely some amplification and than a comparator (or schmidt-trigger).

author: snoozy
author_rank: Contributor
timestamp: October 29, 2020, 11:28:23 am
content: The crystal oscillator was excluded, because of it's mechanical weakness.Sorry, but I don't understand, what you mean with "some series element" and the 0 Ohm resistor.Also, what do you mean with "loss terms" for the sensor and where do you want to put caps to damp the resonance.For second version with the coil in the oszillator, how excactly should that work. With a Schmitt trigger you want to turn the sinus of the oszillator in a rectangular signal and integrate it?

author: Kleinstein
author_rank: Super Contributor
timestamp: October 29, 2020, 11:48:43 am
content: Real inductors and capacitors have parasitic loss terms, like a series resistance. One should include estimated values to get a realistic picture. Otherwise the resonance would be extreme and not realistic. It could be extra resistors to dampen the resonance, not extra caps.The resistor R6 is the series element to the DUT. In one simulation it was set to 0 ohms, which would not be good. A capacitor instead of R6 would be likely better.The inductance to measure looks like really small, so it is a difficult task. The capacitor in parallel may have comparable to larger parasitic inductance. With a small inductance keep in mind that the inductance is a property of the whole current loop, not really a property of the components. In theory 10 nH in series with 10 nH would be 20 nH, but in real word the loop changes and the inductors interact, so 10+10 may end up as 18 or 25 depending on the details.If it is about measuring a small inductance, if may be better to do it the way LCR meters do: impose some current and than measure the AC voltage drop with a kind of LockIn amplifier. So measure the AC components phase sensitive. This is a little similar to the phase detector, but also taking the amplitude of the signal into account.With some 1 mA at 160 kHz (so that 2*pi*f = 1000000 s-1) one would get 1 mV per µH.

author: snoozy
author_rank: Contributor
timestamp: October 29, 2020, 01:05:29 pm
content: Now I understand what you mean about the losses. I actually put series restance and parallel capacitance in the L. You cannot see that on the picture, since it is included in the L. The C is ideal right now.The very small L is some general problem. For the real circuit, I will try to reach a higher L in the range of 5-50 µH.The application will be a inductive distance measurement device. The best inductance (value and construction) should be chosen.Adding two inductors in series may leed to new problems... But this might be not such a big problem for the real circuit, since the absolute value is not that important, only the change.I never heart about the lock in amplifiers before. That seems to be interesting. As far as I know, these LCR-Meter are quite slow. In may case it needs to detect changes of distance in a kHz range.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 29, 2020, 01:50:55 pm
content: The Lockin amplifiers are often used relatively slow, but the principle of phase sensitive detection can also be used with a higher BW at the output. It only gets tricky if the output frequency approaches the modulation frequency. Requiring the measurement fast us also an important information for the other methods - all have to fight with more noise bandwidth. Frequency counters are also usually slow - though the newer one can work fast too.A larger inductance would make things a little simpler, as it would be a more manageable impedance and thus more voltage and thus less amplification needed. I kind of doubt one would reach 50 µH. Too many turns also lower the self resonance frequency due to more parasitic capacitance.If the change in inductance is relatively large I would not use a fixed frequency and phase detection, as the change in resonanc frequency can be larger than the resonance width. So this would be a rather nonlinear curve and amplitude would also change. One could in principle still have a phase locked loop - adjust the oscillator frequency to get a fixed phase shift. This would be kind of a special oscillator only using the DUTs phase shift, not the amplitude part.

author: snoozy
author_rank: Contributor
timestamp: November 28, 2020, 08:57:22 am
content: Hey guys, I'm back with my "breadboard"I put different circuits and options on this board to play around.One is an Colpitts oscillator and and the Clapp oscillator as discussed before.The Colpitts is working quite nice. The Clapp does not start.I was measuring the voltages around my BC847 and it seems to be everything correct.Maybe some of you have an idea what I could try to get it running.I will attach the schematic and PCB (ground is flooded, but not displayed)EDIT: While wrinting the post, I found the mistake! The connection between -15V and C303/C304 is missing. I added a wire and now it's working, tooThe good news is, that it one of the concepts seems to work:The sensor coil is in the Collpitts Oszillator and causes a frequency shift. This shift is detected by the 74HC4046 and gives me a DC Voltage depending on the distance. A few calaculations of to rise the sensitivity are necessaray here.

author: Yansi
author_rank: Super Contributor
timestamp: November 28, 2020, 09:39:32 am
content: How many times did I say that 10pF coupling cap is not enough for 1MHz?What is its impedance at 1MHz?//And the circuit does not look right anyway.Some random Clapp osc image from the interwebz. See the difference?//EDIT2: By the small coupling caps, you have tons of signal attenuation. And C302 also has an impedance of 15ohm, make it 100nF instead, to get the most gain available from the gain stage. In the end, there may be too little gain to oscillate, even after you wire it right.

author: snoozy
author_rank: Contributor
timestamp: November 28, 2020, 03:07:01 pm
content: Aight, shame on me. Somehow the 10 pF went in again. I will change them by 100 nF. They will have then around 1 Ohm Impedance.Sorry, if you oversaw my EDIT in the post. I found the mistake in the circuit and it was working after adding a wire.I will try changing C302 and see how it might improve.Thanks a lot for your check.Right now I was calculating the values for R1, R2 and C1 of the HC4046.I tried to get an offset, so I have the biggest sensitivity.I'm following the steps of the NXP datasheet:https://assets.nexperia.com/documents/data-sheet/74HC_HCT4046A.pdffmax = 2.06 MHzf0 = 1.96 MHzfmin = 1.86 MHzfoff = f0 - 1.6 x fl = 1.96 MHz - 1.6 x 100 kHz = 1.8 MHzFrom Figure 33 I got R1C1 = 23 x 10^-6From Fig. 32 I got C1 = 440 pF and R2 = 10 kOhmR1 = R1xC1 / C1 = 23x10^-6 / 440 pF = 63 KOhmSo I haveR1 = 63 kOhm (I used 62k)R2 = 10 KOhmC1 = 440 pF (I stacked a 180 pF and a 270 pF)I was expecting to see a change of the voltage at R410/C425 between 1 V and 4 V.The voltage is 2.5 V (Vdd/2) and goes up about to 2.6 V when I rise the freuqency.I added a picture after the coupling capacitor at PIN 14 (signal in) of the 4046.You can see the signal changing, after adding the aluminum close to the coil.I'm coupling in the signal via 10 nF... May needs to be bigger, too.

author: snoozy
author_rank: Contributor
timestamp: November 29, 2020, 04:45:17 pm
content: EDIT:I did some more tests and I think I should get the VCO of the 4046 running as expected first. Therefore I removed the input filter and added a adjustable 5 V supply. Now I'm able to give a input signal and change the frequency. Actually the frequency changes in the range of 3.6 MHz and 4 MHz. Kind of the double I need.I will go to the steps I did to calcualte R1, R2 and C1.First I got the product R1C1 from figure 33 (green line):2fl = fmax-fmin = 2.06 MHz - 1.86 MHz = 200 kHzR1C1 = 37x10^-6foff = f0 - 1.6 x fl = 1.96 MHz - 1.6 x 100 kHz = 1.8 MHzFrom Fig. 32 I gotC1 = 450 pFandR2 = 10 kOhm(fat red line)R1= R1xC1 / C1 = 37x10^-6 / 450 pF =82 kOhm

author: snoozy
author_rank: Contributor
timestamp: December 05, 2020, 07:04:58 am
content: Just want to tell, that I got it working. I got new capacitors and now I have it in the right range.

author: snoozy
author_rank: Contributor
timestamp: February 03, 2021, 05:10:07 pm
content: Just want to keep you guys updated and ask a question.I could get now a nice sensitivity and did a measurement that shows me the solution with the 4046 is a good way.Thanks for that.I it true, that I always need to reach the basic frequency of the VCO to log it on my input signal?The beaviour of my prototype looks like that:First the output voltage keeps at around 2.5 V doesn't matter the frequency of my input signal.After changing the input signal the PLL locks and the output signal changes as expected.Is that a normal behaviour?

author: Yansi
author_rank: Super Contributor
timestamp: February 03, 2021, 05:15:04 pm
content: Post the schematic. Dunno how you use the 4046, but PLL's purpose is usually what you describe: To match two signals: in both frequency and phase.

author: snoozy
author_rank: Contributor
timestamp: February 11, 2021, 07:00:36 pm
content: The changing signal is coming from OSZ_IN. The VCO is going directly in the comparator. (Ignore the rest of the schematic)