For situation that received signal is complex, how Early and late are calculated in spread spectrum tracking? How I can consider both real and imaginary in error calculation?
This is the common case for receiving spread spectrum signals since we do not know carrier frequency and phase offset but can determine that from the complex output of our correlators.
Each correlator (Early, Prompt and Late) would be complex; the complex Prompt correlator output is used for Carrier Recovery (measure rate of rotation or change in phase from one complex symbol to the next), and the magnitudes of the Early and Late correlators are used for Timing Recovery. If you are using spread spectrum that once carrier offset is removed only resides on the real axis (BPSK modulation), then the Early and Late Correlators can be simplified to be real only as long as the carrier offset is removed prior to timing recovery and carrier tracking is implemented in such a way to rotate the signal to the real axis. This is not necessary as complex Early and Late correlators can optionally be used in which case you would use the magnitudes to derive timing.
Here is a link to a decent online tutorial showing the use of the complex (I and Q) correlator outputs and further details timing recovery using Early-Late.
From which I clipped this diagram:
Additional methods to determine the error that I didn't see mentioned in the tutorial (after a quick review, perhaps they are detailed there as well):
$err = Re((P)^*(E-L))$
Where $(P)^*$ is the complex conjugate of the complex Prompt correlator output ($I_P-jQ_P$) sampled at the estimated symbol timing location, and E and L are the complex correlator outputs 1/2 a chip earlier ($I_E+jQ_E$) and 1/2 a chip later ($I_L+jQ_L$) than the estimated symbol timing location. The operation $Re()$ is to take the real part of the result: if there is no carrier offset, the phase of P should be the same as the phase of E-L on average such that the complex conjugate multiplication will rotate the result to the real axis, however due to noise contributions or possible carrier offset the result will have an imaginary component so the Re() operation is to remove that.
Multiplying out this form of the error discriminator based on I and Q outputs of each correlator results in:
$$ = I_P I_E - I_P I_L - Q_P Q_E +Q_P Q_L$$
If the signal is rotated to the real axis first using carrier recovery then this can be $P(E-L)$ were P, E and L are the output of the I (Real) correlator only in this case.
By multiplying by P as in both approaches above we both normalize the result and strip the data modulation from effecting the error result.