Skip to content

Commit

Permalink
Make BiasT available for SPICE #374
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Dec 1, 2023
1 parent 826c862 commit b5921f2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
40 changes: 28 additions & 12 deletions qucs/components/biast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,30 @@

#include "biast.h"
#include "extsimkernels/spicecompat.h"
#include "node.h"


BiasT::BiasT()
{
Description = QObject::tr("bias t");
Simulator = spicecompat::simQucsator;
Simulator = spicecompat::simAll;

Arcs.append(new qucs::Arc( -3, 2, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1)));
Arcs.append(new qucs::Arc( -3, 8, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1)));
Arcs.append(new qucs::Arc( -3, 14, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line(-22,-10, 22,-10,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line(-22,-10,-22, 22,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line(-22, 22, 22, 22,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line( 22,-10, 22, 22,QPen(Qt::darkBlue,1)));
Arcs.append(new qucs::Arc( -3, 2, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2)));
Arcs.append(new qucs::Arc( -3, 8, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2)));
Arcs.append(new qucs::Arc( -3, 14, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line(-22,-10, 22,-10,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line(-22,-10,-22, 22,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line(-22, 22, 22, 22,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( 22,-10, 22, 22,QPen(Qt::darkBlue,2)));

Lines.append(new qucs::Line(-13, -6,-13, 7,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( -9, -6, -9, 7,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( -9, 0, 22, 0,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line(-22, 0,-13, 0,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line( -9, 0, 22, 0,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line(-22, 0,-13, 0,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line(-30, 0,-22, 0,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( 22, 0, 30, 0,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( 0, 0, 0, 2,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line( 0, 20, 0, 22,QPen(Qt::darkBlue,1)));
Lines.append(new qucs::Line( 0, 0, 0, 2,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( 0, 20, 0, 22,QPen(Qt::darkBlue,2)));
Lines.append(new qucs::Line( 0, 22, 0, 30,QPen(Qt::darkBlue,2)));

Ports.append(new Port(-30, 0));
Expand All @@ -53,6 +54,7 @@ BiasT::BiasT()
ty = y2+4;
Model = "BiasT";
Name = "X";
SpiceModel="L";

Props.append(new Property("L", "1 uH", false,
QObject::tr("for transient simulation: inductance in Henry")));
Expand All @@ -77,3 +79,17 @@ Element* BiasT::info(QString& Name, char* &BitmapFile, bool getNewOne)
if(getNewOne) return new BiasT();
return 0;
}

QString BiasT::spice_netlist(bool isXyce)
{
Q_UNUSED(isXyce);
QString s;
QString L = spicecompat::normalize_value(getProperty("L")->Value);
QString C = spicecompat::normalize_value(getProperty("C")->Value);
QString pin1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name);
QString pin2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name);
QString pin3 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name);
s += QString("C_%1 %2 %3 %4\n").arg(Name).arg(pin1).arg(pin2).arg(C);
s += QString("L_%1 %2 %3 %4\n").arg(Name).arg(pin2).arg(pin3).arg(L);
return s;
}
2 changes: 2 additions & 0 deletions qucs/components/biast.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class BiasT : public Component {
~BiasT();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
protected:
QString spice_netlist(bool isXyce);
};

#endif
7 changes: 4 additions & 3 deletions qucs/components/potentiometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ void potentiometer::createSymbol()

QString potentiometer::spice_netlist(bool isXyce)
{
Q_UNUSED(isXyce);
QString s;
QString R = getProperty("R_pot")->Value;
QString rot = getProperty("Rotation")->Value;
QString max_rot = getProperty("Max_Rotation")->Value;
QString pin1 = Ports.at(0)->Connection->Name;
QString pin2 = Ports.at(1)->Connection->Name;
QString pin3 = Ports.at(2)->Connection->Name;
QString pin1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name);
QString pin2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name);
QString pin3 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name);
s += QString("R%1_1 %2 %3 R='(%4)*(%5)/(%6)'\n").arg(Name).arg(pin1).arg(pin2).arg(R).arg(rot).arg(max_rot);
s += QString("R%1_2 %2 %3 R='(%4)*(1.0-(%5)/(%6))'\n").arg(Name).arg(pin2).arg(pin3).arg(R).arg(rot).arg(max_rot);
return s;
Expand Down

0 comments on commit b5921f2

Please sign in to comment.