Stationeers

Stationeers

55 个评价
PID Controller & Filter
3
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
198.251 KB
2021 年 2 月 7 日 上午 4:46
2021 年 5 月 11 日 上午 6:49
2 项改动说明 ( 查看 )

订阅以下载
PID Controller & Filter

描述
General purpose PID controller with sensor filter

Pins

d0
Sensor
Device to read Process value from
d1
Actuator
(optional) Device to control
d2
SleepToggle
(optional) Device to toggle controller sleep
d3
SPDevice
(optional) Device to easily change setpoint

System variables
SetPoint: Desired target for the controller. Not used if you have set SPdevice.
Min/Max output: Upper and lower limits on the output of the controller.
FilterTicks: The number of ticks the controller should take an average of the sensor readings.
SPDeviceMultiplier: Simply a number that is multiplied with SPdevice readout if used.

Tuning
RegulatorMode: can be either 1 (direct) or -1 (reversed).
If your ProcessValue is higher than setpoint, should your actuator:
  • Increase: Direct mode (1)
  • Decrease: Reverse mode (-1)

In order to tune the controller, start with Ti and Td at zero. Find the highest Kp value that gives stable oscillation without reaching max or min, called Ku. Take not of the oscillation period (time between peeks) Tu. You can then calculate your variables based on desired behavior:
Control Type
Kp
Ti
Td
PI
0.45 * Ku
0.8 * Tu
0
classic PID
0.6 * Ku
0.5 * Tu
0.125 * Tu
no overshoot
0.2 * Ku
0.5 * Tu
0.33 * Tu

See https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method
and don't be afraid to tinker with the values and see it's behavior change.

Example world:
Europa: https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2394680235
Mars: https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2394680007
Moon: https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2394679313

AC example world:
https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2488371541
19 条留言
micle546 2023 年 11 月 26 日 上午 3:18 
Added 2 lines to add optional sleep inversion, for those pesky levers to face the correct way.
After "define SPDeviceMultiplier 1":
-Add: "define InvertSleep 0"
and after "l OnState SleepToggle Setting":
-Add: "xor OnState Onstate InvertSleep"
PhoenixKnight314 2023 年 10 月 6 日 上午 5:38 
This really is an awesome set of code! Is it easy for someone new to stationers with limited coding/ process control experience, no. But with trial and error and learning I have discovered just how powerful this is for controlling things when more than just a proportional controller is needed.

Great work and well worth the tutorials and trial and error to get it working. Using this in a few places, but my favorite application right now is on a system to condense pollutant in a heat pump system :sothappy:
Mr-Chris 2023 年 9 月 26 日 上午 10:33 
Sorry for the delay... I have been out of town. I will give this a try today and see what happens!
Elmo  [作者] 2023 年 9 月 3 日 下午 1:20 
@Meester Kreess the best thing about this script is that it is the only thing i have ever released that will never be out of date and stop working. But it's not nesseserily easy to set up. i had 2 courses in university just on how to manage PID controllers ;)

it sounds like you got a case of "integrator windup" https://en.wikipedia.org/wiki/Integral_windup

Long story short: your settings is way to sensitive and accumulates integral error rapidly.
try a much lower Kp and/or a much higher Ti
Mr-Chris 2023 年 9 月 3 日 下午 1:12 
I have this thing all wired up and I have the temp and room pressure under control. The volume(fuel) pump comes on for a few seconds when I first take it out of sleep mode. Then it never activates again while the generator is running. The generator runs out of fuel and then about 5 seconds later the fuel pump comes on and just starts pressurizing the line but the generator never activates again. I am not sure what the issue is with this but I am unable to get this script to do much of anything.
I have the generator Pressure as d0
fuel pump as d1
and a sleep switch as d2
set point is 50 but the generator runs at full pressure always
Does this no longer work ??
Universal82 2023 年 8 月 16 日 上午 5:00 
You are a legend
Xinax 2023 年 1 月 6 日 上午 3:02 
Is there a way, that I can use 2 PID controller in 1 IC10? I do not need the sleep, so It should work, when I make the PID inside the controller have 2 seperate Variable for them?
Elmo  [作者] 2022 年 7 月 22 日 上午 3:56 
stiefelriemenWill 2022 年 7 月 21 日 下午 11:58 
can u please make a video for dummies for the airconditioner how to setup everything? sorry for my bad english im using google translator. im 12 years old and using my brother pc thank you :steamhappy:
Soondead 2021 年 2 月 22 日 下午 12:17 
@Elmo I already have a setup for collecting, cooling and recycling the hot waste because running both input and output at the same time was always part of the plan. THANK YOU SO MUCH for the numbers, I'll try them right away! They're way, WAY higher than anything I ever tried, mostly because PID tuning is a big mystery to me :-)