cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

RiTa_288331
New Contributor II

Greetings all!

I'm trying to make a type 2 phase detector for a PLL circuit (see attachment).  In this PLL, the VCO is external, and the PSOC will control it by a single control voltage through the VDAC (but it could also be a PWM).

I'm looking for a kind of "accumulator", or up/down counter, that will control the VDAC's output voltage.  Normally, lines Qa and Qb are both low (this represents a locked phase condition, which is what we ultimately want).

--> I want a condition, where:

     if there are pulses on the Qa line, then VDAC should increase its output.

     if there are pulses on the Qb line, then VDAC should decrease its output

     if there are no pulses, then VDAC should keep using its "last" value

Is there such an accumulator/counter in PSOC?  I see counters, but I don't see an up/down counter.

0 Likes
1 Solution
odissey1
Honored Contributor II

I have 60Hz type-2 analog PLL all made inside PSoC (plus a couple of capacitors and resistors). I believe  that generating quadrature sine outputs is also feasible within PSoC chip. Attached are type-II phase-frequency detector (PFD), loaded to RC filter. The output of the filter directed to a VCO (using Delta-Sigma Modulator inside the PSoC). It was tested and locks in approx. 30-150Hz range. I will dust-of the PLL demo project and post it. Meanwhile attached are screenshots from the project. The filter is most tricky part of PLL, as those combinations of Caps and Resistors are designed to provide a "phase margin" (aka friction) in the loop - otherwise loop will not settle and continue to oscillate around lock frequency.

Phase-Frequency_detector_type_2_01.png

Analog_Low-Pass_Filter_01.png

VCO_DelSig_modulator_01.png

View solution in original post

0 Likes
10 Replies
odissey1
Honored Contributor II

What frequency range you want to lock-in?

odissey1

P.S. Have you checked this AN (Demystifying the PLL - Cypress Semiconductor)

0 Likes
RiTa_288331
New Contributor II

Greetings odissey1!

My frequency range is 59-61Hz (for a standard 60Hz US outlet, which doesn't vary in frequency very much at all).

My VCO is using two Analog Devices multipliers AD633 (in their datasheet, one of the examples is making a voltage controlled quadrature oscillator).  This oscillator generates two sinusoidal waveforms that are 90 degrees apart.  The control range is something like 0 - 10Vin gives you 0 - 1000Hz frequency in the output, which is WAY more than I need.

--> Ultimately, I'm trying to make a single-phase dq transform circuit (I.E. a park transform circuit), for use in an AC-DC power electronics circuit.  Having both in-phase and quadrature sinusoids, both phase-locked to the 60Hz wall frequency, are needed for this d-q transform.

Yes - I saw the app note - it's my understanding that this uses a type-1 phase detector, and I'm trying to make a type-2 phase detector (for wider lock range and smaller phase offset).

0 Likes
odissey1
Honored Contributor II

I have 60Hz type-2 analog PLL all made inside PSoC (plus a couple of capacitors and resistors). I believe  that generating quadrature sine outputs is also feasible within PSoC chip. Attached are type-II phase-frequency detector (PFD), loaded to RC filter. The output of the filter directed to a VCO (using Delta-Sigma Modulator inside the PSoC). It was tested and locks in approx. 30-150Hz range. I will dust-of the PLL demo project and post it. Meanwhile attached are screenshots from the project. The filter is most tricky part of PLL, as those combinations of Caps and Resistors are designed to provide a "phase margin" (aka friction) in the loop - otherwise loop will not settle and continue to oscillate around lock frequency.

Phase-Frequency_detector_type_2_01.png

Analog_Low-Pass_Filter_01.png

VCO_DelSig_modulator_01.png

View solution in original post

0 Likes
RiTa_288331
New Contributor II

This is a PERFECT solution - thank you odissey1!  I never thought to use an IDAC and a capacitor, but it makes perfect sense, as the capacitor will hold the previous value if there is no need for the IDAC to adjust the frequency.

I'm looking into the SC_Modulator component now (I see that it's a shared community component).  THANK YOU for sharing a perfect solution!

-Rick 

0 Likes
odissey1
Honored Contributor II

Rick, I will drop the project this evening. The modulator is a part of a KEES library, which I slightly 'beautified'.

odissey1

0 Likes
odissey1
Honored Contributor II

Attached is a demo project. I had no time to re-test it, so there might be issues.., but I hope that it will keep you going. I will be able to return to it on weekends.

The KEES_SCModulator component which is needed for the project was slightly "beautified" (no functionality change from the original), it is attached below.

The QuadDecoder_SW library used in the project can be downloaded here:

Quad Decoder with Button Switch component for rotary shaft encoders

PLL_SCM_01_b_demo_01.png.png

0 Likes
RiTa_288331
New Contributor II

I have the files odissey1 - I'll try the whole system out after Christmas shopping.

THANK YOU again for this solution, I think this is exactly what the doctor ordered!

-Rick

0 Likes
RiTa_288331
New Contributor II

UPDATE - I think it works!  So far, I've used a function generator to sweep ~55Hz to 65Hz, and the waveforms look good!

--> A question: If you look at the two attached waveforms, there is a slight phase offset between the two waveforms that is dependant on frequency.  The 57.6Hz waveform has almost none, but the 61.1Hz waveform has a little bit.  Theoretically, I'd expect none because this is a type-II PLL.  Any ideas as to what could be causing this?

Freq_57_6Hz.BMPFreq_61_1Hz.BMP

0 Likes
odissey1
Honored Contributor II

I suggest to add OpAmp buffer between LPF and VCO, it seems that the Modulator has low input impedance, ~20k, which is loading LPF. Also check if LPF is properly tuned by observing output of LPF on scope while jumping input frequency between two adjacent frequencies (e.g. 50Hz - 70Hz). Particularly important R_2, which creates dumping, use ~10k trimpot to find value when transition looks like on screenshot below. Attached are screenshots of the PLL properly tuned, and LPF output shows critically dumped transition (no high frequency oscillations).

odissey1

YouTube video:

PSoC5 custom PLL at 60Hz - YouTube

PLL_60 Hz locked _02.pngPLL_LPF output tuned up_01.pngPLL_SCM_01_b_demo_LPF_01b.pngVCO_01.png

0 Likes
odissey1
Honored Contributor II

Hi All,

You can obtain finished component, a datasheet, demo project and YouTube video, showing the component in action.

custom Phase-Locked Loop (PLL) implementation using PSoC5

/odissey1

0 Likes