Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 20th November 2007, 04:45 PM   (permalink)
Default Phase Locked Loop Using Micro

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
alisarhangpour is offline  
Old 20th November 2007, 04:50 PM   (permalink)
Default

No idea on Atmel, but your original premise sounds wrong? - it's normal to use a zero-crossing detector, not convert it to a squarewave.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 20th November 2007, 04:56 PM   (permalink)
Default

The interrupt works as the zero crossing detector, I've just converted it into a square wave to detect its zero crossing easily using external interrupts, besides I'm not so stuck to Atmel, any idea which can be implemented using micros is appreciated.
alisarhangpour is offline  
Old 20th November 2007, 05:55 PM   (permalink)
Default

Quote:
Originally Posted by alisarhangpour
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
Well the basic premise of a PLL is one of a feedback system where the error detected is feed back for correction. If there was no error then the system would not function. Most PLL systems use some form of analog filtering after the phase detector to 'tune' the error response of the system. This error filtering and tuning is probably the most complex part of designing a good PLL system. Your PWM step resolution (10 bits?) will be one factor in the overall loop response but some form of digital filtering (averaging of multiple samples) may smooth out the response.

Lefty
__________________
Measurement changes behavior
Leftyretro is offline  
Old 20th November 2007, 07:56 PM   (permalink)
Default

If you don't detect the zero-crossing as accurately as possible, and are depending on a rising/falling threshhold value to create your signal, then you will have phase problems relative to the original signal. You have to lock-in on zero and not some threshhold value.
wschroeder is offline  
Old 20th November 2007, 08:21 PM   (permalink)
Default

Quote:
Originally Posted by wschroeder
If you don't detect the zero-crossing as accurately as possible, and are depending on a rising/falling threshhold value to create your signal, then you will have phase problems relative to the original signal. You have to lock-in on zero and not some threshhold value.
I think Detection of ZERO crossing can't be that accurate. Unless the paramater is of recognisible lebel after changing the direction, only then any hardware circuitry can respond. Thus it may be well after the zero croosing , not at the zero crossing.
As rightly indicated by Leftyretro, this observable oscillatory behavior can't be avoided if PLL is attampted at 50Hz.
The attempt by Alisarhangpour is appreciable and there and perhaps may form a good topic for debate.
__________________
Regards,
Sarma.

Last edited by mvs sarma; 20th November 2007 at 08:23 PM.
mvs sarma is offline  
Old 20th November 2007, 08:55 PM   (permalink)
Default

There are a number of good zero-crossing detection circuits which are fast enough so that phasing differences relative to 50Hz are of no appreciable significance.

http://www.discovercircuits.com/XYZ/zerocross.htm
wschroeder is offline  
Old 21st November 2007, 02:32 AM   (permalink)
Default

Quote:
Originally Posted by Leftyretro
Well the basic premise of a PLL is one of a feedback system where the error detected is feed back for correction. If there was no error then the system would not function.
How about PLL configuration that locks at 90 degree phase difference between input and output?
__________________
L.Chung
eblc1388 is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Variable capacitor circuits walters General Electronics Chat 83 11th March 2008 03:59 PM
phase locked loop (PLL) design for tx and rx missy Electronic Projects Design/Ideas/Reviews 3 4th October 2005 02:26 AM
phase locked loop ic for robotic localization xmat Robotics Chat 1 11th February 2005 02:14 AM
learning phase locked loops Kurupt General Electronics Chat 1 27th January 2005 03:05 AM
phase locked loop?? jovabiot Electronic Projects Design/Ideas/Reviews 0 27th February 2004 10:18 PM



All times are GMT. The time now is 01:08 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker