-
Notifications
You must be signed in to change notification settings - Fork 0
/
Impedanceplotter.grc
586 lines (583 loc) · 15.9 KB
/
Impedanceplotter.grc
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
options:
parameters:
author: Joseph Eoff
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
copyright: ''
description: ''
gen_cmake: 'On'
gen_linking: dynamic
generate_options: qt_gui
hier_block_src_path: '.:'
id: Impedance_plotter
max_nouts: '0'
output_language: python
placement: (0,0)
qt_qss_theme: ''
realtime_scheduling: ''
run: 'True'
run_command: '{python} -u {filename}'
run_options: prompt
sizing_mode: fixed
thread_safe_setters: ''
title: Impedance Plotter
window_size: ''
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [47, 11]
rotation: 0
state: enabled
blocks:
- name: block_size
id: variable
parameters:
comment: ''
value: '8192'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [816, 12.0]
rotation: 0
state: enabled
- name: samp_rate
id: variable
parameters:
comment: ''
value: '44100'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [656, 12.0]
rotation: 0
state: enabled
- name: series_resistor
id: variable_qtgui_range
parameters:
comment: ''
gui_hint: 0,0
label: Series Resistor (ohms)
min_len: '50'
orient: Qt.Horizontal
rangeType: float
start: '0'
step: '0.01'
stop: '100000'
value: '20'
widget: counter
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [200, 12.0]
rotation: 0
state: enabled
- name: smoothing
id: variable
parameters:
comment: ''
value: '0.03'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [736, 12.0]
rotation: 0
state: enabled
- name: units
id: variable_qtgui_chooser
parameters:
comment: ''
gui_hint: 0,1
label: Units
label0: ohms (impedance)
label1: microfarads (capacitance)
label2: microhenries (inductance)
label3: ''
label4: ''
labels: '[]'
num_opts: '3'
option1: microfarads (capacitance)
option2: microhenries (inductance)
option3: '3'
option4: '4'
options: '[0, 1, 2]'
orient: Qt.QVBoxLayout
type: string
value: ohms (impedance)
widget: combo_box
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [360, 12.0]
rotation: 0
state: true
- name: analog_noise_source_x_0
id: analog_noise_source_x
parameters:
affinity: ''
alias: ''
amp: '1'
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
noise_type: analog.GR_GAUSSIAN
seed: '0'
type: float
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [32, 180.0]
rotation: 0
state: enabled
- name: audio_sink_0
id: audio_sink
parameters:
affinity: ''
alias: ''
comment: ''
device_name: sysdefault
num_inputs: '1'
ok_to_block: 'True'
samp_rate: samp_rate
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [216, 188.0]
rotation: 0
state: enabled
- name: audio_source_0
id: audio_source
parameters:
affinity: ''
alias: ''
comment: ''
device_name: sysdefault
maxoutbuf: '0'
minoutbuf: '0'
num_outputs: '2'
ok_to_block: 'False'
samp_rate: samp_rate
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [32, 264.0]
rotation: 0
state: enabled
- name: blocks_complex_to_mag_0
id: blocks_complex_to_mag
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
vlen: block_size
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [584, 236.0]
rotation: 0
state: enabled
- name: blocks_complex_to_mag_0_0
id: blocks_complex_to_mag
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
vlen: block_size
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [584, 332.0]
rotation: 0
state: enabled
- name: blocks_divide_xx_0
id: blocks_divide_xx
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_inputs: '2'
type: float
vlen: block_size
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [936, 296.0]
rotation: 0
state: enabled
- name: blocks_keep_m_in_n_0
id: blocks_keep_m_in_n
parameters:
affinity: ''
alias: ''
comment: ''
m: int(block_size/2)
maxoutbuf: '0'
minoutbuf: '0'
n: block_size
offset: '0'
type: float
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [48, 620.0]
rotation: 0
state: enabled
- name: blocks_multiply_const_xx_0
id: blocks_multiply_const_xx
parameters:
affinity: ''
alias: ''
comment: ''
const: series_resistor
maxoutbuf: '0'
minoutbuf: '0'
type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [176, 636.0]
rotation: 0
state: enabled
- name: blocks_stream_to_vector_0
id: blocks_stream_to_vector
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_items: block_size
type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [208, 264.0]
rotation: 0
state: enabled
- name: blocks_stream_to_vector_0_0
id: blocks_stream_to_vector
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_items: block_size
type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [208, 296.0]
rotation: 0
state: enabled
- name: blocks_stream_to_vector_0_0_0
id: blocks_stream_to_vector
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_items: int(block_size/2)
type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [352, 640.0]
rotation: 0
state: enabled
- name: blocks_sub_xx_0
id: blocks_sub_xx
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_inputs: '2'
type: float
vlen: block_size
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [752, 240.0]
rotation: 0
state: enabled
- name: blocks_vector_to_stream_0
id: blocks_vector_to_stream
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_items: block_size
type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [816, 440.0]
rotation: 180
state: enabled
- name: epy_block_0
id: epy_block
parameters:
_source_code: "\"\"\"\nEmbedded Python Blocks:\n\nEach time this file is saved,\
\ GRC will instantiate the first class it finds\nto get ports and parameters\
\ of your block. The arguments to __init__ will\nbe the parameters. All of\
\ them are required to have default values!\n\"\"\"\n\nimport numpy as np\n\
from gnuradio import gr\nimport numpy \n\nclass ImpedanceConverter(gr.sync_block):\
\ # other base classes are basic_block, decim_block, interp_block\n \"\"\
\"Calculates capacitance or inductance from impedances. \"\"\"\n Impedance\
\ = \"ohms (impedance)\"\n Capacitance = \"microfarads (capacitance)\"\n\
\ Inductance = \"microhenries (inductance)\"\n def __init__(self, block_size=4096,\
\ samp_rate= 44100, outputType=0): # only default arguments here\n \
\ \"\"\"arguments to this function show up as parameters in GRC\"\"\"\n \
\ gr.sync_block.__init__(\n self,\n name='Impedance\
\ to inductance or capacitance converter', # will show up in GRC\n \
\ in_sig=[(np.float32, block_size)],\n out_sig=[(np.float32,\
\ block_size)]\n )\n # if an attribute with the same name as a\
\ parameter is found,\n # a callback is registered (properties work,\
\ too).\n self.block_size = block_size\n self.outputType = outputType\n\
\ self.samp_rate = samp_rate\n self.frequencies = numpy.arange(0,\
\ self.block_size) * ((self.samp_rate/2)/self.block_size) * 2 * numpy.pi\n\
\ self.frequencies[0]=1\n\n def work(self, input_items, output_items):\n\
\ block = input_items[0].flatten(order='C')\n output_items[0][:]\
\ = self.calculateByOutputType(block)\n return len(output_items)\n\n\
\ def calculateByOutputType(self, block):\n if self.outputType ==\
\ self.Capacitance:\n return self.calculateCapacitanceFromImpedance(block)\n\
\ if self.outputType == self.Inductance:\n return self.calculateInductanceFromImpedance(block)\n\
\ \n #No idea what we got, return the data unmodified\n \
\ return block\n \n def calculateInductanceFromImpedance(self, impedances):\n\
\ impedances[0] = 0\n inductance = 1000000 * impedances/self.frequencies\n\
\ return inductance\n \n def calculateCapacitanceFromImpedance(self,\
\ impedances):\n impedances[0] = 1\n #Need this because my sound\
\ card delivers a bunch of zeros if the input level goes too low.\n try:\n\
\ capacitance = 1000000/(self.frequencies*impedances)\n except:\n\
\ capacitance = impedances\n \n return capacitance\n"
affinity: ''
alias: ''
block_size: int(block_size/2)
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
outputType: units
samp_rate: samp_rate
states:
_io_cache: ('Impedance to inductance or capacitance converter', 'ImpedanceConverter',
[('block_size', '4096'), ('samp_rate', '44100'), ('outputType', '0')], [('0',
'float', 4096)], [('0', 'float', 4096)], 'Calculates capacitance or inductance
from impedances. ', ['block_size', 'outputType', 'samp_rate'])
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [664, 620.0]
rotation: 0
state: true
- name: fft_vxx_0
id: fft_vxx
parameters:
affinity: ''
alias: ''
comment: ''
fft_size: block_size
forward: 'True'
maxoutbuf: '0'
minoutbuf: '0'
nthreads: '1'
shift: 'True'
type: float
window: window.blackmanharris(block_size)
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [376, 212.0]
rotation: 0
state: enabled
- name: fft_vxx_0_0
id: fft_vxx
parameters:
affinity: ''
alias: ''
comment: ''
fft_size: block_size
forward: 'True'
maxoutbuf: '0'
minoutbuf: '0'
nthreads: '1'
shift: 'True'
type: float
window: window.blackmanharris(block_size)
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [376, 308.0]
rotation: 0
state: enabled
- name: qtgui_vector_sink_f_0
id: qtgui_vector_sink_f
parameters:
affinity: ''
alias: ''
alpha1: '1.0'
alpha10: '1.0'
alpha2: '1.0'
alpha3: '1.0'
alpha4: '1.0'
alpha5: '1.0'
alpha6: '1.0'
alpha7: '1.0'
alpha8: '1.0'
alpha9: '1.0'
autoscale: 'True'
average: '1.0'
color1: '"black"'
color10: '"dark blue"'
color2: '"red"'
color3: '"green"'
color4: '"black"'
color5: '"cyan"'
color6: '"magenta"'
color7: '"yellow"'
color8: '"dark red"'
color9: '"dark green"'
comment: ''
grid: 'True'
gui_hint: 1,0,4,5
label1: ''
label10: ''
label2: ''
label3: ''
label4: ''
label5: ''
label6: ''
label7: ''
label8: ''
label9: ''
maxoutbuf: '0'
minoutbuf: '0'
name: ''
nconnections: '1'
ref_level: '0'
showports: 'False'
update_time: '0.01'
vlen: int(block_size/2)
width1: '1'
width10: '1'
width2: '1'
width3: '1'
width4: '1'
width5: '1'
width6: '1'
width7: '1'
width8: '1'
width9: '1'
x_axis_label: '"Frequency (Hz)"'
x_start: '0'
x_step: (samp_rate/2)/(block_size/2)
x_units: '"Hz"'
y_axis_label: ''
y_units: units
ymax: series_resistor*2
ymin: '0'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [976, 580.0]
rotation: 0
state: enabled
- name: walkingaverage
id: epy_block
parameters:
_source_code: "\"\"\"\nEmbedded Python Blocks:\n\nEach time this file is saved,\
\ GRC will instantiate the first class it finds\nto get ports and parameters\
\ of your block. The arguments to __init__ will\nbe the parameters. All of\
\ them are required to have default values!\n\"\"\"\n\nimport numpy as np\n\
from gnuradio import gr\nimport scipy.signal\n\n\nclass blk(gr.sync_block):\
\ # other base classes are basic_block, decim_block, interp_block\n \"\"\
\"Calculate a walking average of blocks of data.\"\"\"\n \n def __init__(self,\
\ block_size=4096, averaging=1.0, medianrank=51): # only default arguments\
\ here\n \"\"\"arguments to this function show up as parameters in GRC\"\
\"\"\n gr.sync_block.__init__(\n self,\n name='Walking\
\ average', # will show up in GRC\n in_sig=[(np.float32, block_size)],\
\ \n out_sig=[(np.float32, block_size)]\n )\n # if\
\ an attribute with the same name as a parameter is found,\n # a callback\
\ is registered (properties work, too).\n self.averaging = averaging\n\
\ self.block_size = block_size\n self.lastblock = np.zeros(shape=(self.block_size))\n\
\ self.medianrank = medianrank\n\n def work(self, input_items, output_items):\n\
\ newblock = scipy.signal.medfilt(input_items[0].flatten(order='C'),self.medianrank)\n\
\ self.lastblock = (newblock - self.lastblock ) * self.averaging + self.lastblock\n\
\ output_items[0][:] = self.lastblock\n return len(output_items)\n\
\n"
affinity: ''
alias: ''
averaging: smoothing
block_size: int(block_size/2)
comment: ''
maxoutbuf: '0'
medianrank: '101'
minoutbuf: '0'
states:
_io_cache: ('Walking average', 'blk', [('block_size', '4096'), ('averaging', '1.0'),
('medianrank', '51')], [('0', 'float', 4096)], [('0', 'float', 4096)], 'Calculate
a walking average of blocks of data.', ['averaging', 'block_size', 'medianrank'])
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [512, 620.0]
rotation: 0
state: enabled
connections:
- [analog_noise_source_x_0, '0', audio_sink_0, '0']
- [audio_source_0, '0', blocks_stream_to_vector_0, '0']
- [audio_source_0, '1', blocks_stream_to_vector_0_0, '0']
- [blocks_complex_to_mag_0, '0', blocks_sub_xx_0, '0']
- [blocks_complex_to_mag_0_0, '0', blocks_divide_xx_0, '0']
- [blocks_complex_to_mag_0_0, '0', blocks_sub_xx_0, '1']
- [blocks_divide_xx_0, '0', blocks_vector_to_stream_0, '0']
- [blocks_keep_m_in_n_0, '0', blocks_multiply_const_xx_0, '0']
- [blocks_multiply_const_xx_0, '0', blocks_stream_to_vector_0_0_0, '0']
- [blocks_stream_to_vector_0, '0', fft_vxx_0, '0']
- [blocks_stream_to_vector_0_0, '0', fft_vxx_0_0, '0']
- [blocks_stream_to_vector_0_0_0, '0', walkingaverage, '0']
- [blocks_sub_xx_0, '0', blocks_divide_xx_0, '1']
- [blocks_vector_to_stream_0, '0', blocks_keep_m_in_n_0, '0']
- [epy_block_0, '0', qtgui_vector_sink_f_0, '0']
- [fft_vxx_0, '0', blocks_complex_to_mag_0, '0']
- [fft_vxx_0_0, '0', blocks_complex_to_mag_0_0, '0']
- [walkingaverage, '0', epy_block_0, '0']
metadata:
file_format: 1