PDA

View Full Version : How to program PIC microcontroller as a PLL or DPLL



Zain
23rd May 2013, 10:27
I want to program PIC 16F877A as a Phase-locked loop , help!!!

charliecoultas
23rd May 2013, 10:32
Have you got any idea at all about how this might be done? Give us your thoughts...

Charlie

Zain
23rd May 2013, 10:38
we will be providing two digital signals of different frequencies at input, and at output they will be synchronized, this is phase locked looping,and this we want to achieve

charliecoultas
23rd May 2013, 14:54
Would you like us to do all the work in writing the software for you?

Charlie

barak
23rd May 2013, 16:15
Think of a XOR as the heart of a PLL: when the two inputs are perfectly phase matched, the output is 0. Otherwise, you get pulses with duration proportional to the phase offset. In analog PLL you integrate the output pulses and use the DC voltage to control a VCO. In DPLL you use the pulses as numeric reference.
The implementation on PIC depends on your signals and requirements.
In my opinion, the ultimate solution will be to use a PIC with Configurable Logic Cell Modules like PIC16F1509.
You configure hardware XOR. You feed a reference signal from the MCU to one input (can be a PWM or clock output that is all hardware no instructions needed). Your controlled signal goes to the other input and you use the output pulses to control the signal's frequency/phase.
If you don't need speed or accuracy you can perform software XOR by comparing: output = reference ^ input

PA1OKZ
24th May 2013, 20:04
Interesting concept of PLL-ing. This is quite an unconventional way of doing, not meaning to say it's impossible. However, I would advise you to study the principal behind a PLL. The idea behind comparing two signals is right, but there is a lot more around it. A phase comparator is rather different from what you propose.

One major other point is the question whether the generated frequency should be variable/programmable or not. If not, then it's easier but it only makes sense if the desired output frequency is not related to your reference source, otherwise you can just time- and toggle a port to generate whatever you desire.

If you want to be ultimately flexible, better spend 4Euro on a decent PLL, e.g. ADF411x that can easily be driven by a PIC over SPI. If that is what you intend, I can give you a start with some working code...

Best regards and good luck,

Mischa

Edit: Barak's approach sounds like it, though still I have no idea what you try to achieve (what are you trying to create?)

barak
24th May 2013, 21:10
Mischa, you are right, "no idea what he is trying to achieve".
Regarding XOR approach, we used to design PLL, DPLL, FLL, etc. into ASICs and this simple logic XOR works like a charm . If you want a ready made analog PLL, a 4046 cost only $0.15 and with a added cheap logic it can be controlled from mcu.

PA1OKZ
24th May 2013, 21:45
Sure, I have utilized tons of 4046, preferably with 4059 etc. but I find them so oldfashioned right now, prefer more modern ones, not in the last case because of significantly better phase noise performance. In many regular PLL's, phase comparison works according to the principal of a modified XOR indeed, so why not experimenting with it in a PIC for that purpose. I only think that building PLL circuitry in a PIC is kinda illogical. It's maybe a bit of a bold statement without knowing the application though...

barak
24th May 2013, 21:58
I have a PLL on a PIC. Works very well for signals under 100KHz. I made a "hardware" XOR from elements on the PIC and use PWM for the reference so it does not use instructions to generate the control signal. In this case, the output is integrated and fed to ADC and the ADC value is used to determine the phase shift. For lower frequencies it would be possible to measure the pulse width.

Zain
25th May 2013, 06:23
I am a final year student and implementation of PLL is a part of our project,our project internal has asked us to program a PIC as a PLL, meanwhile we will be working on timers, within a short period ,we will start working on PLL,then I may be able to ask properly for help, thankyou to all who have responded!!!

Zain
2nd July 2013, 03:35
We have got to signals one at a frequency of 1Hz and other at a frequency of 2500Hz both being fed to a PLL, the output should be such that they are phase-locked.

Zain
2nd July 2013, 08:21
In general, we will be having an nmea string from the gps module, there is also a pin that will provide a 1 pps signal, this 1 pps signal is synchronized with the nmea string.

What we need to do is that synchronize (i.e phase lock) a 2500 pps with the 1 pps signal, provided the nmea string also remains synchronized with the 1 pps.

That's all we need to acheive.

charliecoultas
2nd July 2013, 08:49
Where does your 2500 pps signal come from? Because that is the one you will need to change to line up with the 1pps from the GPS module. Your say "provided the nmea string also remains synchronised with the 1pps". The 1pps is fixed and will be more or less once per second. The nmea strings come tumbling out of the module and I am not sure if they are "synchronised" with the 1pps. One of the ppl guys will no doubt pick this up as I'm not too hot on pll's.

Charlie

taha
13th February 2015, 13:56
I am a final year student and implementation of PLL is a part of our project,our project internal has asked us to program a PIC as a PLL, meanwhile we will be working on timers, within a short period ,we will start working on PLL,then I may be able to ask properly for help, thankyou to all who have responded!!!
Zain,can you give me the program of using pic as pll.I m also a final yr student doing a proj. using pic

Quinton
6th May 2015, 15:54
Zain, can you also send my the program or some guidelines 22739742@gmail.com