From: John Larkin on
On Sun, 18 Apr 2010 16:03:12 +1000, Grant <omg(a)grrr.id.au> wrote:

>On Sat, 17 Apr 2010 22:10:09 -0700, John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:
>
>>
>>Here's a quantizer in LT Spice:
>>
>>ftp://jjlarkin.lmi.net/Quantizer.jpg
>>
>>It wasn't hard, but the HELP is really obscure about syntax, and there
>>is no example of a schematic with a b-source that I could find.
>>
>>There is a sample-and-hold schematic symbol, so one can simulate the
>>effects of a clocked ADC or a DAC on a control loop.
>>
>>John
>>
>>
>>
>>Version 4
>>SHEET 1 880 680
>>WIRE 48 48 0 48
>>WIRE 112 48 48 48
>>WIRE 384 48 320 48
>>WIRE 432 48 384 48
>>WIRE 0 96 0 48
>>WIRE 112 112 112 48
>>WIRE 320 112 320 48
>>WIRE 432 128 432 48
>>WIRE 0 224 0 176
>>WIRE 112 224 112 192
>>WIRE 320 240 320 192
>>WIRE 432 240 432 208
>>FLAG 0 224 0
>>FLAG 320 240 0
>>FLAG 112 224 0
>>FLAG 432 240 0
>>FLAG 48 48 X
>>FLAG 384 48 OUT
>>SYMBOL bv 320 96 R0
>>WINDOW 3 36 198 Left 0
>>SYMATTR InstName B1
>>SYMATTR Value V=int(5.1*V(X))*0.2
>>SYMBOL voltage 0 80 R0
>>WINDOW 3 16 199 Left 0
>>WINDOW 123 0 0 Left 0
>>WINDOW 39 0 0 Left 0
>>SYMATTR InstName V1
>>SYMATTR Value SINE(0 1 1k 0 0 0 3)
>>SYMBOL res 96 96 R0
>>SYMATTR InstName R1
>>SYMATTR Value 1k
>>SYMBOL res 416 112 R0
>>SYMATTR InstName R2
>>SYMATTR Value 1k
>>TEXT 144 40 Left 0 !.tran 0 .005 0 1u
>>
>>
>Shouldn't those steps spend equal time inside and outside the sine wave?
>
>Grant.

That depends on your personal definition of "quantizer." Once the
structure is there, one can play with the equation. I'll be simulating
a 12-bit ADC and a 10-bit DAC, so exactly where the transitions happen
doesn't matter much.

John

From: John Larkin on
On Sun, 18 Apr 2010 10:02:13 +0100, "Andrew Holme" <ah(a)nospam.com>
wrote:

>
>"Grant" <omg(a)grrr.id.au> wrote in message
>news:q38ls59vs9ja60rp7gmv17hra9u4oluva5(a)4ax.com...
>> On Sat, 17 Apr 2010 22:10:09 -0700, John Larkin
>> <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:
>>
>>>
>>>Here's a quantizer in LT Spice:
>>>
>>>ftp://jjlarkin.lmi.net/Quantizer.jpg
>>>
>>>It wasn't hard, but the HELP is really obscure about syntax, and there
>>>is no example of a schematic with a b-source that I could find.
>>>
>>>There is a sample-and-hold schematic symbol, so one can simulate the
>>>effects of a clocked ADC or a DAC on a control loop.
>>>
>>>John
>>>
>>>
>>>
>>>Version 4
>>>SHEET 1 880 680
>>>WIRE 48 48 0 48
>>>WIRE 112 48 48 48
>>>WIRE 384 48 320 48
>>>WIRE 432 48 384 48
>>>WIRE 0 96 0 48
>>>WIRE 112 112 112 48
>>>WIRE 320 112 320 48
>>>WIRE 432 128 432 48
>>>WIRE 0 224 0 176
>>>WIRE 112 224 112 192
>>>WIRE 320 240 320 192
>>>WIRE 432 240 432 208
>>>FLAG 0 224 0
>>>FLAG 320 240 0
>>>FLAG 112 224 0
>>>FLAG 432 240 0
>>>FLAG 48 48 X
>>>FLAG 384 48 OUT
>>>SYMBOL bv 320 96 R0
>>>WINDOW 3 36 198 Left 0
>>>SYMATTR InstName B1
>>>SYMATTR Value V=int(5.1*V(X))*0.2
>>>SYMBOL voltage 0 80 R0
>>>WINDOW 3 16 199 Left 0
>>>WINDOW 123 0 0 Left 0
>>>WINDOW 39 0 0 Left 0
>>>SYMATTR InstName V1
>>>SYMATTR Value SINE(0 1 1k 0 0 0 3)
>>>SYMBOL res 96 96 R0
>>>SYMATTR InstName R1
>>>SYMATTR Value 1k
>>>SYMBOL res 416 112 R0
>>>SYMATTR InstName R2
>>>SYMATTR Value 1k
>>>TEXT 144 40 Left 0 !.tran 0 .005 0 1u
>>>
>>>
>> Shouldn't those steps spend equal time inside and outside the sine wave?
>
>Use round() instead of int():
>
>SYMATTR Value V=round(5*V(X))/5
>

That does look a little nicer.

John

From: Grant on
On Sun, 18 Apr 2010 08:45:24 -0700, John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:

>On Sun, 18 Apr 2010 16:03:12 +1000, Grant <omg(a)grrr.id.au> wrote:
>
>>On Sat, 17 Apr 2010 22:10:09 -0700, John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:
>>
>>>
>>>Here's a quantizer in LT Spice:
>>>
>>>ftp://jjlarkin.lmi.net/Quantizer.jpg
>>>
>>>It wasn't hard, but the HELP is really obscure about syntax, and there
>>>is no example of a schematic with a b-source that I could find.
>>>
>>>There is a sample-and-hold schematic symbol, so one can simulate the
>>>effects of a clocked ADC or a DAC on a control loop.
>>>
>>>John
>>>
>>>
>>>
>>>Version 4
>>>SHEET 1 880 680
>>>WIRE 48 48 0 48
>>>WIRE 112 48 48 48
>>>WIRE 384 48 320 48
>>>WIRE 432 48 384 48
>>>WIRE 0 96 0 48
>>>WIRE 112 112 112 48
>>>WIRE 320 112 320 48
>>>WIRE 432 128 432 48
>>>WIRE 0 224 0 176
>>>WIRE 112 224 112 192
>>>WIRE 320 240 320 192
>>>WIRE 432 240 432 208
>>>FLAG 0 224 0
>>>FLAG 320 240 0
>>>FLAG 112 224 0
>>>FLAG 432 240 0
>>>FLAG 48 48 X
>>>FLAG 384 48 OUT
>>>SYMBOL bv 320 96 R0
>>>WINDOW 3 36 198 Left 0
>>>SYMATTR InstName B1
>>>SYMATTR Value V=int(5.1*V(X))*0.2
>>>SYMBOL voltage 0 80 R0
>>>WINDOW 3 16 199 Left 0
>>>WINDOW 123 0 0 Left 0
>>>WINDOW 39 0 0 Left 0
>>>SYMATTR InstName V1
>>>SYMATTR Value SINE(0 1 1k 0 0 0 3)
>>>SYMBOL res 96 96 R0
>>>SYMATTR InstName R1
>>>SYMATTR Value 1k
>>>SYMBOL res 416 112 R0
>>>SYMATTR InstName R2
>>>SYMATTR Value 1k
>>>TEXT 144 40 Left 0 !.tran 0 .005 0 1u
>>>
>>>
>>Shouldn't those steps spend equal time inside and outside the sine wave?
>>
>>Grant.
>
>That depends on your personal definition of "quantizer."

Hmm, I like zero accumulated errors, so your staircase waveform
looked somewhat anorexic to me ;) I imagine the quantised waveform
being filtered back to sinewave.

> Once the
>structure is there, one can play with the equation. I'll be simulating
>a 12-bit ADC and a 10-bit DAC, so exactly where the transitions happen
>doesn't matter much.

Yep, except I had no idea where to find the 'lever' to change it, but
another poster already pointed that out.

Only recently did I start playing with LTSpice, much to learn as I've
not used spice before (returning to electronics design after a 'short'
break in 1993).

Grant.
--
http://bugs.id.au/
From: John Larkin on
On Mon, 19 Apr 2010 08:29:07 +1000, Grant <omg(a)grrr.id.au> wrote:

>On Sun, 18 Apr 2010 08:45:24 -0700, John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:
>
>>On Sun, 18 Apr 2010 16:03:12 +1000, Grant <omg(a)grrr.id.au> wrote:
>>
>>>On Sat, 17 Apr 2010 22:10:09 -0700, John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote:
>>>
>>>>
>>>>Here's a quantizer in LT Spice:
>>>>
>>>>ftp://jjlarkin.lmi.net/Quantizer.jpg
>>>>
>>>>It wasn't hard, but the HELP is really obscure about syntax, and there
>>>>is no example of a schematic with a b-source that I could find.
>>>>
>>>>There is a sample-and-hold schematic symbol, so one can simulate the
>>>>effects of a clocked ADC or a DAC on a control loop.
>>>>
>>>>John
>>>>
>>>>
>>>>
>>>>Version 4
>>>>SHEET 1 880 680
>>>>WIRE 48 48 0 48
>>>>WIRE 112 48 48 48
>>>>WIRE 384 48 320 48
>>>>WIRE 432 48 384 48
>>>>WIRE 0 96 0 48
>>>>WIRE 112 112 112 48
>>>>WIRE 320 112 320 48
>>>>WIRE 432 128 432 48
>>>>WIRE 0 224 0 176
>>>>WIRE 112 224 112 192
>>>>WIRE 320 240 320 192
>>>>WIRE 432 240 432 208
>>>>FLAG 0 224 0
>>>>FLAG 320 240 0
>>>>FLAG 112 224 0
>>>>FLAG 432 240 0
>>>>FLAG 48 48 X
>>>>FLAG 384 48 OUT
>>>>SYMBOL bv 320 96 R0
>>>>WINDOW 3 36 198 Left 0
>>>>SYMATTR InstName B1
>>>>SYMATTR Value V=int(5.1*V(X))*0.2
>>>>SYMBOL voltage 0 80 R0
>>>>WINDOW 3 16 199 Left 0
>>>>WINDOW 123 0 0 Left 0
>>>>WINDOW 39 0 0 Left 0
>>>>SYMATTR InstName V1
>>>>SYMATTR Value SINE(0 1 1k 0 0 0 3)
>>>>SYMBOL res 96 96 R0
>>>>SYMATTR InstName R1
>>>>SYMATTR Value 1k
>>>>SYMBOL res 416 112 R0
>>>>SYMATTR InstName R2
>>>>SYMATTR Value 1k
>>>>TEXT 144 40 Left 0 !.tran 0 .005 0 1u
>>>>
>>>>
>>>Shouldn't those steps spend equal time inside and outside the sine wave?
>>>
>>>Grant.
>>
>>That depends on your personal definition of "quantizer."
>
>Hmm, I like zero accumulated errors, so your staircase waveform
>looked somewhat anorexic to me ;) I imagine the quantised waveform
>being filtered back to sinewave.

"round" does look nicer, in having zero average errors through the
quantizer. I'm mostly interested in how using the ADC and DAC in the
NXP ARM will change the dynamics of a loop that I'm simulating as all
analog but will in fact be digital. The uP has a 10-bit DAC, which
isn't good enough, so if we oversample hard (100 KHz) and add some
lowpass filtering downstream of the dac, we should be able to dither a
few more bits. That part will be interesting to simulate, but doesn't
care much how the quantizers round. The actual NXP ADC and DAC will do
whatever they do.

>
>> Once the
>>structure is there, one can play with the equation. I'll be simulating
>>a 12-bit ADC and a 10-bit DAC, so exactly where the transitions happen
>>doesn't matter much.
>
>Yep, except I had no idea where to find the 'lever' to change it, but
>another poster already pointed that out.
>
>Only recently did I start playing with LTSpice, much to learn as I've
>not used spice before (returning to electronics design after a 'short'
>break in 1993).

I find the HELP in LT Spice to be a bit abstract and not terribly
consistent. More examples would be great. At least one can come to
s.e.d. and ususlly find somebody who knows how to do what you need.

For basic stuff, LT Spice is great and eesy to drive. I can't imagine
how much it has cost the people who sell simulators.

John


From: John Devereux on
John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> writes:


[...]

>
> I find the HELP in LT Spice to be a bit abstract and not terribly
> consistent. More examples would be great. At least one can come to
> s.e.d. and ususlly find somebody who knows how to do what you need.
>
> For basic stuff, LT Spice is great and eesy to drive. I can't imagine
> how much it has cost the people who sell simulators.

Yeah, Mike E should be arrested for "using a computer to destroy their
business model"... Why did you do it Mike?? :) :)

Seriously, LTSPice is great, thank you LTC.

--

John Devereux