I'm doing a bit of research for academic purposes. And a thesis is "selftuning pid controller".
I've started with hardware - managed to make solid stand: DC motor - encoder, but got a problem: my system lacks inertia moment. I dont see where I can improve process with pid.
So I've moved to 3D printer (Marlin firmware Ramps 1.4 hw) extruder temp control management.
I've only basic knowledge in programming so I'm asking for advise before consequences 
in file temperature.cpp functions use P I D values, but they control digital output 10, so there is no PWM.
So my gues PID would be for time control when heater is on, am I right?
Would there be any use of using PWM?
temperature.cpp (43.1 KB)
You could add a flywheel to your DC motor to provide inertia.
For slow-responding systems (like a heater turned on and off with a relay) the 400 to 900 Hz hardware PWM is way too fast for the hardware. The relay would not be able to respond fast enough. In those cases the Output of the PID is often used to control a SLOW PWM output. For example an Output of range 0 to 5000 could be used to control how many milliseconds out of each 5-second PWM interval the output relay is activated.
I am currently working on a Slow Cooker (Crock Pot) PID Controller; I have posted on this forum about it and it includes the code I have been using and the issues I have had.
I short though I have found the best way is to use the PID calculation to return an output between 1-100% based on error and parameters. I then take this and multiply it by a factor of a time window I wish to use (50 to use a 5000 m/s window)
I then call a function to turn an SSR on for the calculated output period (100% = 5000m/s, 50% = 2500m/s etc.) and then switch off for the remainder of the window (so at 20% it would turn on, delay 1000 m/s, turn off, delay 4000 m/s and so on)