Skip to content

Instantly share code, notes, and snippets.

@JerryWiltz
Last active May 29, 2019 19:32
Show Gist options
  • Save JerryWiltz/6d2ea0066b4e2b4433ec3566663c2662 to your computer and use it in GitHub Desktop.
Save JerryWiltz/6d2ea0066b4e2b4433ec3566663c2662 to your computer and use it in GitHub Desktop.
Attenuator Comparison
license: gpl-3.0
height: 600
scrolling: yes
border: yes

A 3dB Attenuator is simulated with and without parasitic capacitance. Two plots are shown, one the the ideal and the other with the parasitics considered.

<!DOCTYPE html>
<html>
<head>
<title>3dB Attenuator with and without Parasitics</title>
</head>
<body>
<svg id="chart1" width="600" height="400"></svg>
<img src='AttenuatorParasitic.png'></img>
<script src="https://cdn.jsdelivr.net/gh/JerryWiltz/nP@latest/dist/nP.js"></script>
<script>
// generate frequency list
g = nP.global;
g.fList = g.fGen(50e6, 6e9, 101);
// define the 3 dB attenuator
var R1 = nP.paR(292);
var R2 = nP.seR(18);
var R3 = nP.paR(292);
var Attenuator = R1.cas(R2).cas(R3);
// define the output of an ideal attenuator and add to the plot in lineChart below
var AttenuatorOut = Attenuator.out('s21dB');
// add the parasitic capacitances
var cParasitic = nP.paC(0.5e-12);
// add the parasitics to the input and outputs sides of the Attenuator
var AttenuatorWithParasitics = cParasitic.cas(Attenuator).cas(cParasitic);
// define the output with the effect of the parasitics
var AttenuatorWithParasiticsOut = AttenuatorWithParasitics.out('s21dB');
// set up the lineChartInputObject, notice there are two input tables for two plots
var fullInputObject = {
inputTable: [AttenuatorOut, AttenuatorWithParasiticsOut],
chartID: 'chart1',
metricPrefix: 'giga',
titleTitle: 'Comparison of 3dB Attenuator with and without 0.5 pF parasitic capacitance',
xAxisTitle: 'Input Frequency, GHz',
yAxisTitle: 's21, dB',
xRange: [0,6e9],
yRange: [0,-6],
showPoints: 'hide',
showLables: 'show'
};
// plot the attenuator responses
nP.lineChart(fullInputObject);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment