回路の素101 019 2次ロー・パス・フィルタ LC型
減衰率40dB/dec
シンプルな構成
回路図作成
- 基本的な構成
カットオフ周波数 は下記で設定できる
今回の回路の場合、28kHz
応答性確認
100Hz入力
シミュレーションを tranモード(デフォルト) で実行し、応答を見る
import matplotlib.pyplot as plt import numpy as np from PyLTSpice import RawRead fig = plt.figure(figsize=(6, 3)) ax1 = fig.add_subplot(1, 1, 1) fname = 'PrimaryCircuit2-019.raw' LTR = RawRead(fname) x = LTR.get_trace('time').get_time_axis(0) tmp1 = LTR.get_trace('V(vin+)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vin+') tmp1 = LTR.get_trace('V(vout)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vout') ax1.legend(); ax1.grid() ax1.set_xlabel('[ms]'); ax1.set_ylabel('[V]') fig.tight_layout() fig.savefig('PrimaryCircuit2-019_Graph1.png')
3kHzに対しては、ゲインも1で、位相もほとんど変化しない
28kHz入力
信号源の周波数設定と、シミュレーションのパラメータを変更する
from PyLTSpice import SimCommander fname = 'PrimaryCircuit2-019' fname_tmp = '_28kHz' LTC = SimCommander(fname + '.asc') line_no = LTC._get_line_starting_with('V1') sim_cmd = LTC.netlist[line_no] LTC.netlist[line_no] = sim_cmd.replace('3k', '28k') print(LTC.netlist[line_no], end='') # 確認 line_no = LTC._get_line_starting_with('.tran') LTC.netlist[line_no] = LTC.netlist[line_no].replace('1m', '200u') print(LTC.netlist[line_no], end='') # 確認 # 編集したnetlistの情報でバッチ処理を実行する run_net_file = fname + fname_tmp + '.net' LTC.run(run_filename=run_net_file) LTC.wait_completion()
V1 Vin+ 0 SINE(0 1.5 28k) AC 1 .tran 0 200u 0 10n
True
import matplotlib.pyplot as plt import numpy as np from PyLTSpice import RawRead fig = plt.figure(figsize=(6, 3)) ax1 = fig.add_subplot(1, 1, 1) LTR = RawRead(fname + fname_tmp + '.raw') x = LTR.get_trace('time').get_time_axis(0) tmp1 = LTR.get_trace('V(vin+)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vin+') tmp1 = LTR.get_trace('V(vout)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vout') ax1.legend(); ax1.grid() ax1.set_xlabel('[ms]'); ax1.set_ylabel('[V]') fig.tight_layout() fig.savefig('PrimaryCircuit2-019_Graph2.png')
ゲインは0.7倍、位相は90度遅れている
300kHz
信号源の周波数設定と、シミュレーションのパラメータを変更する
from PyLTSpice import SimCommander fname = 'PrimaryCircuit2-019' fname_tmp = '_300kHz' LTC = SimCommander(fname + '.asc') line_no = LTC._get_line_starting_with('V1') sim_cmd = LTC.netlist[line_no] LTC.netlist[line_no] = sim_cmd.replace('3k', '300k') print(LTC.netlist[line_no], end='') # 確認 line_no = LTC._get_line_starting_with('.tran') LTC.netlist[line_no] = LTC.netlist[line_no].replace('1m', '100u') LTC.netlist[line_no] = LTC.netlist[line_no].replace('10n', '1n') print(LTC.netlist[line_no], end='') # 確認 # 編集したnetlistの情報でバッチ処理を実行する run_net_file = fname + fname_tmp + '.net' LTC.run(run_filename=run_net_file) LTC.wait_completion()
V1 Vin+ 0 SINE(0 1.5 300k) AC 1 .tran 0 100u 0 1n
True
import matplotlib.pyplot as plt import numpy as np from PyLTSpice import RawRead fig = plt.figure(figsize=(6, 4)) ax1 = fig.add_subplot(2, 1, 1) ax2 = fig.add_subplot(2, 1, 2, sharex=ax1) LTR = RawRead(fname + fname_tmp + '.raw') x = LTR.get_trace('time').get_time_axis(0) tmp1 = LTR.get_trace('V(vin+)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vin+') tmp1 = LTR.get_trace('V(vout)').get_wave(0) ax2.plot(x * 1000, tmp1, label='Vout') ax1.legend(); ax1.grid() ax1.set_xlabel('[ms]'); ax1.set_ylabel('[V]') ax2.legend(); ax2.grid() ax2.set_xlabel('[ms]'); ax2.set_ylabel('[V]') fig.tight_layout() fig.savefig('PrimaryCircuit2-019_Graph3.png')
ゲインは0.01倍、位相は180度遅れている
方形波応答
from PyLTSpice import SimCommander fname = 'PrimaryCircuit2-019' fname_tmp = '_pulse' LTC = SimCommander(fname + '.asc') line_no = LTC._get_line_starting_with('V1') sim_cmd = LTC.netlist[line_no] LTC.netlist[line_no] = sim_cmd.replace('SINE(0 1.5 3k)', 'PULSE(0 1 50u 0 0 50u 100u)') print(LTC.netlist[line_no], end='') # 確認 line_no = LTC._get_line_starting_with('.tran') LTC.netlist[line_no] = LTC.netlist[line_no].replace('1m', '200u') LTC.netlist[line_no] = LTC.netlist[line_no].replace('10n', '0.1n') print(LTC.netlist[line_no], end='') # 確認 # 編集したnetlistの情報でバッチ処理を実行する run_net_file = fname + fname_tmp + '.net' LTC.run(run_filename=run_net_file) LTC.wait_completion()
V1 Vin+ 0 PULSE(0 1 50u 0 0 50u 100u) AC 1 .tran 0 200u 0 0.1n
True
import matplotlib.pyplot as plt import numpy as np from PyLTSpice import RawRead fig = plt.figure(figsize=(6, 3)) ax1 = fig.add_subplot(1, 1, 1) LTR = RawRead(fname + fname_tmp + '.raw') x = LTR.get_trace('time').get_time_axis(0) tmp1 = LTR.get_trace('V(vin+)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vin+') tmp1 = LTR.get_trace('V(vout)').get_wave(0) ax1.plot(x * 1000, tmp1, label='Vout') ax1.legend(); ax1.grid() ax1.set_xlabel('[ms]'); ax1.set_ylabel('[V]') fig.tight_layout() fig.savefig('PrimaryCircuit2-019_Graph4.png')
入力に遅れて応答している
小さなオーバーシュートが発生している
周波数特性
Vin+(V1) に AC 1
の設定がついているので、シミュレーションモードをac
にすれば良い
負荷の抵抗を4,6,8,10Ωに変えて実施する
from PyLTSpice import SimCommander fname = 'PrimaryCircuit2-019' fname_tmp = '_ac' LTC = SimCommander(fname + '.asc') line_no = LTC._get_line_starting_with('.tran') sim_cmd = LTC.netlist[line_no] LTC.netlist[line_no] = sim_cmd.replace('.tran', ';tran') line_no = LTC._get_line_starting_with(';ac') sim_cmd = LTC.netlist[line_no] LTC.netlist[line_no] = sim_cmd.replace(';ac', '.ac') print(LTC.netlist[line_no], end='') # 確認 for param in [4, 6, 8, 10]: line_no = LTC._get_line_starting_with('R1') LTC.netlist[line_no] = 'R1 Vout 0 %d\n' % param print(LTC.netlist[line_no], end='') # 確認 # 編集したnetlistの情報でバッチ処理を実行する run_net_file = fname + fname_tmp + 'R%d' % param + '.net' LTC.run(run_filename=run_net_file) LTC.wait_completion()
.ac oct 40 1k 100k R1 Vout 0 4 R1 Vout 0 6 R1 Vout 0 8 R1 Vout 0 10
from PyLTSpice import RawRead fig = plt.figure(figsize=(6, 4)) ax1 = fig.add_subplot(2, 1, 1) ax2 = fig.add_subplot(2, 1, 2, sharex=ax1) fname = 'PrimaryCircuit2-019' fname_tmp = '_ac' for param in [4, 6, 8, 10]: LTR = RawRead(fname + fname_tmp + 'R%d' % param + '.raw') freq = np.abs(LTR.get_trace('frequency').get_wave(0)) Vout = LTR.get_trace("V(vout)").get_wave(0) ax1.plot(freq, 20*np.log10(np.abs(Vout)), label='%dΩ' % param) ax2.plot(freq, np.angle(Vout) / np.pi * 180) ax1.grid() ax1.set_xlabel("[Hz]"); ax1.set_ylabel("Gain[dB]") ax1.set_xscale('log') ax1.set_ylim(-25, 5) ax2.grid() ax2.set_xlabel("[Hz]"); ax2.set_ylabel("Phase[deg]") ax2.set_xscale('log') ax2.set_ylim(-180, 0) ax1.legend() fig.tight_layout() fig.savefig('PrimaryCircuit2-019_Graph5.png')
負荷抵抗が変わると、周波数特性も変化する
参考文献
この記事は以下の書籍を参考にしましたが、
私の拙い知識で書いておりますので、誤り等ありましたらご指摘ください