A new real-time calibration algorithm for phase shifting based on the fast Fourier transform (FFT) is presented. The purpose of this algorithm is to determine the phase shift between two fringe images rapidly and accurately. in it, the background distributions of two current fringe images are removed by recording additional fringe data with arbitrary phase shifts S. Thus, the phase shift between these two fringe patterns can be obtained correctly by the FFT method. With the help of an adaptive bandpass filter and a new modulation function defined in this paper, the accuracy of the phase-shift determination is further improved. By this method, we can simultaneously control the phase shift of the projection grating. The accuracy and the automation of the PMP system are enhanced greatly.