LTspice(11) arbitrary behavioral source

LTspice(11) arbitrary behavioral source

在电子系统里我们需要的信号多种多样,所以为了更加准确的仿真,输入信号应该也是多种多样。在LTspice里通常的电压源支持的模式虽然比较多,但是还不够全面。

常规的电压源可选配置如下⬇️

图1:常规电压源可选配置

如果你的信号超出了这个的定义范围,那么就需要使用arbitrary voltage,在SPICE里面他的开头是B可以是BV也可以是BI分别代表随机电压和电流。以下给出了帮助里的说明。

B. Arbitrary Behavioral Voltage or Current Sources

Symbol names: BV, BI

Syntax: Bnnn n001 n002 V=<expression> [ic=<value>]
        + [tripdv=<value>] [tripdt=<value>]
        + [laplace=<expression> [window=<time>]
        + [nfft=<number>] [mtol=<number>]]

        Bnnn n001 n002 I=<expression> [ic=<value>]
        + [tripdv=<value>] [tripdt=<value>] [Rpar=<value>]
        + [laplace=<expression> [window=<time>]
        + [nfft=<number>] [mtol=<number>]]

The first syntax specifies a behavioral voltage source and the next is a behavioral current source. For the current source, a parallel resistance may be specified with the Rpar instance parameter.

在任意行为仿真源(arbitrary behavioral source)中 time代表当前仿真时间pi代表

3.14159265358979323846.可以使用LTspice几乎所有的表达式,支持的表达式如下所示。

Function Name

Description

abs(x) 

Absolute value of x 

absdelay(x,t[,tmax]) 

x delayed by t. Optional max delay notification tmax.

acos(x) 

Real part of the arc cosine of x, e.g., acos(-5) returns 3.14159, not 3.14159+2.29243i

arccos(x) 

Synonym for acos() 

acosh(x) 

Real part of the arc hyperbolic cosine of x, e.g., acosh(.5) returns 0, not 1.0472i

asin(x) 

Real part of the arc sine of x, asin(-5) is -1.57080, not -1.57080+2.29243i

arcsin(x) 

Synonym for asin() 

asinh(x) 

Arc hyperbolic sine 

atan(x) 

Arc tangent of x 

arctan(x) 

Synonym for atan() 

atan2(y,x) 

Four quadrant arc tangent of y/x

atanh(x) 

Arc hyperbolic tangent

buf(x) 

1 if x > .5, else 0

ceil(x) 

Integer equal or greater than x

cos(x) 

Cosine of x 

cosh(x) 

Hyperbolic cosine of x

ddt(x) 

Time derivative of x 

delay(x,t[,tmax] 

Same as absdelay() 

dnlim(x,y,z) 

Similar to max(x,y) but with a continuous 1st derivative transition width z

exp(x) 

e to the x 

floor(x) 

Integer equal to or less than x

hypot(x,y) 

sqrt(x**2 + y**2) 

idt(x[,ic[,a]]) 

Integrate x, optional initial condition ic, reset if a is true.

idtmod(x[,ic[,m[,o]]]

Integrate x, optional initial condition ic, reset on reaching modulus m, offset output by o.

if(x,y,z) 

If x > .5, then y else z

int(x) 

Convert x to integer

inv(x) 

0. if x > .5, else 1.

limit(x,y,z) 

Intermediate value of x, y, and z

ln(x) 

Natural logarithm of x

log(x) 

Alternate syntax for ln()

log10(x) 

Base 10 logarithm 

max(x,y) 

The greater of x or y 

min(x,y) 

The smaller of x or y 

pow(x,y) 

Real part of x**y, e.g., pow(-1,.5)=0, not i.

pwr(x,y) 

abs(x)**y 

pwrs(x,y) 

sgn(x)*abs(x)**y 

rand(x) 

Random number between 0 and 1 depending on the integer value of x.

random(x) 

Similar to rand(), but smoothly transitions between values.

round(x) 

Nearest integer to x 

sdt(x[,ic[,assert]])

Alternate syntax for idt()

sgn(x) 

Sign of x 

sin(x) 

Sine of x 

sinh(x) 

Hyperbolic sine of x 

smallsig() 

Returns 1 if a .ac or .noise analysis is being done. Otherwise 0.

sqrt(x) 

Square root of x 

table(x,a,b,c,d,...) 

Interpolate a value for x based on a look up table given as a set of pairs of points.

tan(x) 

Tangent of x. 

tanh(x) 

Hyperbolic tangent of x

u(x) 

Unit step, i.e., 1 if x > 0., else 0.

uplim(x,y,z) 

Similar to min(x,y) but with a continuous 1st derivative transition width z

uramp(x) 

x if x > 0., else 0.

white(x) 

Random number between -.5 and .5 smoothly transitions between values even more smoothly than random().

!(x) 

Alternative syntax for inv(x)

~(x) 

Alternative syntax for inv(x)

• The following operations, grouped in reverse order of precedence of evaluation:

Operand

Description

Convert the expressions to either side to Boolean, then AND.

Convert the expressions to either side to Boolean, then OR. 

Convert the expressions to either side to Boolean, then XOR.

True if expression on the left is greater than the expression on the right, otherwise false.

True if expression on the left is less than the expression on the right, otherwise false.

>= 

True if expression on the left is greater than or equal the expression on the right, otherwise false.

<= 

True if expression on the left is less than or equal the expression on the right, otherwise false.

Floating point addition

Floating point subtraction

Floating point multiplication

Floating point division

** 

Raise left hand side to power of right hand side. Only the real part is returned, e.g., -1**1.5 gives zero not i.

Convert the following expression to Boolean and invert.

了解了大概咋回事,咱们就开始搭建一个简单的任意电压源(arbitrary behavioral voltage source)吧!

在LTspice的器件库中直接搜索bv即可,如图2所示。

图2:任意行为电压源

放置好以后我们就可以对其进行测试,我们可以弄个以时间变化的电压值。如图3所示,仿真结果如图4所示。

图3:随时间变化的电压

图4:仿真结果

也许我们想来个随机信号,那我们只要将随机信号的公式带入即可。我们使用random(x)函数,对于它的描述如下所示。

rand(x) 

Random number between 0 and 1 depending on the integer value of x.

random(x) 

Similar to rand(), but smoothly transitions between values.

他可以生成0~1之间的数,具体取决于x的整数值。设置如图5所示。仿真结果如图6所示。

图5:随机电压设置

图6:仿真结果

图7:PP值

图8:Meas测量结果 测量代码:.MEAS TRAN B1 PP V(vout)

电路测试代码:

* xutong 2023/3/14

B1 vout 0 V=random(time*1000)/1000

.tran 10

.MEAS TRAN B1 PP V(vout)

.backanno

.end

今天就先聊到这里啦,拜拜~

更多精彩内容关注公众号 xuyutong

  • 20
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值