Introduction to Phase Locked Loops

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Cool video, thanks for sharing! It's good to finally see your face.

A comment led me back to http://kennethfinnegan.blogspot.com

... where this made me jealous as hell: http://4.bp.blogspot.com/-gkMXEdSjXKo/TcMYi7u3OKI/AAAAAAAAA1Q/r3XN3wmB2WI/s1600/0503112240.jpg !

πŸ‘οΈŽ︎ 5 πŸ‘€οΈŽ︎ u/ModernRonin πŸ“…οΈŽ︎ Feb 16 2012 πŸ—«︎ replies

Its a nice video. Granted that i am not focusing on integrated electronics, but PLLs are in general skipped or only touched in most curricula. Even in my Integrated RF CMOS class, it was only briefly mentioned. There was a lot of focus on VCOs, but no focus on the phase-detector.

πŸ‘οΈŽ︎ 4 πŸ‘€οΈŽ︎ u/petemate πŸ“…οΈŽ︎ Feb 17 2012 πŸ—«︎ replies

Sometimes I feel like I'm the only person who cares about PLLs, it's always nice to see others appreciate these little guys.

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/typon πŸ“…οΈŽ︎ Feb 17 2012 πŸ—«︎ replies
Captions
hey this is Kenneth and today I'm going to show you kind of a basic introduction to the phase lock loop this is kind of a one of the basic circuits that you use an advanced digital and analog design and I'm going to be using for a specific example the CD 4046 which is part of the original 4000 CMOS series which is a real standard jellybean set of logic much like the 7400 series which most people will often see in many projects the phase lock loop consists of three parts you have the phase detector the low-pass filter and the voltage control oscillator the voltage controlled oscillator is probably the easiest to understand you put in a DC voltage and it puts out some frequency you raise the voltage the frequency goes up you lower the voltage the frequency goes down I'll demonstrate that Y for you in a moment what the voltage controlled oscillator does is if you feed that back into the phase detector what the phase detector does is it compares the voltage controlled oscillator to a different input frequency so the input frequency would be some sort of analog signal or something you need to recover or some sort of RF transmission and it would compare these two it would look at the frequency coming in and it would look at the frequency from the VCO and it would make some sort of judgment as to whether these two signals were in phase or if one was a higher frequency than another and it would produce an error error signal so like if they were if the this if the VCO frequency was too low or it was behind in phase the phase detector would produce a positive error voltage if the VCO was too high or ahead it would produce a low error voltage this weak fed into a low-pass filter a low pass filter is a filter that only passes low frequencies so it's like in music if you were to put standard music through a low pass filter you would only hear the bass and the low you know deep stuff we're using this is kind of a as a kind of a long-term average is we're going to look at the error signals coming out over the last few cycles and then use that to make a judgment on whether the control voltages or sending to the VCO is high too high or too low because if we get a lot of positive error signals coming from the phase detector then the our control voltage is probably too low and so the average will eventually slowly trend up and the VCO will lock on frequency when we say lock that means that when you first start it this is going to be some random value you're going to start feeding in some random frequency and the loop is going to have all sorts of errors because it's like whoa like these are completely different frequencies all right and eventually the VCO is going to be like wandering all over the place eventually once this frequency the frequency in and the frequency out or I guess the frequency out going back into the phase detector once those are the same the lot the loop will be locked and once it becomes locked it'll be much more stable and we'll be able to track the input frequency of it drifts or anything very closely all right now you kind of have to ask what is this useful for um the really simple example is you could use it as a frequency multiplier so if you were in this feedback part of the loop to put in some sort of divided by n counters like the simplest would be a divided by 2 what you would do is this frequency would be divided by 2 and then compared to the input frequency so if we feed it feed it in like 1 kilohertz here we would get some sort of error signal it would be filtered and then the voltage controlled oscillator would start making some frequency but that frequency would be divided by 2 and so if the voltage controlled oscillator was also running at 1 kilohertz it would be divided by 2 and you end up with 500 Hertz here which would be too low and so the phase detector would create a positive error voltage it would get filtered the VCO would slowly drift up to 2 kilohertz two kilohertz out but it's divided by two so go back and be one kilohertz here and so we'd be comparing one kilohertz with one kilohertz this would say hey these are in you know these are in phase and walked we would it would be slowly filtered and the VCO would be very stable running it two kilohertz this obviously has other applications I mean multiplying one kilohertz by two is you know kind of a silly example but this has all sorts of other useful examples where if you were to take something like an atomic clock is this is a rubidium frequency standard that puts out 10 kilohertz 10 megahertz sorry 10 megahertz so if you were to feed 10 megahertz in here and then have some arbitrary / n here and another / M here you can then divide these both down to some equal frequency and then multiply it out again to any frequency you wanted and the stability of the output frequency is just as good as the input frequency and so since this verb idiom standard is crazy accurate whatever frequency that you managed to synthesize from it would also be very very good so that's one example there's tons and tons of other examples but of course if anything in this video doesn't make sense I highly recommend the horowitz the art of electronics I'll link a link of this below this is where most of my information has come from and it is an incredibly good book in this and many many many many many other subjects um but yeah so let's try and shows to you live let's fire up my 1970s classic era oscilloscope and you see here we have one square wave so what I've done is I've taken one CD forty forty six and I've wired up just the voltage controlled oscillator on it with potentiometer so if I take a screwdriver I can sit here and I can change the control blow said I could change the control voltage and it changes the frequency I turn up the control voltage the frequency goes up I turn down the control voltage the frequency goes down so that is the voltage control oscillator this of course has other useful applications other than in the phase lock loop so you'll see the 4046 kind of pop up and kind of ran in little projects to kind of give you a more guttural understanding of this I'm going to take a little half watt speaker I'm going to plug it in so you hopefully now you can hear this kind of obnoxious square wave which as I shift this will raise and lower in frequency cool so that's the VCO now what I'm doing is I'm feeding that VCO in as the frequency in to another into the second CD 4046 which I have actually built as this control loop so we have a phase detector a low-pass filter a voltage controlled oscillator and then if the this voltage control oscillator feeds back and is compared to our first voltage control oscillator which you see here so that second one you will see as channel 2 so here's channel 1 here's channel 2 and you can see they are in frequency and for your listening pleasure I will give you both of them so as you can see they are at the same frequency and there are a locked phase apart this is because very using a type 1 phase detector so now let's explain what these what the two different types of phase detectors are and the advantages and disadvantages to each one so let's now talk about half the operation of this phase detector the cd40 46 happens to have both a phase detector and a voltage control oscillator but the phase detector is generally the heart the more difficult part to build of this control loop and so many phase locked loop chips will actually only have the phase detector and they'll expect you to build your own low-pass filter and voltage controlled oscillator which really isn't that hard so first the type 1 phase detected thinking about it digitally the phase the type 1 phase detector is very analogous to the exclusive-or or xor gate what the exclusive or gate does is it compares to two signals and it outputs a positive signal when they're different and a zero signal when they are the same so given an input signal up here on the top and the VCO signal down here in the middle you can see when the VCO frequency signal goes high early this is low this is high output signal goes high and so at this point it would start raising the frequency of the VCO until the input frequency an input signal goes high then they're both high and the RF signal goes low one goes low this so the VCO is now low and the input is high error signals high then the input signal finally goes low and they're both low and originals low now eventually if these two frequencies were different the width of these error signals being high and low would be different and eventually it would change the VCO frequency until it matched this frequency unfortunately the average of these error signals when they're locked has to be the correct control voltage so once you feed the red signal through low-pass filter it has to be the right signal to run the VCO at the same frequency as FN but that's not necessarily going to be halfway up our control voltage so we're running that I'm running this on five volts right now and so it's not necessarily two and a half volts so the width of the positive and negative error signals won't necessarily be 50% if we need to run the VCO at four volts of the five volts the high parts going to be 80% wide and the low part is going to be 20% because we need to take the average of this and have it end up being the right VCO control voltage this the width of these signals are a function of how out of phase these are because as you can see there it's about 90 degrees out of phase right now is because this positive edge is one quarter of a wavelength earlier than this positive edge and so right now it's 90 degrees out of phase so the average of this would be 50% but if we need to run the VCO at like 80% or 90% of the full of the power supply voltage we need this even farther out of phase so we're going to need this closer to 180 degrees out of phase where if we need to run the VCO at a lower voltage almost down to zero these need to be much more closer in phase and so depending on where you are in your VCO range the the frequencies will always be the same when the loop is locked but when the loop is locked the phase will vary from zero degrees out to 180 degrees all right so let's show you that now hopefully we'll show that too now on my oscilloscope so here's the input signal here's the output signal as you can sell it saw it kind of ramped up until it locked on to it and now if I could find my screwdriver here we go so now take my screwdriver I'm going to adjust the input frequency so you can see just as we predicted the output is leading by 90 degrees right because we're kind of we're right in the middle of our control voltage we're running about two and a half volts so now if I were to raise the frequency I thought of course it isn't gonna lock on me now all right so there's locked now if I slowly move it upwards weight is one anyways um as I turn it up you can kind of see that this positive part is getting closer to this negative part I don't know if I'm going to get it all the way to five volts without this loop unlocking on me but you can kind of see the seat see the point is as we get higher in control voltage this phase gets farther and farther until the point where we're almost completely out of phase between these two square waves now something you'll notice is as I'm running this our low-pass filter isn't very good is I'll talk about that you know once we talk about the phase converters I'll talk about that later but you can see you know every time we kick it the output phase oscillates quite a bit before it finally settles down but we'll talk about that you know later if we want to talk about phase detectors first so that was the type 1 phase detector luckily that someone at some point back in the banal history of logical engineering came up with a very creatively named type 2 phase detector the type 2 phase detector differs from the type 1 in that it doesn't look at the levels of the signals but it simply looks at the edges of the signals in the CD 4046 it happens look at the positive edges there's no reason why you couldn't look at the negative edges instead but they just chose the positive ones so what the type 2 phase detector does is it watches for these positive edges and it outputs an error signal based on whether the VCO positive edge is early or late compared to the input 1 this has all sorts of advantages because now our duty cycles don't have to be exactly 50% if we're looking at very very short pulses the type 1 phase detector would give almost continual error voltages where now we're only looking for the edge and so it doesn't matter how wide this positive and this negative part are because we're only watching for the edge in case you haven't picked up on that yet um and so what the VCF what the phase detector does is it says up here's the input positive edge and it watches for the VCO positive edge and while it's waiting here in the mill it outputs a positive error signal to try and speed the VCO up and bring its edge closer to now the trick is though once it sees this second positive edge and says ah all right we're good it doesn't go low like in the type 1 but it goes into this high impedance state where it won't change the control voltage at all and so now this in this region the VCO is going to be running at a fixed frequency until the phase detector sees another positive edge in this case it happens to see a positive edge from the input again and says up the VCOs late and it starts outputting a positive until it sees the positive edge I guess I'm kind of screwed up a diagram then almost right away since it's at 8 mm-hmm we're doing this live and then almost right away it's going to see another positive edge from the input frequency and so it's going to tart outputting a 1 again now obviously if the VCO is running at a higher frequency you would start seeing these positive edges before the input positive edges and the phase detector would start pulling it low which you know would then lower the frequency of the VCO and start putting these edges farther in the future and hopefully in phase with these positive edges now the big advantage here is when the loop is finally locked and it isn't changing the VCO control voltage these two edges are always going to be lined up and these edges are going to be lined up and there's going to be not only are they going to the same frequency there's going to be no phase difference between the two signals that frequency end and the frequency of the VCO this lack of phase difference is advantageous in the control loop because the low-pass filter is going to have some sort of phase difference to it and if we can remove this phase difference um it's much easier to make a stable loop as you just saw with the type one phase detector it was kind of hard for me to get it to lock outside of the middle frequency range the farther you went out of the center the low-pass filter and the phase detector couldn't generate the correct control voltage to lock on to it with the type 2 it's going to be much more forgiving as far as the lock range is the kind of the range of frequencies that this loop can log on to alright so let's switch from pin 2 which is the type 1 phase detector to pin 13 which is the type 2 phase detector conveniently this 4046 provides us with both so again we let my fantastically antique oscilloscope warm up if any one from like Rygel would like to sponsor my blog I will gladly take any digital four channel oscilloscope and I will put your you know every post will be sponsored by rival pretty much ever so give me a call be nice turning on our control voltage though here's the input here's the output you can see it's still oscillating quite a bit that's because of our low-pass filter but eventually when it locks you can see these positive edges this positive edge and this positive edge are perfectly lined up alright if we change the frequency again it oscillates because they have a bad low-pass filter but eventually they lock we go down in frequency they lock and positive edge positive edge all prefer off lined up so the type 2 phase detector is in many ways superior to type 1 when you're dealing with square waves like this the type 1 is much easier to implement in analog signals and sine waves and stuff so they both certainly have applications but as you can see the type 2 phase detector is in many ways very gives you much more flexibility than the type one does just to show you again I'm going to zero out the loop so we're going to short out the VCO control voltage so now it's running at zero and we're going to let it come up and relock again and as you see very very quickly it comes up and locks on to it so that's the difference between a type 1 or type 2 phase type in it just to kind of give you an idea of what it looks like instead of looking at the output were going to look at the actual phase detector so this is the output of the type 2 phase detector so ideally when the loop is locked it's going to be completely in this middle high impedance range unfortunately due to such reality inconveniences as input impedances of the VCO and leakages through the capacitor it inevitably is going to have to refill the capacitor just a little bit so there is going to be a little bit of positive voltage but so now if we were to turn down the VCO you can see that it starts putting out low voltages as well until eventually it locks on to it again and we end up again with just this small positive pulse which ideally isn't there but we need because of such inconveniences as leakage and then this line right here is while the type 2 phase detector is high impedance and so that's actually the voltage on the capacitor and so you can see that as I turn the potentiometer down this high impedance line or the voltage on the capacitor actually matches the voltage coming out of our potentiometer which is only connected to the system by the frequency fun fact this is actually a way to decode FM radio stations because if you had the FM radio station coming into this and you had your phase lock loop locked on to it the control voltage of the phase lock loop would actually be the original audio frequencies used to modulate your you know 95.7 megahertz FM radio station fun fact um so that is the what the output of the faith type - phase detector looks like where if we look at again at the type 1 phase detector which isn't going to lock on this strange of a frequency and I said if we actually looked at the type 1 phase detector so now it's locked and you can see it's positive half the time and negative half the time this is why having the low-pass filter is important because if we didn't have the low-pass filter during this time the VCO is trying to run it its highest frequency and during this time it trying to learn it run its lowest frequency which isn't what we want we want it to be running at the average of these two signals this is what the potentiometer right in the middle if we try and bend it downwards so at a lower frequency you can now see that the top portion of the phase detector is narrower than the bottom portion not not significantly in this case because I can't bend it very far out of walk oh let's see yeah so you can kind of see that this is about one two three four four and a half divisions there and that's about two and a half divisions there so we're running at about one-third of the VCO control voltage which matches the potentiometer so that's what the output of the phase detectors look like which then goes through the low-pass filter into the VCO now we're going to talk about this low-pass filter which as you can kind of see since is giving us some problems since if I sit here and kick it even when they're on the right frequency and even if I just do a real mild link or Ewing you can see that the output jitter is quite a bit even with the far superior in this case type two phase detector it still oscillates and in many frequencies it'll keep oscillating or it'll actually go completely unstable as you can see if we raise this eventually it starts oscillating so much that's not going to do it for me now I said if we go far enough it'll start awesome mmm-hmm I said if we start do this and go far enough it'll start oscillating so much that it'll actually go on completely unstable as you saw there so that is a problem that is when the phase delay between type 1 faith comparator which I switch back to and the low-pass filter goes beyond 180 degrees and the loop just can't walk we can sit here all day and it won't walk at all will be very sad but it just won't do it and that's kind of a problem so I'll I'll sketch out the schematic for your basic low-pass filter and show you how we can fix it and then I'll show you vastly improved performance so lastly let's talk about the low-pass filter so what you see here is this is about the most basic low-pass filter you can have is this is a first order RC low-pass filter so what it has it has a resistor here and a capacitor to ground and so any high frequency signals would be bypassed by this capacitor and in a DC or low signal or low frequency signals would be stored on the capacitor and output it to the VCO so this is what we've been using so far you'll notice that with a hundred kilo ohm resistor and a 10 micro farad capacitor this is a incredibly slow filter which I deliberately did so that you could that you'll be able to see it actually like you know ramping up and seen how it oscillates and kind of putting this all onto a kind of temporal scale that would be easy to demonstrate but obviously you would design a better filter that would better meet your needs as far as being able to lock on and you'd have a much wider lock range and everything with a faster filter that you know this has a time constant of like one second but as you saw with this it oscillated there's quite a bit of jitter in the phase as it tried to get closer to walk and kind of the easiest way to resolve that is you add what's called lag compensation there's lead compensation and lag lead compensation and then there's all of the proportional and proportional integral and for chanel integral differential all these there's a tremendous number of different compensators and I've taken whole classes on this and unfortunately like classes very good but the key to line compensation is you add a second resistor in series with capacitor I put in a 10k ohm and so the initial speed of the filter is essentially about the same because you have a 100 K ohm plus 10k ohm sets 110 km and the 10 micro farad capacitor so I've only slowed the first-order filter down by 10% if you would slowed it down by like an order of magnitude if you just try to add more resistance here to be as effective as this one you'd have to significantly slow it down and it would take even longer for a phase lock loop to lock but by putting this 10k ohm resistor here we've kind of put a second low-pass filter from the capacitor out you know out to the output or I got that about wrong I'm inevitably I want to get this good that they subtly long but essentially line compensation gives us a better gives us this about the same DC performance as the low-pass filter but as you get in higher frequencies it gets a kind of a better knee to it than just the 20 decibels that you get with the low-pass and so I'll show this to you right now in my cell scope I'll kind of show you the difference between the first order low-pass filter and the lag compensator so we let my oscilloscope warmup alright so again input signal up here output signal down here you can see that we're using a type 1 phase comparator and if I just kind of tweak it you can see that it oscillates tweak it again it oscillates alright so now what we're going to do is add the 10k ohm resistor in series with it kick it you can see it shifts the boy it is stable it's quite a bit more stable zero out the VCO and let it catch up again you fun fact the type 1 phase comparator can actually lock onto harmonics of it and which is little unfortunate so as you see here it locked on to the kind of the one-and-a-half the the input frequency is one and a half times the output frequency so we'll just have to break that lock for a moment as you can see it's much Stabler I'll go again with the type 1 face comparator we don't have quite the lock range that we do with the type to face and garter so you can see with this one it's very stable right if we switch back to just the low pass filter so that's it oscillating but since we can filter out that high-frequency noise better without losing our DC response by putting the lag compensator you can see now it's much much more stable all right so that was that was the low-pass filter part here obvious timp lamented it with some passive resistors and capacitors but obviously you could use op amps and gyrators and you could over design the most sophisticated low-pass filter that you could ever want to be as part of this control loop I've taken several mechanical engineering classes in control loop theory but they weren't so practical or applied so I fully diss warrant any claims I made here as far as actually getting any of the technical Apple applied details of that correct because i neva tably probably did not and so it's kind of one final last thing we're going to slow this filter down would slow so we're this is a 10 microfarad we're going to take this I believe it's a thousand and be kind of yeah I believe this is a yeah this is a thousand microfarad so we're going to slow this filter down a hundred times in order to start it grounded and so the VCO is essentially stopped because of because the output is you know the capacitor is completely discharged and so as it slowly ever so slowly is going to pick up here hopefully yeah so you can see if you got its first transition and so as you can see the output is slowly ever so slowly increasing and obviously this is a I'm seen lead slow I mean it's like a hundred second time constant filter so you would never actually design a phase lock loop with 100 second filter on it but this will very well demonstrate this kind of semi harmonic semi law the harmonic semi locks it gets is even with the type two phase comparator you'll see that every time that it reaches some round multiple of the input frequency is going to go into this kind of semi lock state and it's going to for a long time before it breaks lock on it and as it gets closer these semi locks will actually last longer with a type one phase comparator you can actually solidly lock on to harmonics but you want to be careful that when you design it that you design your filter fast enough so it doesn't block on one of these will be kind of obnoxious but yeah I thought this would kind of be just an entertaining way to end the video so please enjoy as you can you can see when these two positive edges line up it'll break the semi lock because the type 2 faith comparator watches for these edges and so the negative the positive feedback which will increase this frequency doesn't occur until the positive edges line up and so as it reaches each harmonic the music majors in the audience of which I know there are actually several will actually be able to tell you which chords each of these semi locks are because these semi locks are actually very much based on it being an octave apart or 1/5 apart or a third part and then some of the faster ones will be minor chords and this actually goes to show that you can quite possibly find a lot of useful applications for the CD 40:46 or other simpler other simple phase-locked loops and a sort of music synthesizer because this will kind of grab onto some frequency and kind of hold to it and then you can have it kind of drift away from it one direction another based on some other control frequency so this would be a real easy square square wave generator and it kind of next progression beyond your standard five of six Atari Punk synth as you can see that these lot locks now are lasting really long I think is that pot that might I think that isn't quite a walk as I think we're oh my god diminished second or something um so it'll very very slowly phase shift I don't know that might that might be the right frequency so the main problem now is it's out of phase and so again between these two positive edges it's sending a little bit of positive blip which will pull it over well that might just because of the leakage that fast rate but anyways um so that was kind of a demonstration of it starting from a complete stop and of what the phase locked loop kind of likes about the two signals being locked onto each other this is the forty forty six obviously in modern eras and people like Texas Instruments and analog have put out significantly more powerful and faster and fancier phase locked loops with programmable like fourteen bit dividers built into them and everything I will likely eventually build some sort of frequency synthesizer based on my rubidium standard for amateur radio but this has a multitude of applications so this is Kenneth showing you phase locked loops with a little bit of hopefully mostly correct control loop theory built-in enjoy
Info
Channel: Kenneth Finnegan
Views: 87,074
Rating: undefined out of 5
Keywords: PLL
Id: 0jzLDe950AY
Channel Id: undefined
Length: 38min 33sec (2313 seconds)
Published: Fri Feb 10 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.