September 2017
Intermediate to advanced
206 pages
4h 34m
English
First, we define our PID parameters:
P = 1.4 I = 1 D = 0.001 pid = PID.PID(P, I, D) pid.SetPoint = 0.0 pid.setSampleTime(0.01) total_sampling = 100 feedback = 0 feedback_list = [] time_list = [] setpoint_list = []
After that, we compute the PID value during sampling. In this case, we set the desired output values as follows:
for i in range(1, total_sampling): pid.update(feedback) output = pid.output if pid.SetPoint > 0: feedback += (output - (1 / i)) if 20 < i < 60: pid.SetPoint = 1 if 60 <= i < 80: pid.SetPoint = 0.5 if i >= 80: pid.SetPoint = 1.3 time.sleep(0.02) feedback_list.append(feedback) ...
Read now
Unlock full access