.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/communications/modulation/plot_02_carson_suppressed_carrier.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_communications_modulation_plot_02_carson_suppressed_carrier.py: Carson's suppressed-carrier modulation ====================================== In 1915 John Renshaw Carson of AT&T showed that the carrier in AM carries no information. Multiplying the message by the carrier alone, :math:`s(t) = m(t)\cos 2\pi f_c t` (:func:`~engineeringkit.communications.dsb_sc`), puts all the transmitted power into the sidebands. The receiver must supply a coherent carrier: mix, low-pass filter, and the message returns, scaled by :math:`\tfrac12\cos\phi` for a phase error :math:`\phi`. Carson also showed that one sideband is enough, the basis of single-sideband telephony. .. GENERATED FROM PYTHON SOURCE LINES 16-22 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from scipy.signal import butter, sosfiltfilt from engineeringkit.communications import dsb_sc .. GENERATED FROM PYTHON SOURCE LINES 23-25 Coherent demodulation and phase error ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 25-43 .. code-block:: Python fs, fc = 200e3, 10e3 t = np.arange(0, 0.02, 1 / fs) message = np.cos(2 * np.pi * 300 * t) + 0.5 * np.sin(2 * np.pi * 700 * t) s = dsb_sc(message, t, fc) lowpass = butter(6, 2e3, fs=fs, output="sos") phases = np.radians([0, 45, 90]) fig, axes = plt.subplots(1, 2, figsize=(10, 3.6)) for phi in phases: recovered = 2 * sosfiltfilt(lowpass, s * np.cos(2 * np.pi * fc * t + phi)) gain = np.dot(recovered, message) / np.dot(message, message) print(f"phase error {np.degrees(phi):3.0f} deg: recovered gain {gain:+.3f} (cos phi = {np.cos(phi):+.3f})") assert np.isclose(gain, np.cos(phi), atol=0.01) axes[0].plot(t * 1e3, recovered, label=f"φ = {np.degrees(phi):.0f}°") axes[0].plot(t * 1e3, message, "k:", label="message") axes[0].set(xlim=(0, 10), xlabel="time [ms]", title="Coherent detection") axes[0].legend(fontsize=8) .. image-sg:: /api/gallery/communications/modulation/images/sphx_glr_plot_02_carson_suppressed_carrier_001.png :alt: Coherent detection :srcset: /api/gallery/communications/modulation/images/sphx_glr_plot_02_carson_suppressed_carrier_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none phase error 0 deg: recovered gain +1.001 (cos phi = +1.000) phase error 45 deg: recovered gain +0.708 (cos phi = +0.707) phase error 90 deg: recovered gain -0.000 (cos phi = +0.000) .. GENERATED FROM PYTHON SOURCE LINES 44-46 No carrier line in the spectrum ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 46-55 .. code-block:: Python freq = np.fft.rfftfreq(t.size, 1 / fs) axes[1].plot(freq / 1e3, np.abs(np.fft.rfft(s)) / t.size) axes[1].set(xlim=(8.5, 11.5), xlabel="frequency [kHz]", title="DSB-SC spectrum: sidebands only") carrier_bin = np.argmin(np.abs(freq - fc)) assert np.abs(np.fft.rfft(s))[carrier_bin] / t.size < 1e-10 fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.166 seconds) .. _sphx_glr_download_api_gallery_communications_modulation_plot_02_carson_suppressed_carrier.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/communications/modulation/plot_02_carson_suppressed_carrier.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_carson_suppressed_carrier.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_carson_suppressed_carrier.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_carson_suppressed_carrier.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_