Voltage controlled switch and smooth curve


 

Hello there, 
I am working on a non-linear model for a capacity on Ltspice. I am using two voltage controlled switches for that, that turn off (resp. on) at the same time, to change the branch used by the current at some precise voltage. I managed to have a curve of the expected shape. My issue is that once my switches turn off (resp. on) it creates an abrupt change in the behaviour of my system (which is normal) and I would like to smooth it
I believe that the level 2 of voltage controlled switches could help me to make the transition between the two switches smoother. I tried a few things with this level 2 settings but I don't fully get how it works and didn't manage to change anything. 
If some of you have advice / solution, I would be glad to read them. 
Thanks in advance !


 

I think that using switches is not the best approach, and Level 2 works by adding resistances, which would spoil your capacitor model. There is already a recent thread on modelling non-linear capacitance. It is https://groups.io/g/LTspice/files/Temp/GRM035R60J475ME15.zip in the TEMP folder. I suggest you study the messages in this thread.

It usually helps a lot if you let us see more of what you are doing. Upload your .ASC file AND all the other files required to run the simulation, but not .RAW  and .LOG files or pictures,  in a ZIP archive to Files => Temp. Go to the web page: https://groups.io/g/LTspice/topics. Click on Files in the list on the left. Then click on Temp. Then click on New Upload in the blue box at top left. Click on Upload File in the drop-down menu. Then send a message to tell us that you did that.

On 2024-07-09 14:20, lucie.camp26@... wrote:
Hello there, 
I am working on a non-linear model for a capacity on Ltspice. I am using two voltage controlled switches for that, that turn off (resp. on) at the same time, to change the branch used by the current at some precise voltage. I managed to have a curve of the expected shape. My issue is that once my switches turn off (resp. on) it creates an abrupt change in the behaviour of my system (which is normal) and I would like to smooth it
I believe that the level 2 of voltage controlled switches could help me to make the transition between the two switches smoother. I tried a few things with this level 2 settings but I don't fully get how it works and didn't manage to change anything. 
If some of you have advice / solution, I would be glad to read them. 
Thanks in advance !
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.www.avg.com


 

Thank you for your answer, I'll try to understand the models. 
Please find bellow the link of my updated file. 

https://groups.io/g/LTspice/files/Temp/Cap_Derating%20factor%20training%20-%20Copie.zip


 

lucie.camp26,

I can't quite figure out what the circuit is supposed to do.  You wrote that the switches turn ON and OFF "at the same time", but that isn't true.  S2 turns ON when the control voltage V(V1) reaches or exceeds 0.5+0.5 = 1 V, and S1 turns OFF when its control voltage V(V1) reaches -(0.5-0.5) = -0 V or is more positive.  They are not simultaneous.  Anyway, S1 probably never ever switches ON.  It can only switch ON when V(V1) exceeds -1 V, that is, when V(V1) <= -1 V, which it probably never does, given the fact that I1 is a positive current, tending to make V(V1) always positive.  (But I might have misread what's going on.  I don't completely understand what happens.  I need more time, or another cup of coffee.)

Switching an ideal current source is a tricky matter.  If you cut the path, even momentarily, the voltage would go to infinity.  The voltage-controlled switches won't do that because they are never fully "off"; there is always Roff = 100Meg.

Andy


 

I also updated the file you uploaded.  Your .zip file contained a file named "Cap_Derating factor training - Copie", which is of course not a valid filename.  I fixed it.

Andy


 

On 09/07/2024 15:20, lucie.camp26@... wrote:
I am working on a non-linear model for a capacity on Ltspice. I am using two voltage controlled switches for that, that turn off (resp. on) at the same time, to change the branch used by the current at some precise voltage. I managed to have a curve of the expected shape. My issue is that once my switches turn off (resp. on) it creates an abrupt change in the behaviour of my system (which is normal) and I would like to smooth it
I believe that the level 2 of voltage controlled switches could help me to make the transition between the two switches smoother. I tried a few things with this level 2 settings but I don't fully get how it works and didn't manage to change anything. 
If some of you have advice / solution, I would be glad to read them. 
The usual method of creating non-linear capacitors is to use the charge model of the capacitor. This is described in:

Help > LTspice > LTspice® > Circuit Elements > C. Capacitor - last couple of paragraphs.

There are also extensive examples here:

https://groups.io/g/LTspice/files/z_yahoo/Tut/Nonlinear%20Capacitance%20of%20Capacitors

--
Regards,
Tony


 

FYI -

In lucie.camp26's schematic, the capacitor with "Q=4700n-x*5n" gives you a -5nF capacitor, with an extra 4700 nanoCoulombs of steady charge on it.   Yes, it is a negative capacitance, which is probably why the positive charging current charges its voltage in a negative direction.

The capacitance is the derivative of charge Q with respect to its voltage, where 'x' in the Q equation represents the voltage.

Regarding smoothing the switches, be aware that they "switch" more smoothly just by using a negative value for Vh, causing the switch to gradually transition between OFF and ON.  The positive Vh makes  them "snap".  I think what Level=2 does is change the shape of that transition between OFF and ON.  Without Level=2, the transition begins and ends abruptly at Vt-Vh and Vt+Vh, but it is smooth between those points.  With Level=2, the shape of the transition itself is curved without the abrupt corners at Vt-Vh and Vt+Vh.  It may or may not be useful to do that.

FYI, if the two switch models have identical parameter values, it's not necessary to make two of them.  Use the same .MODEL for both.

Andy


 

My goal is to create a capacity model that would take into account the derating factor. 
I started using switches because there is no simple equation that can follow the right trend from 0V to 
approximately 10V. Hence my attempt to work on the model by bits, using switches to transition from one bit to another. 


 

The two switches do not have the same parameters, the resistor values for ON and OFF modes are reversed.


 

On 10/07/2024 10:49, lucie.camp26@... wrote:
I am not finding any folder in the help section ...
Then I guess you looked in the wrong place. I meant the Help that comes with LTspice. Press F1 and the Help will appear. In V17.x, it's a CHM file and opens in Windows Help, for V24, it opens in your default browser. You should read it, even though it's a bit terse - it is the definitive LTspice reference.

The section on capacitors says:
..
There is also a general nonlinear capacitor available. Instead of specifying the capacitance, one writes an expression for the charge.

LTspice will compile this expression and symbolically differentiate it with respect to all the variables, finding the partial derivative's that correspond to capacitances.

Syntax: Cnnn n1 n2 Q=<expression> [ic=<value>] [m=<value>]

There is a special variable, x, that means the voltage across the device. Therefore, a 100pF constant capacitance can be written as

Cnnn n1 n2 Q=100p*x

A capacitance with an abrupt change from 100p to 300p at zero volts can be written as

Cnnn n1 n2 Q=x*if(x<0,100p,300p)

This device is useful for rapidly evaluating the behavior of a new a hypothetical charge model for, e.g., a transistor.


--
Regards,
Tony


 

I'm really sorry I uploaded the wrong file ..... my apologies...

You'll be able to find the right one on the following link :

https://groups.io/g/LTspice/files/Temp/Cap_Derating_factor.zip


 

In my opinion -

It is best to find a C(V) expression that follows the capacitors from 0 to 10 V.  An expression that uses algebra probably is smooth (continuous function values and derivatives), which is essential for it to simulate "nicely".  Anything with discontinuities is somewhat prone to have simulation convergence problems.  I think your attempt to use switches could do that, especially if the switches toggle (if Vh ≥ 0).  That is kind of a basic rule of simulation.  Smooth functions = Good.  Discontinuous functions = Bad.

I wonder if you are trying to do too much at once.

I don't understand what your switches were intended to do - but if they switch between a fixed value (4.7 uF) and a variable value, be aware that you can incorporate the fixed value 4.7 uF into the Q= formula and eliminate the second capacitor and the switches.  But it is hard for me to understand what is going on in your circuits.

Andy


 

lucie,
This is a copy of my message # 154544.
Reiner Bidenbach, an applications engineer with Analog Devices, published an article on this subject.
How to Use LTspice Simulations to Account for the Effect of Voltage Dependence | Analog Devices

The article discusses simulating the DC voltage effect on ceramic capacitors using LTspice.
I would suggest that you download the pdf file and study it.

Hopefully, this will allow you to generate an reasonable equation which accounts for the capacitance change versus applied DC voltage.
Please remember, as Andy I , Tony and others have frequently pointed out, C versus voltage is only one of many variables. 
Mike