PDA

View Full Version : Sigma Delta - Modeling s-function


subh
12-17-2007, 05:33 AM
Hey guys,

I have a continuous-time sigma-delta converter that includes a
continuous-time transfer function H(s) at the input, followed by a
sampler, quantizer and a digital-to-analog converter (DAC) in the
feedback path. I'm trying to model the transfer function H(s) that
includes some non-ideal effects and hence, the order of H(s) is higher
than that of the system (say for the second-order system, I'm getting
a fourth-order H(s) term).

If I use simulink blocks to model this, the simulation speed is very
slow and it doesn't tend to converge. So, if anyone has modelled a
continuous-time transfer function using s-function blocks (I guess
writing C codes will speed it up), please suggest me how to design
it.

Matlab has an example in the sfundemos for continuous-time c-code
transfer function, but if I incorporate it, I initially get an input
port width error (for quantization levels exceeding 2) and hence,
either I need to use a quantizer with 2 levels or change the
inputPortWidth to "DYNAMICALLY SIZED" in the example code itself.

Any help will be great!

Thanks,
Subh.

Tim Wescott
12-17-2007, 07:48 AM
On Sun, 16 Dec 2007 21:33:53 -0800, subh wrote:

> Hey guys,
>
> I have a continuous-time sigma-delta converter that includes a
> continuous-time transfer function H(s) at the input, followed by a
> sampler, quantizer and a digital-to-analog converter (DAC) in the
> feedback path.

So far so good. Is H(s) in the loop?

> I'm trying to model the transfer function H(s) that
> includes some non-ideal effects and hence, the order of H(s) is higher
> than that of the system (say for the second-order system, I'm getting a
> fourth-order H(s) term).

What are these non-ideal effects? If they are nonlinearities, why not
include them in the filter model? Or do you mean that you _wish_ the
input filter were 2nd order, but you _know_ that, like all physical
systems it is of infinite order, and you're settling on 4th order as a
good-enough model?

> If I use simulink blocks to model this, the simulation speed is very
> slow and it doesn't tend to converge. So, if anyone has modelled a
> continuous-time transfer function using s-function blocks (I guess
> writing C codes will speed it up), please suggest me how to design it.

I doubt that C code will speed up the model of a simple linear filter.
If you're just putting in one great big 4th-order transfer function block
then it would be wise to split it into 1st- and 2nd-order blocks --
polynomials are not well conditioned numerically, and this will show.
Better, implement it as a state-space system, making sure to choose a
state evolution matrix that's well conditioned.

Are you sure that it's having difficulty because of your linear filter?
Have you tried this with a 2nd-order ideal model and gotten different
results? It may be some other part of your model that's giving the
solver fits.

> Matlab has an example in the sfundemos for continuous-time c-code
> transfer function, but if I incorporate it, I initially get an input
> port width error (for quantization levels exceeding 2) and hence, either
> I need to use a quantizer with 2 levels or change the inputPortWidth to
> "DYNAMICALLY SIZED" in the example code itself.

You're barking up the wrong tree. You should be able to implement H(s)
within MATLAB just as efficiently as you could using C. Learn to
implement blocks in C because you want to, or because you _really_ have
to, not because you _think_ you have to.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html

subh
12-17-2007, 06:53 PM
Thanks for your reply.

On Dec 16, 11:48 pm, Tim Wescott <[email protected]> wrote:
> On Sun, 16 Dec 2007 21:33:53 -0800, subh wrote:
> > Hey guys,
>
> > I have a continuous-time sigma-delta converter that includes a
> > continuous-time transfer function H(s) at the input, followed by a
> > sampler, quantizer and a digital-to-analog converter (DAC) in the
> > feedback path.
>
> So far so good. Is H(s) in the loop?

Yes, H(s) is in a negative feedback loop.

>
> > I'm trying to model the transfer function H(s) that
> > includes some non-ideal effects and hence, the order of H(s) is higher
> > than that of the system (say for the second-order system, I'm getting a
> > fourth-order H(s) term).
>
> What are these non-ideal effects? If they are nonlinearities, why not
> include them in the filter model? Or do you mean that you _wish_ the
> input filter were 2nd order, but you _know_ that, like all physical
> systems it is of infinite order, and you're settling on 4th order as a
> good-enough model?
>

No, I guess I should be more clear about this. When you initially
model the filter, you try using the most ideal model available (say
for an integrator, H(s) = 1/s). As you introduce non-idealities in it,
like gain and bandwidth, the model order will increase to say 2nd
order rather than just the first order.


> > If I use simulink blocks to model this, the simulation speed is very
> > slow and it doesn't tend to converge. So, if anyone has modelled a
> > continuous-time transfer function using s-function blocks (I guess
> > writing C codes will speed it up), please suggest me how to design it.
>
> I doubt that C code will speed up the model of a simple linear filter.
> If you're just putting in one great big 4th-order transfer function block
> then it would be wise to split it into 1st- and 2nd-order blocks --
> polynomials are not well conditioned numerically, and this will show.
> Better, implement it as a state-space system, making sure to choose a
> state evolution matrix that's well conditioned.


I think that's a good suggestion. I will try splitting it up or work
using the state-space model. I'm not very good at state-space modeling
and hence was avoiding that.

>
> Are you sure that it's having difficulty because of your linear filter?
> Have you tried this with a 2nd-order ideal model and gotten different
> results? It may be some other part of your model that's giving the
> solver fits.

Yes, its the filter that causes the problem. The ideal model works
fine.
>
> > Matlab has an example in the sfundemos for continuous-time c-code
> > transfer function, but if I incorporate it, I initially get an input
> > port width error (for quantization levels exceeding 2) and hence, either
> > I need to use a quantizer with 2 levels or change the inputPortWidth to
> > "DYNAMICALLY SIZED" in the example code itself.
>
> You're barking up the wrong tree. You should be able to implement H(s)
> within MATLAB just as efficiently as you could using C. Learn to
> implement blocks in C because you want to, or because you _really_ have
> to, not because you _think_ you have to.
>
> --

Yes, I think I should do that now. Do you think, mex functions in C
are a better way to approach c-codes and then include that function in
a simulink block or writing s-functions for simulink directly?

Thanks for your suggestions.
Subh.