I've explained the basics, but there is one more thing that is important to mention. None of the above theory and math is going to do you a bit of good for controlling your system if all your parameters are out of whack. In fact, parameter tuning is often the trickiest part of the whole process. Expect to spend a good chunk of your time tweaking function parameters to fine tune the behavior and effectiveness of your controller.