In the previous articles I used an ideal synchronous detector to understand how a weak signal can be extracted from noise. Before designing the circuit, however, there is a question I want to address: what happens if the two channels that let me reconstruct amplitude and phase are not perfectly equal and the references are not exactly in quadrature?

I start from a simple model that can be corrected by calibration. Later I will have to distinguish these linear errors from those that change the waveform or destroy information, such as clipping, distortion and aliasing. The tests are numerical and educational, not measurements of an amplifier that has already been built.

1. Gains, offsets and phase: an affine model

In the article on quadrature detection I had already observed how errors transform the ideal circular locus of the X and Y readings. Now I want to understand whether they can be compensated. I use the peak-amplitude convention: for an input A cos(ωt+φ), the ideal references 2 cos(ωt) and −2 sin(ωt) give, in steady state, X=A cos φ and Y=A sin φ. Suppose instead that the second reference is −2 sin(ωt+ε). The averaged product is A sin(φ−ε), which is no longer the ideal orthogonal projection.

\[ \begin{aligned} X_m &= g_X X + o_X\\ Y_m &= g_Y\,(Y\cos\varepsilon – X\sin\varepsilon) + o_Y\end{aligned} \]

The two readings m include the baseband offsets oX, oY and the relative gains gX, gY. I am not attributing to these offsets the effect of a DC component at the input of the multiplier: here they are additive errors of the demodulated readings. The model contains no noise, clipping, transients or time variation of the parameters. I choose A=1 V as the reference amplitude, not as a limit or specification of the future instrument.

ParameterEducational value
A1 V (peak)
gX1.02
gY0.98
oX+0.020 V
oY−0.015 V
ε3°

Try it yourself with GX-TXT

I carried out the tests that follow with GX-TXT, free software you can install on Linux. There is no need to take my numbers on trust: follow the steps, rebuild the tables and the graphs and compare your results with mine. Then change something — the gains, the offsets, the phase error, the clipping level, the jitter, the frequency mismatch or the sampling frequency — and see which errors can be corrected and which cannot. It is the best way to really understand how a real lock-in departs from the ideal model, and to have some fun too.

1.1. The test in the Worksheet

I create an independent session called LockIn_12_modello_reale. I use 13 phases from 0° to 360° in steps of 30° (0° and 360° represent the same direction). The sheet works with the numerical values in V and degrees according to the conventions stated here; I do not assign structured units to the voltage columns. The trigonometric functions with the suffix d interpret angles directly in degrees.

In Viewers (1) I search for Worksheet in the Search box (2) and open the viewer (3).

I select A1 (4), enter the formula in Cell & Formula (5) and confirm with Apply (6). Column A: the thirteen phases in degrees.

=vector(0,30,60,90,120,150,180,210,240,270,300,330,360)

To calculate the ideal X I select B1 (7), open Functions (8), type cosd in the search box (9), select the function (10) and press Insert formula (11). The description specifies that the argument is an angle expressed in degrees.

The command puts a ready-made example, =cosd(60) (12), into Cell & Formula. I replace it with the reference to the thirteen phases.

I select B1 (13), enter the formula in Cell & Formula (14) and confirm with Apply (15). Column B: ideal X for A=1 V.

=cosd(A1:A13)

I select C1 (16), enter the formula in Cell & Formula (17) and confirm with Apply (18). Column C: ideal Y.

=sind(A1:A13)

Look for example at row 4, where φ=90°: X is practically zero and Y is 1. The small numerical residue of the cosine is due to floating-point arithmetic. The initial cell of each vector column shows the anchor with the sequence; the formulas that read the range use the individual elements.

I select D1 (19), enter the formula in Cell & Formula (20) and confirm with Apply (21). Column D: X reading with gain and offset.

=numeric.add(numeric.multiply(1.02,B1:B13),0.02)

I select E1 (22), enter the formula in Cell & Formula (23) and confirm with Apply (24). Column E: Y reading with phase error, gain and offset.

=numeric.subtract(numeric.multiply(0.98,sind(numeric.subtract(A1:A13,3))),0.015)

I select F1 (25), enter the formula in Cell & Formula (26) and confirm with Apply (27). Column F: magnitude of the two uncorrected readings, in V.

=numeric.sqrt(numeric.add(numeric.square(D1:D13),numeric.square(E1:E13)))

In the ideal case the magnitude is 1 V at all phases. In the non-ideal case the row at 90° gives about 0.963864 V, while the one at 330° gives about 1.056956 V: at these points the amplitude error is −3.61% and +5.70% respectively. The error depends on the phase even though the input amplitude is unchanged. These are the extremes among the thirteen directions examined, not guaranteed extremes over the whole circle.

1.2. Inverting the model

When the correction is possible

If I know offsets, gains and phase error, I can recover the corrected components. First I remove the offsets and normalize the gains; then I use the corrected X to separate the non-orthogonal part from Y. The inversion exists if gXgY cos ε is non-zero. When cos ε tends to zero the two references become almost parallel: the correction is ill-conditioned and can strongly amplify noise and calibration errors.

\[ \begin{aligned} X_c &= \frac{X_m – o_X}{g_X}\\ Y_c &= \frac{1}{\cos\varepsilon}\left[\frac{Y_m – o_Y}{g_Y} + X_c\sin\varepsilon\right]\end{aligned} \]

I select G1 (28), enter the formula in Cell & Formula (29) and confirm with Apply (30). Column G: corrected X.

=numeric.divide(numeric.subtract(D1:D13,0.02),1.02)

I select H1 (31), enter the formula in Cell & Formula (32) and confirm with Apply (33). Column H: corrected Y.

=numeric.divide(numeric.add(numeric.divide(numeric.add(E1:E13,0.015),0.98),numeric.multiply(G1:G13,sind(3))),cosd(3))

I select I1 (34), enter the formula in Cell & Formula (35) and confirm with Apply (36). Column I: reconstructed amplitude after compensation.

=numeric.sqrt(numeric.add(numeric.square(G1:G13),numeric.square(H1:H13)))

To compare the phases I do not directly subtract two angles returned by atan2: a phase of 359° and one of 1° would give an artificial jump if I did not handle periodicity. I calculate the argument of the rotation from the ideal vector (X,Y) to the observed vector by means of the determinant and the scalar product.

\[ \Delta\varphi = \operatorname{atan2}\!\left(X Y_m – Y X_m,\; X X_m + Y Y_m\right) \]

The rad2deg function converts the result to degrees. The result is the principal angular error, between −180° and +180°; it is defined if both vectors are non-zero.

I select J1 (37), enter the formula in Cell & Formula (38) and confirm with Apply (39). Column J: phase error before correction, in degrees.

=rad2deg(numeric.atan2(numeric.subtract(numeric.multiply(B1:B13,E1:E13),numeric.multiply(C1:C13,D1:D13)),numeric.add(numeric.multiply(B1:B13,D1:D13),numeric.multiply(C1:C13,E1:E13))))

I select K1 (40), enter the formula in Cell & Formula (41) and confirm with Apply (42). Column K: phase error after compensation, in degrees.

=rad2deg(numeric.atan2(numeric.subtract(numeric.multiply(B1:B13,H1:H13),numeric.multiply(C1:C13,G1:G13)),numeric.add(numeric.multiply(B1:B13,G1:G13),numeric.multiply(C1:C13,H1:H13))))

Among the test points the phase error ranges from about −4.550° (at 30°) to +1.153° (at 270°). After the inversion, the magnitude is 1 V within numerical precision and the phase errors shown are of the order of 10−14 degrees or less. This is not a metrological result: I am using exactly the same coefficients with which I built the model. The real calibration will have to estimate them from independent data with finite uncertainty, also checking thermal stability, frequency and signal level.

1.3. Looking at the amplitude error

Procedure in GX-TXT: creating the amplitude chart (Figure 15)

I select A1:I13 (43) and open Insert (44) → Native chart from selection (45).

I set the title Quadrature amplitude error and correction (46), X=A (47), Y=F I (48), rows 1–13 (49, 50), circle marker (51), X limits 0–360 (52, 53) and Y limits 0.94–1.08 (54, 55), with linear scales. I confirm with Apply (56). I do not plot the angular error on the same axis, since it has different units.

In the live graph the horizontal axis A is the phase in degrees and the ordinate is the magnitude in volts. The blue curve varies with phase and the red curve lies on the true value of 1 V. The markers correspond to the thirteen calculated conditions: the segment connecting them helps to read the trend, it is not a further measurement. In this linear model the compensation solves the mathematical problem; if the signal exceeds the dynamic limit of a stage or is altered by distortion, however, inverting a gain and phase matrix is not enough.

1.4. Final comparison of the two corrections

Procedure in GX-TXT: publishing the two charts and axis labels (Figures 17–20)

I save the Worksheet with Save (57) and publish the magnitude graph with Publish immutable Graph to Plots (58). I wait for it to complete before creating the next graph.

For the phases I select J1:K13 (59) and repeat the Insert → Native chart from selection procedure of Figure 15. I do not include voltage columns and angular columns together: the graph must have compatible ordinates. The new initial chart uses J as X and K as Y; I therefore change the columns as follows.

I set the title Quadrature phase error and correction (60), X=A (61), Y=J K (62), rows 1–13 (63, 64), circle marker (65), X limits 0–360 (66, 67) and Y limits −5–2 (68, 69), linear scales. Apply (70), Save and Publish immutable Graph to Plots (71). I close by saving the changes to the working session.

In Plots I select the published graph, open Presentation → Title and labels, write Input phase (deg) (72) and Amplitude (V) (73), then Save (74). I use Render → Rerender selected and confirm completion.

Procedure in GX-TXT: axis labels of the phase chart (Figure 22)

In Plots I select the published graph, open Presentation → Title and labels, write Input phase (deg) (75) and Phase error (deg) (76), then Save (77). I use Render → Rerender selected and confirm completion.

The two graphs complete the comparison of section 1. The amplitude and phase CSV files are the ones published directly by the Worksheet. The maximum difference of the corrected magnitude from 1 V over the thirteen points is about 4.44·10−16 V, while the maximum corrected angular error in absolute value is about 2.54·10−14 degrees. I do not interpret these figures as the accuracy of an instrument: they simply show the numerical inversion of the model with the exact coefficients.

2. Clipping: when the signal can no longer be recovered with a linear correction

Now I imagine an amplifier ahead of the demodulator that ideally has unity gain but cannot exceed ±1 V. I want to understand what a perfectly calibrated lock-in will read if the signal is already distorted before it reaches the multiplier. In this test I exclude offset, noise, asymmetries, slew rate, recovery from saturation and other dynamic effects: I want to isolate instantaneous, symmetrical, memoryless clipping.

\[ \begin{aligned} u(\theta) &= A\cos\theta\\ v(\theta) &= \max\bigl(-L,\,\min(L,\,u(\theta))\bigr), \qquad L = 1\ \mathrm{V}\end{aligned} \]

For A=0.8 V the signal always stays within the limits. For A=1.5 V the upper and lower parts of the sine wave are cut off. The fundamental coincides neither with the input peak (1.5 V) nor necessarily with the output peak (1 V): it is the coefficient of the projection onto the fundamental sinusoid. A lock-in with a sinusoidal reference, averaging over whole periods and ideal rejection of the other components measures exactly that projection, with the peak-amplitude normalization of the previous articles.

2.1. From waveforms to coefficients

I reopen the saved Worksheet in the same session, without modifying the first sheet. I create the new sheet Clipping.

I use the + button (78), type Clipping in the Sheet name dialog (79) and press Apply (80).

In Functions (81) I search for uniform_grid (82) and select numeric.uniform_grid (83).

I set start=0 (84), stop=359 (85), spacing=360 (86), Options=mode="count" (87) and Output cell=A1 (88). I press Preview fields (89), select x in Result field (90) and confirm with Apply result (91). I get 360 points, one per degree from 0° to 359°. I do not repeat 360°, because for a discrete average over one period that sample would coincide with the first.

I select B1 (92), enter the formula in Cell & Formula (93) and confirm with Apply (94). B: unit cosine reference.

=cosd(A1:A360)

I select C1 (95), enter the formula in Cell & Formula (96) and confirm with Apply (97). C: input with 0.8 V peak.

=numeric.multiply(0.8,B1:B360)

I select D1 (98), enter the formula in Cell & Formula (99) and confirm with Apply (100). D: stage output for the 0.8 V input.

=numeric.maximum(-1,numeric.minimum(1,C1:C360))

I select E1 (101), enter the formula in Cell & Formula (102) and confirm with Apply (103). E: input with 1.5 V peak.

=numeric.multiply(1.5,B1:B360)

I select F1 (104), enter the formula in Cell & Formula (105) and confirm with Apply (106). F: output limited to ±1 V for the 1.5 V input.

=numeric.maximum(-1,numeric.minimum(1,E1:E360))

Already in the first samples you can see that C and D coincide, while E exceeds the limit and F stays at 1 V. To read the other harmonics I use the same idea as the synchronous detector: with θj=2πj/N and j=0,…,N−1, I calculate the cosine coefficients ak and sine coefficients bk for the orders of interest. The peak amplitude of the k-th harmonic is √(ak²+bk²). For symmetrical clipping of an ideal cosine the signal is even and has half-wave symmetry, so the sine coefficients and the even-order cosine coefficients are zero in the continuous series; for the fundamental I also check the sine component and the DC component in the sampling.

\[ \begin{aligned} a_k &= \frac{2}{N}\sum_{j=0}^{N-1} v(\theta_j)\cos(k\theta_j)\\ b_k &= \frac{2}{N}\sum_{j=0}^{N-1} v(\theta_j)\sin(k\theta_j)\end{aligned} \]

With a reference of amplitude 2 the first coefficient coincides with the X reading of the ideal lock-in; the sign of the higher coefficients specifies the relative phase, not a negative amplitude. In G1:G4 I calculate a1 for the small signal and a1, a3, a5 for the clipped one.

I select G1 (107), enter the formula in Cell & Formula (108) and confirm with Apply (109). Formula of the discrete projection, before the coefficients are displayed (visible in Figure 34).

=vector(2*numeric.mean(numeric.multiply(D1:D360,B1:B360)),2*numeric.mean(numeric.multiply(F1:F360,B1:B360)),2*numeric.mean(numeric.multiply(F1:F360,cosd(numeric.multiply(3,A1:A360)))),2*numeric.mean(numeric.multiply(F1:F360,cosd(numeric.multiply(5,A1:A360)))))

2.2. Analytical check and THD

For A>L I set α=arccos(L/A). Over the first quadrant the signal equals L between 0 and α and A cos θ between α and π/2. Exploiting the symmetries of the signal, the fundamental coefficient of the continuous waveform is:

\[ \begin{aligned} a_1 &= \frac{4}{\pi}\left[\int_0^{\alpha} L\cos\theta\,d\theta + \int_{\alpha}^{\pi/2} A\cos^2\theta\,d\theta\right]\\ &= \frac{2A}{\pi}\left[\arcsin r + r\sqrt{1-r^2}\right], \qquad r = \frac{L}{A}\end{aligned} \]

For A≤L the result is simply A. I evaluate the analytical expression with A=1.5 V and L=1 V; in H1:H4 I store, in order, the continuous fundamental coefficient, the RMS of the clipped samples, b1 and the mean (DC component) μ. I use pi() instead of an approximate decimal constant written by hand; asin returns an angle in radians.

I select H1 (110), enter the formula in Cell & Formula (111) and confirm with Apply (112). Analytical check, RMS, fundamental quadrature and DC.

=vector(3/pi()*(numeric.asin(2/3)+(2/3)*numeric.sqrt(1-(2/3)^2)),numeric.rms(F1:F360),2*numeric.mean(numeric.multiply(F1:F360,sind(A1:A360))),numeric.mean(F1:F360))

THD (Total Harmonic Distortion) compares the RMS of the harmonics other than the fundamental with the RMS of the fundamental. Instead of truncating the sum to the third and fifth only, for this periodic sequence I use Parseval’s power balance: I subtract the power of the DC component and of the fundamental from the total mean square power. The estimate refers to the samples, so it is not a measurement of the continuous series up to infinite frequency.

\[ \begin{aligned} P_1 &= \frac{a_1^2 + b_1^2}{2}\\ \mathrm{THD} &= \sqrt{\frac{V_{RMS}^2 – \mu^2 – P_1}{P_1}}\end{aligned} \]

In I1:I3 I calculate the percentage error of the fundamental coefficient with respect to the input, the THD in percent and the relative difference with respect to the continuous model.

I select I1 (113), enter the formula in Cell & Formula (114) and confirm with Apply (115). Amplitude error, THD and comparison with the analytical formula.

=vector(100*(G2/1.5-1),100*numeric.sqrt(2*(H2^2-H4^2)-G2^2-H3^2)/numeric.sqrt(G2^2+H3^2),100*(G2/H1-1))
QuantityValue
a₁, 0.8 V input0.800000 V
a₁, 1.5 V input, clipped1.171349 V
a₃ of the clipped signal−0.175746 V
a₅ of the clipped signal−0.019529 V
a₁, continuous analytical model1.171347 V
RMS of the clipped signal0.837969 V
Amplitude error−21.9101%
Discrete THD15.3490%
Relative difference of a₁ from the continuous model+0.0001647%

The small discrepancy between the discrete projection and the continuous coefficient is consistent with the approximation of the one-degree grid. The mean and the sine component of the fundamental are of the order of 10−17 and 10−16 V: numerical residues, as expected from the symmetry. The important result is the difference of about 0.329 V between input and fundamental: even with ideal synchronous detection the reading is 21.91% smaller.

2.3. Looking at the clipped waveform

Procedure in GX-TXT: clipping chart and axis labels (Figures 35–36)

I select the first rows of columns A:F (116) and create a new chart with Insert → Native chart from selection as in Figure 15. I set the title Symmetric clipping and harmonic distortion (117), X=A (118), Y=D E F (119), first row 1 (120), last row 360 (121), marker none (122), X limits 0–360 (123, 124) and Y limits −1.6–1.6 (125, 126), linear scales. Apply (127), Save and Publish immutable Graph to Plots (128). Choosing 360 as the last row extends the graph to the whole period; it does not limit the data to the initially visible selection.

In Plots I select the published graph, open Presentation → Title and labels, write Phase within period (deg) (129) and Voltage (V) (130), then Save (131). I use Render → Rerender selected and confirm completion.

The green trace flattens at ±1 V, while the red trace reaches ±1.5 V. The blue trace stays sinusoidal. The original CSV contains the 360 points of the three curves. I chose lines without markers because the one-degree step is already very dense. The harmonics created by clipping are not noise that can simply be cancelled by averaging longer. With a sinusoidal reference and ideal averaging over whole periods, harmonics other than the fundamental do not contribute directly to the reading; a square-wave reference, on the other hand, can be sensitive to odd harmonics, as seen in the discussion of harmonics. In both cases the signal is already distorted before demodulation.

The dynamic range of every stage

When I design the circuit, I will have to check the dynamic range of every stage, not just the useful input voltage. An out-of-band interferer can saturate the preamplifier, and a non-linearity in the presence of several frequencies can generate intermodulation products in the useful band. Downstream filtering does not, in general, reconstruct the information lost in the clipped samples. It will therefore be necessary to choose input gain and filtering taking into account the maximum foreseeable levels, with margin for disturbances and tolerances. The ±1 V limits adopted here are only a model: they are not the supply voltages or the already fixed specifications of the future lock-in.

3. Relative jitter: how much does timing instability matter?

The reference must be coherent not only in average frequency but also in phase. If a delay changes from one reading to the next, the projection of the signal onto the two quadratures changes. I want to separate this fluctuation from the loss of coherence caused by a constant frequency mismatch, which I will study in the next section.

Suppose that the time difference δt between signal and reference is a Gaussian variable with zero mean and standard deviation σt. For a sinusoid at frequency f, the phase deviation δφ=2πfδt is Gaussian with standard deviation σφ=2πfσt in radians. I use the convention X+iY=A exp(iφ) of the previous articles. Neglecting transients and high-frequency components, with an additive phase error I can write the complex reading as A exp[i(φ+δφ)].

If the phase noise is stationary, with the assumed distribution, the expected value of the complex reading follows from the characteristic function of the Gaussian:

\[ \begin{aligned} E[X+iY] &= A\,e^{i\varphi}\,E\!\left[e^{i\delta\varphi}\right]\\ &= A\,e^{i\varphi}\,e^{-\sigma_\varphi^2/2}\\ G &= \frac{\left|E[X+iY]\right|}{A} = \exp\!\left[-\frac{(2\pi f\sigma_t)^2}{2}\right]\end{aligned} \]

Coherent gain, not the magnitude of a reading

The function G is the gain of the mean coherent component, not the expected value of the magnitude of a single reading. A single ideal rotation in fact preserves the magnitude A. The reduction emerges when vectors with different phases are averaged. The time correlation of the jitter determines the spread of finite averages; the formula alone does not provide that spread. It does not automatically hold for jitter with a different distribution, for a phase that is almost constant over the whole window, if I consider the magnitude of the single average, or for common jitter that cancels in the difference between signal and reference. I am not calculating the signal-to-noise ratio of an ADC subject to aperture jitter.

3.1. Two frequencies compared

In session S12 I create a separate Workspace, Timing errors, to leave unchanged the one already used for quadrature and clipping. I choose 1 kHz and 10 kHz, and eight standard deviations from 0 to 50 µs. These are educational conditions, not a final choice of the circuit’s frequency range.

In Workspace → Open workspace I open Session Workspaces, use New (132), replace the proposed name New Workspace with Timing errors (133) and press Apply (134). The figure shows the dialog before the name is replaced.

I select A1 (135), enter the formula in Cell & Formula (136) and confirm with Apply (137). A: RMS relative jitter, expressed numerically in microseconds.

=vector(0,1,2,5,10,20,30,50)

I select B1 (138), enter the formula in Cell & Formula (139) and confirm with Apply (140). B: coherent ratio at 1 kHz.

=numeric.exp(numeric.multiply(-0.5,numeric.square(numeric.multiply(2*pi()*1000/1000000,A1:A8))))

I select C1 (141), enter the formula in Cell & Formula (142) and confirm with Apply (143). C: coherent ratio at 10 kHz.

=numeric.exp(numeric.multiply(-0.5,numeric.square(numeric.multiply(2*pi()*10000/1000000,A1:A8))))

The factor 1/1000000 converts the numerical values of A into seconds; I do not assign a structured unit to the column. The constant pi() keeps the precision of the calculation engine. I also want to derive a first condition on the relative stability of the reference: I require G≥0.99, i.e. a loss not greater than 1% in the expected coherent value.

\[ \sigma_{t,\max} = \frac{\sqrt{-2\ln(0.99)}}{2\pi f} \]

I select D1 (144), enter the formula in Cell & Formula (145) and confirm with Apply (146). D1:D2: RMS limit in microseconds at 1 and 10 kHz respectively.

=vector(1000000*numeric.sqrt(-2*numeric.log(0.99))/(2*pi()*1000),1000000*numeric.sqrt(-2*numeric.log(0.99))/(2*pi()*10000))
Procedure in GX-TXT: jitter chart and axis labels (Figures 43–44)

I start from the selection of columns A:C (147) and use Insert → Native chart from selection, as in Figure 15. I set the title Coherent gain versus relative timing jitter (148), X=A (149), Y=B C (150), first row 1 (151) and last row 8 (152), circle marker (153), X 0–50 (154, 155) and Y 0–1.05 (156, 157), linear scales. I confirm with Apply (158), save and publish with Publish immutable Graph to Plots (159).

In Plots I repeat Presentation → Title and labels: I enter RMS relative jitter (us) (160), Coherent amplitude ratio (161) and Save (162); then Render → Rerender selected and confirm completion.

σt (µs)G at 1 kHz (%)G at 10 kHz (%)
0100.0000100.0000
199.998099.8028
299.992199.2135
599.950795.1850
1099.802882.0869
2099.213545.4041
3098.239216.9225
5095.18500.7192

The markers represent the eight points actually calculated; the original CSV contains G as a dimensionless ratio, not as a percentage. The red curve falls much faster: at 10 µs the model predicts about 82.087% at 10 kHz, against 99.803% at 1 kHz. Result D is about 22.5645 µs at 1 kHz and 2.25645 µs at 10 kHz. In this model, to keep the same attenuation while increasing f tenfold, I must reduce σt tenfold. It is a preliminary criterion for Gaussian jitter alone, not a complete specification of the clock or the circuit.

4. Different frequencies: coherence during a measurement window

In the article on harmonics I already verified that a difference between signal and reference frequency produces a reading that depends on the duration of the window. I take up the problem again to derive a condition useful for design. Suppose fs−fr=Δf constant, with zero jitter. After ideal demodulation and removal of the sum-frequency component, the complex baseband reading is z(t)=A exp[i(2πΔft+φ)].

The rectangular average over [0,T] is:

\[ \begin{aligned} \bar z &= \frac{1}{T}\int_0^T z(t)\,dt\\ &= A\,e^{i(\varphi+\pi\Delta f T)}\,\frac{\sin(\pi\Delta f T)}{\pi\Delta f T}\\ G_T &= \frac{|\bar z|}{A} = \left|\frac{\sin(\pi\Delta f T)}{\pi\Delta f T}\right|\end{aligned} \]

For Δf=0 the limit is 1. The phase of the average includes the evolution up to the centre of the window and, when the sinc is negative, a further change of sign. At its zeros the phase is undefined. The result represents a continuous rectangular integration of the ideal quadrature, not the steady-state response of an RC filter and not a new experiment with discrete sampling of the carrier. With a baseband RC filter the magnitude of the response to Δf would instead be that of the low-pass at the beat frequency.

4.1. Two integration durations

In the same Worksheet I use rows 11–23, separate from the jitter table. I choose T=0.1 s and T=0.2 s. The frequency error is expressed numerically in hertz; I study only non-negative Δf, since GT is even. In A11, B11 and C11 I directly enter 0, 1 and 1, using the analytical limit of the sinc at zero: I do not divide by a very small number to simulate that limit.

After entering the exact values in A11 (163), B11 (164) and C11 (165), I select A12 (166), enter the other twelve frequency offsets (167) and confirm with Apply (168).

=vector(0.5,1,2,3,4,5,6,7.5,10,12.5,15,20)

I select B12 (169), enter the formula in Cell & Formula (170) and confirm with Apply (171). B12:B23: magnitude of the response for T=100 ms.

=numeric.abs(numeric.divide(numeric.sin(numeric.multiply(pi()*0.1,A12:A23)),numeric.multiply(pi()*0.1,A12:A23)))

I select C12 (172), enter the formula in Cell & Formula (173) and confirm with Apply (174). C12:C23: magnitude of the response for T=200 ms.

=numeric.abs(numeric.divide(numeric.sin(numeric.multiply(pi()*0.2,A12:A23)),numeric.multiply(pi()*0.2,A12:A23)))
Procedure in GX-TXT: frequency-mismatch chart and axis labels (Figures 49–50)

I start from the selection of columns A:C (175) and use Insert → Native chart from selection, as in Figure 15. I set the title Frequency mismatch and coherent integration (176), X=A (177), Y=B C (178), first row 11 (179) and last row 23 (180), circle marker (181), X 0–20 (182, 183) and Y 0–1.05 (184, 185), linear scales. I confirm with Apply (186), save and publish with Publish immutable Graph to Plots (187).

In Plots I repeat Presentation → Title and labels: I enter Frequency mismatch (Hz) (188), Coherent amplitude ratio (189) and Save (190); then Render → Rerender selected and confirm completion.

The native CSV contains thirteen points for each duration. You can see the first zeros at 10 Hz for 100 ms and at 5 Hz for 200 ms, with numerical residues of the order of 10−17. At 1 Hz about 98.363% remains for T=100 ms and 93.549% for T=200 ms. At 5 Hz about 63.662% remains in the first case, while the second reaches its first zero. The graph connects the markers of a deliberately sparse grid: between 15 and 20 Hz, for example, the red segment joins two zeros but the continuous function has an intermediate lobe that is not sampled. I do not use those interpolations to estimate the maxima of the lobes.

Near Δf=0, from the expansion sin x/x≈1−x²/6 I obtain an approximate condition for a 1% loss: |Δf|T≲√0.06/π≈0.078. This gives an order of magnitude of 0.78 Hz for 100 ms and 0.39 Hz for 200 ms. For a rigorous specification the exact expression is solved in the region around zero; the criterion obtained from the expansion is only preliminary. The systematic phase error during the window and the residual noise impose additional conditions.

The trade-off is the same one met in the study of uncertainty: a longer measurement reduces white noise, but requires coherence for longer. The actual synchronization of the reference, the acquisition mode and the output filter will have to be chosen together, not as three independent blocks.

5. Sampling: when two frequencies become indistinguishable

If the lock-in multiplier is digital, before performing the product I have to acquire the signal with an analog-to-digital converter (ADC). Once sampled, the signal does not necessarily retain the identity of the analog frequency it came from. The risk is not only that of distorting the waveform: an out-of-band disturbance can become a component exactly synchronous with the reference, and therefore be interpreted as useful signal.

I consider uniform, instantaneous sampling, without quantization, noise or jitter, at a frequency Fs=10 kHz. The step is Δt=1/Fs=0.1 ms. For a sinusoid of amplitude A and zero initial phase, the samples are:

\[ x[n] = A\cos\!\left(\frac{2\pi f n}{F_s}\right), \qquad n = 0,\dots,N-1 \]

If I replace f with f+kFs, for integer k, I add 2πkn to the argument. The cosine does not change. For a zero-phase cosine it does not change either when f is replaced with −f+kFs. This is why 1 kHz, 9 kHz and 11 kHz produce the same sequence at 10 kHz: 9=10−1 and 11=10+1. With a non-zero initial phase the reflection in frequency can invert the observed phase, without removing the ambiguity. The Nyquist frequency is 5 kHz; for baseband acquisition the analog band to be preserved must stay below this limit, leaving room for the transition band of a real filter. Any intentional undersampling of a selected band would require different conditions and a dedicated analog filter.

5.1. Four signals and a control test

I want to observe the phenomenon directly on the samples, even before doing an FFT. In the same session I create a separate Workspace, Sampling and aliasing, following the creation procedure shown in Figure 38. I choose N=20, times from 0 to 1.9 ms, equivalent to a summation window of N/Fs=2 ms. The 1 kHz reference completes exactly two periods; the 2 kHz control signal completes four. All signals are cosines of 1 V peak, without offset, with zero initial phase. The columns are numerical; I state the units here in milliseconds and volts.

In the New Workspace dialog I replace the proposed name with Sampling and aliasing (191) and press Apply (192). The figure shows the dialog before the name is replaced.

I select A1 (193), enter the formula in Cell & Formula (194) and confirm with Apply (195). A contains the sampling times in ms.

=vector(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9)

Since A is expressed in ms and the chosen frequencies in kHz, their numerical product gives the number of cycles. I therefore multiply f·t by 360° and use cosd. The following formulas calculate only the values at the twenty sampling instants, not the continuous analog waveforms.

I select B1 (196), enter the formula in Cell & Formula (197) and confirm with Apply (198). B: 1 kHz signal, also used as reference.

=cosd(numeric.multiply(360,A1:A20))

I select C1 (199), enter the formula in Cell & Formula (200) and confirm with Apply (201). C: 9 kHz analog signal evaluated at the same instants.

=cosd(numeric.multiply(3240,A1:A20))

I select D1 (202), enter the formula in Cell & Formula (203) and confirm with Apply (204). D: 11 kHz analog signal evaluated at the same instants.

=cosd(numeric.multiply(3960,A1:A20))

I select E1 (205), enter the formula in Cell & Formula (206) and confirm with Apply (207). E: 2 kHz control, which remains distinct from the reference.

=cosd(numeric.multiply(720,A1:A20))

Looking at B, C and D, the coincidence of the three sequences is already visible. To check the effect on the lock-in I calculate the discrete projection onto the reference of column B, with the peak normalization:

\[ X_f = \frac{2}{N}\sum_{n=0}^{N-1} x_f[n]\cos\!\left(\frac{2\pi f_r n}{F_s}\right), \qquad f_r = 1\ \mathrm{kHz} \]

I do not apply an RC filter, nor do I approximate the continuous integral of the 9 or 11 kHz waveform. I take the exact average of the twenty products of the samples, that is, discrete synchronous detection on a coherent record. In F1:F4 I collect the four readings, in the order B, C, D, E.

I select F1 (208), enter the formula in Cell & Formula (209) and confirm with Apply (210). F1:F4: synchronous projections onto the 1 kHz reference.

=vector(2*numeric.mean(numeric.multiply(B1:B20,B1:B20)),2*numeric.mean(numeric.multiply(C1:C20,B1:B20)),2*numeric.mean(numeric.multiply(D1:D20,B1:B20)),2*numeric.mean(numeric.multiply(E1:E20,B1:B20)))

I select G1 (211), enter the formula in Cell & Formula (212) and confirm with Apply (213). G1:G3: RMS of the differences C−B, D−B and E−B.

=vector(numeric.rms(numeric.subtract(C1:C20,B1:B20)),numeric.rms(numeric.subtract(D1:D20,B1:B20)),numeric.rms(numeric.subtract(E1:E20,B1:B20)))
Analog frequency (kHz)Apparent frequency (kHz)X reading (V)RMS of the difference from B (V)
111Reference
911≈2.07·10−15
1111≈2.53·10−15
22−2.36·10−161

The results are those expected from the trigonometric identity and from the discrete orthogonality of the two cosines at 1 and 2 kHz over the chosen record. The differences of the order of 10−15 V are residues of numerical arithmetic, not physical noise. The 2 kHz control instead gives an RMS difference of 1 V and a practically zero synchronous reading. I am not proving that any non-synchronous tone cancels over any record: the coherent duration chosen here is essential for the control.

5.2. The overlapping samples

Procedure in GX-TXT: four-series chart settings (Figure 60)

I select A1:E20 (214) and use Insert → Native chart from selection, as in Figure 15. I set the title Aliased samples and in-band control (215), X=A (216), Y=B C D E (217), rows 1–20 (218, 219), circle marker (220), X 0–2 ms (221, 222) and Y −1.1–1.1 V (223, 224), linear scales. I confirm with Apply (225), save and publish with Publish immutable Graph to Plots (226). The figure places side by side two crops of the controls and of the selection; the complete live view is in the next figure.

Procedure in GX-TXT: axis labels (Figure 62)

In Plots I repeat Presentation → Title and labels: I enter Sampling time (ms) (227), Sample voltage (V) (228) and Save (229); then Render → Rerender selected and confirm completion.

The first three curves overlap to numerical precision: in the plot what is mainly visible is the last overlapping curve, D. The control curve E remains distinct. The markers indicate the twenty actual samples; the straight lines between the points are not the analog waveforms. The native CSV keeps all four columns separately. A digital filter after the ADC, even if perfectly selective at 1 kHz, cannot identify the origin of components that now overlap. Before sampling, interferers must be attenuated in the bands that can fold into the useful band. It is also necessary to prevent them from saturating the stages ahead of the filter.

5.3. ADC resolution is not lock-in accuracy

An ideal b-bit ADC with total input range VFS divides that range into 2b levels, with approximate step q=VFS/2b. With ideal rounding, without overload and if the quantization error is sufficiently decorrelated and uniformly distributed between −q/2 and +q/2, its standard deviation is q/√12. These assumptions are not guaranteed by a weak, deterministic, synchronous signal; quantization can produce correlated errors and spurs. Averaging does not always make it possible to recover a variation below one LSB. In the real circuit I will also have to consider the converter noise, the voltage reference, the gain before the ADC, the actual dynamic range, non-linearities and clock noise. This is a theoretical design criterion, not a simulation of a particular ADC.

6. Three ways to build the lock-in

Now I have the elements to compare the architectures without assuming that one is better in absolute terms. I compare the three functional schemes on the same measurement: recovering X and Y of a component of known frequency, with the same peak normalization, equivalent noise bandwidth and input conditions. The following differences describe where the operations take place, not results of circuits already simulated or measured.

ArchitectureSignal pathAdvantages and constraints to verify
AnalogInput → preamplifier/filter → two multipliers or switches → X/Y low-pass → readings.Continuous demodulation; the carrier does not need to be sampled directly. Offset, gains, quadrature, noise and distortion of the multipliers, sum-frequency products, reference harmonics and filter stability must be controlled. A readout ADC can be slow, provided it is adequate for the baseband and preceded by an anti-aliasing filter.
DigitalInput → preamplifier and anti-aliasing filter → ADC → numerical I/Q references → multiplication, filtering and amplitude/phase estimation.Programmable coefficients and windows, numerical quadrature and repeatable calibration. The analog dynamic range ahead of the converter remains decisive; sampling, relative jitter, quantization, bandwidth and folding of interferers impose limits. A numerical reference must be synchronized with the signal or with an acquired reference; two nominally equal frequencies do not guarantee coherence.
HybridInput → analog demodulation or down-conversion to a lower frequency → anti-aliasing filters → ADC → digital integration and correction.Reduces the bandwidth required of converters and computation, leaving final filtering and calibration programmable. It does not eliminate the errors of the analog front-end; image components, conversion products, baseband, channel mismatches and noise of the two domains must be controlled.

For analog demodulation with a sinusoidal reference, the sum-frequency component must be sufficiently attenuated without sacrificing the useful band around the difference frequency. With square-wave switching I will also have to consider the response to odd multiples already studied in article S08. For the digital version, if I directly sample a baseband containing the carrier, the filter ahead of the ADC must have a passband and stopband attenuation consistent with Fs. In the hybrid I must impose the same constraints on the band actually acquired, not automatically on the original carrier. A correct comparison of sensitivity also requires the same input-referred noise and the same filter and settling conditions.

I am not choosing a final architecture yet. For an educational project it makes sense to evaluate source, preamplification, references, analog or switched multiplication, output filter and digital acquisition in a modular way. This way I can measure the errors of each stage and compare alternatives under equal conditions, preventing the electronics of one block from hiding the behaviour of the previous one.

7. From the tests to preliminary requirements

The figures obtained so far are not commercial specifications. Some establish quantitative relations; others are educational conditions that I will use to start the sizing. I choose 1 kHz as the first point of comparison and 10 kHz as the more demanding condition for the study of synchronization, without yet fixing the final frequency range. The durations of 100 and 200 ms serve to compare coherent behaviour; the time constant of the real filter will be chosen through its equivalent noise bandwidth, not arbitrarily identified with these durations.

QuantityInitial requirement or criterionSubsequent verification
Measurement conventionsX, Y in volts referred to the input, peak amplitude R=√(X²+Y²), phase atan2(Y,X). Distinguish RMS and peak voltage and state the time reference.Known signals and comparison with generator and oscilloscope; test at variable phase.
Dynamic rangeEvaluate the maximum useful signal plus interferers and noise, gains and offsets at every stage. Reserve margin with respect to the real input, output and supply limits; do not use the ±1 V of the model as the circuit limit.Amplitude sweep, distortion, overload margin and recovery; multi-frequency model and bench.
Gain, offset, quadratureProvide a calibration procedure with independent estimates of offset and I/Q matrix. Check that the inversion is well conditioned. Residual errors to be included in the uncertainty budget.Measurements with zero input and known phases, temperature, frequency, amplitude and repeatability; calibration data separate from verification data.
Relative jitterFor the Gaussian model of 1% coherent loss alone: σt≤22.56 µs at 1 kHz and ≤2.26 µs at 10 kHz. Use stricter limits if the overall budget or the phase require it.Synchronization of the reference, distribution and spectrum of the phase noise; distinguish relative jitter from ADC aperture jitter.
Frequency mismatchFor a rectangular average, preliminary estimate for a loss of about 1%: |Δf|T≲0.078, i.e. about 0.78 Hz at 100 ms and 0.39 Hz at 200 ms. Prefer a truly coherent reference.Check with the exact expression and the response of the actual filter, drift, phase and locking of the reference.
AliasingBefore every ADC define useful band, sampling frequency and attenuation of disturbances in the bands that fold back. The example Fs=10 kHz is valid for the 1 kHz test, not for a future baseband input at 10 kHz.Interferers at kFs±fr, realistic levels, response of the analog filter and absence of saturation.
Noise and selectivityDefine the input-referred noise density and the ENBW of the output. Compare architectures at equal ENBW and settling criterion; consider correlation, drift and synchronous components.SPICE simulations, noise by contribution, transients, repeated measurements and metrological budget.
ADC and referenceChoose dynamic range, effective resolution, bandwidth, sampling frequency and reference stability according to front-end, gain, interferers and architecture.Tests on known levels, noise, spurs, linearity and effective sensitivity; do not infer accuracy from the number of bits.

I can already express a general requirement for the anti-aliasing filter: if an interferer of amplitude Ai falls, after sampling, exactly at the useful frequency, then to keep its contribution within a fraction η of the useful signal As, the ratio of the magnitudes of the analog transfer function at the two frequencies must satisfy |H(fi)/H(fs)|≤ηAs/Ai. For example, with an interferer equal to the signal and η=0.01 at least 40 dB of relative attenuation is needed; if the interferer is a hundred times larger at least 80 dB is needed. These are budget examples, not results of a filter already designed. Several coherent interferers can add up, and the filter must work without overload. The same criterion makes it clear why the maximum level of the disturbances is a fundamental input to the design.

Separate limits, not an overall budget

The 1% limits on jitter and frequency mismatch have been evaluated separately. They are not an overall 1% accuracy budget: losses, offsets and correlated contributions must be combined with a criterion consistent with the model and with the uncertainty. Gain, useful band, input limits, maximum frequency, supplies and components will be defined after comparing the architectures and the circuit tests, not deduced from a single ideal test.

8. Conclusions

The results at a glance

  • Gain, offset and 3° quadrature error: the magnitude varies from 0.963864 V (−3.61%, at 90°) to 1.056956 V (+5.70%, at 330°) and the phase error from −4.550° to +1.153°; the inversion with exact coefficients brings the residuals down to 4.44·10−16 V and 2.54·10−14 degrees.
  • Clipping at ±1 V of a 1.5 V input: fundamental 1.171349 V (−21.91%), a₃ = −0.175746 V, discrete THD 15.349%.
  • Gaussian relative jitter, 1% coherent loss: σt ≤ 22.56 µs at 1 kHz and ≤ 2.26 µs at 10 kHz; at 10 µs and 10 kHz only 82.09% remains.
  • Frequency mismatch with rectangular average: |Δf|T ≲ 0.078, about 0.78 Hz at 100 ms and 0.39 Hz at 200 ms; first zeros at 10 Hz and 5 Hz.
  • Sampling at 10 kHz: 9 and 11 kHz give the same 1 V synchronous reading as the 1 kHz signal; the 2 kHz control gives a practically zero reading.

This article closes the theoretical part. I have seen that some of the errors of the lock-in can be described with a linear model and compensated, provided the parameters are estimated with known uncertainty. Clipping, on the other hand, changes the fundamental and cannot be solved by a simple gain correction. Jitter and frequency mismatch reduce the coherence of a measurement; aliasing can transfer an interferer directly into the component I want to measure. None of these problems is solved simply by reducing the output bandwidth.

The next step will not be to choose straight away all the components of a complete lock-in. I will start from the source that will let me generate a known weak signal, add controlled noise and check the conditions of impedance, amplitude and bandwidth. That source will be the reference for progressively evaluating the blocks of the amplifier. The performance of the real instrument can only be stated after circuit simulations and bench measurements. This is the subject of the next article, Generating a weak signal and controlled noise.

#electronics #GX-TXT #signals

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *