Ejemplo n.º 1
0
 def plot_ac_amplifier(self, dir, longmsg):
     ret = 0
     pp = plotter()
     
     plots = spice_read.auto_read(
             os.path.join(dir, "ac_amplifier.data")).get_plots()
     x = plots[0].get_scalevector().get_data()
     vin = plots[0].get_datavectors()[0].get_data()
     vout = plots[0].get_datavectors()[1].get_data()
     
     pp.multiplot(2, 1)
     pp.subplot(2,1,1)
     pp.loglog(x, numpy.abs(vout / vin), label="magnitude v(out)")
     pp.xlabel("Frequency [Hz]")
     pp.ylabel("U [V]")
     pp.grid()
     pp.subplot(2,1,2)
     pp.semilogx(x, 180. / numpy.pi * numpy.angle(vout), label="theta v(out)")
     pp.xlabel("Frequency [Hz]")
     pp.ylabel("theta (degrees)")
     pp.grid()
     pp.legend(loc="best")
     pp.savefig(os.path.join(dir, "ac_amplifier.png"), dpi=80)
     pp.close()
     return ret
Ejemplo n.º 2
0
    def plot_saturation_voltages(self, dir, longmsg):
        pp = plotter()
        plots = spice_read.auto_read(
                os.path.join(dir, "saturation_voltages.data")).get_plots()

        for n, pl in enumerate(plots):
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Ic = -pl.get_datavector(0).get_data()
            Vbe = pl.get_datavector(1).get_data()
            Vce = pl.get_datavector(2).get_data()
            ## only plot the values where Vce sat is smaller than a limit
            firstind = numpy.where(self.icc_sign * Vce < self.VCEsat_plot_limit)[0][0]
            Ic_plot = Ic
            pp.loglog(Ic[firstind:] * 1000, self.icc_sign * Vce[firstind:]*1000, label=t)
        pp.xlabel("Ic [mA]")
        pp.ylabel("VCE sat [mV]")
        pp.grid()
        pp.legend(loc='best')
        pp.savefig(os.path.join(dir, "vce_saturation_voltage.png"),dpi=80)
        pp.close()

        for n, pl in enumerate(plots):
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Ic = -pl.get_datavector(0).get_data()
            Vbe = pl.get_datavector(1).get_data()
            Vce = pl.get_datavector(2).get_data()
            pp.semilogx(Ic * 1000, self.icc_sign * Vbe * 1000, label = t)
        pp.xlabel("Ic [mA]")
        pp.ylabel("V BE sat [mV]")
        pp.grid()
        pp.legend(loc='best')
        pp.savefig(os.path.join(dir, "vbe_saturation_voltage.png"),dpi=80)
        pp.close()
        return 0
Ejemplo n.º 3
0
    def plot_dc_current_gain(self, dir, longmsg):
        pp = plotter()
        plots = spice_read.auto_read(
                os.path.join(dir, "dc_current_gain.data")).get_plots()
        for n, pl in enumerate(plots):
            #TODO: DRY.  Move this table as far up the object hierarchy as 
            #possible
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Ib = pl.get_scalevector().get_data()
            Ic = -pl.get_datavector(0).get_data()
            hfe = -Ic / Ib
            pp.semilogx(Ic * 1000, hfe, label=t)

        pp.xlabel("Ic [mA]")
        pp.ylabel("hfe")
        pp.grid()
        pp.legend(loc="best")
        pp.savefig(os.path.join(dir, "dc_current_gain.png"),dpi=80)
        pp.close()

        for n, pl in enumerate(plots):
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Ic = -pl.get_datavector(0).get_data()
            Vbe = pl.get_datavector(1).get_data()
            pp.semilogx(Ic * 1000, self.icc_sign * Vbe * 1000, label = t)
        pp.xlabel("Ic [mA]")
        pp.ylabel("V BE [mV]")
        pp.grid()
        pp.legend(loc='best')
        pp.savefig(os.path.join(dir, "base_emitter_voltage.png"),dpi=80)
        pp.close()
        return 0
Ejemplo n.º 4
0
 def plot_transient(self, dir, longmsg):
     ret = 0
     pp = plotter()
     plots = spice_read.auto_read(
             os.path.join(dir, 'switching.data')).get_plots()
     x = plots[0].get_scalevector().get_data()
     vin = plots[0].get_datavectors()[0].get_data()
     vout = plots[0].get_datavectors()[1].get_data()
     if not self.trans_voltage_ok(vin, vout, longmsg):
         ret = 1
     pp.plot(x, vin, label="v(in)")
     pp.plot(x, vout, label="v(out)")
     pp.xlabel("Uin [V]")
     pp.ylabel("U [V]")
     pp.grid()
     pp.legend(loc="best")
     pp.savefig(os.path.join(dir, "dc_amplifier.png"), dpi=80)
     pp.close()
     return ret
Ejemplo n.º 5
0
 def plot_reverse_voltage(self, dir, longmsg):
     pp = plotter()
     labels = ["0C", "25C", "50C", "75C", "100C"]
     ret = 0
     plots = spice_read.auto_read(
             os.path.join(dir, "reverse_voltage.data")).get_plots()
     for n,pl in enumerate(plots):
         Ir = pl.get_scalevector().get_data()
         Ur = pl.get_datavectors()[0].get_data()
         if not self.reverse_voltage_ok(Ir, Ur, longmsg):
             ret = 2
         if not numpy.any(numpy.isnan(Ir)) and not numpy.any(numpy.isnan(Ur)):
             pp.semilogy(-Ur, Ir * 1000.0, label = labels[n])
     pp.ylabel("Ir [mA]")
     pp.xlabel("Ur [V]")
     pp.grid()
     pp.legend(loc="best")
     pp.savefig(os.path.join(dir, "dc_reverse_voltage.png"),dpi=80)
     pp.close()
     return ret
Ejemplo n.º 6
0
 def plot_forward_voltage(self, dir, longmsg):
     pp = plotter()
     labels = ["0C", "25C", "50C", "75C", "100C"]
     ret = 0
     plots = spice_read.auto_read(
             os.path.join(dir, "forward_voltage.data")).get_plots()
     for n,pl in enumerate(plots):
         If = -pl.get_scalevector().get_data()
         Uf = pl.get_datavectors()[0].get_data()
         if not self.forward_voltage_ok(If, Uf, longmsg):
             ret = 1
         if not numpy.any(numpy.isnan(If)) and not numpy.any(numpy.isnan(Uf)):
             pp.semilogy(Uf, If*1000.0,label = labels[n])
     pp.ylabel("If [mA]")
     pp.xlabel("Uf [V]")
     pp.grid()
     pp.legend(loc="best")
     pp.savefig(os.path.join(dir, "dc_forward_voltage.png"),dpi=80)
     pp.close()
     return ret
Ejemplo n.º 7
0
    def plot_dc_current(self, dir, longmsg):
        ret = 0
        pp = plotter()
        plots = spice_read.auto_read(os.path.join(dir, "dc_current.data")
                ).get_plots()

        for n, pl in enumerate(plots):
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Vbe  = pl.get_scalevector().get_data()
            Ib = -pl.get_datavector(0).get_data()
            if not self.base_current_ok(Vbe, Ib, longmsg):
                ret = 1
            pp.plot(Vbe, Ib * 1000, label=t)

        pp.xlabel("Vin [V]")
        pp.ylabel("IB [mA]")
        pp.grid()
        pp.legend(loc="best")
        pp.savefig(os.path.join(dir, "dc_IB.png"), dpi=80)
        pp.close()

        for n, pl in enumerate(plots):
            t = {0: '0 C', 1: '25 C', 2: '50 C', 3: '75 C', 4: '100 C'}[n]
            Vbe  = pl.get_scalevector().get_data()
            Ib = pl.get_datavector(0).get_data()
            Ic = -pl.get_datavector(1).get_data()
            if not self.collector_current_ok(Vbe, Ic, longmsg):
                ret = 1
            pp.plot(Vbe, Ic * 1000,label=t)
        pp.xlabel("Vin [V]")
        pp.ylabel("IC [mA]")
        pp.grid()
        pp.legend(loc='best')
        pp.savefig(os.path.join(dir, "dc_IC.png"), dpi=80)
        pp.close()
        return ret