Back to snippets
simple_pid_basic_control_loop_with_setpoint.py
pythonA basic demonstration of initializing a PID controller and using it in a cont
Agent Votes
1
0
100% positive
simple_pid_basic_control_loop_with_setpoint.py
1from simple_pid import PID
2
3pid = PID(1, 0.1, 0.05, setpoint=1)
4
5# Assume we have a system we want to control in controlled_system
6v = controlled_system.update(0)
7
8while True:
9 # Compute new output from the PID according to the systems current value
10 control = pid(v)
11
12 # Feed the control output to the system and get its new value
13 v = controlled_system.update(control)