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 ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
Arbitrary delay in LTspice
Started by ●April 8, 2015
Reply by ●April 8, 20152015-04-08
On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> wrote:>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: >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 jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
Reply by ●April 8, 20152015-04-08
On Wed, 08 Apr 2015 08:55:28 -0700, John Larkin <jlarkin@highlandtechnology.com> wrote:>On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs ><pcdhSpamMeSenseless@electrooptical.net> wrote: > >>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: >> > > >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.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 | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.
Reply by ●April 8, 20152015-04-08
On 04/08/2015 11:55 AM, John Larkin wrote:> On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs > <pcdhSpamMeSenseless@electrooptical.net> wrote: > >> 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: >> > > > 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. > >It was in the undocumented features file on the LTspice Yahoo group, under files/FAQ. http://tinyurl.com/kxrzmup Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
Reply by ●April 8, 20152015-04-08
On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> wrote:>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[snip]>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 HobbsWhat's that supposed to do? When I run your file I get bizarre results... <http://www.analog-innovations.com/SED/HobbsDelay_2015-04-08_10-25-36.jpg> almost like an FM function ?? ...Jim Thompson -- | James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.
Reply by ●April 8, 20152015-04-08
On Wed, 08 Apr 2015 10:29:58 -0700, Jim Thompson <To-Email-Use-The-Envelope-Icon@On-My-Web-Site.com> wrote:>On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs ><pcdhSpamMeSenseless@electrooptical.net> wrote: > >>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 >[snip] >>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 > >What's that supposed to do? When I run your file I get bizarre >results... > ><http://www.analog-innovations.com/SED/HobbsDelay_2015-04-08_10-25-36.jpg> > >almost like an FM function ?? > > ...Jim ThompsonWorks 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 | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.
Reply by ●April 8, 20152015-04-08
On 04/08/2015 01:29 PM, Jim Thompson wrote:> On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs > <pcdhSpamMeSenseless@electrooptical.net> wrote: > >> 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 > [snip] >> 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 > > What's that supposed to do? When I run your file I get bizarre > results... > > <http://www.analog-innovations.com/SED/HobbsDelay_2015-04-08_10-25-36.jpg> > > almost like an FM function ?? > > ...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 ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
Reply by ●April 11, 20152015-04-11
On Wed, 08 Apr 2015 14:29:08 -0400, Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> wrote:>On 04/08/2015 01:29 PM, Jim Thompson wrote: >> On Wed, 08 Apr 2015 04:49:30 -0400, Phil Hobbs >> <pcdhSpamMeSenseless@electrooptical.net> wrote: >> >>> 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 >> [snip] >>> 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 >> >> What's that supposed to do? When I run your file I get bizarre >> results... >> >> <http://www.analog-innovations.com/SED/HobbsDelay_2015-04-08_10-25-36.jpg> >> >> almost like an FM function ?? >> >> ...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 HobbsPondering 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 | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.