Arbitrary delay in LTspice

Awhile back we were trying to figure out how to make a voltage-variable delay line in LTspice. Turns out there is a way to use one signal to delay another: there's an undocumented function delay(x,y). Unlike the documented one, delay y can be a simulation variable, like so:

Version 4 SHEET 1 880 680 WIRE -96 112 -112 112 WIRE 96 112 80 112 WIRE 112 112 96 112 WIRE 304 112 288 112 WIRE 80 144 80 112 WIRE 288 144 288 112 WIRE -112 160 -112 112 WIRE -112 256 -112 240 WIRE 80 256 80 224 WIRE 288 256 288 224 FLAG 80 256 0 FLAG 288 256 0 FLAG 96 112 input FLAG 288 112 delayed FLAG -112 256 0 FLAG -112 112 delay SYMBOL voltage 80 128 R0 WINDOW 3 24 98 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value SINE(0 1 0.5) SYMBOL bv 288 128 R0 SYMATTR InstName B1 SYMATTR Value V=delay(v(input),v(delay)) SYMBOL voltage -112 144 R0 WINDOW 3 -75 149 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V2 SYMATTR Value PULSE(0 4 0.2 3 3 1) TEXT 208 312 Left 2 !.tran 5 TEXT 168 48 Left 2 ;This shows how to make a variable delay.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
 Click to see the full signature
Reply to
Phil Hobbs
Loading thread data ...

It avoids complications by refusing to do negative delay.

We're about to ship the first unit of an 8-channel waveform playback box. It stores big waveform files on an SD card and each channel has a DDS-clocked FIFO and a DAC. We added a programmable time-shift parameter per channel, that allows us to tweak time alignment, up to

+-999.999 samples, fractional part interpolated, with obvious causality concerns. We pad the waveform data with 1024 zero samples, when we open the file and again at EOF.

How did you find the delay() function? I bet LT Spice has all sorts of undocumented tricks. Even the documented features aren't usually very well documented.

--
John Larkin         Highland Technology, Inc 
picosecond timing   laser drivers and controllers 
 Click to see the full signature
Reply to
John Larkin

I have a collection of manuals, tutorials and undocumented features in LTspiceTutorials.zip on the Simulation Tools & Macros Page of my website. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

It was in the undocumented features file on the LTspice Yahoo group, under files/FAQ.

formatting link

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
 Click to see the full signature
Reply to
Phil Hobbs

[snip]

What's that supposed to do? When I run your file I get bizarre results...

almost like an FM function ?? ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

Works OK when you don't slew the delay so fast relative to the incoming signal... then you can see it working properly. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

Right. It has a sine wave source, a ramp, and a behavioural voltage source which is the sine wave delayed by the value of the ramp voltage in volts. The flat spot in the middle is where there's no data for the BV to use, but it catches up again at the end.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
 Click to see the full signature
Reply to
Phil Hobbs

Pondering my navel, I was wondering how to implement such a creature in PSpice.

I can't.

Mikey can because he writes the executable and can make a device model that looks back into the data stream.

But I can make a voltage-controlled all-pass that will be quite useful for simulating DLL's (delay-locked loops).

Watch for it on the Device Models & Subcircuits Page of my website. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.