| Author |
Message |
euniceliu
Joined: 26 Nov 2008 Posts: 8
|
04 Nov 2009 2:48 sample-and-hold circuit simulation in MATLAB |
|
|
|
|
Does anyone have ideas about how to simulate a sample-and-hold circuit using MATLAB code (not simulink)? The model I have is
Vo = Vi + (a0+a1*Vi+a2*Vi^2)*(dVo/dt).
I don't know how to derive the solution of Vo to model it? Thank you in advance.
|
|
| Back to top |
|
 |
JoannesPaulus
Joined: 19 Mar 2008 Posts: 261 Helped: 44 Location: USA
|
04 Nov 2009 3:02 sample-and-hold circuit simulation in MATLAB |
|
|
|
|
you need not solving the "differential equation", since it is not one!
The model is simply telling you that the output of the SHA is non-linear and it is giving some coefficients. The term "dt" is your sampling period and "dVo" is the difference Vo(n)-Vo(n-1).
|
|
| Back to top |
|
 |
euniceliu
Joined: 26 Nov 2008 Posts: 8
|
04 Nov 2009 3:37 sample-and-hold circuit simulation in MATLAB |
|
|
|
|
thank you very much! i will have a try.
Added after 33 minutes:
Hi, JoannesPaulus, I have another question. If "dVo" can be regarded as Vo(n)-Vo(n-1), then how can I get Vo(n) from a set of Vi(n) since I don't know the Vo(n-1) especial when n=1. Thanks!
|
|
| Back to top |
|
 |
Google AdSense

|
04 Nov 2009 3:37 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
JoannesPaulus
Joined: 19 Mar 2008 Posts: 261 Helped: 44 Location: USA
|
04 Nov 2009 18:46 sample-and-hold circuit simulation in MATLAB |
|
|
|
|
If I understand correctly, what you are trying to do is a linear interpolation of your input, adding some distortion to model the effect of the non-linearity in the sample and hold circuit. So,
Vo(n)=Vo(n-1)+(Vi(n)-Vi(n-1))*dVo/dt is your linear interpolation, for n=2,... and Vo(1)=0;
The problem is how to model dVo, which is the local derivative of your signal. In the ideal SHA Vo(n)=Vi(n) and therefore dVo(n)=dVi(n) (but only at the sampling times). This is the easiest approximation.
|
|
| Back to top |
|
 |
dick_freebird
Joined: 04 Mar 2008 Posts: 312 Helped: 45 Location: USA
|
06 Nov 2009 6:30 sample-and-hold circuit simulation in MATLAB |
|
|
|
|
I think you might be better off code-modeling the various
functions and artifacts of interest, in a more straightforward
and expressive way. Why would you want to do it using
polynomial math, when you can talk sample time and slope
error, sample pedestal, through-delay and rise-fall? I bet
there's an elegant one-liner that's like a koan or something,
if you only wanted the event value and not the details.
There's probably verilog-a code out there already that you
could dig up, rip up and turn into MATLAB or whatever.
|
|
| Back to top |
|
 |