{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Qcodes example with the NI RFSG signal generator driver\n", "\n", "The generic `NI_RFSG` driver used below should be compatible with most NI signal generatros (see the driver documentation for list of devices). For some devices, a device-specific driver is available, which differs from the generic one only in that it has appropriate limits set for the `Parameter`s." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# generic driver\n", "from qcodes_contrib_drivers.drivers.NationalInstruments.RFSG import NI_RFSG\n", "\n", "# device-specific driver, used in the same way as the generic one\n", "#from qcodes_contrib_drivers.drivers.NationalInstruments.PXIe_5654 import NI_PXIe_5654" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize the instrument\n", "\n", "The `resource` name should be the name you have set up in NI MAX." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: National Instruments NI PXIe-5654 (10 GHz) (serial:03176E2E, firmware:Firmware: 2015-03-01 21:42, Bootloader: 8) in 1.68s\n" ] } ], "source": [ "pxie5654 = NI_RFSG(\"PXIe5654\", resource=\"MW_source\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate a signal\n", "\n", "Set a power level (in dBm) and frequency, and start signal generation." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "pxie5654.power_level(-2)\n", "pxie5654.frequency(5e9)\n", "pxie5654.output_enabled(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The signal should be visible in your oscilloscope now." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "pxie5654.output_enabled(False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate a pulsed signal" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "using clock source 'onboard'\n" ] } ], "source": [ "pxie5654.output_enabled(True)\n", "print(f\"using clock source '{pxie5654.clock_source()}'\")\n", "pxie5654.pulse_mod_enabled(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now signal output is on only when there is TTL high level voltage present on the \"pulse in\" connector at the instrument's front panel." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "pxie5654.pulse_mod_enabled(False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now signal output is on regardless of voltage level present on \"pulse in\" connector" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analog (amplitude / phase / frequency) modulation\n", "\n", "In this example, we show amplitude modulation (AM). You should connect a modulation signal (for example from an other RF source or an AWG) to the AM IN port on the front of the device for this to work.\n", "\n", "With analog modulation disabled, the unmodulated carrier signal output by the MW source is $A_c \\cos(2\\pi f t)$. If you connect a modulation signal $m(t)$ to the AM IN port, the output signal will nominally be\n", "\n", "$$\n", "(m(t) + A_c)\\cos(2\\pi f t).\n", "$$\n", "\n", "Note that connecting a 0V signal to the modulation port produces a continuous tone at the base amplitude $A_c$. In order to suppress the carrier wave, you need to send a negative voltage to the AM IN port." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'none'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pxie5654.analog_mod_type()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# turn on signal generation\n", "pxie5654.output_enabled(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Enable amplitude modulation. After running the cell below, the amplitude of the signal should be modulated by the signal sent to AM IN." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "pxie5654.analog_mod_type(\"AM\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The AM sensitivity can be adjusted with the `amplitude_mod_sensitivity` parameter." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "100.0" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pxie5654.amplitude_mod_sensitivity()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "pxie5654.amplitude_mod_sensitivity(50)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "pxie5654.amplitude_mod_sensitivity(100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Turn off analog modulation and revert to normal continuous signal generation with a constant amplitude." ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [], "source": [ "pxie5654.analog_mod_type(\"none\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Stop RF generation" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "pxie5654.output_enabled(False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Take a snapshot" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PXIe5654:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "IDN :\t{'vendor': 'National Instruments', 'model': 'NI PXIe-5654...\n", "clock_source :\tonboard \n", "frequency :\t5e+09 (Hz)\n", "output_enabled :\tFalse \n", "power_level :\t-2 (dBm)\n", "pulse_mod_enabled :\tFalse \n" ] } ], "source": [ "pxie5654.print_readable_snapshot(update=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Close the instrument" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "pxie5654.close()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 2 }