digital pll implementation for grid tied inverter - Page 1
Forum section: electronics / general

author: logan123
author_rank: Newbie
timestamp: September 24, 2013, 07:05:00 am
content: hello,I am trying to implement digital pll using dspic33fj16gs504.It will be a single phase pll based on transport delay...Basically i will have to do the following steps..1) ADC a sine wave.. and generate its corresponding 90degrees shifted waveform (i.e cosine)2) Use these two to perform ab-dq transformation which would be some trignometric based equation.3) The use one of the components (say the q component) for a PI controller (which acts as the loop filter) and then have the integrator (as a vco).Now, how does one go about it....For those who are new to PLL may refer to the image attached...Any kind of help is hugely appreciated...

author: Kremmen
author_rank: Super Contributor
timestamp: September 24, 2013, 11:45:34 am
content: Is this a homework assignment? You know you should do those yourselfYou have the block diagram already in front of you. What you do is find the expression in a programming language for each of those blocks. Then you basically connect the dots.Normalize your variable value ranges to something. -1...0...1 is an often used choice but it is up to you, depending on what numeric presentation you want to use. As this is a task in digital signal processing, one part of the task is to come up with a cycle time appropriate for the signaling in the real world. That will give you a value for the s operator (or actually the z operator, seeing how this will be a discrete time system).The "some trigonometric based equation" is the Park Transformation. Look it up. This converts your signals to an orthogonal rotating frame of reference (d-q or direct/quadrature) where subsequent processing is easier.The rest you have said yourself. The PI controller outputs the beat frequency between the output and reference frequency (w). Integrating the beat you get instantaneous phase between the input and reference. That is used to close the feedback to the transform that then also acts as the summation point of the PI controller.A very similar configuration is typically seen in CNC control systems where resolvers are used to encode motion. A typical solution is the so called Angle Tracking Observer that provides a very robust conversion from resolver signal to motion signals without any singularities that can appear in more naive implementations.

author: logan123
author_rank: Newbie
timestamp: September 24, 2013, 03:09:27 pm
content: Thanks for the replyNo this is not "home assignment".. its just a work i have taken up.Well, i have understood how a PLL works. Its just the implementation of it where i am having doubts. Let me explain..Firstly, i will be using a transport delay to generate the 90* phase shifted reference of the sine wave. (as this will be single phase pll)Then with these two references (lets name it,Va and Vb), i perform the park transformation to get the values of Vd and Vq. Then we have the PI and the Integrator.I am having trouble in generating the delay. You see, the original sine will be sampled and taken in as digital values.. but how do i use this for getting a 90* phase shifted values?? Please kindly suggest..

author: Kremmen
author_rank: Super Contributor
timestamp: September 24, 2013, 04:50:09 pm
content: Perhaps you should backtrack a bit and let us know what are the requirements this PLL needs to fulfill. Or what is the application where it does its thing. That would make it easier to comment on the specifics of your design.To get a 90 degree phase shift you only need a simple lookup table enumerating the angle vs measured sine value. From a measured sine signal lookup the index in the table. Then it is trivial to reverse lookup the corresponding cosine by shifting the index of the sine a quarter cycle. Just a quarter of the full cycle will do, the rest can be handled with playing with the signs of the signals.I am not by any means an expert on phase locks so i would have to look more closely what the injection of the w between the PI block and integrator does to the loop. Only i am currently occupied with a pesky optimization task in linear programming and don't have any surplus brain capacity at this moment to dive deeper.

author: logan123
author_rank: Newbie
timestamp: September 25, 2013, 01:23:38 pm
content: Okk see my purpose is to develop a PLL technique within my microcontroller so that it can fetch the phase and frequency information and make my inverter inject current at unity power factor. So basically i will be sensing the grid voltage, taking it into my controller and extract the phase and thereby process my entire closed loop.I have the grid voltage which is a sine signal of 50hz..now the PLL technique i am referring to is using a transport delay wherein i generate a quadrature component of the sine.Referring to what you said, how am i going to use a "look up table" in this case?? Bcoz i will be sensing the grid voltage and sampling it..but how do i relate that with a pre defined LUT within the controller..I didnt quite get the look up table technique u were talking abt... sorry for that. If its not a trouble could you explain it again..

author: Kremmen
author_rank: Super Contributor
timestamp: September 25, 2013, 05:46:37 pm
content: Very well, without paying attention to exactly how you are going to use the PLL, my comment on the lookup table was based on the thinking that to know the phase angle of the sine, you need to lookup the measured voltage against a table of sine values. What i mean is you have a reading from the ADC and you need to know what angle this represents. So, look it up in a table of sine values. This is a very common technique; i am sure the net is full of examples. Now, because this is a table of sines it is also a table of cosines. You just apply a 90 degree phase shift, i.e. first from the measured voltage you get the angle of the sine wave. Then add 90 degrees to that and look up the corresponding cosine value. Done.The rest of your PLL loop will act as an observer to (mostly) compensate for any digitizing erors and line distortion. At least that should be why it is there in the first place.Having said all of this, a word of warning. As i have no idea of your level of experience in electronics and power electronics in particular, i should warn you that you are taking on a definitely non-trivial project. If you have been there and done it, then no problemo, but if you consider yourself in any way a beginner, maybe you want to think one more time about this project.

author: logan123
author_rank: Newbie
timestamp: September 25, 2013, 06:07:45 pm
content: Okkkk thanks for explaining once again..Well, i will try out your method.. however, there's another thing that can be done.I can sense the sine (grid voltage)wave thru my ADC, and continue to store the values up to Ts/4 samples. Where Ts defines the total number of samples in one complete cycle. Once i reach Ts/4 sample, i can simply use the first value stored as a value of my 90 deg lag signal and go on constructing the entire phase shifted wave.Let me know if there's a loophole in this method.And yeah, i am aware of what kind of work i have taken up... Thanks againP.S- The signal that i'll try to construct from the sine will be a 90 deg lagging one.. and not a cosine. (but a -cosine) Sorry for the confusion created..

author: Harvs
author_rank: Super Contributor
timestamp: September 27, 2013, 01:35:20 am
content: To b honest I might well be missing something here. But... This sounds like about the most complicated way of achieving this:QuoteIt sounds a bit like you're trying to take a model from Matlab and transfer it to the real world, where there's more practical methods for achieving the end goal.Firstly, if it's only single phase, and it's only unity PF you're trying to achieve (not a variable "SATCOM" type of arrangement), then why are you even trying to achieve a 90 degree phase shift?Secondly, as it's grid tied with a largely fixed frequency and voltage, a simple fast zero crossing detector is all you'll need to get the timing information from the mains. There's plenty of good app notes out there on zero crossing detection and their various complications. With that it's trivial to count the exact period and you know the start of each cycle, therefore with a simple timer you know the exact phase of the mains at any given time.

author: Kremmen
author_rank: Super Contributor
timestamp: September 27, 2013, 09:59:40 am
content: The same questions have occurred to me as well. I haven't commented though, assuming this is the way the OP wants it done (i.e. I answer the question made).A tracking observer could make sense because it would be robust against spikes and jitter in the measured signal. On the other hand it does introduce some phase shit due to the intgration terms in the loop. That could probably be compensated but yes, i agree this is definitely not the simplest way.