alisarhangpour
New Member
I've tried to implement a complete phase locked loop in an atmega16, and got succeed to follow the 50Hz mains frequency.It works as follows:
A rising edge of the mains sine wave (converted into square wave) triggers an interrupt, a lookup table is used to make an internal sine wave, and interrupt service routine decides whether this internal sine wave is lagging or leading, and makes the pwm period longer or shorter.
But PLL works somewhat oscillatory, it doesn't stay fixed at, say, 50Hz. it goes around 49 Hz to 51 Hz. And it makes a dangerous phase difference. Probably because of a low resolution VCO, or bad designed transfer function.
Can anyone give a good algorithm for a microcontroller based PLL?
Thank You
A rising edge of the mains sine wave (converted into square wave) triggers an interrupt, a lookup table is used to make an internal sine wave, and interrupt service routine decides whether this internal sine wave is lagging or leading, and makes the pwm period longer or shorter.
But PLL works somewhat oscillatory, it doesn't stay fixed at, say, 50Hz. it goes around 49 Hz to 51 Hz. And it makes a dangerous phase difference. Probably because of a low resolution VCO, or bad designed transfer function.
Can anyone give a good algorithm for a microcontroller based PLL?
Thank You