Sampled Data Analysis Using LTSpice

What is this page about? Sampled-data systems are interesting if you are considering closing your control loops via a digital controller or compensator of some sort. A starting point is to model the system using an analogue simulation in LTSpice and then translate it into a digital form. This isn't an easy process if you're starting from scratch because you need to generate a transfer function in terms of z before you can create the difference equations to plug into your digital compensator.

There is a second catch: how exactly do you model the compensator in LTSpice?  This page canters through the process of using XFunc (a DOS program by Henry Yiu) that generates transfer functions in s or z from netlists (provided you are not too ambitious!) and a simple utility written by me that generates an importable .LIB file that can be included in your LTSpice model.  If you manage to follow it, it will give you a starting point to creating a digital emulation of an analogue circuit that can be tested in LTSpice.

You can download some files from http://www.richard-aston.com/LTSpice/Downloadable/



Saint Mike of Englehart had the good sense to add a sample and hold block to LTSpice. It's easy to cascade them to make a sort of CCD analogue delay line.

You need a block to add the outputs.

The second picture shows three blocks. The first delays the input signal and the block below it delays the output. The right-hand block

combines the signals.

 

It's basically an interpretation of

Rearrange and fiddle about a bit, we get:

So, what's the easy way to find values for the gain coefficients? If you are a purist, you can get out your pad and do the algebra.

I, however, am not a purist. I want to start with something I understand like a bunch of resistors and capacitors and click a few buttons and see the lovely results.

XFunc is a great little DOS program written by Henry Yiu. Find it and download it.

I found it here: http://www.ufrgs.br/eng04030/Xfunc.zip

The manual is here: http://www.ufrgs.br/eng04030/MANUAL%20XFUNC.pdf

With XFunc, you can input a netlist and extract a symbolic transfer function in s for it. Neat, huh? Even neater is that you can then input an expression for the sampling period and pull out the TF in terms of z.

Tip: don't edit your netlists in LTSpice. It doesn't save them very nicely. Better to use Notepad or something.

You now need a little utility wot I wrote which you can get here: http://www.richard-aston.com/LTSpice/XFuncDecoder2.exe

There's only two buttons, so I won't explain it. Open the .MOD file and extract the coefficients of z. Include it on your LTSpice diagram.

Don't forget to add Ts as a parameter for both the delay lines.

Here's what the output of XFuncDecoder2 looks like:

Here's the waveforms:

We can apply this to a simple buck regulator. First, with a synthetic variable DC transformer.

This uses behavioural sources to make variable resistors. The voltage at 'RATIO' musn't be zero for obvious reasons.

I know it looks like it doesn't work but it does so don't email me. Letters that suggest that because the writer doesn't understand the circuit

it must be me rather than they who are the idiot will not receive any response! I don't understand why it works. It just does. Mind you, it did work

better on ECA than LTSpice (the 100G resistor to ground wasn't ever needed) but then, ECA allowed you to use conductances preceded by a modulator.

ECA was really very good.

Exhibit A: Using an analogue feedback loop.




Exhibit B: With the sampled-data feedback path

If you reduce the sampling period, it gets to be a closer approximation. Note how it gets closer to instability. There is an intrinsic lag due to the sampling interval.

Exhibit C: This version uses a series switch instead of the DC transformer.



Which gives pleasantly similar results...