Continue to Site

# sample-and-hold circuit simulation in MATLAB

Status
Not open for further replies.

#### euniceliu

##### Newbie level 5
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.

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-Vo(n-1).

### euniceliu

Points: 2
thank you very much! i will have a try.

Hi, JoannesPaulus, I have another question. If "dVo" can be regarded as Vo-Vo(n-1), then how can I get Vo from a set of Vi since I don't know the Vo(n-1) especial when n=1. Thanks!

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=Vo(n-1)+(Vi-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=Vi and therefore dVo=dVi (but only at the sampling times). This is the easiest approximation.

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.

Status
Not open for further replies.