Warning, file /sdk/ktechlab/src/electronics/simulation/bjt.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (C) 2003-2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef BJT_H 0012 #define BJT_H 0013 0014 #include "nonlinear.h" 0015 0016 class BJTState 0017 { 0018 public: 0019 BJTState(); 0020 void reset(); 0021 0022 BJTState operator-(const BJTState &s) const; 0023 0024 double A[3][3]; 0025 double I[3]; 0026 }; 0027 0028 class BJTSettings 0029 { 0030 public: 0031 BJTSettings(); 0032 0033 double I_S; ///< saturation current 0034 double N_F; ///< forward emission coefficient 0035 double N_R; ///< reverse emission coefficient 0036 double B_F; ///< forward beta 0037 double B_R; ///< reverse beta 0038 }; 0039 0040 /** 0041 @author David Saxton 0042 */ 0043 class BJT : public NonLinear 0044 { 0045 public: 0046 BJT(bool isNPN); 0047 ~BJT() override; 0048 0049 Type type() const override 0050 { 0051 return Element_BJT; 0052 } 0053 void update_dc() override; 0054 void add_initial_dc() override; 0055 BJTSettings settings() const 0056 { 0057 return m_bjtSettings; 0058 } 0059 void setBJTSettings(const BJTSettings &settings); 0060 0061 protected: 0062 void updateCurrents() override; 0063 0064 /** 0065 * Calculates the new BJTState from the voltages on the nodes. 0066 */ 0067 void calc_eq(); 0068 void calcIg(double V_BE, double V_BC, double *I_BE, double *I_BC, double *I_T, double *g_BE, double *g_BC, double *g_IF, double *g_IR) const; 0069 void updateLim(); 0070 0071 BJTState m_os; 0072 BJTState m_ns; 0073 int m_pol; 0074 double V_BE_prev, V_BC_prev; 0075 double V_BE_lim, V_BC_lim; 0076 BJTSettings m_bjtSettings; 0077 }; 0078 0079 #endif