-
Notifications
You must be signed in to change notification settings - Fork 0
/
vco_cmos_tl270u.py
executable file
·367 lines (327 loc) · 16 KB
/
vco_cmos_tl270u.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
from scipy import optimize
from functools import partial
import skrf as rf
import re
do_pn = False
do_title = True
meas_dir = "/mnt/home/documents/Measurements/MPW2215_VCO/"
meas_dir = "/home/zoltan/ccn/Measurements/MPW2215_VCO/"
sim_dir = "/home/zoltan/ccn/Measurements/MPW2215_VCO/sim/"
style_sim = {"linestyle":"--", "color":"grey", "marker":"None"} #, "label":"sim"} # for plot
style_meas = {"linestyle":":", "color":"black", "marker":"o","s":40} # , "label":"meas"} # for scatter
style_meas1 = {"linestyle":"-", "edgecolor":None,"facecolor":"blue", "s":20, "marker":"o"} #, "label":"meas", "marker":"o"}
style_meas2 = {"linestyle":"-", "edgecolor":None,"facecolor":"green", "s":20, "marker":"v"} #, "label":"meas", "marker":"o"}
style_meas3 = {"linestyle":"-", "edgecolor":None,"facecolor":"orange", "s":20, "marker":"s"} #, "label":"meas", "marker":"o"}
style_meas4 = {"linestyle":"-", "edgecolor":None,"facecolor":"purple", "s":20, "marker":"^"} #, "label":"meas", "marker":"o"}
legend_style = {"frameon":False, "fontsize":7, "handletextpad":0.4, "borderaxespad":0, "ncol":3, "loc":'lower center', "mode":"expand", "handlelength":2, "bbox_to_anchor":(0.16,1.0,0.84,0.04)}
legend_style_ncol2 = {"frameon":False, "fontsize":7, "handletextpad":0.4, "borderaxespad":0, "ncol":2, "loc":'lower center', "mode":"expand", "handlelength":2, "bbox_to_anchor":(0.2,1.0,0.75,0.04)} # for no simulation
legend_style2 = {"frameon":False, "fontsize":7, "handletextpad":0.4, "borderaxespad":0, "ncol":1, "loc":'lower center', "mode":"expand", "handlelength":1, "labelspacing":0.3, "title_fontsize":8}
legend_style2_ncol2 = {"frameon":False, "fontsize":7, "handletextpad":0.4, "borderaxespad":0, "ncol":2, "loc":'lower center', "mode":"expand", "handlelength":1, "title_fontsize":8, "labelspacing":0.3}
legend_style2_ncol2_ul = {"frameon":False, "fontsize":7, "handletextpad":0.4, "borderaxespad":0, "ncol":2, "loc":'upper left', "mode":"expand", "handlelength":0.6}
vdd_ib_annot = {"s":r"V\textsubscript{DD} I\textsubscript{b}:","xy":(0,1.12),"xycoords":"axes fraction","fontsize":8}
l_style_meas = [style_meas1, style_meas2,style_meas3,style_meas4]
plot_style = {"figsize":(3.3914487339144874, 2.0960305886619515*0.7)}
xlabel = {"xlabel":r"Frequency $\left[\si{\GHz}\right]$", "labelpad":0}
opt_vcsv = {'header':None, 'skiprows':6, 'dtype':np.float64, 'usecols':[0,1,3,5],'names':['vtune','freq','pout','pdc']}
def eff(pout, vdc, idc, in_dBm=False):
""" Calculating the DC-to-RF efficiency.
Paramters
---------
pout: float
output power
vdc: float
dc supply voltage
idc: float
dc suply current
in_dBm: boolean, optional
is pout value in dBm?
Returns
-------
float
DC-to-RF efficiency in percentage.
"""
if in_dBm:
ret = (10**(pout/10))*1e-3/vdc/idc*100
else:
ret = pout/vdc/idc*100
return ret
latex=True
if latex:
matplotlib.use('pgf')
pgf_with_custom_preamble = {
"font.family": "serif", # use serif/main font for text elements
"text.usetex": True, # use inline math for ticks
"pgf.rcfonts": False, # don't setup fonts from rc parameters
# "figure.dpi" : 300,
# "figure.autolayout" : True,
# Use 10pt font in plots, to match 10pt font in document
# "axes.labelsize": 10,
"axes.labelsize": 8,
"axes.grid" :True,
"font.size": 10,
# Make the legend/label fonts a little smaller
"legend.fontsize": 8,
"legend.title_fontsize": 8,
"xtick.labelsize": 8,
"ytick.labelsize": 8,
"xtick.direction":"in",
"ytick.direction":"in",
"xtick.major.size":1.5,
"ytick.major.size":1.5,
# "xtick.major.pad":2,
# "ytick.major.pad":2,
"grid.alpha": 0.5,
'lines.markersize':4,
"savefig.pad_inches":0,
"savefig.bbox":"tight",
"savefig.dpi":300,
"pgf.preamble": [
"\\usepackage{siunitx}", # load additional packages
"\\usepackage{amsmath}", # load additional packages
"\\usepackage{metalogo}",
"\\usepackage{unicode-math}", # unicode math setup
r"\newcommand{\da}{\textsuperscript{$\dagger$}}"
r"\DeclareSIUnit{\Bm}{Bm}",
r"\DeclareSIUnit{\dBm}{\deci\Bm}",
r"\sisetup{detect-weight=true, detect-family=true, per-mode=fraction, fraction-function=\tfrac,range-phrase=--, range-units=single}",
# r"\setmathfont{xits-math.otf}",
# r"\setmainfont{DejaVu Serif}", # serif font via preamble
]
}
matplotlib.rcParams.update(pgf_with_custom_preamble)
#######################################
# Cable loss interpolation
#######################################
f_loss = "Probe_842922_cable_05439601_dcblock_avg.s2p"
f_loss = "2tier_cable_SN06149358_D7032_CSR8_Thru_DCblock.s2p"
nw_loss = rf.Network(meas_dir + f_loss)
def loss_func(f, dc,sq,lin):
return dc + sq*np.sqrt(f) + lin*f
x = nw_loss.f
y = nw_loss.s_db[:,1,0]
par, cov = optimize.curve_fit(loss_func, x, y)
cable_loss = partial(loss_func, dc=par[0], sq=par[1], lin=par[2])
#################################
# Measurement results from Excel
#################################
meas_xlsx = meas_dir + "vco_cmos_60G_TL270u.xlsx"
df_meas = pd.read_excel(meas_xlsx, usecols="B:G",sheet_name="20200218", header=0).rename(columns={"IDD[m]":"idd", "freq [GHz]":"freq", "Pout [dBm]":"pout", "Vtune":"vtune", "VDD":"vdd", "Iosc[mA]":"ib"})
df_meas = pd.read_excel(meas_xlsx, usecols="B:G",sheet_name="20200522", header=0).rename(columns={"IDD[m]":"idd", "freq [GHz]":"freq", "Pout [dBm]":"pout", "Vtune":"vtune", "VDD":"vdd", "Iosc[mA]":"ib"})
# l_my_vdd = [1, 1.6]
l_cond = [
{"vdd":1,"ib":4},
{"vdd":1.2,"ib":4},
{"vdd":1.4,"ib":4},
# {"vdd":1.4,"ib":6} # higher output power, but slightly lower efficiency
{"vdd":1.6,"ib":6}
]
# p_out supposed to be the DIFFERENTIAL output power available at the PADS
# The single ended output was measured
df_meas.pout += 3 - cable_loss(df_meas.freq*1e9) # it should be moved to the common part
df_meas["eff"] = eff(df_meas.pout, df_meas.vdd, df_meas.idd*1e-3, in_dBm=True)
suffix = "cmos_tl270u"
outfile = suffix + ".png"
df_sim1 = pd.read_csv(sim_dir + 'cmos_tl270u_vdd1p0V_ib4mA_20200527_tt_90C.vcsv', **opt_vcsv)
df_sim1['vdd'] = 1
df_sim1['ib'] = 4
df_sim1p2 = pd.read_csv(sim_dir + 'cmos_tl270u_vdd1p2V_ib4mA_20200527_tt_90C.vcsv', **opt_vcsv)
df_sim1p2['vdd'] = 1.2
df_sim1p2['ib'] = 4
df_sim1p4 = pd.read_csv(sim_dir + 'cmos_tl270u_vdd1p4V_ib4mA_20200527_tt_90C.vcsv', **opt_vcsv)
df_sim1p4['vdd'] = 1.4
df_sim1p4['ib'] = 4
df_sim1p6 = pd.read_csv(sim_dir + 'cmos_tl270u_vdd1p6V_ib6mA_20200527_tt_90C.vcsv', **opt_vcsv)
df_sim1p6['vdd'] = 1.6
df_sim1p6['ib'] = 6
# Create one dataframe for easier use
df_sim = pd.concat([df_sim1, df_sim1p2, df_sim1p4, df_sim1p6], ignore_index=True)
df_sim.loc[:,'freq'] *= 1e-9
df_sim.loc[:,'pout'] += 3
df_sim["eff"] = np.power(10,(df_sim.pout-df_sim.pdc)/10) * 100
######################################
# Tuning range
######################################
fig_s, ax_s = plt.subplots(**plot_style)
tr_label = []
cnt = 0
for cond in l_cond:
mask = pd.DataFrame([df_meas[key] == val for key, val in cond.items()]).T.all(axis=1)
dfm = df_meas[mask]
mask = pd.DataFrame([df_sim[key] == val for key, val in cond.items()]).T.all(axis=1)
dfs = df_sim[mask]
assert dfm.ib.nunique()==1, "Multiple bias current values"
ax_s.plot(dfs.vtune, dfs.freq, **style_sim)
ax_s.scatter(dfm.vtune, dfm.freq, **l_style_meas[cnt], label="%.1fV %dmA" % (cond["vdd"],cond["ib"]))
cnt += 1
fmin, fmax = dfm.freq.min(), dfm.freq.max()
favg = (fmin+fmax)/2
fper = (fmax-favg)/favg*100
tr_label.append(r"$\SI{%.1f}{\GHz}\pm\SI{%.1f}{\percent}$" % (favg,fper))
ax_s.plot([],[],**style_sim, label="sim") # to add label
ax_s.set_xlim(-0.5, 1.5)
ax_s.set_ylim(48.5, 59)
ax_s.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(2))
# ax_s.yaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(0.5))
ax_s.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(0.5))
# ax_s.xaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(0.1))
ax_s.set_xlabel(r"Tuning voltage $\left[\si{\volt}\right]$", labelpad=0)
ax_s.set_ylabel(r"Frequency $\left [ \si{\GHz} \right ]$", labelpad=1)
# ax_s.grid()
handles, labels = ax_s.get_legend_handles_labels()
# # checking order of the labels
# print(handles)
# print(labels)
handles = [*handles[1:], handles[0]]
labels = [*labels[1:], labels[0]]
leg = ax_s.legend(handles=handles, labels=labels, **legend_style)
ax_s.legend(handles=handles[:len(handles)-1], labels=tr_label, **legend_style2, bbox_to_anchor=(0.62,-0.02,0.4,0.2), title="Tuning range")
ax_s.add_artist(leg)
ax_s.annotate(**vdd_ib_annot)
for ext in ["png","pgf"]:
# fig_s.savefig(meas_dir + suffix + "_tune." + ext, bbox_inches='tight', pad_inches = 0)
fig_s.savefig(meas_dir + suffix + "_tune." + ext, bbox_inches='tight', pad_inches = 0)
######################################
# Output power
######################################
# The differential output power is plotted
fig_s,ax_s = plt.subplots(**plot_style)
cnt = 0
pout_label = []
cond = {"vdd":1, "ib":4}
for cond in l_cond:
mask = pd.DataFrame([df_meas[key] == val for key, val in cond.items()]).T.all(axis=1)
dfm = df_meas[mask]
mask = pd.DataFrame([df_sim[key] == val for key, val in cond.items()]).T.all(axis=1)
dfs = df_sim[mask]
assert dfm.ib.nunique()==1, "Multiple bias current values"
ax_s.plot(dfs.freq, dfs.pout, **style_sim)
ax_s.scatter(dfm.freq, dfm.pout, **l_style_meas[cnt], label="%.1fV %dmA" % (cond["vdd"],cond["ib"]))
cnt += 1
p_avg = 10*np.log10(sum(10**(dfm.pout/10))/float(len(dfm.pout)))
pout_label.append("%.1f-%.1f; %.1fdBm" % (dfm.pout.min(), dfm.pout.max(), p_avg) )
ax_s.plot([],[],**style_sim, label="sim") # to add label
ax_s.set_xlabel(**xlabel)
ax_s.set_ylabel("Pout [dBm]")
ax_s.set_ylabel(r"P\textsubscript{out} $\left[ \si{\dBm} \right ]$")
ax_s.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(2))
ax_s.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1))
ax_s.set_xlim(50,59)
ax_s.set_ylim(-1.99,7)
# ax_s.grid()
handles, labels = ax_s.get_legend_handles_labels()
# # checking order of the labels
# print(handles)
# print(labels)
handles = [*handles[1:], handles[0]]
labels = [*labels[1:], labels[0]]
leg = ax_s.legend(handles=handles, labels=labels, **legend_style)
ax_s.legend(handles=handles[:len(handles)-1], labels=pout_label, **legend_style2_ncol2, bbox_to_anchor=(0.05,-0.02,0.9,0.2), title="P\\textsubscript{out}: min-max; avg")
ax_s.add_artist(leg)
ax_s.annotate(**vdd_ib_annot)
for ext in ["png","pgf"]:
fig_s.savefig(meas_dir + suffix + "_pout." + ext) #, bbox_inches='tight', pad_inches = 0)
######################################
# Power consumption
######################################
# The differential output power is plotted
fig_s,ax_s = plt.subplots(**plot_style)
fig_s2,ax_s2 = plt.subplots(**plot_style)
pdc_label = []
pdc_label2 = []
cnt = 0
for cond in l_cond:
mask = pd.DataFrame([df_meas[key] == val for key, val in cond.items()]).T.all(axis=1)
dfm = df_meas[mask]
mask = pd.DataFrame([df_sim[key] == val for key, val in cond.items()]).T.all(axis=1)
dfs = df_sim[mask]
assert dfm.ib.nunique()==1, "Multiple bias current values"
ax_s.plot(dfs.freq, dfs.pdc, **style_sim)
ax_s2.plot(dfs.freq, np.power(10,dfs.pdc/10), **style_sim)
meas_pdc_mW = dfm.vdd * dfm.idd
meas_pdc = 10*np.log10(meas_pdc_mW)
ax_s.scatter(dfm.freq, meas_pdc, **l_style_meas[cnt], label=r"\SI{%.1f}{\volt} \SI{%d}{\mA}" % (cond["vdd"],cond["ib"]))
ax_s2.scatter(dfm.freq, meas_pdc_mW, **l_style_meas[cnt], label=r"\SI{%.1f}{\volt} \SI{%d}{\mA}" % (cond["vdd"],cond["ib"]))
cnt += 1
pdc_label.append("\SIrange{%.1f}{%.1f}{}; \SI{%.1f}{\dBm}" % (meas_pdc.min(), meas_pdc.max(), meas_pdc.mean()) )
pdc_label2.append("\SIrange{%.1f}{%.1f}{}; \SI{%.1f}{\mW}" % (meas_pdc_mW.min(), meas_pdc_mW.max(), meas_pdc_mW.mean()) )
ax_s.plot([],[],**style_sim, label="sim") # to add label
ax_s2.plot([],[],**style_sim, label="sim") # to add label
ax_s.set_xlabel(**xlabel)
ax_s.set_ylabel(r"P\textsubscript{DC} $\left [ \si{\dBm} \right ]$")
ax_s.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(2.5))
ax_s.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1))
ax_s.set_xlim(50,59)
ax_s.set_ylim(2.6,15)
# ax_s.grid()
ax_s2.set_xlabel(**xlabel)
ax_s2.set_ylabel(r"P\textsubscript{DC} $\left [ \si{\mW} \right ]$")
ax_s2.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(5))
ax_s2.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1))
ax_s2.set_xlim(50,59)
ax_s2.set_ylim(5,40)
# ax_s2.grid()
handles, labels = ax_s.get_legend_handles_labels()
# # checking order of the labels
# print(handles)
# print(labels)
hand = [*handles[1:], handles[0]]
lab = [*labels[1:], labels[0]]
leg = ax_s.legend(handles=hand, labels=lab, **legend_style)
ax_s.legend(handles=handles[1:], labels=pdc_label, **legend_style2_ncol2, bbox_to_anchor=(0.05,-0.02,0.9,0.2), title="P\\textsubscript{DC}: min-max; avg")
ax_s.add_artist(leg)
leg = ax_s2.legend(handles=hand, labels=lab, **legend_style)
ax_s2.legend(handles=handles[1:], labels=pdc_label2, **legend_style2_ncol2, bbox_to_anchor=(0.05,0.65,0.9,0.2), title="P\\textsubscript{DC}: min-max; avg")
ax_s2.add_artist(leg)
ax_s.annotate(**vdd_ib_annot)
ax_s2.annotate(**vdd_ib_annot)
for ext in ["png","pgf"]:
fig_s.savefig(meas_dir + suffix + "_pdc." + ext) #, bbox_inches='tight', pad_inches = 0)
fig_s2.savefig(meas_dir + suffix + "_pdc_mW." + ext) #, bbox_inches='tight', pad_inches = 0)
######################################
# DC to RF efficiency
######################################
# l_eff = [eff(p_out[i], VDD, IDD[i], in_dBm=True) for i in range(len(p_out))]
fig_s,ax_s = plt.subplots(**plot_style)
eff_label = []
cnt = 0
for cond in l_cond:
mask = pd.DataFrame([df_meas[key] == val for key, val in cond.items()]).T.all(axis=1)
dfm = df_meas[mask]
# mask = pd.DataFrame([df_sim[key] == val for key, val in cond.items()]).T.all(axis=1)
# dfs = df_sim[mask]
assert dfm.ib.nunique()==1, "Multiple bias current values"
# ax_s.plot(dfs.freq, dfs.eff, **style_sim)
ax_s.scatter(dfm.freq, dfm.eff, **l_style_meas[cnt], label="%.1fV %dmA" % (cond["vdd"],cond["ib"]))
cnt += 1
eff_min, eff_max, eff_mean = dfm.eff.min(), dfm.eff.max(), dfm.eff.mean()
eff_label.append("%.f-%.f%%; %.f%%" % (eff_min, eff_max, eff_mean))
# ax_s.plot([],[],**style_sim, label="sim") # to add label
# ax_s2.plot([],[],**style_sim, label="sim") # to add label
ax_s.set_xlabel(**xlabel)
ax_s.set_ylabel(r"$\eta \left [ \si{\percent} \right ]$")
ax_s.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(2.5))
ax_s.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1))
ax_s.set_xlim(50,59)
# ax_s.set_ylim(14,25)
# ax_s.grid()
handles, labels = ax_s.get_legend_handles_labels()
# # checking order of the labels
# print(handles)
# print(labels)
label_order = [1, 2, 0]
# handles = [*handles[1:], handles[0]]
# labels = [*labels[1:], labels[0]]
# leg = ax_s.legend(handles=handles, labels=labels, **legend_style_ncol2)
leg = ax_s.legend(**legend_style_ncol2) # no simulation
# ax_s.legend(handles=handles[:len(handles)-1], labels=eff_label, **legend_style2_ncol2, bbox_to_anchor=(0.15,-0.02,0.7,0.2), title="$\eta$: min-max; avg")
ax_s.legend(labels=eff_label, **legend_style2_ncol2, bbox_to_anchor=(0,0.65,0.65,0.2), title="$\eta$: min-max; avg")
ax_s.add_artist(leg)
ax_s.annotate(**vdd_ib_annot)
# if suffix == "cmos_tl270u":
# ax_s.text(max(f_tune)*0.97,30,"%.1f%% - %.1f%%\nAvg: %.1f%%" %( min(l_eff),max(l_eff),sum(l_eff)/float(len(l_eff))),ha="center")
for ext in ["png","pgf"]:
fig_s.savefig(meas_dir + suffix + "_eff." + ext) #, bbox_inches='tight', pad_inches = 0)