Skip to content

Commit

Permalink
Add potentiometer for SPICE #122
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Dec 1, 2023
1 parent 164107a commit 826c862
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
24 changes: 20 additions & 4 deletions qucs/components/potentiometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@

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

potentiometer::potentiometer()
{
Description = QObject::tr ("Potentiometer verilog device");
Simulator = spicecompat::simQucsator;
Simulator = spicecompat::simAll;

Props.append (new Property ("R_pot", "1e4", false,
Props.append (new Property ("R_pot", "10k", true,
QObject::tr ("nominal device resistance")
+" ("+QObject::tr ("Ohm")+")"));
Props.append (new Property ("Rotation", "120", false,
Props.append (new Property ("Rotation", "120", true,
QObject::tr ("shaft/wiper arm rotation")
+" ("+QObject::tr ("degrees")+")"));
Props.append (new Property ("Taper_Coeff", "0", false,
QObject::tr ("resistive law taper coefficient")));
Props.append (new Property ("LEVEL", "1", false,
QObject::tr ("device type selector")+" [1, 2, 3]"));
Props.append (new Property ("Max_Rotation", "240.0", false,
Props.append (new Property ("Max_Rotation", "240.0", true,
QObject::tr ("maximum shaft/wiper rotation")
+" ("+QObject::tr ("degrees")+")"));
Props.append (new Property ("Conformity", "0.2", false,
Expand All @@ -51,6 +52,7 @@ potentiometer::potentiometer()
tx = x1 + 8;
ty = y2 + 4;
Model = "potentiometer";
SpiceModel = "R";
Name = "POT";
}

Expand Down Expand Up @@ -108,3 +110,17 @@ void potentiometer::createSymbol()
x1 = -40; y1 = -20;
x2 = 40; y2 = 15;
}

QString potentiometer::spice_netlist(bool 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;
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;
}
1 change: 1 addition & 0 deletions qucs/components/potentiometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class potentiometer : public Component
static Element* info(QString&, char* &, bool getNewOne=false);
protected:
void createSymbol();
QString spice_netlist(bool isXyce);
};

#endif /* potentiometer_H */
2 changes: 1 addition & 1 deletion qucs/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ void Module::registerModules (void) {
REGISTER_LUMPED_1 (Inductor);
REGISTER_LUMPED_1 (IndQ);
REGISTER_LUMPED_1 (CapQ);
REGISTER_LUMPED_1 (potentiometer);
REGISTER_LUMPED_1 (Mutual);
REGISTER_LUMPED_1 (Mutual2);
REGISTER_LUMPED_1 (MutualX);
Expand Down Expand Up @@ -434,7 +435,6 @@ void Module::registerModules (void) {
// verilog-a devices
REGISTER_VERILOGA_1 (mod_amp);
REGISTER_VERILOGA_1 (log_amp);
REGISTER_VERILOGA_1 (potentiometer);
REGISTER_VERILOGA_1 (MESFET);
REGISTER_VERILOGA_1 (photodiode);
REGISTER_VERILOGA_1 (phototransistor);
Expand Down

0 comments on commit 826c862

Please sign in to comment.