¿ªÔÆÌåÓý

Noise source in Transient analysis #NOISE


 

Hi everbody,

does anyone know, how I can add a noise source in a transient
simulation (if it is possible at all)?
I tried to modell a noise source with a behavioral voltage source
but i didn't work.

Thanks,

Ingo


 

You might be able to use the rand() function
to get what you're looking for. Check the
example ./LTC/SwCADIII/examples/Educational/PLL.asc
There it is used to generate a random bit stream
by boolean comparison to 0.5.

--Mike
--- "ingodettmann
<ingod@...>"
<ingod@...> wrote:
Hi everbody,

does anyone know, how I can add a noise source in a
transient
simulation (if it is possible at all)?
I tried to modell a noise source with a behavioral
voltage source
but i didn't work.

Thanks,

Ingo




__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.


 

--- In LTspice@..., "ingodettmann <ingod@y...>"
<ingod@y...> wrote:
Hi everbody,

does anyone know, how I can add a noise source in a transient
simulation (if it is possible at all)?
I tried to modell a noise source with a behavioral voltage source
but i didn't work.
Hello Ingo,

there is a very easy way to make such a noise source.
Firstly we should be aware that the rand() funktion has equal
probability for every voltage level between 0 and 1.
This is not like a gaussian noise where you have higher values with
lower probabilty. I remembered a theorem that the generated noise
becomes more gaussian by adding many such noise sources.
I have preferred three sources.

Example:
Digital noise clock is 1e4Hz. "time" is the keyword for time in
the .tran analysis. You can use it in your B-sources.
You have to increase the rand() frequency 1e4 to your requirements.
I think that the offset parameter in the rand() function should be
increased proportionally to the frequency. The intention of this
offset parameter is to make the three rand() functions more like
independant noise sources.

Best Regards
Helmut


Example; f=1.0e4

B1: V=2*rand(time*1e4)
B2: V=2*rand(time*1e4+0.0911e4)
B3: V=2*rand(time*1e4+0.2131e4)

.tran 0 100m 0 10u


Example; f=1.0e9

B1: V=2*rand(time*10e9)
B2: V=2*rand(time*10e9+0.0911e9)
B3: V=2*rand(time*10e9+0.2131e9)

.tran 0 1u 0 0.1n


netlist
-------

*
B1 N001 0 V=2*rand(time*1e9+0.2131e9)
B2 N002 N001 V=2*rand(time*1e9+0.0911e9)
B3 N003 N002 V=2*rand(time*1e9)
R1 N003 out 50
C1 out 0 1p
.tran 0 1u 0 0.1n
.backanno
.end


Schematic
---------

SHEET 1 912 712
WIRE 192 80 192 32
WIRE 192 208 192 160
WIRE 192 -96 192 -48
WIRE 192 -176 192 -224
WIRE 192 -224 464 -224
WIRE 544 -224 576 -224
WIRE 576 -224 576 -192
WIRE 576 -128 576 -96
FLAG 192 208 GND
FLAG 576 -96 0
FLAG 576 -224 out
SYMBOL BV 192 64 R0
SYMATTR InstName B1
SYMATTR Value V=2*rand(time*1e9+0.2131e9)
SYMBOL bv 192 -64 R0
SYMATTR InstName B2
SYMATTR Value V=2*rand(time*1e9+0.0911e9)
SYMBOL bv 192 -192 R0
SYMATTR InstName B3
SYMATTR Value V=2*rand(time*1e9)
SYMBOL res 448 -208 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 0 56 VBottom 0
SYMATTR InstName R1
SYMATTR Value 50
SYMBOL cap 560 -192 R0
SYMATTR InstName C1
SYMATTR Value 1p
TEXT 192 -256 Left 0 !.tran 0 1u 0 0.1n


 

--- In LTspice@..., Panama Mike <panamatex@y...> wrote:
You might be able to use the rand() function
to get what you're looking for. Check the
example ./LTC/SwCADIII/examples/Educational/PLL.asc
There it is used to generate a random bit stream
by boolean comparison to 0.5.

--Mike
--- "ingodettmann
<ingod@y...>"
<ingod@y...> wrote:
Hi everbody,

does anyone know, how I can add a noise source in a
transient
simulation (if it is possible at all)?
I tried to modell a noise source with a behavioral
voltage source
but i didn't work.
rand and white on their own are no use -these are rectangular random
variables.

Use a behavioural voltage source with V for example

V=SQRT(-2*LN(white(time*1.07G)+0.5))*COS(2*PI*(white
((time*0.93G+0.5)))


This is the Box-Mueller algorithm for Gaussian Noise. You need two
independent random variables. The factors 1.07 and 0.93 is an attempt
to do this. You will need to alter these, and the time step to get
what you want. You also may need to scale to get the correct rms
value in your noise bandwidth.

It's not perfect.

Brian Howie


Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.


 

--- In LTspice@..., "gm4dij <brian.howie@b...>"
<brian.howie@b...> wrote:
--- In LTspice@..., Panama Mike <panamatex@y...> wrote:
You might be able to use the rand() function
to get what you're looking for. Check the
example ./LTC/SwCADIII/examples/Educational/PLL.asc
There it is used to generate a random bit stream
by boolean comparison to 0.5.

--Mike
--- "ingodettmann
<ingod@y...>"
<ingod@y...> wrote:
Hi everbody,

does anyone know, how I can add a noise source in a
transient
simulation (if it is possible at all)?
I tried to modell a noise source with a behavioral
voltage source
but i didn't work.
rand and white on their own are no use -these are rectangular
random
variables.

Use a behavioural voltage source with V for example

V=SQRT(-2*LN(white(time*1.07G)+0.5))*COS(2*PI*(white
((time*0.93G+0.5)))


This is the Box-Mueller algorithm for Gaussian Noise. You need two
independent random variables. The factors 1.07 and 0.93 is an
attempt
to do this. You will need to alter these, and the time step to get
what you want. You also may need to scale to get the correct rms
value in your noise bandwidth.

It's not perfect.
Hello Brian,
thanks for the formula. I googled and found this reference.


I couldn't resist to test it immediately in LTSPICE.
I have got some extremely high peaks(30V) at 47us, 48us and 84us
with the setting ".tran 0 100000n 0 0.5n".
So the formula needs a little change to avoid extreme values at
log(0).


The original formula:

V=SQRT(-2*LN(white(time*1.07G)+0.5))*COS(2*PI*(white(time*0.93G+0.5)))

My slightly modified formula for LTSpice:

V=SQRT(-2*LN(0.999997*white(time*1.07e9) +0.50001))*COS(2*PI*white
(time*0.93e9+0.5))

This B-source doesn't have the above mentioned "defects".

Best Regards
Helmut


 

There were reports at one time that 2 or more rand() functions were random but very well correlated with each other. Has this been corrected?


 

WHS wrote, "There were reports at one time that 2 or more rand() functions were random but very well correlated with each other. Has this been corrected?"

What is there to correct?

The rand() function is a deterministic function.? That is by design.? You give it an argument, and it converts it to a semi-random result.? It is not a random-sequence generator, like a linear-feedback-shift-register.? No, not like that.? Given the same argument x, rand(x) always returns the same result, every time.? That's how it should work, and that's how it does work.

The way to use two rand() functions in the same simulation and have them different, is to assure that their arguments are significantly different.? For example, use rand(time) and rand(-time).? Or rand(time+1e6).? Or rand(time*1e6).? Or something else.? Use your head to choose something that is different for each function's argument.

As another simple example, if one rand() function uses argument values between 1.0 and 1e9, make the second rand()'s argument go from 1e9 to 2e9.? Now the two functions generate a different sequence of semi-random values.

Andy


 

¿ªÔÆÌåÓý

On 23/02/2021 06:36, Andy I wrote:
WHS wrote, "There were reports at one time that 2 or more rand() functions were random but very well correlated with each other. Has this been corrected?"

What is there to correct?

The rand() function is a deterministic function.? That is by design.? You give it an argument, and it converts it to a semi-random result.? It is not a random-sequence generator, like a linear-feedback-shift-register.? No, not like that.? Given the same argument x, rand(x) always returns the same result, every time.? That's how it should work, and that's how it does work.

The way to use two rand() functions in the same simulation and have them different, is to assure that their arguments are significantly different.? For example, use rand(time) and rand(-time).? Or rand(time+1e6).? Or rand(time*1e6).? Or something else.? Use your head to choose something that is different for each function's argument.

As another simple example, if one rand() function uses argument values between 1.0 and 1e9, make the second rand()'s argument go from 1e9 to 2e9.? Now the two functions generate a different sequence of semi-random values.
Don't forget that there is a Control Panel setting to randomise the mc() function by using the system clock to seed the generator. This is a sticky setting, so it stays set or unset until you change it.

Control Panel > Hacks! > "Use the clock to reseed..."
-- 
Regards,
Tony


 

? ? "Don't forget that there is a Control Panel setting to randomise the mc() function by using the system clock to seed the generator."

That's right.

LTspice has six different random functions.? Rand(), random(), and white() can be used with B-sources to generate noisy signals in transient simulations.? They are unaffected by the system clock and are always deterministic when used with the same arguments.? Flat(), gauss(), and mc() can be used with .PARAM assignments.? This means they can't change during a .tran simulation.??Among the six, I think only mc() can be controlled by the system clock to make it non-deterministic (if you change that setting in the Control Panel).

The trick here is that you can use a randomized mc() function to alter the argument of a rand(), random(), or white() function, and then make your noisy B-source generate different noise every time you run the simulation -- if that is something you really need.? I don't see a need for it, but maybe you do.

Andy


 

Hello Andy

Among the six, I think only mc() can be controlled by the
system clock to make it non-deterministic (if you change that setting in the
Control Panel).
flat() and gauss() are also affected by the clock seed. It has been so
since LTspice IV.

--
Vlad
______________________
ltspicegoodies.ltwiki.org v2:
quite universal analog/digital filter,
power electronics, signal processing,
easy to work with math functions,
digital models, and rants.


 

Vlad wrote, "flat() and gauss() are also affected by the clock seed."

Thanks.? I remember experimenting with it to see if they were also affected, but that was a long time ago.

Andy


 

Hello Andy

Thanks. I remember experimenting with it to see if they were also affected,
but that was a long time ago.
Well I had forgotten about flat(), but seeing it triggered the right memory.

--
Vlad
______________________
ltspicegoodies.ltwiki.org v2:
quite universal analog/digital filter,
power electronics, signal processing,
easy to work with math functions,
digital models, and rants.