continuous and discrete time systems

Status
Not open for further replies.

PG1995

Active Member
Hi

I have trying to make sense out of **broken link removed** for the last two hours. It seems all garbage and as you can see there are obvious mistakes. At first the guy is trying to state the equation for RC lowpass filter as a continuous time system, and then, I think, he is stating the discrete time equation for the filer. Can you make any sense out of this? Or, can you give me correct version of it? Thank you.

Regards
PG
 
Can you make any sense out of this?
I can make sense out off some of it and some of it is intractable.


Or, can you give me correct version of it?

In order to make a correct version of it, we need a proper problem statement. What is the goal and what are you trying to do. As written, there is no stated problem and no stated goal.

With a proper problem statement or goal, yes we can give a correct version of it.
 
Hi

The discussion was about the properties of continuous-time and discrete-time systems. There was no specific problem statement. For instance, **broken link removed** in the textbook the author is simply deriving the formulae for RC circuit where the 'RC circuit' is looked on more as a continuous-time system. I don't need the derivation of the expressions. You can just state the correct version of the formulae, that's all. Thank you.

Regards
PG
 

Which formula? The statement is too vague. When you say "state the formula for an RC circuit", I can think of more than 10 different formulas I could derive and state as being very relevant for the circuit.
 
Last edited:
Thanks for the reply.

Which formula? The statement is too vague. When you say "state the formula for an RC circuit", I can think of more than 10 different formulas I could derive and state as being very relevant for the circuit.

The **broken link removed** in my last post might help you to see what is being done on **broken link removed**. For example, **broken link removed** is what I think is being done. I hope it's somewhat clear now. Thank you.

Regards
PG
 
Last edited:
So, you just want to derive the state equation, or the differential equation for the circuit. This is just an application of Kirchhoff's Voltage Law (KVL). The resistor and capacitor are in series, so the current is the same between them. The output voltage is the same as the capacitor voltage, and the capacitor voltage is the state variable for the system. We know the current in the cap is i=C dVc/dt, and this current must flow through the resistor, hence, Vr=RC dVc/dt. Hence KVL is directly

Vin=Vr+Vc=RC dVC/dt + Vc

And, Vout and Vc are the same, so it should be clear now.
 
Thanks a lot.

And, Vout and Vc are the same, so it should be clear now.

Yes, it is clear now. Actually I wasn't having too much trouble with this part. I was more worried about **broken link removed** because I couldn't make head or tails of it. Please see if you can decipher any of it. Thank you.

Regards
PG
 
Again, there is no clear context for what is being attempted. My best guess is that you are trying to make a discrete time version of the first order RC system. Presumably, you are sampling with period T and would like your sampled system to match the response of the real system.

Please confirm what you are trying to do because a properly phrased question is an important part of the learning process.
 
Thank you for the reply.

My best guess is that you are trying to make a discrete time version of the first order RC system. Presumably, you are sampling with period T and would like your sampled system to match the response of the real system.

Yes, I also think so. It is discrete time version of first order RC system. Actually I took a picture of someone else's notes and the guy who had written it didn't have any idea what was being done there. I'm sorry for all this confusion. Thanks.

Regards
PG
 
Last edited:
OK, the reason why I asked is that I didn't recognize the form of the solution given, but since I wasn't sure of the goal, I couldn't be sure if it was right or wrong.

The process of discretization can take a few different forms depending on the accuracy needed, the type of sampling that is used, and the relation between the sampling frequency and the system time constants. However, I can present the most typical and formal method as follows.

First order systems generally have the following form in continuous time, where τ is the system time constant, y(t) is the output and x(t) is the input.

[latex] \tau\cdot \frac{y(t)}{dt}+y(t)=x(t) [/latex]

Discretization of this can be done formally and with mathematical correctness when zero-order hold sampling is used. Zero-order hold is the process of keeping all sampled values constant during the entire sampling period. Let's call the sampling period T, in which case we expect the discrete version of the system to match the continuous time version of the system at any point in time t=nT, where n is an integer that represents the discrete time.

The reason why this problem becomes simple for zero-order hold sampling is that during any sampling period the input signal is constant, and it turns out that the differential equation can be solved exactly in that case. I think you have learned how to solve a differential equation of this form, where C is a constant, so I will leave out the details..

[latex] \tau\cdot \frac{y(t)}{dt}+y(t)=C [/latex]

If we consider an initial value for y(t) at time t=nT, and want the solution for time t>nT, the solution is as follows.

[latex] y(t)=(y(nT)-C)\cdot \exp(\frac{-(t-nT)}{\tau})+C [/latex]

But, (if we limit t to the range nT<t<(n+1)T ) the constant C is just the initial input signal value x(nT) because the input signal is a staircase type of function after sampling. Hence the solution is as follows.

[latex] y(t)=(y(nT)-x(nT))\cdot \exp(\frac{-(t-nT)}{\tau})+x(nT)[/latex]

This can be rewritten using the [n] notation rather than (nT), and rearrangement with algebra results in the following.

[latex] y(t)= \exp(\frac{-(t-nT)}{\tau})\cdot y[n]+\left(1-\exp(\frac{-(t-nT)}{\tau})\right)\cdot x[n][/latex]

The last step is to realize that in a discrete time system, there is no meaning to time between the values of nT and (n+1)T, hence the above form is not proper and we need to replace t with (n+1)T because we only care about the value at the next time sample. This results in the following.

[latex] y[n+1]= \exp(\frac{-T}{\tau})\cdot y[n]+\left(1-\exp(\frac{-T}{\tau})\right)\cdot x[n][/latex]

This basic process can be applied to more complex linear systems with higher order differential equations. There are very powerful techniques that can be applied to get the answer with relatively little work. These methods are typically taught in systems theory courses.
 
Last edited:
Thank you very much, Steve.

I need to go through it several times before asking any follow-on questions.

Best wishes
PG
 
Hi,


That first page looks like a simple numerical method for solving a differential equation more than a discreet time solution, but the two are indistinguishable in a way. If you consider T to be the sample time for the discreet system then that is just h in the numerical solutions of an ODE. The one shown looks like a predictor-corrector method and is not self starting.

To see this better look at some common numerical methods i'll list a few here:
Euler's (the simplest of all, first order) y[n+1]=y[n]+h*y'[n]
Heun's (one step up from Euler's)
Taylor's
Nystrom's (not self starting) y[n+1]=y[n-1]+2*h*y'[n] note the y[n-1] term which means it needs a value from the past possibly not yet calculated.
Runge-Kutta Methods, considered pretty good (RK3, RK4, RK5).
Adams Bashforth (not one of my favorites by any measure)
Predictor-corrector methods and modified predictor-corrector methods:
Milne's
Hamming's

These all attempt to solve the ODE numerically. The methods that depend on a value in the past such as y[n-1] or x[n-1] are not self starting.
Since there is no real way to tell the accuracy it is considered good practice to use an N^th order method followed by an (N+1)^th order method and compare the results to see if the higher degree method worked that much better. For example, using an RK 3rd order followed by an RK 4th order would be a good way to go.

Gear's is a very good one being iterative.

You can also turn your Z transforms into difference equations which provide solutions in a similar manner more or less.
 
Last edited:
Thank you very much, Steve.

I need to go through it several times before asking any follow-on questions.

Best wishes
PG

No problem, take your time.

While you are studying this, you can compare what I derived with what you provided. There is certainly a similarity in the form of the equations, and if you calculate the numbers (a and b), you will find they are numerically similar when T is much smaller than tau=RC. Hence, it is likely that a particular method was used there, and this method is limited to systems that are sampled at a rate much faster than the system time constant.

There is another approximate form called the forward Euler method, which just amounts to approximating the derivative dy(t)/dt as (y[n+1]-y[n])/T. This also works only when T is much smaller than tau=RC. This should make sense to you because you know that when you approximate a time derivative, you need to use a small change in time to be accurate. This will give the solution of

[latex] y[n+1]=\left( 1-\frac{T}{\tau}\right) y[n]}+\frac{T}{\tau}x[n] [/latex]

You can also arrive at this form if you use my result and make the substitution exp(-T/τ)=1-T/τ. Check the numbers when T is small and you will see it works.

There is also the backward Euler method, in which the derivative is written as dy(t)/dt is about equal to (y[n]-y[n-1])/T. This will result in the following, which looks more similar to the form you showed.

[latex] y[n]=\left( 1-\frac{T}{\tau}\right) y[n-1]}+\frac{T}{\tau}x[n] [/latex]

Still, the coefficients are different, even if they are approximately the same in the limit as T goes to zero. Hence, there may be a method to the form you gave, but I'm not familiar with the principle by which it is derived.

As an exercise, you should compare the numbers of the Euler method with the method you showed and see which is more accurate compared to the rigorous form I showed previously.
 
Thanks a lot, MrAl, Steve.

Q1:

Yes, what you think is correct. I learned to solve some of the differential equations but it was about a year ago and my knowledge of it is a little rusty. So, please give me a clue here. In this problem the equation is of the following type:

**broken link removed**

I was wondering how you got this expression:

[latex] y(t)=(y(nT)-C)\cdot \exp(\frac{-(t-nT)}{\tau})+C [/latex]

So, if you don't mind then please let me know. Thank you.

Q2:
Please have a look on **broken link removed** related query. Thank you.

Regards
PG

PS: I now see that Steve and MrAl have already replied. As Steve has suggested that the expression in yellow highlight is correct one, therefore I think I can give this thread a little rest and will just memorize the stuff for time being. But if someone likes to reply, then you are always welcome. Thanks a lot.
 
Last edited:
I answered this question in my above post. If you look at the backward Euler method, you will see the form is very similar, but the a and b coefficients are different. Still, they match in the limit as T goes to zero, which shows they have validity.

I pointed out that if you compare the values of the a and b coefficients for the rigorous method, the Euler methods and the method that you show in yellow, they are very similar in value when T is small compared to tau=RC.

By the way, why do you think the green expression is OK, but the yellow is not. It seems to me that they are similar but the yellow has the values of the a and b coefficients worked out. As I mentioned, I'm not sure of the principle by which the a and b coefficients are derived, but I think it must be an accepted method since it gives a useful result. I expect that if we consult a book (which I will try to do later) we can discover the name of the method. There is another method you might want to look at called the Tustin Method. As I mentioned, there are various different techniques for discretization, but the first one I provided is the most rigorous form in that it is the exact solution if the input signal is exactly representable by the staircase function created by sampling (for example, a step input function would give an exact solution).

Did you compare the values of a and b for the various methods, as I suggested? You can plot them as a function of the ratio T/tau, in the range of 0< T/tau<1, which is the practical range you might actually use in practice.
 
Hi,

Steve:
Isnt that equation just derived from Euler's Method (see my previous post). I wrote out the entire thing:
y[n+1]=y[n]+h*y'[n]
or
y[n]=y[n-1]+h*y'[n]
where h=T.

Steve, PG:
Also, if you look at some values using that equation you'll see that as T gets smaller the approximation gets better by roughly the same degree that T gets smaller (see these results using two different values of T where PErr is the percent error between the true exact value and the approximate value).
This suggests taking the limit of the right hand side as T approaches zero and indeed doing this we get the exact expression for Vc(t):
Vc(t)=Vin*(1-e^(-t/RC))

Code:
[There are two sets of data here to be compared...one for T=0.1 and one for T=0.01]
[Also, when T is infinitesimal the true solutions always match the approximate solutions for any time t]
[Time t runs from top to bottom, from t=0 to t=2 seconds with increments of 0.1 seconds, and with RC=1 and Vin=1]


T=0.100000
True      Approx    PErr
0.095163  0.090909  0.044697
0.181269  0.173554  0.042564
0.259182  0.248685  0.040499
0.329680  0.316987  0.038502
0.393469  0.379079  0.036574
0.451188  0.435526  0.034713
0.503415  0.486842  0.032921
0.550671  0.533493  0.031195
0.593430  0.575902  0.029537
0.632121  0.614457  0.027944
0.667129  0.649506  0.026416
0.698806  0.681369  0.024952
0.727468  0.710336  0.023551
0.753403  0.736669  0.022212
0.776870  0.760608  0.020933
0.798103  0.782371  0.019713
0.817316  0.802155  0.018550
0.834701  0.820141  0.017443
0.850431  0.836492  0.016391
0.864665  0.851356  0.015391



T=0.010000
True      Approx    PErr
0.095163  0.094713  0.004724
0.181269  0.180456  0.004489
0.259182  0.258077  0.004262
0.329680  0.328347  0.004044
0.393469  0.391961  0.003833
0.451188  0.449550  0.003630
0.503415  0.501685  0.003436
0.550671  0.548882  0.003249
0.593430  0.591609  0.003069
0.632121  0.630289  0.002898
0.667129  0.665305  0.002734
0.698806  0.697005  0.002577
0.727468  0.725703  0.002427
0.753403  0.751682  0.002284
0.776870  0.775201  0.002148
0.798103  0.796493  0.002018
0.817316  0.815767  0.001895
0.834701  0.833217  0.001778
0.850431  0.849013  0.001668
0.864665  0.863314  0.001563
 
Last edited:
Thank you very much, Steve, MrAl.

By the way, why do you think the green expression is OK, but the yellow is not. It seems to me that they are similar but the yellow has the values of the a and b coefficients worked out.

My reply is **broken link removed**. In the attachment I referenced this Wikipedia article.

Regards
PG
 
Hello again,


Now try using the Euler Method i posted several posts back!
 
I was wondering how you got this expression:

[latex] y(t)=(y(nT)-C)\cdot \exp(\frac{-(t-nT)}{\tau})+C [/latex]

So, if you don't mind then please let me know. Thank you.

There are many ways to get this expression, including trial and error. However, the method you show here is perfectly fine since the equation is of the form defined. Here P=1/tau and Q=C/tau. You will get a solution of the correct form, and then you need to choose the constant "c" (little c, not big C) to match the initial condition. There is also a time shift that is needed, but if you find this confusing, then just do the case with n=0, and realize that every time step requires the same solution with each value of nT behaving like t=0 for the initial condition.
 
Hello again,


Yes i used Euler's and got the same results.

Just for a little comparison of that method with the z transform of the circuit and a bilinear transform to difference equation technique i'll post the numerical results here. Note how much more accurate the z transform+bilinear transform to difference equation results come out (on the order of 1/50 times less error percent). Note also that in the second set of data with the time increment T reduced by one half the percent error of that method only halved while the z transform plus method quartered which means it even went down my a much larger percentage roughly the square of the ratio of the time increments.

Code:
[PErr is the percent error using that method, PErr(z) is the percent error using the z transform plus method, both using the same time step T]


T=0.100000
True      Approx    PErr      zTransform  PErr(z)
0.095163  0.090909  0.044697  0.095238   -0.000794
0.181269  0.173554  0.042564  0.181406   -0.000754
0.259182  0.248685  0.040499  0.259367   -0.000716
0.329680  0.316987  0.038502  0.329904   -0.000679
0.393469  0.379079  0.036574  0.393722   -0.000643
0.451188  0.435526  0.034713  0.451463   -0.000609
0.503415  0.486842  0.032921  0.503705   -0.000576
0.550671  0.533493  0.031195  0.550971   -0.000545
0.593430  0.575902  0.029537  0.593736   -0.000514
0.632121  0.614457  0.027944  0.632427   -0.000486
0.667129  0.649506  0.026416  0.667434   -0.000458
0.698806  0.681369  0.024952  0.699107   -0.000431
0.727468  0.710336  0.023551  0.727764   -0.000406
0.753403  0.736669  0.022212  0.753691   -0.000382
0.776870  0.760608  0.020933  0.777149   -0.000359
0.798103  0.782371  0.019713  0.798373   -0.000338
0.817316  0.802155  0.018550  0.817575   -0.000317
0.834701  0.820141  0.017443  0.834949   -0.000297
0.850431  0.836492  0.016391  0.850668   -0.000279
0.864665  0.851356  0.015391  0.864890   -0.000261




T=0.050000
True      Approx    PErr      zTransform  PErr(z)
0.095163  0.092971  0.023035  0.095181   -0.000198
0.181269  0.177298  0.021911  0.181303   -0.000188
0.259182  0.253785  0.020824  0.259228   -0.000179
0.329680  0.323161  0.019775  0.329736   -0.000169
0.393469  0.386087  0.018763  0.393533   -0.000161
0.451188  0.443163  0.017788  0.451257   -0.000152
0.503415  0.494932  0.016850  0.503487   -0.000144
0.550671  0.541888  0.015949  0.550746   -0.000136
0.593430  0.584479  0.015083  0.593507   -0.000128
0.632121  0.623111  0.014254  0.632197   -0.000121
0.667129  0.658150  0.013459  0.667205   -0.000114
0.698806  0.689932  0.012698  0.698881   -0.000108
0.727468  0.718759  0.011972  0.727542   -0.000101
0.753403  0.744906  0.011278  0.753475   -0.000095
0.776870  0.768623  0.010616  0.776940   -0.000090
0.798103  0.790134  0.009986  0.798171   -0.000084
0.817316  0.809645  0.009386  0.817381   -0.000079
0.834701  0.827343  0.008816  0.834763   -0.000074
0.850431  0.843395  0.008274  0.850491   -0.000070
0.864665  0.857954  0.007761  0.864721   -0.000065
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…