PID Controller Implementation in Software
Source code available here: https://github.com/pms67/PID
How to implement a PID controller in software using C, discussing theory and practical considerations. Demonstration of PID controller code using a custom flight simulator.
If you're enjoying my content, please consider becoming a patron: https://www.patreon.com/phils94
[NOTE] Something I forgot to mention in the video! Note on 'derivative-on-measurement': Since the 'error signal' effectively going into the differentiator does not depend on the setpoint: e[n] = 0 - measurement, and therefore (e[n] - e[n - 1]) = (0 - measurement) - (0 - prevMeasurement) = -Kd * (measurement - prevMeasurement). Note the minus sign compared to derivative-on-error!
I've made the change in the Git repo - before you would have had to use a negative Kd gain to get the same result. Now you can, as normal with derivative-on-error, use a positive Kd gain as usual.
Additional note: The derivative low-pass filter can be controlled by the constant 'tau', which is the time constant of the filter (-3dB frequency in Hz, fc = 1 / (2*pi*tau)). A larger value of tau means the signal is filtered more heavily. As tau approaches zero, the differentiator approaches a 'pure differentiator' with no filtering.
[TIMESTAMPS]
00:00 Introduction
00:39 Control system basics
02:40 PID representation in continuous domain
04:57 Converting from the continuous to the discrete domain
06:11 PID controller difference equation
07:35 Practical considerations
10:48 Basic software structure
11:53 Implementation in C
18:46 Example: Flight simulator using PID controller code
Видео PID Controller Implementation in Software канала Phil’s Lab
How to implement a PID controller in software using C, discussing theory and practical considerations. Demonstration of PID controller code using a custom flight simulator.
If you're enjoying my content, please consider becoming a patron: https://www.patreon.com/phils94
[NOTE] Something I forgot to mention in the video! Note on 'derivative-on-measurement': Since the 'error signal' effectively going into the differentiator does not depend on the setpoint: e[n] = 0 - measurement, and therefore (e[n] - e[n - 1]) = (0 - measurement) - (0 - prevMeasurement) = -Kd * (measurement - prevMeasurement). Note the minus sign compared to derivative-on-error!
I've made the change in the Git repo - before you would have had to use a negative Kd gain to get the same result. Now you can, as normal with derivative-on-error, use a positive Kd gain as usual.
Additional note: The derivative low-pass filter can be controlled by the constant 'tau', which is the time constant of the filter (-3dB frequency in Hz, fc = 1 / (2*pi*tau)). A larger value of tau means the signal is filtered more heavily. As tau approaches zero, the differentiator approaches a 'pure differentiator' with no filtering.
[TIMESTAMPS]
00:00 Introduction
00:39 Control system basics
02:40 PID representation in continuous domain
04:57 Converting from the continuous to the discrete domain
06:11 PID controller difference equation
07:35 Practical considerations
10:48 Basic software structure
11:53 Implementation in C
18:46 Example: Flight simulator using PID controller code
Видео PID Controller Implementation in Software канала Phil’s Lab
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Hardware Demo of a Digital PID ControllerFIR Filter Design and Software ImplementationControlling Self Driving CarsEmbedded Programming for QuadcoptersSTM32 Programming Tutorial for Custom Hardware | SWD, PWM, USB, SPIWhat is a PID Controller?KiCad STM32 Hardware Design - An Overview in 20 MinutesPID Math DemystifiedEEVacademy #6 - PID Controllers ExplainedHow to Tune a PID ControllerTop 3 Programming Languages to Learn in 2019PID temperature controller DIY ArduinoPID brushless motor control tutorialWhy Most People FAIL to Learn ProgrammingKiCad STM32 + RF + USB Hardware DesignModelling of Dynamical Systems - Control System Design 2/6Coding Adventure: Ant and Slime SimulationsFlight Control System Design: Hardware and PCB Design with KiCADPID Balance+Ball | full explanation & tuning