{ "cells": [ { "cell_type": "markdown", "id": "fundamental-insertion", "metadata": {}, "source": [ "# Bode plot" ] }, { "cell_type": "markdown", "id": "balanced-pocket", "metadata": {}, "source": [ "## List connected devices" ] }, { "cell_type": "code", "execution_count": null, "id": "limiting-gardening", "metadata": {}, "outputs": [], "source": [ "import JDS6600\n", "import SDS1202XE\n", "from bodeplot import bodeplot\n", "import time\n", "import math\n", "\n", "rm = SDS1202XE.get_resource_manager()\n", "SDS1202XE.list_resources(rm)\n", "JDS6600.list_com_ports()" ] }, { "cell_type": "markdown", "id": "fuzzy-closure", "metadata": {}, "source": [ "## Connect devices" ] }, { "cell_type": "code", "execution_count": null, "id": "judicial-invite", "metadata": {}, "outputs": [], "source": [ "gen = JDS6600.connect(\"COM5\")\n", "sds = SDS1202XE.connect(rm, \"USB0::0xF4ED::0xEE3A::SDS1EDEQ4R7911::INSTR\")\n", "\n" ] }, { "cell_type": "markdown", "id": "thorough-speech", "metadata": {}, "source": [ "## Initialize" ] }, { "cell_type": "code", "execution_count": null, "id": "reduced-collection", "metadata": {}, "outputs": [], "source": [ "MAXV = 2\n", "\n", "JDS6600.set_waveform(gen, 1, JDS6600.SINE)\n", "JDS6600.set_frequency(gen, 1, 10)\n", "JDS6600.set_amplitude(gen, 1, MAXV)\n", "JDS6600.set_offset(gen, 1, 0)\n", "JDS6600.set_output(gen, channel1=1, channel2=0)\n", "\n", "time.sleep(1)\n", "#SDS1202XE.autosetup(sds)\n", "#time.sleep(3)\n", "SDS1202XE.set_vertical(sds, channel=1, volt_by_div = \"1V\")\n", "SDS1202XE.set_vertical(sds, channel=2, volt_by_div = \"500mV\")\n", "SDS1202XE.set_tdiv(sds, tdiv=\"20MS\")\n", "SDS1202XE.set_measure(sds, channel=1)\n", "SDS1202XE.set_phase_measure(sds)\n", "time.sleep(1)" ] }, { "cell_type": "markdown", "id": "atomic-california", "metadata": {}, "source": [ "## Launch measures" ] }, { "cell_type": "code", "execution_count": null, "id": "classified-mineral", "metadata": {}, "outputs": [], "source": [ "frequencies = [10, 20, 50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 18000, 20000, 22000]\n", "\n", "gains = []\n", "phases = []\n", "\n", "from tqdm import tqdm\n", "\n", "for i in tqdm(range(len(frequencies))):\n", " f = frequencies[i]\n", " JDS6600.set_frequency(gen, 1, f)\n", " time.sleep(1.0)\n", " v = SDS1202XE.get_measure_vpp(sds, channel=1)\n", " p = SDS1202XE.get_phase(sds)\n", " gains.append(10*math.log(v/MAXV, 10))\n", " phases.append(p)\n" ] }, { "cell_type": "markdown", "id": "dated-sample", "metadata": {}, "source": [ "## Bode plot" ] }, { "cell_type": "code", "execution_count": null, "id": "parental-strap", "metadata": {}, "outputs": [], "source": [ "bodeplot(frequencies, gains, phases)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "guilty-accent", "metadata": {}, "outputs": [], "source": [] } ], "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.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }