The Knock Sensor detects engine knock and sends a voltage signal to the ECM. The ECM uses the Knock Sensor signal to control timing. Engine knock occurs within a specific frequency range. The knock sensor, located in the engine block, cylinder head, or intake manifold is tuned to detect that frequency.
The knock sensor senses when fuel is burning unevenly and causing knocking or irregular vibrations in the engine. It consists of an electric coil that is wound around two ceramic rods with a magnet in the center. The vibration of the engine causes the rods to vibrate. This disturbs the coil s magnetic field and alters the current passing through the coil. This disturbance returns to the computer as a signal pattern that the computer analyzes. The computer then determines whether the vibrations are characteristic of engine knocking.
There are special sensor testing machines, but 99% of the time if the code come up with a fault it will be faulty, fit a new one.