1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Phase lock loop question

Discussion in 'General Electronics Chat' started by boro3, Nov 26, 2017.

  1. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    Hello to all,
    i have a question concerning the pll.
    i know that it is used to gernerate a stable frequency at the output of the vc0,
    like the input ist 100hz und it generates 1000hz at the output.

    but how can it be used for zero cross detection? without changing the output frequency.
    i have a 100hz sinus signal, and i want to use pll to know when it crosses zero.
    is it possible to work with an cd4046d together with a mikrocontroller for this ?
    thx
     
  2. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,624
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    What do you want the PLL to do when it detects a zero crossing?

    The CD4046 Type II digital phase comparator has zero phase shift between the leading edges of the input and output when locked.
    Is that what you want?

    I don't know what a microcontroller would do for you. :confused:
     
  3. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,763
    Likes:
    259
    Location:
    North west UK
    Or use phase comp1 and correct the 90 degree phase shift in software.
    The use of a 4046 seems a little odd for this, last time I saw a 40406 in this application it was multiplying the mains frequency by 100 and syncing it with the mains so that a processor could fire a triac at 1% power intervals.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,624
    Likes:
    479
    Location:
    L.A., USA Zulu -8

    But phase comparator 1 does not necessarily have a 90 degree shift.
    That only occurs if the output from the phase detector to the VCO is exactly 1/2 the supply voltage when the PLL is in lock.
    Its variation from 90 degrees is proportional to how much the actual VCO lock voltage differs from 1/2 the supply voltage.
     
  6. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    thanks for your replies,
    i just want to know, when the signal crosses zero.
    i can use a zero corss detector wich gives the mikrocontroller every time when the signal crosses zero an interrupt.

    but ist this also possible using a pll ?
    i´ve heard that, but didn´t understand how to realise it, because the main function of an pll is to get the output in phase with the input ( output can have difference frequency) and not to get pulses if the input crosses the zero.
     
  7. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,763
    Likes:
    259
    Location:
    North west UK
    Last edited: Nov 27, 2017
  8. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,624
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    And who did you hear "that" from?
    Why would you want to use a PLL for a zero-crossing detector when that's not what it's designed for?
     
  9. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    and what about software pll on the mikrocontroller?,
    there is not an main reason to use it instead of zcd, its just a question if its possible.
    a reason could be to get a better zero cross signal if the input signal is noisy
     
    Last edited: Nov 27, 2017
  10. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,624
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    Then I suppose you could use a PLL with Type II digital phase comparator with sufficient output filtering so the noise doesn't appear in the VCO clock.
    That would give a stable zero crossing point of the VCO clock even with noise in the input.
     
  11. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    thank you very much for the answer ( all who have answered)
    but do i have to use an ic for the pll?
    what if i use it only mikrocontroller with the software.
     
  12. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,375
    Likes:
    975
    Location:
    Loveland, CO USA
    Question: "zero" what? zero volts? zero phase?
    I can use a PLL detector to know when the 100hz is 99hz or 101hz. (above or below)
    I can use a PLL detector to know when two signals are in phase.
    Maybe you have a 5volt peak to peak signal. (+2.5V to -2.5V) and you want to know when the signal cross 0 volts.

    I think each of us has a different idea what "zero" indicates.
     
  13. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,624
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    That can work also, if it can operate at the speed of the signal you are detecting although you still may need an external VCO.
     
  14. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    For the question above:
    zero volt.
    yeah we can take your example, i have a sinus voltage witch 5volt peak, and want to know when its zero volt.
     
  15. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,375
    Likes:
    975
    Location:
    Loveland, CO USA
    upload_2017-11-28_15-52-56.png
    Here I am using a general purpose camparitor. Most need a pull up resistor on the output.
    If Vdd matches you computer that is good. 5V or 3.3V
    I grounded the (-) input so it is looking for a signal above or below zero volts.
    The input has a 10k resistor added. ( You should not drive the input below ground so I added the resistor for protection)
    So the input signal is 5 volts above "zero" and -5 volts below "zero".
    The output will switch from ground (zero) to Vdd.

    How accurate to you need on the "zero"? If 0.6 volts is fine then there is a simple way.
     
  16. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    thank you for your help, but i dont want to do it with external parts, only software based.
     
  17. MrAl

    MrAl Well-Known Member Most Helpful Member

    Joined:
    Sep 7, 2008
    Messages:
    11,049
    Likes:
    961
    Location:
    NJ
    Hello,

    The error pulses are probably synced to the zero crossing so with a small phase error you would get short pulses near the zero crossing. That's with PLL's that i have worked with in the past that were somewhat custom designed. I'll check your chip if i get the chance but you could check that too.

    The real question is why would you want to use a PLL which is much more complicated than a more typical method to detect the zero crossing. Do you actually have some issue in the input signal (jitter, etc.) that would make you seek such an esoteric method like using an PLL?

    LATER:
    A quick look at the chip and it looks like the pulses out will be of width equal to the phase difference in time and synced to the input signal. The input signal however is shown as a square wave, so if you have a sine wave input you'd have to square that up anyway so using a PLL does not make sense unless you have some specific design goal in mind that is different than most zero cross detect circuits.

    The strangest thing about this question is that many microcontrollers can detect zero crossing with very little extra circuitry like maybe a couple resistors or something like that.
     
    Last edited: Dec 1, 2017
  18. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,375
    Likes:
    975
    Location:
    Loveland, CO USA
    So you are saying:
    No external parts. No external PLL IC. ????

    Schematic:
    upload_2017-12-1_13-58-12.png
    We have a micro controller running on Vcc which might be 5 volts or 3.3 volts.
    The uC should not have a voltage applied to any pin that is below 0 volts or above the supply.
    The signal is "5v p-p" which swings from +5V to -5V.
    Inside the uC's pin there are probably diodes to help protect the part from over voltage. But I added external diodes for more protection. The 10k resistor is to limit the current into the protection diodes.
    With the resistor and diodes, the voltage on the input pin will be limited to -0.6V to (supply+0.6V).

    If the input pin is "digital" then it will switch at about 1.5 volts above ground. Maybe at about 1/2 supply. (depends on what type of uC) So this not really "zero crossing".

    If the uC has a ADC on board, then you can measure the voltage. (depends on what type of part) The ADC can measure from ground to (VCC or Vref [which might be 1.25V or 2.5V or ??]). So if you measure the input as fast as you can and look for a voltage of 0 you will get a good idea of when the signal is above ground or below ground. There will be some delay because it might take 10uS for the ADC to work. Then another 10uS for the interrupt to get through the system.

    I added some external parts, sorry. How simple do you want this?
     
  19. MrAl

    MrAl Well-Known Member Most Helpful Member

    Joined:
    Sep 7, 2008
    Messages:
    11,049
    Likes:
    961
    Location:
    NJ

    Hello there,

    That is like something i had in mind too although you would need one more resistor and possibly a second one.

    The thing is though that most systems that have to detect zero crossing have 120vac line voltage coming in so a small error in the zero crossing is easy to obtain. If you REALLY only have plus and minus 5v (5v peak or even 2.5v peak) then the method starts to depend on the application itself and how bad one mis-detected zero crossing will affect the system.

    For example, with 120vac that is 170v peak, so an error of 0.5v is no big deal in detecting the zero crossing in most cases.
    If it is much lower like plus and minus 5, then you can predict the NEXT zero crossing after the original detection by waiting for a small period of time. This starts to get application specific though.

    I recommend one larger resistor from the sine source to the diodes, then another smaller resistor from the diodes to the chip i/o pin, then if needed another resistor from Vcc to ground.
    So that could be three resistors total.
     
  20. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,375
    Likes:
    975
    Location:
    Loveland, CO USA
    We do not have any information. So we are just guessing. Most micro computer have input protection diodes good for 1 to 2mA.
    I set 10k -5V = 500uA
    and
    10k +5V (or maybe +3.3v) = 0 or 200uA

    If the signal was any stronger I would have used:
    resistor, two external diodes (1n914 or 1n4148), resistor, internal diodes.
    This way the first R and diodes can have high current. The last R & internal diodes see a single that is 0.6V above and below the supply.
    -------------------------------------------
    "zero crossing" is a analog function that microcomputers (and digital) simply do not do.
    When you read zero crossing in a PLL data sheet you are going down a different road.
     
  21. boro3

    boro3 New Member

    Joined:
    Nov 26, 2017
    Messages:
    9
    Likes:
    0
    thank you guys,
    realy nice to have forums like this,

    i want to use it for 120v ac, if i use a pll, i can detect the phase.if i can detect the phase, then it should be possilbe to detect the zero cross.
    and yes, jitter ist the problem
     

Share This Page