A seismogram is a record of the seismic waves from an earthquake.
A seismograph or seismometer is the measuring instrument that creates the seismogram.
Almost all seismometers are based on the principle of inertia: a suspended mass tends to remain still when the ground moves.
The relative motion between the suspended mass and the ground will then be a measure of the ground’s motion.
On a seismogram from an earthquake, the P-wave is the first signal to arrive, followed by the slower S-wave, then the surface waves.
The arrival times of the P- and S-waves at different seismographs are used to determine the location of the earthquake.
Given that we know the relative speed of P- and S-waves, the time difference between the arrivals of the P- and S-waves determines the distance the earthquake is from the seismograph.