Quantization and sample/hold in spice

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi

I need to introduce and error in a signal, both quantization and sample/hold

Sofar I have done it by placing an opamp based sample/hold followed by a 8bit ADC (ADC8break) and a 8 bit DAC (DAC8break)

But it doesn't feel right to use that much circuitry just to simulate an error in the system

Anyone know if it can be done with ABM blocks? (sample and hold can be done with a zero order hold I think, but the quantisation is more difficult)

Some sort of rounding function?

Or I could use the C interface API, and write it in code, but that seems stupid also

Cheers

Klaus

Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 06:13:59 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

Spice has an ideal sample/hold.

Here's a quantizer:

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 2
SYMATTR Value V=int(5.1*V(X))*0.2
SYMATTR InstName B1
SYMBOL voltage 0 80 R0
WINDOW 3 16 199 Left 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value SINE(0 1 1k 0 0 0 3)
SYMATTR InstName V1
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 2 !.tran 0 .005 0 1u





--  

John Larkin         Highland Technology, Inc

lunatic fringe electronics  


Re: Quantization and sample/hold in spice
On Friday, August 18, 2017 at 4:14:29 PM UTC+2, John Larkin wrote:
Quoted text here. Click to load it
Great, I will try it out (although I have problems finding the INT() function in pspice and the ability to feed into the equation the voltage from a node name net directly)

Cheers

Klaus

Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 09:42:57 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

EVALUE
        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 09:42:57 -0700 (PDT), Klaus Kragelund

[snip]
Quoted text here. Click to load it

PSpice Reference Guide
Before you begin
July 2006 17 Product Version 15.7
Expressions can contain the standard operators as shown in the
following table:

ceil(arg) Returns an integer value.
The argument for this function should be a
numeric value or an expression that evaluates
to a numeric value. If arg is an integer, the
return value is equal to the argument value. If
arg is a non-integer value, the return value is
the nearest integer greater than the argument
value.
Example:
ceil(PI)=4
ceil(5)=5
ceil(5.4)=6

floor(arg) Returns an integer value.
The argument for this function should be a
numeric value or an expression that evaluates
to a numeric value. If arg is an integer, the
return value is equal to the argument value. If
arg is a non-integer value, the return value is
the nearest integer smaller than the argument
value.
Example:
floor(PI)=3
floor(5)=5
floor(5.4)=5

        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
Den fredag den 18. august 2017 kl. 19.53.14 UTC+2 skrev Jim Thompson:
Quoted text here. Click to load it
Many thanks :-)   (like doing an integer division in C)

Cheers

Klaus

Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 09:42:57 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

Well, use LT Spice!


--  

John Larkin         Highland Technology, Inc
picosecond timing   precision measurement  

We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 11:10:22 -0700, John Larkin

Quoted text here. Click to load it

Just proves my point that most simulator users don't actually know how
to use their simulator.
        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 11:24:34 -0700, Jim Thompson

Quoted text here. Click to load it

I haven't used Pspice, but I found the "BV" block quantizer easy to
create. I had to play with the equation a bit to get precise 0.1 volt
steps, but that's not a Spice issue, it's just math.

Dumping a BV block on the schematic prompts you for an equation, so
it's pretty easy. I had a little confusion about syntax, but that's OK
now.

I think a lot of simulator users don't really understand electronics,
especially hobbyists without a formal EE education. They fiddle with
circuits. Nothing wrong with that as a hobby, I guess.

We wouldn't want everybody to be good at electronic design, would we?




--  

John Larkin         Highland Technology, Inc
picosecond timing   precision measurement  

We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 11:52:17 -0700, John Larkin

Quoted text here. Click to load it
[snip]
Quoted text here. Click to load it

PSpice has all kinds of behavioral blocks, plus I've created many
more.

Quoted text here. Click to load it

Nor math.



No ;-)

        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
Den fredag den 18. august 2017 kl. 20.24.48 UTC+2 skrev Jim Thompson:
Quoted text here. Click to load it

I have never had the need for a "rounding" function before

These days I only do in average 1 hours per week simuation

Re: Quantization and sample/hold in spice
Den fredag den 18. august 2017 kl. 20.10.40 UTC+2 skrev John Larkin:
Quoted text here. Click to load it
I have 20 years of simulation blocks and earlier project in PSpice, so that is not an option. And Capture PSpice gives me some features not available in LTSpice

Cheers

Klaus

Re: Quantization and sample/hold in spice
On Fri, 18 Aug 2017 06:13:59 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

In PSpice....

<
http://www.analog-innovations.com/SED/QuantizerInPSpice.png


You can put slicing point "down the middle" by using both ceil() and
floor().
        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Sat, 19 Aug 2017 08:56:39 -0700, Jim Thompson

Quoted text here. Click to load it

As in...

<
http://www.analog-innovations.com/SED/QuantizerInPSpiceBalanced.png

        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Saturday, August 19, 2017 at 6:43:51 PM UTC+2, Jim Thompson wrote:
Quoted text here. Click to load it

Very nice, thanks :-)

I am looking into THD magnitude versus microcontroller PWM resolution in a PMSM drive. Higher PWM resolution equates into more accurate motor field vectors and more smooth control

Very limited papers about that out there

Cheers

Klaus

Re: Quantization and sample/hold in spice
On Sat, 19 Aug 2017 15:57:34 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

Happy to have been of help!
        
                                        ...Jim Thompson
--  
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      |
We've slightly trimmed the long signature. Click to see the full one.
Re: Quantization and sample/hold in spice
On Sat, 19 Aug 2017 15:57:34 -0700 (PDT), Klaus Kragelund

Quoted text here. Click to load it

You can delta-sigma or noise dither low-resolution DACs or PWMs to get
more effective resolution.


--  

John Larkin         Highland Technology, Inc

lunatic fringe electronics  


Re: Quantization and sample/hold in spice
On Sunday, August 20, 2017 at 2:06:45 AM UTC+2, John Larkin wrote:
Quoted text here. Click to load it
Yes, but in this case the problem is that the microcontroller is running at max speed, and the max clock frequency and the inverter stage frequency sets the number of effective dutycycles.

So, say a 30MHz timer clock, and a switching frequency of 20kHz, the number of different dutycycles possible is 1500

Cheers

Klaus

Re: Quantization and sample/hold in spice

d:
Quoted text here. Click to load it
ample/hold
Quoted text here. Click to load it
d by a 8bit ADC (ADC8break) and a 8 bit DAC (DAC8break)
Quoted text here. Click to load it
ate an error in the system
Quoted text here. Click to load it
n be done with a zero order hold I think, but the quantisation is more diff
icult)
Quoted text here. Click to load it
 seems stupid also
Quoted text here. Click to load it
d
in a PMSM drive. Higher PWM resolution equates into more accurate motor fie
ld vectors and more smooth control
Quoted text here. Click to load it
at max speed, and the max clock frequency and the inverter stage frequency  
sets the number of effective dutycycles.
Quoted text here. Click to load it
er of different dutycycles possible is 1500
Quoted text here. Click to load it

per cycle, but you might be able to average over multiple cycles





Re: Quantization and sample/hold in spice
On Sunday, August 20, 2017 at 3:10:17 AM UTC+2, Lasse Langwadt Christensen  
wrote:

und:
Quoted text here. Click to load it
:
Quoted text here. Click to load it
 sample/hold
Quoted text here. Click to load it
wed by a 8bit ADC (ADC8break) and a 8 bit DAC (DAC8break)
Quoted text here. Click to load it
ulate an error in the system
Quoted text here. Click to load it
can be done with a zero order hold I think, but the quantisation is more di
fficult)
Quoted text here. Click to load it
at seems stupid also
Quoted text here. Click to load it
and
ng>
Quoted text here. Click to load it
n in a PMSM drive. Higher PWM resolution equates into more accurate motor f
ield vectors and more smooth control
Quoted text here. Click to load it
t
g at max speed, and the max clock frequency and the inverter stage frequenc
y sets the number of effective dutycycles.
Quoted text here. Click to load it
mber of different dutycycles possible is 1500
Quoted text here. Click to load it

Yes, that might have an effect. I do not know if the FOC algoritm does that
 already, will check :-)

In any case, it is probably way lower than the effect of the non-ideal dist
ribution of the windings

Cheers

Klaus

Site Timeline