P only control model----PID controlor

本文通过MATLAB代码实例,详细分析了PID控制器中比例系数Kp对输出的影响,包括静差变化、过调现象及稳定性,通过不同Kp值的比较,直观展示了PID控制器参数调整对系统响应的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如图PID是什么不解释了。


对于仅仅只有P控制的模型

%% 
% Code writer:EOF
% Time : 2013.09.23 In XTU
% 
% This code just used for understand how PID work .So you may not to be
% intertwind with this code how to work!

% Matlab language is not like the C language which is strict to detail of a
% description of  problems

% What I want to say is that you should understand what is PID and then
% program it
clear all
clc

syms s
hold on
%% abstract the object which is controled into a function 1/(s^2+3*s+1)
num = 1;
den = sym2poly(s^2+3*s+1);
G = tf(num,den);

%% Set up the coefficient
%--------------------------
H = 1;%THE TARGET VALUE!!
%--------------------------
% PID系数
Kp = 2;
Ki = 0;
Kd = 0;
%% Set up the coefficient controlor
C = pid(Kp,Ki,Kd);% set up a PID controlor
T = feedback(C*G,H);%backforward loop

step(T)

Kp = 4;% coefficient of  PID
Ki = 0;
Kd = 0;

C = pid(Kp,Ki,Kd);

T = feedback(C*G,H);

step(T)
%% repeat simply
Kp = 6;
Ki = 0;
Kd = 0;

C = pid(Kp,Ki,Kd);

T = feedback(C*G,H);

step(T)

Kp = 40;
Ki = 0;
Kd = 0;

C = pid(Kp,Ki,Kd);

T = feedback(C*G,H);

step(T)
Kp = 400;
Ki = 0;
Kd = 0;

C = pid(Kp,Ki,Kd);

T = feedback(C*G,H);

step(T)

legend('Kp = 2','Kp = 4','Kp = 6','Kp = 40','Kp=400');

我们假定控制对象抽象成一个函数

1/(s^2+3*s+1)
预设期望达到的值是1

当Kp = 2时


可以看到,在不到0.7的位置,输出就趋于稳定了,形成一个静差



当Kp = 4时,静差变小,输出几乎稳定在0.8的样子,但是此时出现过调的现象!



当Kp = 6时,静差进一步缩小,过调进一步明显



当Kp = 40时,静差更小了,过调导致的初期波动也越发明显


综合性的我们来看这幅图,分析P系数对输出的影响


根据图像分析,可以很容易的得到结论


随着Kp 的增大,静差会越变越小,但是,会来带来过调导致的不稳定性,输出稳定时间明显边长

一开始我误以为当Kp很大的时候,静差消除了,其实不是的,只是很小很小而已,本想上传图说明一下,但是貌似不能传图了。。。不过这个地放

可以自己去运行我上面的代码去观察曲线的变化的啦。。。就不吐槽CSND的这个编辑器了


当然啦,我是抛砖引玉的,看大牛怎么总结:

引自stephen zahra


简单翻译一下,勿喷:

1:在仅有P控制的模型中,控制器简单的将误差用比例系数相乘之后,得到控制器的输出

2:小的比例系数Kp是接近预设期望值的最安全的方法,但是你的控制器可能表现的很慢。如果增加Kp,就会出现过调

(翻译成中文真心没意思。。。英文很直观的语言感受,经过汉字抽象处理之后,简单的概念就变得抽象了)



If the pretrained HGNetV2 can't be downloaded automatically. Please check your network connection. Please check your network connection. Or download the model manually from https://github.com/Peterande/storage/releases/download/dfinev1.0/PPHGNetV2_B0_stage1.pth to weight/hgnetv2/. Loaded stage1 B0 HGNetV2 from URL. /root/D-FINE-master/src/nn/backbone/hgnetv2.py:534: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. state = torch.load(model_path, map_location="cpu") Loaded stage1 B0 HGNetV2 from URL. Initial lr: [0.0001, 0.0001, 0.0002, 0.0002] building train_dataloader with batch_size=8... [rank0]: Traceback (most recent call last): [rank0]: File "train.py", line 113, in <module> [rank0]: main(args) [rank0]: File "train.py", line 75, in main [rank0]: solver.fit() [rank0]: File "/root/D-FINE-master/src/solver/det_solver.py", line 22, in fit [rank0]: self.train() [rank0]: File "/root/D-FINE-master/src/solver/_solver.py", line 172, in train [rank0]: self.cfg.train_dataloader, shuffle=self.cfg.train_dataloader.shuffle [rank0]: File "/root/D-FINE-master/src/core/yaml_config.py", line 79, in train_dataloader [rank0]: self._train_dataloader = self.build_dataloader("train_dataloader") [rank0]: File "/root/D-FINE-master/src/core/yaml_config.py", line 185, in build_dataloader [rank0]: loader = create(name, global_cfg, batch_size=bs) [rank0]: File "/root/D-FINE-master/src/core/workspace.py", line 119, in create [rank0]: module = getattr(cfg["_pymodule"], name) [rank0]: KeyError: '_pymodule' E0716 16:37:12.999565 140709997880512 torch/distributed/elastic/multiprocessing/api.py:833] failed (exitcode: 1) local_rank: 0 (pid: 797171) of binary: /root/miniconda3/bin/python Traceback (most recent call last): File "/root/miniconda3/bin/torchrun", line 8, in <module> sys.exit(main()) File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 348, in wrapper return f(*args, **kwargs) File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/run.py", line 901, in main run(args) File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/run.py", line 892, in run elastic_launch( File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 133, in __call__ return launch_agent(self._config, self._entrypoint, list(args)) File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 264, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError: ============================================================ train.py FAILED ------------------------------------------------------------ Failures: <NO_OTHER_FAILURES> ------------------------------------------------------------ Root Cause (first observed failure): [0]: time : 2025-07-16_16:37:12 host : autodl-container-9efe41855c-0b570216 rank : 0 (local_rank: 0) exitcode : 1 (pid: 797171) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html ============================================================
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值