As simple as that. I assume that you use PID when you do not know the Transfer Function of the system, otherwise you use it and plug it directly in the closed-loop control.
No, you do not have to know the whole transfer function. It is quite common practice to manually tune a PID either by hand or with some computer. Sometimes, the transfer function would be way to complex/arbitrary to be computed, so you may approximate it or use a device which generate a step response of your system in order to generate an approximate PID.
The latter method does not give the "perfect/ideal" response for your system, but in practice you will never be able to do that. Even if you have the transfer function of a system, there are factors that will have an impact on it: components tolerance, process tolerance, aging, temperature, etc. So you use a PID which is the closest to the specification that you expect.
In control theory, it would be possible to use a linear function for everything (only P factor), but you would have very bad response on many system and that response is not acceptable in most situations, but even with a PID you cannot always provide good enough feedback. It is up to you to determine whether you need a complex transfer function or not. I already had to design a PID for a complex system with a 8th order transfer function. A simple PID was not sufficient to model the inverse of that tranfer function, but I've been able to remove many components through the study of the pole and zero map of the transfer function. Then, I decided which transfer function would be best PID for my system. I had many candidates and I tested them (manually) to find out.
Update: To answer your comment:
A PID is a tool, but it is not "THE only feedback possible". If you have the transfer function, you can use it directly. What you learn from textbooks is that most of the time a PID is good enough to model most simple systems.
However, I study in robotics and I can tell you that I rarely can use a PID to control to control the robot (call it a plant). We use a PID to drive the joint motors, because the mechanics are simple (You have a torque, friction, etc.). But you cannot use a PID to smooth the movements performed by a complete arm or a leg. Instead, you use more powerful tools: The direct kinematics (a set of matrix) allows to defines the location of the end effector relative to another part on the robot and then we use the inverse kinematics (another set of matrix) in the feedback loop, so that you can adjust the current position of the robot relative to the path that we expect.
Those matrixes are elements of a control loop but they cannot be modeled as a 2nd order equation. This may seeem weird at first, but if you have matlab at hand, you can try to convert any PID transfer function to an SOS matrix. The maths are very similar: you mutiply every matrix together and you implement your feedback loop with it.
The reason why PID are very popular is because they are:
- Easy to implement, even in machine code (practical for microcontrollers);
- Good enough most of the time;
- They require very little calculus.
Since I already discussed points 1 and 2, I discuss third one: If you really have the transfer function of your system, say a huge 23-rd order transfer function that includes a lot of sines, cosines (in your polynomial parameters) and so on, you may end up with a very complex calculus which may require the usage of floating point arithmetic. On a computer, this is not much of a big deal, but on an embedded system, this may be problematic, because it is too slow to keep up with expected update rate. If you study the pole zero plot and identify that you can reduce your gigantic 23-rd order TF to a 4-th order one, then the calculus is much more manageable.
The goal in a typical control system is to produce the sequence of output stimuli which will allow the system to achieve a desired state at lowest "cost" [cost may be measured in energy, time, machine stress, imprecision in the achieved state, or various other ways]. If one knows precisely how the system will react to various stimuli, one may simulate what it would do if fed various sequences of stimuli and determine which would yield the best results. Indeed, if one's knowledge of the system was perfect, one could determine what sequence was necessary and then output that sequence without bothering to look at any feedback. In general, however, one won't know precisely how the system will respond to stimuli, but will be able to establish an envelope of states which can be achieved within a certain length of time. For example, if one knows that "accelerate 90% maximum forward" will increase a machine's forward speed (or decrease reverse speed) by at least 1m/s, and "accelerate maximum reverse" will do the reverse, and if the goal is to have the machine arrive as quickly as possible at a spot 10 meters ahead, one may calculate the maximum speed the machine may be traveling at any particular distance from the target without having to apply more than 90% maximum acceleration; if one's present velocity is less than the maximum, one may calculate how much time may be saved by accelerating versus coasting until one would have to reduce speed and accelerate or coast as appropriate; otherwise, one can request 90% maximum reverse if one's speed precisely matches the envelope, more than 90% of maximum if it's too fast, or less than 90% of maximum if it's slower than it needs to be.
If a system has a nice clean relationship between "position" and "velocity" (as with the motion-control example), one can read velocity directly, and one's goal is to reach the target quickly, an envelope-based approach can offer very good response. If, however, the relationship between control system's output and any observable response is more complex or less-well characterized, a PID loop may be helpful. When using a complex behavioral model, even if one can predict how the system will respond to any given stimulus, it may be difficult to determine what stimulus should be given to achieve a desired response. If one assumes that system response may be modeled as a second-order linear filter on the outut stimulus, one can compute the inverse of that filter (which will, itself, be a second-order filter). That resulting second-order filter may in turn be converted to a PID loop (a PID loop is basically a second order infinite-impulse-response filter with a very short time constant on the first stage and a very long one on the second; the sum of the coefficients of the input and first stage are the "P" term and the difference, divided by the time constant, is the "D" term; the second-stage coefficient divided by the second-term time constant represents the "I" term).