From 4fb7daebca63df0e1c4c127a618ed4c21e3c6b1f Mon Sep 17 00:00:00 2001 From: Kelvin Ly Date: Sun, 14 Apr 2019 02:59:21 -0400 Subject: [PATCH] Match mixer LO input and RF output to 50 ohms --- sim/.gitignore | 2 + sim/README.md | 2 + sim/bfu520_mixer.sch | 163 ++++++++++++++++++++++++++++ sim/mixer_large_signal.sch | 215 +++++++++++++++++++++++++++++++++++++ sim/mixer_match.sch | 196 +++++++++++++++++++++++++++++++++ sim/mixer_matching.ipynb | 206 +++++++++++++++++++++++++++++++++++ sim/qucs/qucsdata.py | 6 +- 7 files changed, 788 insertions(+), 2 deletions(-) create mode 100644 sim/README.md create mode 100644 sim/bfu520_mixer.sch create mode 100644 sim/mixer_large_signal.sch create mode 100644 sim/mixer_match.sch create mode 100644 sim/mixer_matching.ipynb diff --git a/sim/.gitignore b/sim/.gitignore index 9d13b70..be962b0 100644 --- a/sim/.gitignore +++ b/sim/.gitignore @@ -1,3 +1,5 @@ .ipynb_checkpoints *.dat *.dpl +__pycache__/ +*.pyc diff --git a/sim/README.md b/sim/README.md new file mode 100644 index 0000000..53a4785 --- /dev/null +++ b/sim/README.md @@ -0,0 +1,2 @@ +Basically a lot of simulations used for designing different stages of the discrete transceiver. +It's an agglomeration of Qucs simulations with Jupyter notebooks, so you'll want those two programs to examine this stuff diff --git a/sim/bfu520_mixer.sch b/sim/bfu520_mixer.sch new file mode 100644 index 0000000..839e15b --- /dev/null +++ b/sim/bfu520_mixer.sch @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + <.DC DC1 1 400 720 0 38 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0> + <.SP SP1 1 130 710 0 61 0 0 "lin" 1 "100 MHz" 1 "2 GHz" 1 "50" 1 "no" 0 "1" 0 "2" 0 "no" 0 "no" 0> + + + <.SW SW1 1 650 730 0 61 0 0 "SP1" 1 "lin" 1 "I1" 1 "-5 mA" 1 "5 mA" 1 "11" 1> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <420 40 420 170 "" 0 0 0 ""> + <900 40 900 170 "" 0 0 0 ""> + <830 70 830 170 "" 0 0 0 ""> + <520 70 520 170 "" 0 0 0 ""> + <560 -20 590 -20 "" 0 0 0 ""> + <520 70 590 70 "" 0 0 0 ""> + <590 70 830 70 "" 0 0 0 ""> + <590 -20 590 70 "" 0 0 0 ""> + <420 40 680 40 "" 0 0 0 ""> + <440 -20 500 -20 "" 0 0 0 ""> + <440 -60 440 -20 "" 0 0 0 ""> + <860 -60 860 -20 "" 0 0 0 ""> + <820 -20 860 -20 "" 0 0 0 ""> + <680 40 900 40 "" 0 0 0 ""> + <680 -20 680 40 "" 0 0 0 ""> + <680 -20 760 -20 "" 0 0 0 ""> + <730 -60 860 -60 "" 0 0 0 ""> + <730 -60 730 90 "" 0 0 0 ""> + <440 -60 620 -60 "" 0 0 0 ""> + <620 -60 730 -60 "" 0 0 0 ""> + <620 -60 620 90 "" 0 0 0 ""> + <320 -60 440 -60 "" 0 0 0 ""> + <320 -60 320 90 "" 0 0 0 ""> + <860 -60 990 -60 "" 0 0 0 ""> + <990 -60 990 80 "" 0 0 0 ""> + <990 250 990 290 "" 0 0 0 ""> + <930 260 930 290 "" 0 0 0 ""> + <800 260 800 290 "" 0 0 0 ""> + <730 280 730 300 "" 0 0 0 ""> + <620 280 620 300 "" 0 0 0 ""> + <550 260 550 290 "" 0 0 0 ""> + <390 260 390 290 "" 0 0 0 ""> + <320 250 320 300 "" 0 0 0 ""> + <320 150 320 170 "" 0 0 0 ""> + <320 170 320 190 "" 0 0 0 ""> + <320 170 360 170 "" 0 0 0 ""> + <620 150 620 170 "" 0 0 0 ""> + <620 170 620 220 "" 0 0 0 ""> + <580 170 620 170 "" 0 0 0 ""> + <730 150 730 170 "" 0 0 0 ""> + <730 170 730 220 "" 0 0 0 ""> + <730 170 770 170 "" 0 0 0 ""> + <990 140 990 170 "" 0 0 0 ""> + <990 170 990 190 "" 0 0 0 ""> + <960 170 990 170 "" 0 0 0 ""> + <830 230 860 230 "" 0 0 0 ""> + <860 230 900 230 "" 0 0 0 ""> + <860 230 860 300 "" 0 0 0 ""> + <860 360 860 390 "" 0 0 0 ""> + <470 370 470 400 "" 0 0 0 ""> + <420 230 470 230 "" 0 0 0 ""> + <470 230 520 230 "" 0 0 0 ""> + <470 230 470 310 "" 0 0 0 ""> + <240 -170 240 -150 "" 0 0 0 ""> + <240 -170 320 -170 "" 0 0 0 ""> + <320 -170 320 -60 "" 0 0 0 ""> + <240 -90 240 -60 "" 0 0 0 ""> + <230 170 320 170 "" 0 0 0 ""> + <700 170 730 170 "" 0 0 0 ""> + <700 170 700 450 "" 0 0 0 ""> + <320 450 700 450 "" 0 0 0 ""> + <620 170 670 170 "" 0 0 0 ""> + <990 170 1140 170 "" 0 0 0 ""> + <680 -110 680 -20 "" 0 0 0 ""> + <680 -110 780 -110 "" 0 0 0 ""> + <840 -110 910 -110 "" 0 0 0 ""> + <740 -170 910 -170 "" 0 0 0 ""> + <590 -170 680 -170 "" 0 0 0 ""> + <660 -110 680 -110 "" 0 0 0 ""> + <590 -170 590 -110 "" 0 0 0 ""> + <590 -110 590 -20 "" 0 0 0 ""> + <590 -110 600 -110 "" 0 0 0 ""> + <670 170 670 530 "" 0 0 0 ""> + <390 530 670 530 "" 0 0 0 ""> + <1140 170 1140 610 "" 0 0 0 ""> + <400 610 1140 610 "" 0 0 0 ""> + <230 170 230 270 "" 0 0 0 ""> + <220 270 230 270 "" 0 0 0 ""> + <320 350 320 450 "" 0 0 0 ""> + <260 350 320 350 "" 0 0 0 ""> + <50 270 50 350 "" 0 0 0 ""> + <170 530 330 530 "" 0 0 0 ""> + <180 610 340 610 "" 0 0 0 ""> + <50 610 120 610 "" 0 0 0 ""> + <50 480 50 530 "" 0 0 0 ""> + <50 530 50 610 "" 0 0 0 ""> + <50 530 110 530 "" 0 0 0 ""> + <50 350 50 420 "" 0 0 0 ""> + <50 350 90 350 "" 0 0 0 ""> + <150 350 200 350 "" 0 0 0 ""> + <140 270 160 270 "" 0 0 0 ""> + <50 270 80 270 "" 0 0 0 ""> + + + + + diff --git a/sim/mixer_large_signal.sch b/sim/mixer_large_signal.sch new file mode 100644 index 0000000..b9d7ed5 --- /dev/null +++ b/sim/mixer_large_signal.sch @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + <.DC DC1 1 400 720 0 38 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0> + <.SP SP1 0 130 710 0 61 0 0 "lin" 1 "100 MHz" 1 "2 GHz" 1 "50" 1 "no" 0 "1" 0 "2" 0 "no" 0 "no" 0> + + + <.SW SW1 0 650 730 0 61 0 0 "SP1" 1 "lin" 1 "I1" 1 "-5 mA" 1 "5 mA" 1 "11" 1> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <.TR TR1 1 -40 720 0 61 0 0 "lin" 1 "0" 1 "50 ns" 1 "1000" 0 "Gear" 0 "2" 0 "1 ns" 0 "1e-16" 0 "150" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "26.85" 0 "1e-3" 0 "1e-6" 0 "1" 0 "CroutLU" 0 "no" 0 "yes" 0 "0" 0> + + + + + + + + + + + + + + + + + + <710 50 710 180 "" 0 0 0 ""> + <1190 50 1190 180 "" 0 0 0 ""> + <1120 80 1120 180 "" 0 0 0 ""> + <810 80 810 180 "" 0 0 0 ""> + <850 -10 880 -10 "" 0 0 0 ""> + <810 80 880 80 "" 0 0 0 ""> + <880 80 1120 80 "" 0 0 0 ""> + <880 -10 880 80 "" 0 0 0 ""> + <710 50 970 50 "" 0 0 0 ""> + <730 -10 790 -10 "" 0 0 0 ""> + <730 -50 730 -10 "" 0 0 0 ""> + <1150 -50 1150 -10 "" 0 0 0 ""> + <1110 -10 1150 -10 "" 0 0 0 ""> + <970 50 1190 50 "" 0 0 0 ""> + <970 -10 970 50 "" 0 0 0 ""> + <970 -10 1050 -10 "" 0 0 0 ""> + <1020 -50 1130 -50 "" 0 0 0 ""> + <1020 -50 1020 100 "" 0 0 0 ""> + <730 -50 910 -50 "" 0 0 0 ""> + <910 -50 1020 -50 "" 0 0 0 ""> + <910 -50 910 100 "" 0 0 0 ""> + <610 -50 690 -50 "" 0 0 0 ""> + <610 -50 610 100 "" 0 0 0 ""> + <1150 -50 1280 -50 "" 0 0 0 ""> + <1280 -50 1280 90 "" 0 0 0 ""> + <1280 260 1280 300 "" 0 0 0 ""> + <1220 270 1220 300 "" 0 0 0 ""> + <1090 270 1090 300 "" 0 0 0 ""> + <1020 290 1020 310 "" 0 0 0 ""> + <910 290 910 310 "" 0 0 0 ""> + <840 270 840 300 "" 0 0 0 ""> + <680 270 680 300 "" 0 0 0 ""> + <610 260 610 310 "" 0 0 0 ""> + <610 160 610 180 "" 0 0 0 ""> + <610 180 610 200 "" 0 0 0 ""> + <610 180 650 180 "" 0 0 0 ""> + <910 160 910 180 "" 0 0 0 ""> + <910 180 910 230 "" 0 0 0 ""> + <870 180 910 180 "" 0 0 0 ""> + <1020 160 1020 180 "" 0 0 0 ""> + <1020 180 1020 230 "" 0 0 0 ""> + <1020 180 1060 180 "" 0 0 0 ""> + <1280 150 1280 180 "" 0 0 0 ""> + <1280 180 1280 200 "" 0 0 0 ""> + <1250 180 1280 180 "" 0 0 0 ""> + <1120 240 1150 240 "" 0 0 0 ""> + <1150 240 1190 240 "" 0 0 0 ""> + <1150 240 1150 310 "" 0 0 0 ""> + <1150 370 1150 400 "" 0 0 0 ""> + <760 380 760 410 "" 0 0 0 ""> + <710 240 760 240 "" 0 0 0 ""> + <760 240 810 240 "" 0 0 0 ""> + <760 240 760 320 "" 0 0 0 ""> + <530 -160 530 -140 "" 0 0 0 ""> + <530 -160 610 -160 "" 0 0 0 ""> + <610 -160 610 -50 "" 0 0 0 ""> + <530 -80 530 -50 "" 0 0 0 ""> + <990 180 1020 180 "" 0 0 0 ""> + <990 180 990 460 "" 0 0 0 ""> + <610 460 990 460 "" 0 0 0 ""> + <910 180 960 180 "" 0 0 0 ""> + <1280 180 1430 180 "" 0 0 0 ""> + <970 -100 970 -10 "" 0 0 0 ""> + <950 -100 970 -100 "" 0 0 0 ""> + <880 -100 880 -90 "" 0 0 0 ""> + <880 -100 890 -100 "" 0 0 0 ""> + <960 180 960 540 "" 0 0 0 ""> + <780 540 960 540 "" 0 0 0 ""> + <1430 180 1430 620 "" 0 0 0 ""> + <770 620 1430 620 "" 0 0 0 ""> + <220 420 270 420 "" 0 0 0 ""> + <220 560 270 560 "" 0 0 0 ""> + <270 560 320 560 "" 0 0 0 ""> + <270 530 270 560 "" 0 0 0 ""> + <270 420 320 420 "" 0 0 0 ""> + <270 420 270 470 "" 0 0 0 ""> + <380 420 440 420 "" 0 0 0 ""> + <380 560 440 560 "" 0 0 0 ""> + <80 420 80 460 "" 0 0 0 ""> + <80 420 160 420 "vin" 120 390 1 ""> + <80 520 80 560 "" 0 0 0 ""> + <880 -170 880 -100 "" 0 0 0 ""> + <880 -170 890 -170 "" 0 0 0 ""> + <970 -170 970 -100 "" 0 0 0 ""> + <950 -170 970 -170 "" 0 0 0 ""> + <1080 -210 1140 -210 "" 0 0 0 ""> + <970 -210 970 -170 "" 0 0 0 ""> + <970 -210 1020 -210 "" 0 0 0 ""> + <880 -280 880 -170 "" 0 0 0 ""> + <880 -280 1020 -280 "" 0 0 0 ""> + <1080 -280 1140 -280 "" 0 0 0 ""> + <1140 -280 1140 -270 "" 0 0 0 ""> + <1140 -210 1200 -210 "" 0 0 0 ""> + <1140 -280 1250 -280 "vout" 1220 -310 56 ""> + <1250 -280 1250 -270 "" 0 0 0 ""> + <1200 -210 1250 -210 "" 0 0 0 ""> + <1200 -210 1200 -180 "" 0 0 0 ""> + <80 560 160 560 "" 0 0 0 ""> + <610 360 610 460 "" 0 0 0 ""> + <590 360 610 360 "" 0 0 0 ""> + <580 180 610 180 "" 0 0 0 ""> + <440 180 460 180 "" 0 0 0 ""> + <440 180 440 360 "" 0 0 0 ""> + <440 360 440 420 "" 0 0 0 ""> + <440 360 470 360 "" 0 0 0 ""> + <440 540 440 560 "" 0 0 0 ""> + <440 540 630 540 "" 0 0 0 ""> + <440 560 440 620 "" 0 0 0 ""> + <440 620 630 620 "" 0 0 0 ""> + <690 620 710 620 "" 0 0 0 ""> + <690 540 720 540 "" 0 0 0 ""> + <60 560 80 560 "" 0 0 0 ""> + <60 560 60 600 "" 0 0 0 ""> + <-110 560 -50 560 "" 0 0 0 ""> + <-110 520 -110 560 "" 0 0 0 ""> + <-110 420 -110 460 "" 0 0 0 ""> + <-110 420 -50 420 "" 0 0 0 ""> + <10 420 80 420 "" 0 0 0 ""> + <10 560 60 560 "" 0 0 0 ""> + <880 -90 880 -10 "" 0 0 0 ""> + <820 -90 880 -90 "" 0 0 0 ""> + <690 -90 760 -90 "" 0 0 0 ""> + <690 -50 730 -50 "" 0 0 0 ""> + <690 -90 690 -50 "" 0 0 0 ""> + <970 -100 1020 -100 "" 0 0 0 ""> + <1130 -50 1150 -50 "" 0 0 0 ""> + <1130 -100 1130 -50 "" 0 0 0 ""> + <1080 -100 1130 -100 "" 0 0 0 ""> + + + + + diff --git a/sim/mixer_match.sch b/sim/mixer_match.sch new file mode 100644 index 0000000..6a2bf1c --- /dev/null +++ b/sim/mixer_match.sch @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + <.DC DC1 1 400 720 0 38 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0> + <.SP SP1 1 130 710 0 61 0 0 "lin" 1 "100 MHz" 1 "2 GHz" 1 "50" 1 "no" 0 "1" 0 "2" 0 "no" 0 "no" 0> + + + <.SW SW1 1 650 730 0 61 0 0 "SP1" 1 "lin" 1 "I1" 1 "-5 mA" 1 "5 mA" 1 "11" 1> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <710 50 710 180 "" 0 0 0 ""> + <1190 50 1190 180 "" 0 0 0 ""> + <1120 80 1120 180 "" 0 0 0 ""> + <810 80 810 180 "" 0 0 0 ""> + <850 -10 880 -10 "" 0 0 0 ""> + <810 80 880 80 "" 0 0 0 ""> + <880 80 1120 80 "" 0 0 0 ""> + <880 -10 880 80 "" 0 0 0 ""> + <710 50 970 50 "" 0 0 0 ""> + <730 -10 790 -10 "" 0 0 0 ""> + <730 -50 730 -10 "" 0 0 0 ""> + <1150 -50 1150 -10 "" 0 0 0 ""> + <1110 -10 1150 -10 "" 0 0 0 ""> + <970 50 1190 50 "" 0 0 0 ""> + <970 -10 970 50 "" 0 0 0 ""> + <970 -10 1050 -10 "" 0 0 0 ""> + <1020 -50 1150 -50 "" 0 0 0 ""> + <1020 -50 1020 100 "" 0 0 0 ""> + <730 -50 910 -50 "" 0 0 0 ""> + <910 -50 1020 -50 "" 0 0 0 ""> + <910 -50 910 100 "" 0 0 0 ""> + <610 -50 730 -50 "" 0 0 0 ""> + <610 -50 610 100 "" 0 0 0 ""> + <1150 -50 1280 -50 "" 0 0 0 ""> + <1280 -50 1280 90 "" 0 0 0 ""> + <1280 260 1280 300 "" 0 0 0 ""> + <1220 270 1220 300 "" 0 0 0 ""> + <1090 270 1090 300 "" 0 0 0 ""> + <1020 290 1020 310 "" 0 0 0 ""> + <910 290 910 310 "" 0 0 0 ""> + <840 270 840 300 "" 0 0 0 ""> + <680 270 680 300 "" 0 0 0 ""> + <610 260 610 310 "" 0 0 0 ""> + <610 160 610 180 "" 0 0 0 ""> + <610 180 610 200 "" 0 0 0 ""> + <610 180 650 180 "" 0 0 0 ""> + <910 160 910 180 "" 0 0 0 ""> + <910 180 910 230 "" 0 0 0 ""> + <870 180 910 180 "" 0 0 0 ""> + <1020 160 1020 180 "" 0 0 0 ""> + <1020 180 1020 230 "" 0 0 0 ""> + <1020 180 1060 180 "" 0 0 0 ""> + <1280 150 1280 180 "" 0 0 0 ""> + <1280 180 1280 200 "" 0 0 0 ""> + <1250 180 1280 180 "" 0 0 0 ""> + <1120 240 1150 240 "" 0 0 0 ""> + <1150 240 1190 240 "" 0 0 0 ""> + <1150 240 1150 310 "" 0 0 0 ""> + <1150 370 1150 400 "" 0 0 0 ""> + <760 380 760 410 "" 0 0 0 ""> + <710 240 760 240 "" 0 0 0 ""> + <760 240 810 240 "" 0 0 0 ""> + <760 240 760 320 "" 0 0 0 ""> + <530 -160 530 -140 "" 0 0 0 ""> + <530 -160 610 -160 "" 0 0 0 ""> + <610 -160 610 -50 "" 0 0 0 ""> + <530 -80 530 -50 "" 0 0 0 ""> + <520 180 520 280 "" 0 0 0 ""> + <520 180 610 180 "" 0 0 0 ""> + <990 180 1020 180 "" 0 0 0 ""> + <990 180 990 460 "" 0 0 0 ""> + <610 460 990 460 "" 0 0 0 ""> + <610 360 610 460 "" 0 0 0 ""> + <520 360 610 360 "" 0 0 0 ""> + <910 180 960 180 "" 0 0 0 ""> + <1280 180 1430 180 "" 0 0 0 ""> + <970 -100 970 -10 "" 0 0 0 ""> + <950 -100 970 -100 "" 0 0 0 ""> + <880 -100 880 -10 "" 0 0 0 ""> + <880 -100 890 -100 "" 0 0 0 ""> + <220 420 270 420 "" 0 0 0 ""> + <220 560 270 560 "" 0 0 0 ""> + <270 560 320 560 "" 0 0 0 ""> + <270 530 270 560 "" 0 0 0 ""> + <270 420 320 420 "" 0 0 0 ""> + <270 420 270 470 "" 0 0 0 ""> + <80 420 80 460 "" 0 0 0 ""> + <80 420 160 420 "" 0 0 0 ""> + <160 560 170 560 "" 0 0 0 ""> + <80 560 160 560 "" 0 0 0 ""> + <80 520 80 560 "" 0 0 0 ""> + <60 420 80 420 "" 0 0 0 ""> + <60 560 80 560 "" 0 0 0 ""> + <-60 560 0 560 "" 0 0 0 ""> + <-60 520 -60 560 "" 0 0 0 ""> + <-60 420 -60 460 "" 0 0 0 ""> + <-60 420 0 420 "" 0 0 0 ""> + <1080 -210 1140 -210 "" 0 0 0 ""> + <880 -280 1020 -280 "" 0 0 0 ""> + <1080 -280 1140 -280 "" 0 0 0 ""> + <1140 -280 1140 -270 "" 0 0 0 ""> + <1140 -210 1250 -210 "" 0 0 0 ""> + <1140 -280 1250 -280 "" 0 0 0 ""> + <1250 -280 1250 -270 "" 0 0 0 ""> + <960 180 960 540 "" 0 0 0 ""> + <920 540 960 540 "" 0 0 0 ""> + <1430 180 1430 620 "" 0 0 0 ""> + <920 620 1430 620 "" 0 0 0 ""> + <380 540 380 560 "" 0 0 0 ""> + <380 540 750 540 "" 0 0 0 ""> + <380 620 760 620 "" 0 0 0 ""> + <380 560 380 620 "" 0 0 0 ""> + <380 360 380 420 "" 0 0 0 ""> + <370 280 370 360 "" 0 0 0 ""> + <370 360 380 360 "" 0 0 0 ""> + <440 360 460 360 "" 0 0 0 ""> + <430 280 460 280 "" 0 0 0 ""> + <810 540 860 540 "" 0 0 0 ""> + <820 620 860 620 "" 0 0 0 ""> + <950 -210 970 -210 "" 0 0 0 ""> + <880 -280 880 -210 "" 0 0 0 ""> + <880 -210 890 -210 "" 0 0 0 ""> + <880 -210 880 -100 "" 0 0 0 ""> + <970 -210 1020 -210 "" 0 0 0 ""> + <970 -210 970 -100 "" 0 0 0 ""> + + + + + diff --git a/sim/mixer_matching.ipynb b/sim/mixer_matching.ipynb new file mode 100644 index 0000000..4a6292c --- /dev/null +++ b/sim/mixer_matching.ipynb @@ -0,0 +1,206 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(array([0.8645785 -0.09823784j, 0.85954376-0.10151559j,\n", + " 0.85534282-0.10389085j, 0.85223139-0.10548823j,\n", + " 0.85032448-0.10640486j, 0.84968251-0.10670324j,\n", + " 0.85032448-0.10640486j, 0.85223139-0.10548823j,\n", + " 0.85534282-0.10389085j, 0.85954376-0.10151559j,\n", + " 0.8645785 -0.09823784j]),\n", + " array([0.58060059-0.38299298j, 0.5812387 -0.39895514j,\n", + " 0.58112332-0.41153593j, 0.58070618-0.42059005j,\n", + " 0.58031978-0.42604352j, 0.58016811-0.42786419j,\n", + " 0.58031978-0.42604352j, 0.58070618-0.42059005j,\n", + " 0.58112332-0.41153593j, 0.5812387 -0.39895514j,\n", + " 0.58060059-0.38299298j]))" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# matching the mixer LO input and RF output to 50 ohms using the S11/S22 parameters\n", + "# calculated using Qucs\n", + "\n", + "import qucs.qucsdata as qd\n", + "data = qd.QucsData('bfu520_mixer.dat').data\n", + "\n", + "\n", + "import numpy as np\n", + "# find the index closest to 915 MHz\n", + "freqs = data['frequency']\n", + "idx = np.abs(freqs - 915e+6).argmin()\n", + "\n", + "s11s = data['S[1,1]']\n", + "s22s = data['S[2,2]']\n", + "\n", + "s11s[idx,:], s22s[idx,:]" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(407.8826087843155-328.42259033407754j)\n", + "834.9901269321724j\n", + "(672.324866234869+0j)\n", + "1.452380394909119e-07\n", + "407.8826087843155 152.45788592627554 133.76894422554054\n", + "5.712576904340215e-08 1.3003005258265486e-12 2.651849853388749e-08\n" + ] + } + ], + "source": [ + "s11 = np.mean(s11s, axis=1)\n", + "s22 = np.mean(s22s, axis=1)\n", + "#print(s11)\n", + "\n", + "import skrf.network as net\n", + "\n", + "# conjugate match the source\n", + "z_s = net.s2z(np.array([[[s11[idx]]]]))[0, 0, 0]\n", + "print(z_s)\n", + "\n", + "# so it looks like it'll need a large series inductor to compensate the imaginary part, followed by a standard \n", + "# L match to 50 ohms\n", + "l_series_s = -np.imag(z_s)/(2*np.pi*915e+6)\n", + "\n", + "# how hard would it be to remove the imaginary part using a shunt element?\n", + "print(1j/np.imag(1/z_s))\n", + "print(1/(1/z_s + 1/(1j/np.imag(1/z_s))))\n", + "print(1/(np.imag(1/z_s)*2*np.pi*915e+6))\n", + "\n", + "# okay, 130 nH is pretty big so I'm going to go with the smaller series option\n", + "\n", + "r_s = np.real(z_s)\n", + "q_s = np.sqrt((r_s - 50.)/50.)\n", + "\n", + "x_1_s = r_s/q_s\n", + "x_2_s = q_s * 50.\n", + "print(r_s, x_1_s, x_2_s)\n", + "\n", + "# let's go with a shunt capacitor followed by an inductor\n", + "l_series_s2 = x_1_s/(2*np.pi*915e+6)\n", + "c_shunt_s = 1/(2*np.pi*915e+6*x_2_s)\n", + "print(l_series_s, c_shunt_s, l_series_s2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(407.8826087843155+0j) (39.61039510850523-120.77834197894384j) (39.61039510850523+31.679543947331695j)\n" + ] + } + ], + "source": [ + "# double check\n", + "\n", + "z_1 = z_s + 2j*np.pi*l_series_s*915e+6\n", + "z_2 = 1/(1/z_1 + 1/(1/(2j*np.pi*915e+6*c_shunt_s)))\n", + "z_3 = z_2 + 2j*np.pi*915e+6*l_series_s2\n", + "\n", + "print(z_1, z_2, z_3)\n", + "\n", + "# TODO maybe simulate it using scikit-rf network stuff" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(89.46617486489218-105.51717177278026j)\n", + "1.83536387636225e-08 3.154815993634542e-08\n", + "(213.91402966297977+0j)\n", + "213.91402966297977 118.14523420131724 90.53011368129937\n", + "1.244415883537231e-08 3.842695462154556e-12\n" + ] + } + ], + "source": [ + "# time to conjugate match the output\n", + "#z_l = net.s2z(np.array([[[s22[idx]]]]))[0, 0, 0]\n", + "z_l = net.s2z(np.array([[[0.544 - 0.345j]]]))[0, 0, 0]\n", + "\n", + "print(z_l)\n", + "\n", + "# series inductor or shunt inductor to cancel out the imaginary impedance? let's compare values like before\n", + "z_series_l = -np.imag(z_l)/(2*np.pi*915e+6)\n", + "z_shunt_l = 1/(np.imag(1/z_l))/(2*np.pi*915e+6)\n", + "\n", + "print(z_series_l, z_shunt_l)\n", + "print(1/(1/z_l + 1/(2j*np.pi*915e+6*z_shunt_l)))\n", + "\n", + "# so either a pair of 15 nH series inductors or a 47 nH shunt; let's see how to the L section looks \n", + "# before deciding here\n", + "\n", + "#r_l = np.real(z_l)\n", + "r_l = np.real(1/(1/z_l + 1/(2j*np.pi*915e+6*z_shunt_l)))\n", + "q_l = np.sqrt((r_l - 50.)/50.)\n", + "\n", + "x_1_l = r_l/q_l\n", + "x_2_l = q_l * 50.\n", + "print(r_l, x_1_l, x_2_l)\n", + "\n", + "# let's give the smaller impedance to the capacitor, so it'll be a shunt inductor\n", + "l_shunt_l = x_1_l/(2*np.pi*915e+6)\n", + "c_series_l = 1/(2*np.pi*915e+6*x_2_l)\n", + "l_shunt_total_l = 1/(1/l_shunt_l + 1/z_shunt_l)\n", + "\n", + "print(l_shunt_total_l, 2*c_series_l)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sim/qucs/qucsdata.py b/sim/qucs/qucsdata.py index 8628884..13d969c 100644 --- a/sim/qucs/qucsdata.py +++ b/sim/qucs/qucsdata.py @@ -53,7 +53,8 @@ class QucsData: if '")) + stripbrackets = str.maketrans(dict.fromkeys("<>")) + r = re.match(r'(\S+) (\S+) (\d+)', line.translate(stripbrackets)) kind, identifier, size = r.groups() # collect identifiers self.names.append(identifier) @@ -63,7 +64,8 @@ class QucsData: if '")) + stripbrackets = str.maketrans(dict.fromkeys("<>")) + r = re.findall('(\S+)', line.translate(stripbrackets)) identifier = r[1] self.dependent[identifier]= r[2:] self.names.append(identifier)