qucs_s
qucs_s copied to clipboard
Add potentiometer component
Is a potentiometer in a future release? Since log or alternate taper pots are pretty much gone today a simple linear one would suffice. The ability to alter resistance via a variable would be a plus.
No, I don't planning to add potentiometer device. Qucs-S has no interactive simulation mode so the potentiometer will be not so useful. For Ngspice it's need to emulate potentiometer using the connection of two resistors and define its resistances using the variable. It will be not easy to use this combined device in parameter sweep, because the parameter sweep is implemented using the alter
command which cannot directly sweep variables. But I am planning to add a Tuner feature that can resolve some tasks for potentiometer. There was an unfinished tuner PR for Qucs https://github.com/Qucs/qucs/pull/471 it's possible to backport it into the Qucs-S.
I did some experimenting trying to get a potentiometer to work. Having issues passing multiple "W" values via Parameter Sweep. Not sure how to use .PARAM to do it.
The .PARAM
section has effect only before the simulation. It is not passed to .control .. .endc
section of the netlist, so it will not help you. The problem with potentiometer implementation comes from this fact that Ngspice has no separte parameter sweep analysis type (like .SW
for Xyce) And Qucs-S needs to emulate the parameter sweep using auto-generated Nutmeg script. See https://github.com/imr/ngspice/blob/master/examples/various/param_sweep.cir for example. The alter
command accepts only a single device and doesn't accept variables. It is fundamental limitation of the Ngspice. Probably something will be changed in the future, because Ngspice team is currently working on .SW
simulation type. The similar problem exists with sweep and vector parameters like SIN source #53
So you can sweep only device but not variable. Your schematic will not work and you need only to write a custom nutmeg script (Simulation->Nutmeg script device). Something like this. There is no other way to get the variable sweep with Ngspice.
let start_w = 0.1
let stop_w = 0.9
let delta_w = 0.1
let w_act = start_w
let rpot = 1k
* loop
while w_act le stop_w
let r1_act = (1-w)*rpot
let r2_act = w*rpot
alter r1 r1_act
alter r2 r2_act
tran 0.1m 5m
write dc-sweep.out v(out)
set appendwrite
let w_act = w_act + delta_w
end
There was a typo in the script. This schematic works as expected.
Hate to beat a dead horse....
Something is either either wrong with my Nutmeg script or I am doing something wrong. I cannot reproduce your plot even though the console output shows "Vout" is correct, 0.1, 0.2...0.9. Netlist doesn't work running under the DuSpice GUI either
- Is file dc-sweep.txt a temporary file? I can find Potentiometer_Nutmeg_custom.txt but not dc-sweep.txt.
- Why is w_act saved twice and r1_act not saved at all in the netlist? -> Potentiometer_Nutmeg_custom.txt V(Vout) VPr1#branch w_act r2_act w_act
The node name Vout
doesn't match the node name in the script out
. You need either to change node name on schematic or in script. This line should be:
write dc-sweep.txt v(vout)
Why is w_act saved twice and r1_act not saved at all in the netlist?
Automatic variables recognition may fail sometimes. Just append the missing variables to the semicolon separated list manually.
Assume this issue has been resolved. Closing ticket.
It makes sense to add potentiometer after implementation of the tuner feature and adding alterparam
support. Reopening this. The potentiometer device is planned for the next release.
I know this isn't what is needed, but I recreated the Verilog Potentiometer component used in Qucs 0.0.19. The symbol files may be useful for a ngspice compatible potentiometer.
Qucs doesn't allow using the same component name in a project as a "native" component. I had to rename potentiometer.va to variable_resistor.va.
The related work should be done in C++ level. It's need to provide a SPICE entry for potentiometer like it was done for INDQ and CAPQ. The symbol for this device already exists, but is hidden as SPICE-incompatible.
I have added SPICE entry for the potentiometer. This device will be available since the next release.
Yesssss THANK YOU SO MUCH kind sir!!! Any estimate when will the next update be available? ...and/or can i clone/checkout the source code with potentionmeter from git right now?
I am planning to make an update in January or February. Yes, you may compile the current
branch for git. It contains the new device.
Hello, i just compiled current branch, it does indeed have the potentiometer device but it's not possible to wire it, i think because the pins don't "align" to the grid. I was able to get the wires to cross once and it stayed connected, but this is unusable. How can i fix this?
@BURN-MICROSUCK Use right click on the device and then "Align to grid" from the context menu. It is a known issue. See #92
Thanks again. Another issue i'm facing is that capacitors don't filter like they're supposed to. Doing a quick test circuit that uses an op-amp to mix 3 sinewaves at different frequencies (100Hz, 1KHz, 10KHz) the shunt cap (output to ground) should filter out nearly all of the 10KHz signal, see screenshot:
https://imgur.com/a/uTVWF5D
I'm presuming the same would go for inductors in series and parallel, making it impossible to simulate RC / RCL circuits.
I'm presuming the same would go for inductors in series and parallel, making it impossible to simulate RC / RCL circuits
This simulation is correct. The ideal opamp has zero output resistance. The time constant of the output stage RC=0. The output signal doesn't depend on the capacitance. Try to replace the opamp with the model from the library. But it also may have very low output resistance. For example for LM358 is set to RO=50 Ohm in the model. And RC gives 2.35us, which gives cutoff frequency 425kHz.
@BURN-MICROSUCK
In real life you would never place a large capacitor across the output of a "standard" OpAmp. It can cause instability. The circuit must be designed to drive capacitive loads.
https://www.analog.com/en/analog-dialogue/articles/ask-the-applications-engineer-25.html
@BURN-MICROSUCK I have just added a fix for device rotation. See https://github.com/ra3xdh/qucs_s/issues/92#issuecomment-1852227360 You may compile and test the current
branch.
I'm not getting the potentiometer working. I used the standard method from Qucs.
I'm not getting the potentiometer working. I used the standard method from Qucs
Define the variable with .PARAM and everything works as expected. Also fix the R4 value. The automatic converter assumes that the value without unit (Ohm) uses SPICE notation and parses it as 1mOhm.
I converted a Qucs tone control project in December using the new potentiometer model. I don't remember uploading it.