PID Control Theory and Practice Part 1, Definitions

preview_player
Показать описание
Overview of PID controllers starting with basic definitions through using PI / PD controllers for controlling a (simulated) DC motor

Part 1
Definitions, basic terms - Proportional, Integral, Derivitive, Control System

Part 2
Simple DC motor model Built with Matlab / Simulink

Part 3
P, I, and PI control of motor velocity

Part 4
Practical considerations
Simple tuning rules

Part 5
PI, PD, and PID control of motor position - why you want to use PD instead of PI

Psuedo Code for a PID controller - Typically only the P and I parts or P and D parts would be used.

Const F32 P_Gain = 1; // Gain for proportional controller
Const F32 I_Gain = .1; // Gain for integral controller
Const F32 D_Gain = .01 // Gain for derivative controller
Const F32 Filter_Const = .25 // Filter constant for filtering input to derivative controller
// minimum value = 0, maximum value = 1
F32 P_Control; // output of proportional controller
F32 I_Control; // output of integral controller
F32 D_Control; // output of integral controller
F32 Filter_Out; // output of filter
F32 Filter_Out_Prev // previous output of thefilter - use to get delta change
Const F32 Target_Value = 100; // target set point for controller
F32 Measured_Value; // measured plant output
F32 Error_Value; // difference between desired and measured plant output.
F32 PID_Out; // final controller output value
F32 Loop_Time // time for one control loop - could be a constant or a measured value

Measured_Value = input(); // get A/D reading -- convert units if necessary
Error_Value = Target_Value -- Measured_Value;

P_Control = P_Gain * Error_Value;

I_Control = I_Control + I_Gain * Error_Value * loop_time; // integrate error * gain*delta time
// you need to include antiwindup here to turn off integrator when the control output saturates.
// If you leave out the loop time, you can adjust the gain value to somewhat compensate

Filter_Out_Prev = Filter_Out; // save previous value
Filter_Out = Filter_Const*Error_Value + (1-Filter_Constant)* Filter_Out;
// take a portion of the new input and a portion of the old value to average out over several samples
// simulate a first order exponential filter.
D_Control = D_Gain * (Filter_Out - Filter_Out_Previous) / Loop_Time; // derivative output based on filtered value

PID_Out = P_Control + I_Control + D_Control; // Final output
Рекомендации по теме
Комментарии
Автор

can u provide us the motor parameters.

tejsw
Автор

The definitions are poorly represented in the context of a PID controller. The explanations don't relate to what the responsibilities of the constants (Kp Ki Kd) are but are mathematical definitions which are very generalised.

daffyduck