世纪电源网社区logo
社区
Datasheet
标题
返回顶部
未解决

求教一下 PLECS怎么计算导数

[复制链接]
查看: 2267 |回复: 3
1
kiritoTT
  • 积分:133
  • |
  • 主题:2
  • |
  • 帖子:6
积分:133
LV2
本网技师
  • 2019-3-29 20:39:21
10问答币
求教一下,plecs工具箱里有导数计算的工具么
greendot
  • 积分:31525
  • |
  • 主题:0
  • |
  • 帖子:8687
积分:31525
LV12
专家
  • 2019-3-29 21:24:04
  • 倒数3
 
没用Toolbox ,Stand alone version 里就没有。
siderlee
  • 积分:2050
  • |
  • 主题:3
  • |
  • 帖子:302
积分:2050
LV8
副总工程师
  • 2023-10-10 09:40:15
  • 倒数2
 
PLECS does not provide a Derivative block because numerical derivatives have very bad numerical properties. To be reasonably accurate, they need small time steps; the automatic step-size control of a variable-step solver, however, only works for integrators but not for derivatives. Another practical issue is that a derivative amplifies noise in the system.
It is therefore preferable to formulate a problem in such a way that it can be modeled with integrators rather than derivatives.
If you absolutely must use a derivative in conjunction with a variable-step solver, you can implement one with a C-Script as follows:
Setup
  • Number of inputs: 1
  • Number of outputs: 1
  • Number of disc. states: 2
  • Sample time: 0
Code declarations
#define lastTime DiscState(0)#define lastInput DiscState(1)
Start function
lastTime = CurrentTime;Output(0) = 0;
Output function
if (lastTime != CurrentTime){   Output(0) = (Input(0) - lastInput)/(CurrentTime - lastTime);}
Update function
lastTime = CurrentTime;lastInput = Input(0);
See the attached PLECS Standalone demo model for a working implementation. Notice the visible difference between the differentiated sine signal and the cosine signal. This difference will become smaller if you reduce the maximum step size in the solver settings.

siderlee
  • 积分:2050
  • |
  • 主题:3
  • |
  • 帖子:302
积分:2050
LV8
副总工程师
最新回复
  • 2023-10-10 09:41:30
  • 倒数1
 
热门技术、经典电源设计资源推荐

世纪电源网总部

地 址:天津市南开区黄河道大通大厦8层

电 话:400-022-5587

传 真:(022)27690960

邮 编:300110

E-mail:21dy#21dianyuan.com(#换成@)

世纪电源网分部

广 东:(0755)82437996 /(138 2356 2357)

北 京:(010)69525295 /(15901552591)

上 海:(021)24200688 /(13585599008)

香 港:HK(852)92121212

China(86)15220029145

网站简介 | 网站帮助 | 意见反馈 | 联系我们 | 广告服务 | 法律声明 | 友情链接 | 清除Cookie | 小黑屋 | 不良信息举报 | 网站举报

Copyright 2008-2024 21dianyuan.com All Rights Reserved    备案许可证号为:津ICP备10002348号-2   津公网安备 12010402000296号