# basics of PID control

Discussion in 'Mathematics and Physics' started by PG1995, Jun 12, 2013.

1. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
I have to disagree with you on these points. You once mentioned several DSP books you are using in your courses. My recollection is that they all explain this reasonably well.

The logic is very simple for any sampling shape (pulse, impulse etc.), but is easies with an impulse function. The arguments can be made very simply and at a high level using basic transform properties.

First, the idea of sampling is modeled simply as the multiplication of an impulse train times the input signal. The act of multiplication in the time domain allows us to use the convolution property, which says that the frequency spectrum will be the convolution of the signal spectrum with the impulse train spectrum. We know that the transform of an impulse train is an impulse train, so convolution of signal spectrum with an impulse train creates a signal frequency spectrum at every harmonic of the sample rate.

So, you are correct that the impulse spectrum does not give that shape. All it does is create the shifted versions of the signal spectrum. It is the signal spectrum that gives that shape.

Now, in reality we can't make an impulse train for sampling. But think about it. Any periodic sampling shape will have Fourier series components at harmonics of the sampling frequency. The only difference is that the amplitudes of the impulses that represent the Fourier coefficients are not the same at all frequencies. Actually, typically the amplitude decrease as frequency increases. But the amplitude is not critical because you still are going to get shifted versions of the signal spectrum, and the Nyquist criterion is still applicable.

So, you see, very basic ideas are used here. The specifics will depend on the exact signal spectrum and exact nature of the sampling process, but if you only care about general effects, such as frequency locations, the basic ideas tell you all you need to know. The signal bandwidth and the sampling rate are the primary factors.

Last edited: May 16, 2014
• Like x 1
2. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Hi

I was in middle of writing a new post but then I got stuck at a point. Fourier transform of an impulse train is also an impulse train where all the impulses constituting the train have equal amplitude. On the other hand, the impulse train used here in case of sampling has almost every impulse with different amplitude. Then, how can we say that such a train with different amplitude for each impulse has Fourier transform similar to the case where each impulse has equal amplitude. Please help me with this. Thank you.

Regards
PG

File size:
225.1 KB
Views:
1,044
3. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
I'm not sure I'm following your question. When you say the impulses are not of equal amplitude, are you talking about the impulses in the time domain, or in the frequency domain.

The example you showed shows no problems with either case, but you need to specify so that we can track down why you think there is an issue.

Let's review the process again. The time domain signal is viewed as a multiplication of the continuous time signal with an infinite impulse train. After the multiplication, of course the final impulses in the time domain have different amplitude, but the starting impulse train has equal amplitudes.

It seems to me that you have not understood the original explanation given in all DSP books and which I tried to summarize. The fact that we can represent the sampled waveform as a multiplication of the infinite impulse train times the continuous signal allows us to instantly give the answer in the frequency domain. Multiplication in the time domain transforms as convolution in the frequency domain. The signal is transformed, and then the infinite impulse trains (with equal amplitudes) is transformed (to another infinite impulse train with equal amplitudes). Then convolve them. Do you understand how convolution of the signal transform with an infinite impulse train results in the signal transform being shifted to every harmonic of the sampling rate?

Last edited: May 18, 2014
• Like x 1

Joined:
Jan 12, 1997
Messages:
-
Likes:
0

5. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13

Thank you, Steve.

In this post I will try to highlight many points which are confusing me. Some of those points are directly related to the discussion of sampling we are already having and some are indirectly related.

Yes, in the past I did tell you that I had downloaded different DSP e-books. But I did not say that I used all of them or any of them. You can check the private message with title "DSP Course". I hope you would also remember that I constantly kept on telling you that that DSP was going nowhere and the instructor knew nothing about DSP. If you ask me, I would say that the way that course was conducted was equivalent to saying that it wasn't taught at all. You can also check the message "now I have doubts about his sanity". But I'm sure that you are just saying that many of those e-books provide a fair explanation of sampling. I agree with you on this. They do try to explain it but perhaps I'm confused about some other things and the worst part is that I don't know how to put all my confusion into words. Anyway, this text really tries to explain it better than many other texts I have referred to as far as typical and regular theoretical analysis is concerned and it looks like I understand it too.

I think what I want to discuss is somewhat along the same lines what I asked you in Q5 in this thread. Please note that we continue to discuss Q5 until post #24 in that thread. Further, I really liked something you said in this paragraph where you said, "I think the mistake that many people make...".

This is an extension to Q5 I referred above. Since that discussion I had with you about Q5, I have always thought that if you have connected a wire to a source supplying an electric current in form of a square wave, then macroscopically that electric current is flowing in form of pulses (i.e. square wave) but microscopically it exists in the form of odd harmonics of sine wave. Putting it differently, on macroscopic scale the electrons are moving in form of pulses (i.e. square wave) but when we look at those electrons individually those electrons exhibit odd harmonics of a sine wave. It shows here that how simple harmonic motion can be viewed as a sine wave of specific frequency and amplitude. Please note that my view is somewhat similar to how we treat light; when we are concerned only about macroscopic effects of light, we treat it as a wave but when it comes to its microscopic view, we adopt photon model. Let's say an electron is a tiny mass and electrostatic force exerted on it by atom(s) constitute an atomic mass-spring system. I understand that what I'm saying is not very clear but it give you some idea what is disturbing me to great degree.

Likewise, we say that an impulse function contains, theoretically, all the frequencies with equal magnitude. Also note that an impulse doesn't need to have infinite amplitude, it just needs to have area of unity as you have always suggested. We usually use an impulse to find frequency response of a system. I tend to think of this as follows. When we apply an impulse to a system, the impulse has the capacity to generate all possible varieties of simple harmonic motion with different frequencies in electrons of that system. The system would allow some frequencies for simple harmonic motion more and the others less.

A single impulse contains theoretically all the frequencies with equal magnitude. But how come a train of impulses only consist of train of frequencies and not the continuum of frequencies. Perhaps, this is what happens. Suppose we have connected a wire to a source supplying impulses at regular intervals which constitute a train of impulses. In this context, an impulse needs to be a very short duration pulse or disturbance with area of almost unity and further note that there could two different ways to look at this - we can think that short duration pulse or disturbance (i.e. impulse) is created by pushing the electrons from negative terminal or by pulling the electrons from positive terminal. Anyway, the frequencies generated by each of those impulses interfere with each other that only certain frequencies survive or are allowed to exist assuming steady-state analysis.

I think that I also understand the concept of negative frequencies to some extent though providing you with textual detail of my mental picture will just be confusing. The following is a note to self. If an electron, B<----o--->A, starts its motion from "o" and moves toward "A", then backward toward "B" and then back toward "o", this constitutes one cycle and number of such cycles makes up frequency. But if the electron had started its motion by moving first toward "B" instead of "A", then it would have resulted into negative frequency.

Now we come to the sampling. We need to discuss how sampling is done. In real sampling, a high-speed switch is turned on for only the small period of time when the sampling occurs. The result is a sequence of samples that retains the shape of the analog signal. The most common sampling method is sample and hold. I believe in this context the operation of turning on the switch for very small period of time is denoted by an impulse. The "f_s" denotes the number of samples taken per second or number of impulses generated per second. (This is where I got stuck yesterday and then asked you about that impulse train with unequal amplitudes). As a matter of fact when switch is turned on for a very small period, small capacitor is charged up. So, turning on of the switch and charging of the capacitor is what sampling is all about, in simple words. So, where is that impulse train which we intend to use for the sampling? I think that turning on of the switch and charging of the capacitor makes up that impulse train. The switch and capacitor mechanism would give us that impulse train where all the impulses have equal amplitude only if the capacitor gets charged up to the same level every time but the capacitor doesn't get charged up to equal amount every time.

For the sake of continuity of this discussion, I'm going to assume that we have an impulse train with equal amplitudes. Suppose the analog signal is a sine wave with frequency of 5 Hz. It would mean that we will get two spikes in frequency domain for such an analog signal where one spike occurs at 5 Hz and the other at -5 Hz. Further assume that the impulse train gives spikes at 10 Hz, 20 Hz, 30 Hz and so on; the spikes also extends in negative direction like this -10 Hz, -20 Hz, -30 Hz, and so on. I will only focus on positive frequencies for simplicity. The analog signal having frequency of 5 Hz means that the electrons are acting like microscopic mass-spring systems with frequency of 5 Hz. Likewise, when it comes to impulse train, it means that some electrons are acting like mass-spring systems with frequency of 10 Hz, others with 20 Hz and so on. Now comes another point which is really confusing me. How can two of such mass-spring systems interact that their frequencies get added up? For a mass-spring system angular frequency, omega, is sqrt(k/m).

Someone might find this alternative view of Nyquist theorem useful. Thank you.

Regards
PG

PS: Please don't think that I'm obsessive with electrons. It's just that I believe that Fourier analysis predicts something real which actually exists and to help myself to capture that 'something real' I'm using electrons because I don't know what else can be used to try to visualize those harmonics. Thanks.

#### Attached Files:

File size:
2.6 MB
Views:
504
• ###### sampling1.jpg
File size:
375.2 KB
Views:
397
Last edited: May 19, 2014
6. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
OK, you are bringing up many many things from various past discussions. Many of those things I explained as best I could. Some of those issues are indeed very difficult to think about and I think we all have those questions, concerns and doubts as we are learning, and sometimes long after that.

So, I will have to stand on my previous comments about those things and focus here only on the narrow question about sampling itself.

Yes, exactly. I was just saying that this explanation is found in many of the books you have access to. Notice how short the descriptions are. Just one short paragraph is needed because they are using very powerful sweeping logic to take a difficult question and strip it down to its essential elements. When viewed from this vantage point, the answer should appear simple if you have a solid understanding of the basic system theory tools used.

The answer to this is simple if you trust all the system theory you've learned.

What is the most critical thing about an impulse train, or any train of pulse-like shapes used to do sampling? The answer is that it is a periodic signal.

Now, isn't it a property of periodic signals that the Fourier transform of that signal is found be converting the Fourier series coefficients into impulses with impulse amplitudes equal to the value of the Fourier series coefficients? And don't those coefficients occur only at the harmonic frequencies? Why would you expect a continuous spectrum to result from a periodic signal?

OK, the final sampled signal looks like a train of impulse with unequal amplitudes. You are bringing up the actual physical process by which we might make the final sampled signal.

However, what you need to realize is that when we mathematically model this, we prefer to think of the physical system as though it is multiplying a perfect impulse train, with equal amplitudes, times the original signal. That model gives pretty much the same (or at least similar) answer.

Here, I think bringing up electrons and how they vibrate is completely off base. System theory does not need to consider the physical mechanisms which compelled us to use the system theory. All that matters is whether the physical system approximates the many critical assumption required by our system theory.

Aside from that, I don't think your electron model/explanation is in any way correct.

It seems to me that using an inaccurate picture/model of the physics is one mistake. Then, worrying about the physical processes, even if you get them correct (whatever correct means) is a second mistake.

The second mistake is a mistake because we are dealing with the logic of a mathematical abstraction about our system. The physical details are not relevant. Once you understand the mathematical answer, you can then go back to the physical system and ask, "What differences are there between my perfect model and my real circuit?". I think the first answer you should get is that you do not have perfect impulses, when you sample. So, what effect does this have? That's the next critical question you should ask, but you can't ask it until you understand the perfect model.

But, notice that my recommended "next question" had nothing to do with physics and electrons, but was more a question related to engineering and circuit implementation.

Let's make an analogy with computer programming. Going too far back into the physics of the system is akin to worrying about machine code, when you are programming in C++. Going back to incorrect physics is akin to worrying about 6800 machine code when you are using a Pentium processor. The first mistake makes your job much harder. The second mistake makes your job impossible.

I'm not suggesting that you shouldn't seek out intuitive understanding and physical explanations, but I'm recommending that you compartmentalize and structure your learning. Know when and where to question the theory you are learning so that you can "own" it, and know when to accept and use that theory you "own" and use that knowledge to progress to the next level.

I suspect that this answer still leaves you in a state of confusion, but it's the only way I know how to answer this. The only other thing I can suggest is to carefully write out each step of the logical argument (on a piece of paper) of how sampling is modeled in the time domain and frequency domain and how it creates the Nyquist condition. Then look at each step and see if you are "ok" to accept that step. If "yes", proceed to the next step. If "no", then attack that step with more thought, or a very specific targeted question here in the forum. Once you are comfortable with each step, you should be comfortable with the whole process and the final answer.

Last edited: May 19, 2014
• Like x 1
7. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Thank you.

I understand the overall process of sampling without much difficulty but my confusion stems from physical details. For instance, if there really exists harmonics as Fourier analysis predicts along with other things then how I can visualize them. I knew that my electron analogy wasn't perfect but my purpose was just to provide you with a general picture so that you can know where I was coming from. Personally, I do accept the principle of duality of light but I don't think in reality light exists like this. It's just a model of light which facilitate us and helps us to get accurate results and make predictions. You can't say at one time something is 'monkey' and at other time it's 'zebra'. If a a programmer doesn't have much know-how about electronics then it's won't be advisable for him to try to understand what's behind those machine code but if he also has good knowledge of electronics then I think he can, at least, understand simple physical processes going behind those machine codes to some extent. Hasn't it ever bothered you that what goes on at atomic level while thinking of those harmonics etc.? Perhaps, we, humans, have more information about reality than reality itself.

Best regards
PG

Last edited: May 19, 2014
8. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
These are issues that go beyond any particular example, like sampling.

I've already given my opinion about the existence of "frequencies" with Fourier analysis. This level of thought deals with interpretations and opinions. Basically we have a mathematical theory that seems to model the physical world very well. That theory seems to hold up even at the quantum level and into quantum field theory. Fourier analysis is even a byproduct of the postulates of quantum mechanics in the Dirac formalism. I really don't know how to separate the physics and the mathematics and the physics is the only way I can access/understand physical reality. To say more would be speculative, at best.

As far as systems theory at the circuit level, you have to be careful going too far down to the molecular level and the electron level is even below this. We do have quantum mechanical models that can be used to attack this level for understanding, but system theory, as we use it, is not dealing with this level of modeling at all. The irony is that the math of QM and that of system theory have many many parallels. But, system theory of circuits is far removed from the atomic level. Remember that the Maxwell's equations we use for circuit theory is an aggregate macroscopic theory that includes matter. The vacuum equations are exactly correct physics at the classical level, but the interactions with matter are approximations, even at the classical level.

As much as I personally promote physics, and intuitive understanding, I think this is a case where you don't want to go too far down this path. We ignore the small scale fields and variations and deal only with macroscopic variables. The EM theory of the macroscopic variables leads to a simplified theory we call circuit theory. When those systems are linear, we can apply linear system theory (Fourier and Laplace).

• Like x 1
9. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Hi

We can think of the capacitor in the frequency domain as an impedance as you said in post #54. We know the effect of sine waves on any impedance whether R, L or C. At any particular frequency we can think of the filter as a voltage divider. At high frequency 1/wC is very low and we are basically shorting out the voltage source, hence the attenuation is increasing as frequency increases.

The text says that we can filter out the higher harmonics and can get the DC value of 3V. I believe the higher harmonics have less amplitude, i.e. volts, than the DC component but they still contain energy. So, don't you think eliminating them or shorting them out using the capacitor result is waste of energy? Thank you.

Regards
PG

File size:
725.6 KB
Views:
370
10. ### nsaspookWell-Known Member

Joined:
Mar 24, 2010
Messages:
1,141
Likes:
219
Location:
Fairview, Or
Yes, it's a lossy filter. You can store that energy in a series inductor L-C filter and release it when the switch opens with a bypass diode like a buck converter.

• Like x 1
11. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
Yes, an RC filter is lossy. That is clear because we have a resistor and a resistor will dissipate power as heat. There is no loss for DC because the DC current is zero and I^2R loss is hence zero.

12. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Thanks.

I'm afraid that I wasn't able to put my question clearly and you might have thought that I was asking something else. So, let me repeat it. I was looking at the circuit this way. In my opinion, the text says that we can filter out the higher harmonics using a capacitor and can get the DC value of 3V. The higher harmonics which have less amplitude, i.e. volts, than the DC component still contain energy but they will be eliminated by the capacitor or shorted out through the capacitor without giving their to the load resistor, R_L. So, don't you think eliminating them or shorting them out using the capacitor result is waste of energy? Thank you.

File size:
7.6 KB
Views:
314
13. ### NorthGuyWell-Known Member

Joined:
Sep 8, 2013
Messages:
1,218
Likes:
206
Location:
Usually, filters operate on signals which have very little energy, so wasting energy is not an issue.

• Thanks x 1

Joined:
Mar 24, 2010
Messages:
1,141
Likes:
219
Location:
Fairview, Or
• Like x 1
15. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Thank you, NG, nsaspook.

I still remember that a pulse or rectangular wave could only have a DC component if it's symmetric around the y-axis. I might be wrong so please bear with me and correct me. In my view, the 1st waveform will have a DC component while the 2nd one won't. Is this correct?

Which of the two waveforms is used in PWM analysis?

The components of a pulse wave occur at multiples of fundamental frequency. For example, if the frequency is 100 Hz then the components will be spaced from each other at 100 Hz intervals.

I hope this power spectrum for a pulse wave is correct one. Assuming it's correct, it looks like there is quite a loss of power because the components other than the DC one contain significant power. The value of DC component increases as duty cycle is increased as the graph in the post above shows. Thanks.

We almost always use RC circuit as a low pass filter but LR circuit can also be used as a low pass filter because impedance for an inductor is Lw which means high frequency components will get attenuated when passing thru the inductor.

Regards
PG

#### Attached Files:

File size:
23.1 KB
Views:
395
• ###### pulse333.jpg
File size:
26.2 KB
Views:
443
Last edited: Jun 1, 2014

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13

17. ### nsaspookWell-Known Member

Joined:
Mar 24, 2010
Messages:
1,141
Likes:
219
Location:
Fairview, Or
Why do you think there is no DC component if it's symmetric from 0 to 1 and 1 to 0 to a resistive load during the integration of a unipolar waveform?

18. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Hi

It looks like I was totally wrong in saying that a pulse or rectangular wave could only have a DC component if it's symmetric around the y-axis.

Let's first talk about Fourier series of a square first. It is said that Fourier series of odd square wave consists of odd harmonics of a sine waves as shown below.

But Fourier series of an even square wave is given as follows.

I believe the above Fourier series for an even square wave can also be written this way. Please let me know if I'm correct.

Further I believe that magnitude spectrum, not amplitude spectrum, would look the same for both odd and even square waves.

Now let's talk about pulse or rectangular train. This shows the cases of both even and odd pulse trains. I believe just like even and odd square waves, the only main difference is that of phase.

I'm sorry that I wasn't able to properly do calculations myself because I'm little tight on time and further my Fourier analysis part is somewhat rusty these days.

I hope this power spectrum for a pulse wave is correct one but there there seems to be one problem that it doesn't show any power for DC component. Assuming it's correct, it looks like there is quite a loss of power because the components other than the DC one contain significant power. The value of DC component increases as duty cycle is increased as the graph in the post above shows. Thanks.

We almost always use RC circuit as a low pass filter but LR circuit can also be used as a low pass filter because impedance for an inductor is Lw which means high frequency components will get attenuated when passing thru the inductor.

Thank you for the help.

Regards
PG

References:
1: http://fourier.eng.hmc.edu/e101/lectures/handout2/node5.html
2: http://mathforum.org/key/nucalc/questions.html
3: http://cnx.org/content/m28717/1.1/#element-566
5: http://www.dspguide.com/graphics/F_13_10.gif
6: http://cnx.org/content/m28717/1.1/
7: http://mathworld.wolfram.com/FourierSeriesSquareWave.html
8: http://en.wikipedia.org/wiki/Pulse_wave
10: http://www.linuxfocus.org/common/images/article271/fig_06c.png
11: http://www.learnemc.com/tutorials/Time-Frequency/Time_Frequency_Notes.html
12: http://www.linuxfocus.org/common/images/article271/fig_06c.png
13: http://ultrasound.ee.ntu.edu.tw/classnotes/ckt2/Chapter12.pdf
14: https://www.seas.upenn.edu/~kassam/tcom370/n99_2.pdf
15: http://en.wikibooks.org/wiki/Signals_and_Systems/Fourier_Series_Analysis#Energy_Spectrum
16: http://www.intmath.com/fourier-series/3-fourier-even-odd-functions.php
17: http://cnx.org/content/m10838/latest/#element-459
18: http://www.ece.rutgers.edu/~psannuti/ece224/PEEII-Expt-6-07.pdf

File size:
26.1 KB
Views:
661
File size:
7.9 KB
Views:
522
File size:
7.7 KB
Views:
524
File size:
8.7 KB
Views:
535
File size:
219.9 KB
Views:
522
File size:
2.5 KB
Views:
617
19. ### PG1995Active Member

Joined:
Apr 18, 2011
Messages:
1,681
Likes:
13
Hi

I wanted to clear something out of curiosity. Why would I need PID control implemented in form of inner loop? A single loop using P&O is enough to achieve the objective of maximizing power. What's the purpose and/or advantage of using PID control loop? Could you please tell me? I'm saying this because it looks like a redundancy to me when using a single loop is enough. Thank you.

20. ### steveBWell-Known MemberMost Helpful Member

Joined:
Jan 16, 2009
Messages:
1,307
Likes:
639
In general, control is not limited to controlling one output with one input. With multivariable control, one either has to control many variables by designing an overall controller that simultaneously considers all variables of interest, or one can design by creating inner loops that progressively deal with each variable of interest. The inner loops are made to have fast response, and then this simplifies the control design for other variables that do not need to be controlled on a fast time scale. The latter method is a "divide and conquer" method, while the former is a very comprehensive method. Most of the best controller designs I've seen for real systems, are fairly complex with inner and outer loops and multivariable control in some cases, where it is warranted.

Also, in a general case of a maximizing controller, there are some special aspects to consider since the control problem is not a strict "regulation" problem. Hence, making the system easier to control with an inner regulator, may ease the issues of trying to make a maximizing controller, as a general rule.

In this particular case, there are two possible reasons for using the method I suggested. First, it might simplify the design and construction. This might seem ironic, because the controller is more complicated, but if you simplify a controller too much, sometimes you lose the ability to control the system well. Second, you may get better overall performance. As to whether this is actually true, you would need to design by both methods and see. But, my experience tells me that the dual loop is a better way. You may discover I'm wrong in this particular case, or you may eventually find that I was right.

Note, that I provided you simulation results using both methods. I did not spend more than a half hour on either method, so you can certainly criticize my presentation and claim that I did not put enough effort into the P&O. However, I was able to show much better performance with the dual feedback loop, and I gave equal effort to both methods when I tried to design them. Still, I would normally put much more time into studying both methods and determining for sure that the dual loop is best, if it were my project. Hence, I am hesitating to say anything definitively.

Also, keep in mind that there are many control strategies one can take, and you don' have to use either of these methods. Fuzzy logic control, pole placement design and LQR design approaches (just to name a few) could also be tried, and might help provide a good solution.

Normally, with control design, one takes the approach to use use the simplest method that meets the specs, and robustness and stability margins are key things to be combined with meeting system specifications. Note, that you are not really designing from this point of view because it is a school project and not a true product design. Also, since this is not my project, I'm not going too far down that path either. Hence, in the end, perhaps neither one of us will really know the answer for sure.

• Like x 1

Joined:
Sep 8, 2013
Messages:
1,218
Likes:
206
Location: