项目作者: hirschmann

项目描述 :
PID控制器/酿造水壶模拟
高级语言: Python
项目地址: git://github.com/hirschmann/pid-autotune.git
创建时间: 2017-04-07T17:28:11Z
项目社区:https://github.com/hirschmann/pid-autotune

开源协议:MIT License

下载


PID-controller/brewing kettle simulation

This project has been created to support tuning a PID controller for a home brewing setup using CraftBeerPI.
It consists of a brewing kettle simulation, a PID controller (based on Arduino PID Library) and a PID autotune algorithm (based on Arduino PID Autotune Library)

Project goals

  • allow users to find PID parameters which provide a sufficient basis for further manual tuning
  • allow users to compare different PID parameters
  • help users to understand how different PID parameters (Kp, Ki, Kd) influence a PID controller’s behavior (not only limited to home brewing setups)
  • speed up auto tuning

PID comparison

Compare different PID parameters using the default kettle setup:
sim.py --pid 'reference' 98 0.66 230 --pid 'Kp too low' 30 0.66 230 --pid 'Ki too low' 98 0.01 230

PID parameters comparison

PID autotune simulation

Simulate a PID autotune run on a 50l kettle with a 4 kW heater:
sim.py --atune --volume 50 --power 4

PID autotune simulation

Generated PID parameters using different tuning rules:

  1. rule: ziegler-nichols
  2. Kp: 7.66141138481997
  3. Ki: 0.4086086071903984
  4. Kd: 35.91286586634361
  5. rule: tyreus-luyben
  6. Kp: 5.920181524633613
  7. Ki: 0.07104217829560336
  8. Kd: 35.239175741866745
  9. rule: ciancone-marlin
  10. Kp: 3.9467876830890756
  11. Ki: 0.46308975481578485
  12. Kd: 18.272165199486462
  13. rule: pessen-integral
  14. Kp: 9.30314239585282
  15. Ki: 0.6202094930568547
  16. Kd: 52.46132929992192
  17. rule: some-overshoot
  18. Kp: 4.341466451397983
  19. Ki: 0.2315448774078924
  20. Kd: 54.26833064247478
  21. rule: no-overshoot
  22. Kp: 2.60487987083879
  23. Ki: 0.13892692644473545
  24. Kd: 32.56099838548487
  25. rule: brewing
  26. Kp: 104.1951948335516
  27. Ki: 0.8335615586684127
  28. Kd: 205.64841085569392

Options

  1. usage: sim.py [-h] [-p name kp ki kd] [-a] [-v] [-e] [-n] [-t T] [-s T]
  2. [--ambient T] [-i t] [-d t] [--sampletime t] [--volume V]
  3. [--diameter d] [--power P] [--heatloss x] [--minout x]
  4. [--maxout x]
  5. optional arguments:
  6. -h, --help show this help message and exit
  7. -p name kp ki kd, --pid name kp ki kd
  8. simulate a PID controller
  9. -a, --atune simulate autotune
  10. -v, --verbose be verbose
  11. -e, --export export data to a .csv file
  12. -n, --noplot do not plot the results
  13. -t T, --temp T initial kettle temperature in °C (default: 40)
  14. -s T, --setpoint T target temperature in °C (default: 45)
  15. --ambient T ambient temperature in °C (default: 20)
  16. -i t, --interval t simulated interval in minutes (default: 20)
  17. -d t, --delay t system response delay in seconds (default: 15)
  18. --sampletime t temperature sample time in seconds (default: 5)
  19. --volume V kettle content volume in liters (default: 70)
  20. --diameter d kettle diameter in cm (default: 50)
  21. --power P heater power in kW (default: 6)
  22. --heatloss x kettle heat loss factor (default: 1)
  23. --minout x minimum PID controller output (default: 0)
  24. --maxout x maximum PID controller output (default: 100)

Installation

  1. Install git and python3
  2. Clone this repository:
    git clone https://github.com/hirschmann/pid-autotune.git
  3. Install project dependencies:
    pip install matplotlib

After you have completed these steps, you should be able to run sim.py as shown above. If plots are not shown, you have to configure the matplotlib backend, see What is a backend?