Build a Passive RC Phase Shifter and Load Its Differential Output

One resistor–capacitor (RC) branch passes low frequencies and another passes high frequencies. Subtract their output voltages and the combined circuit can change phase while keeping nearly the same amplitude. In this experiment you will measure that difference at three frequencies, then connect a 10 kΩ resistor across the two output nodes and see how it changes both amplitude and phase.

This is a first-order all-pass network. Here all-pass means that the ideal, unloaded voltage ratio has the same magnitude at every frequency. The result belongs to the voltage between two nodes. Each node separately still acts as a conventional RC filter. The curves and example captures included here are calculated or synthetic.

Build two complementary arms

Before connecting any input or output cables, connect the RIGOL DHO804's rear Ground Terminal to earth ground using the supplied ground cable, as required by the DHO800 User Guide. Its Type-C power input does not ground the instrument through the power cord. Use the supplied power adapter. Keep the AFG1022's protective earth connected. The generator cable shield and probe ground clips share G0 as described below; they do not replace this required chassis earth lead.

Two resistor-capacitor arms share the same sine input and ground. The low-pass and high-pass midpoint voltages are measured separately. A removable 10 kilohm resistor connects only those two outputs. Calculated gain and phase curves show the effect of the bridging load.
Both arms share VIN and G0. The amber resistor connects LP to HP only in the load run. The calculated curves use nominal components and nominal probe loading. Both frequency axes are logarithmic. The drawing omits the DHO804 power adapter and separate chassis earth lead; connect them as described before adding any input or output cables. Full-size PNG · Editable SVG

Calculate a signed voltage ratio

A phasor is a complex number that records the amplitude and phase of a sine at one frequency. Use cosine as the reference waveform. A negative phase angle means the output lags the input. Define x = 2πfRC for matched arms and use j for the imaginary unit. With the outputs unloaded, the low-pass phasor ratio is 1 ÷ (1 + jx) and the high-pass ratio is jx ÷ (1 + jx). The signed voltage ratio is their difference.

H = (LP − HP) ÷ VIN = (1 − jx) ÷ (1 + jx)

The numerator and denominator have equal magnitude. Their phases have opposite signs, so the phase of H is −2 × arctan(x). At the nominal corner fc = 1 ÷ (2πRC) ≈ 159.15 Hz, each arm is about 0.707 times the input voltage in magnitude. One arm lags by 45°, and the other leads by 45°. Their difference is about 1.00 times the input, lagging by 90°. Subtracting two displayed amplitude readings discards the phase information and would predict the wrong result.

Loading changes the denominator. For two matched arms and a resistor RL bridging LP and HP, the ideal differential ratio becomes (1 − jx) ÷ (1 + jx + 2R/RL). The factor of two arises because the bridge draws current from one arm and returns it into the other. Near 160 Hz with RL = R, the predicted magnitude is about 0.448, even though the source input amplitude is held constant.

Real probes also load the arm nodes. The PVP2350 guide gives nominal 1 MΩ and 50 pF at 1×. Model each arm's probe as a conductance of 1 µS plus that capacitance to G0. For matched arms the effects add R × YP to the denominator, where YP = 1/1 MΩ + j2πf × 50 pF. The program solves the two individual node equations so it can handle different R1, R2, C1 and C2 values. It normalizes each fit to the measured VIN at the circuit. The generator's nominal 50 Ω physical output impedance can change VIN but it is upstream of the voltage the program uses.

Nominal predictions with the scope probes connected
CaptureGainPhase
Open 40 Hz0.991−28.1°
Open 160 Hz0.995−90.0°
Open 640 Hz0.999−151.9°
Loaded 160 Hz0.447−63.6°
Restore 160 Hz0.995−90.0°

Here open means the bridge resistor is absent. The three probes remain connected in all five captures. At sufficiently low frequency the no-probe loaded estimate tends to 1/3 for RL = R. At high frequency the ideal magnitude approaches one because the series capacitor couples HP toward VIN, while the shunt capacitor pulls LP toward G0. The table covers only the specified low-frequency fixture.

Make all five captures

  1. With the fixture disconnected from the generator, use a Fluke 87V MAX or equivalent to measure R1, R2, RL, C1 and C2 individually, out of circuit. Select its resistance or capacitance function as appropriate and remove any stored capacitor charge before connecting the meter. Record ohms and nanofarads in the worksheet. Keep track of which capacitor goes into each arm.
  2. Set the AFG1022 for a continuous 1.00 V peak-to-peak sine, zero offset and High Z display, meaning its amplitude display anticipates a high-impedance load. Confirm the sine amplitude at VIN. On the scope use ordinary sampling, direct-current coupling and 1× probe settings. If you put the three tips on the same VIN point temporarily, their centered traces should agree before moving CH2 and CH3 to the arm outputs. Keep all returns at G0.
  3. Trigger on a rising CH1 midpoint and stop one contiguous acquisition with at least eight rising input crossings. Choose 10 kpts horizontal memory depth, and start at 50 ms/div for 40 Hz, 10 ms/div for 160 Hz, and 2 ms/div for 640 Hz. Use the actual acquisition duration to keep 8–28 rising input-midpoint crossings. Check that the waveforms remain centered and unclipped on the chosen scale, and that the largest adjacent sample-time gap is at most one-fortieth of the period.
  4. With no RL, save captures at 40, 160 and 640 Hz. Return to 160 Hz, disable the generator output, attach RL directly between LP and HP and acquire again after enabling the same sine. Then disable the output, remove RL and save the restored 160 Hz response. Preserve the source amplitude, probe locations and return reference for all three 160 Hz captures.
  5. From Storage → Save → Choose → Save Wave, select Memory and CSV to save all enabled channels from a single stopped acquisition. CSV means comma-separated values. Convert the three simultaneous channels to four columns named time_s,vin_v,lp_v,hp_v with timestamps in seconds and voltages in volts. Preserve the native sample order and spacing. Keep all samples, including the signal's negative swing. Exporting a screenshot or a separate acquisition per channel loses the sample-by-sample phase relationship.

Compare measured phasors with the complete Python program

Download the parts worksheet, complete program or archive with synthetic traces and tests. Use Python 3.8 or later and the standard library.

python3 phase_bridge.py parts.csv open-40.csv open-160.csv open-640.csv load-160.csv restore-160.csv
python3 phase_bridge.py synthetic/parts.csv synthetic/open-40.csv synthetic/open-160.csv synthetic/open-640.csv synthetic/load-160.csv synthetic/restore-160.csv

The analyzer estimates frequency from rising crossings of the input's midpoint. It discards the first and last crossing intervals, then fits a constant plus cosine and sine terms to each channel on the same time base, weighting each retained native sample once. A fitted waveform a × cos(ωt) + b × sin(ωt) has phasor a − jb under the cosine convention. Dividing each arm phasor by VIN makes the result independent of the sine's common absolute starting phase.

For each mode, the program solves a two-node network with the entered component values. Conductance is the reciprocal of resistance. Admittance extends that idea to complex sine voltages and currents. With GL = 1/RL, the bridge current flowing from LP to HP is (LP − HP) × GL. That term leaves the LP node and enters the HP node. The scope probe adds local conductance and capacitance to each node equation. The predictions account for nominal probe loading, without estimating every parasitic or instrument error.

The program screens nominal part ranges, frequency, sample gaps, amplitudes, offsets and non-sine residual. It requires each complex arm ratio to lie within 0.050 of its prediction and the complex differential ratio within 0.065. The three open magnitudes must remain between 0.85 and 1.15 and phase lag must increase by at least 35° on each frequency step. At 160 Hz, the loaded magnitude must be 35–55% of the first open magnitude. After the load is removed the measured complex ratio must return within 0.055 of the original.

Exit 0 means the comparison qualified within these experiment limits. Exit 1 identifies an unreadable or invalid file. Exit 2 means the data or part values failed a stated control. A single channel with the correct amplitude can still have the wrong phase. If an arm fails, check the four arm components, probe scales, and whether LP and HP were interchanged in the export.

#!/usr/bin/env python3
"""Validate five scope captures of a passive RC differential phase shifter."""

import argparse
import cmath
import csv
import io
import math
import statistics
from pathlib import Path

MODES = (("open-40", 40), ("open-160", 160), ("open-640", 640),
         ("load-160", 160), ("restore-160", 160))
MAX_BYTES = 1572864
ROUNDING = 1e-9


class Unresolved(ValueError):
    """Readable observations did not qualify the experiment."""


def within(value, low, high):
    return low - ROUNDING <= value <= high + ROUNDING


def reader(path, header, row_limit):
    with path.open("rb") as stream:
        data = stream.read(MAX_BYTES + 1)
    if len(data) > MAX_BYTES:
        raise ValueError(f"{path}: CSV is larger than 1.5 MiB")
    rows = csv.reader(io.StringIO(data.decode("utf-8-sig"), newline=""), strict=True)
    if next(rows, None) != list(header):
        raise ValueError(f"{path}: expected {','.join(header)}")
    for index, row in enumerate(rows, 1):
        if index > row_limit or len(row) != len(header):
            raise ValueError(f"{path}: row count or column count exceeded")
        values = tuple(map(float, row))
        if not all(math.isfinite(value) for value in values):
            raise ValueError(f"{path}: nonfinite numeric field")
        yield values


def parts(path):
    rows = list(reader(path, ("r1_ohm", "c1_nf", "r2_ohm", "c2_nf", "rl_ohm"), 1))
    if len(rows) != 1:
        raise ValueError("parts.csv requires one data row")
    r1, c1, r2, c2, load = rows[0]
    if not all(within(value, 9750, 10250) for value in (r1, r2, load)):
        raise Unresolved("parts file: all three resistors must be within 9.75–10.25 kΩ")
    if not all(within(value, 87, 113) for value in (c1, c2)):
        raise Unresolved("parts file: both capacitances must be within 87–113 nF")
    return r1, c1, r2, c2, load


def predict(frequency, values, attached):
    r1, c1, r2, c2, load = values
    s = 1j * math.tau * frequency
    g1, g2 = 1 / r1, 1 / r2
    y1, y2 = s * c1 * 1e-9, s * c2 * 1e-9
    probe = 1e-6 + s * 50e-12
    bridge = 1 / load if attached else 0
    a = g1 + y1 + probe + bridge
    d = g2 + y2 + probe + bridge
    determinant = a * d - bridge**2
    return (d * g1 + bridge * y2) / determinant, (bridge * g1 + a * y2) / determinant


def rising_edges(rows):
    voltages = [row[1] for row in rows]
    midpoint = (min(voltages) + max(voltages)) / 2
    return [
        a[0] + (b[0] - a[0]) * (midpoint - a[1]) / (b[1] - a[1])
        for a, b in zip(rows, rows[1:]) if a[1] < midpoint <= b[1]
    ]


def fit(trig, values):
    # Remove each column mean to solve the cosine and sine slopes with a free offset.
    cosine, sine = list(zip(*trig))
    cmean, smean, vmean = map(statistics.mean, (cosine, sine, values))
    centered = [(c - cmean, s - smean, v - vmean) for c, s, v in zip(cosine, sine, values)]
    cc = sum(c * c for c, _, _ in centered)
    ss = sum(s * s for _, s, _ in centered)
    cs = sum(c * s for c, s, _ in centered)
    cv = sum(c * v for c, _, v in centered)
    sv = sum(s * v for _, s, v in centered)
    det = cc * ss - cs**2
    if det <= 1e-8:
        raise Unresolved("sine fit is singular")
    a, b = (cv * ss - sv * cs) / det, (sv * cc - cv * cs) / det
    residual = math.sqrt(statistics.mean((v - a * c - b * s)**2 for c, s, v in centered))
    phasor = complex(a, -b)
    if abs(phasor) < .04 or residual / (abs(phasor) / math.sqrt(2)) > .045 + ROUNDING:
        raise Unresolved("a channel has too little fundamental or too much non-sine content")
    offset = vmean - a * cmean - b * smean
    if abs(offset) > .08 + ROUNDING:
        raise Unresolved("a channel's DC offset exceeds 80 mV")
    return phasor


def capture(path, expected_hz):
    rows = list(reader(path, ("time_s", "vin_v", "lp_v", "hp_v"), 20000))
    if len(rows) < 250:
        raise Unresolved("capture requires at least 250 samples")
    if any(abs(row[0]) > 5 or any(abs(voltage) > .8 for voltage in row[1:]) for row in rows):
        raise Unresolved("capture exceeds ±5 s or ±0.8 V")
    gaps = [b[0] - a[0] for a, b in zip(rows, rows[1:])]
    if min(gaps) <= 0:
        raise Unresolved("timestamps must increase")
    edges = rising_edges(rows)
    if not 8 <= len(edges) <= 28:
        raise Unresolved("capture needs 8–28 rising input-midpoint crossings")
    intervals = [b - a for a, b in zip(edges, edges[1:])]
    period = statistics.median(intervals)
    frequency = 1 / period
    if not within(frequency / expected_hz, .98, 1.02) or any(
        not within(gap / period, .98, 1.02) for gap in intervals
    ):
        raise Unresolved("frequency or individual periods are outside their 2% screens")
    if max(gaps) > period / 40 + ROUNDING:
        raise Unresolved("sample gaps exceed one-fortieth of the measured period")

    origin, stop = edges[1], edges[-2]
    section = [row for row in rows if origin <= row[0] < stop]
    angles = [math.tau * frequency * (time - origin) for time, *_ in section]
    trig = [(math.cos(angle), math.sin(angle)) for angle in angles]
    vin, lp, hp = [fit(trig, [row[channel] for row in section]) for channel in (1, 2, 3)]
    if not within(2 * abs(vin), .85, 1.15):
        raise Unresolved("input peak-to-peak amplitude is outside 0.85–1.15 V")
    return frequency, lp / vin, hp / vin


def angle_deg(phasor):
    return math.degrees(cmath.phase(phasor))


def compare(paths, values):
    measured = {}
    print("condition          Hz    |LP−HP|  phase_deg  model_mag  model_phase_deg")
    for (mode, target_hz), path in zip(MODES, paths):
        try:
            frequency, lp, hp = capture(path, target_hz)
            model_lp, model_hp = predict(frequency, values, mode == "load-160")
            differential = lp - hp
            predicted = model_lp - model_hp
            if max(abs(lp - model_lp), abs(hp - model_hp)) > .05 + ROUNDING:
                raise Unresolved("one branch differs from its model by more than 0.050")
            if abs(differential - predicted) > .065 + ROUNDING:
                raise Unresolved("differential complex error exceeds 0.065")
        except Unresolved as error:
            raise Unresolved(f"{mode}: {error}") from error
        measured[mode] = differential
        print(f"{mode:<14} {frequency:8.3f}  {abs(differential):8.4f}  "
              f"{angle_deg(differential):9.3f}  {abs(predicted):9.4f}  {angle_deg(predicted):15.3f}")

    baseline = [measured[mode] for mode, _ in MODES[:3]]
    if not all(within(abs(value), .85, 1.15) for value in baseline):
        raise Unresolved("unloaded differential magnitude not near unity")
    phases = [angle_deg(value) for value in baseline]
    if any(b - a > -35 + ROUNDING for a, b in zip(phases, phases[1:])):
        raise Unresolved("the three open captures did not show increasing phase lag")
    center = measured["open-160"]
    if not within(abs(measured["load-160"]) / abs(center), .35, .55):
        raise Unresolved("bridge load did not produce the expected attenuation")
    if abs(measured["restore-160"] - center) > .055 + ROUNDING:
        raise Unresolved("restored complex gain disagrees with original 160 Hz capture")


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("parts_csv", type=Path)
    for mode, _ in MODES:
        parser.add_argument(mode.replace("-", "_"), type=Path)
    args = parser.parse_args()
    try:
        values = parts(args.parts_csv)
        compare([getattr(args, mode.replace("-", "_")) for mode, _ in MODES], values)
    except Unresolved as error:
        print(f"UNRESOLVED: {error}")
        return 2
    except (ValueError, OSError, csv.Error) as error:
        print(f"INPUT ERROR: {error}")
        return 1
    print("QUALIFIED: a lightly loaded output keeps its magnitude while phase changes; bridging it reduces the gain.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
Challenge. What changes if you calculate HP − LP?

It negates the complex result. The magnitude stays the same, and the phase shifts by 180° when reported modulo 360°. Near the unloaded corner, the new sign changes about −90° to about +90°. The physical load between the two nodes is unchanged.

Related reading

Primary references