搜索
楼主: PEN

使用Python进行液压缸模拟

    [复制链接]
  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-3-3 03:32:09 | 显示全部楼层
本帖最后由 PEN 于 2018-3-3 03:37 编辑

一个挑战。
通常我使用
10(mm / s)/%开环增益
10 Hz为自然频率
阻尼系数为0.333333
但是,现在尝试
10(mm / s)/%开环增益
2 Hz为自然频率
0.1为阻尼系数
这个动议是一个非常小但很快的举动。
command_position = 100.0
move = ma.MoveAbsolute(command_position,500.0,2500.0,2500.0)
加速时间是0.2秒。
Bosch-Rexroth说加速时间应该是5 /(2 * PI * 2/3)= 1.19秒
使用先进的算法,我可以在0.4秒内完成整个过程。

如果
command_position = 100.0
move = ma.MoveAbsolute(command_position,500.0,2500.0,2500.0)
太难用了
command_position = 1000.0
move = ma.MoveAbsolute(command_position,500.0,400.0,400.0)
现在加速时间是1.25秒,比Bosch-Rexroth预测的1.19秒稍长。

我没有使用普通的PID控制类型。 注意控制输出看起来很奇怪。

回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-3-21 05:56:45 | 显示全部楼层
仅P型控制器不可能具有比PD控制器更高的比例增益,并且可以像PD控制器一样工作。 我选择比较PD和P控制器,因为这是最接近的比较。 两个闭环系统都是三阶的,只有一个增益需要改变才能证明我的观点。

我已经做了两个图片的回应。 一个PD控制,没有前馈。 另一个是P只控制,没有前馈。 PD控制器的增益大于5.6,Kp = 5.654。 有以下错误,因为没有前馈,但跟随误差远远低于P控制所能达到的误差。

对于仅比例控制,我将微分增益设置为0. Kd = 0。
我设定Kp = 4.5。 即使只有比例增益会振荡,您仍可以看到。
PD控制Kp = 5.6并且没有振荡。

A P only controller cannot possibly have a higher proportional gain than a PD controller and work as well as a PD controller.   I choose to compare a PD vs P controller because this is the closest comparison.  Both closed loop systems are third order and only one gain needs to change to prove my point.

I have made two pictures of the response.   One with PD control and no feed forwards.  The other is with P only control and no feed forwards.   The proprtional gain for the PD controller is over 5.6, Kp=5.654.  There is following error because there are no feed forwards but the followign error is much lower than what can be achieved with P control.

For the proportional only control I set the derivative gain to 0. Kd = 0.
I set Kp=4.5.   You can see even though the proportional only gain will oscillate.
The PD control Kp=5.6 and follows with no oscillation.
PD control.png
P only Kp=4pt5.png
回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-4-9 01:34:04 | 显示全部楼层
本帖最后由 PEN 于 2018-4-9 01:36 编辑

我喜欢使用简单的开环线性模型进行仿真。
OLTF(s)= K *ω^2 /(s *(s^ 2+ s *ζ*ω* s+ω^2)
Python模拟器使用等效的微分方程。
K = 10(mm / s)/%开环增益(mm /秒)/%
ζ= 0.3333333阻尼因子
ω= 2 *π* 10弧度/秒
s =拉普拉斯算子

该模型接近使用液压缸1000x63x40mm移动2900 Kg质量。 供应压力为200巴,阀门为100升/分钟的阀门。 这是一个现实的负担。

我期望人们使用模拟器使用VCCM方程和使用固有频率方程的固有频率来计算开环增益。

使用具有二阶微分增益的PID时,控制器效果最佳。 速度,加速度和挺举前馈也用于预测控制输出作为目标速度,加速度和加加速度的函数。 采样时间为0.0005秒。


回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-6-2 10:17:01 | 显示全部楼层
I have updated the Python hydraulic simulator so it can generate sine waves.
There are many little improvements.
http://deltamotion.com/peter/py/HydSim.zip
回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:99
  • 打卡总奖励:674
发表于 2018-6-4 17:42:48 | 显示全部楼层
厉害了,直接运行成功,无聊搜索python液压库,没想到还真有人做。
回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:99
  • 打卡总奖励:674
发表于 2018-6-4 17:46:36 | 显示全部楼层
PEN 发表于 2018-2-4 02:27
希望压缩将是答案
http://deltamotion.com/peter/py/HydSimCN.py.zip

你在公司权限挺高的啊,可以向公司服务器传代码当网盘用啊,哈哈。
回复 支持 反对

使用道具 举报

  • 打卡等级:无名新人
  • 打卡总天数:7
  • 打卡总奖励:7
发表于 2018-6-4 21:22:58 | 显示全部楼层
代码运行出错,请教如何解决?

回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-6-5 00:50:30 | 显示全部楼层
您正在使用基本的python安装程序。
你需要安装numpy,scipy,matplotlib软件包。
软件功能从这些软件包中导入。
使用Anaconda安装所有程序是最容易的。
https://repo.anaconda.com/archiv ... -Windows-x86_64.exe

如果您使用的是Windows 10
由于您安装了常规的Python软件,因此您需要转到正确的目录并键入。 您将需要搜索目录。
pip install numpy
pip install scipy
pip install matplotlib

如果您使用的是Linux或OS X,那很容易。
打开一个终端。
pip install numpy
pip install scipy
pip install matplotlib

模拟器的所有新更新都会在这里。
我将添加一个函数来很快计算开环增益和固有频率
http://deltamotion.com/peter/py/HydSim.zip
回复 支持 反对

使用道具 举报

  • 打卡等级:无名新人
  • 打卡总天数:7
  • 打卡总奖励:7
发表于 2018-6-5 17:20:06 | 显示全部楼层
Anaconda 软件已经安装,如何用Anaconda 软件运行closedloop.py、HydSim-linear.py、hydsimplot.py、model.py、moveabsolute.py、movesine.py

回复 支持 反对

使用道具 举报

  • 打卡等级:偶尔看看
  • 打卡总天数:101
  • 打卡总奖励:315
 楼主| 发表于 2018-6-6 01:36:59 | 显示全部楼层
Spyder是用于编辑和运行Python程序的程序。
启动Spyder。
如果您在Windows 10上安装了Anaconda,则无需启动Anaconda即可启动Spyder。 这很容易。
转到文件 - >打开
搜索Hydsim-linear.py
使用菜单或F5运行。
Hydsim-linear.py是导入其他程序的主要程序。

Spyder is the program that is used to edit and run Python programs.
Start Spyder.
If you installed Anaconda on Windows 10 you can start Spyder without starting Anaconda.  This is easier.
Go to file->open
search for Hydsim-linear.py
Run by using menu or F5.
Hydsim-linear.py is the main program that imports the other programs.


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则