Author Topic: LTspice - problem with definition of parameter  (Read 2867 times)

0 Members and 1 Guest are viewing this topic.

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
LTspice - problem with definition of parameter
« on: March 09, 2018, 11:02:56 am »
Hello.

I am trying to make current dependent inductor in ltspice according my mesurements. How can I use for definiotn of any parameter measured value?

If anyone can help me I would really appreciate it.
Thanks
« Last Edit: March 13, 2018, 09:46:00 am by Roveniki »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #1 on: March 09, 2018, 12:22:10 pm »
LTspice .param statements are evaluated ONCE before the simulation run starts.  They cannot contain any expression that involves dynamic variables (e.g, node voltages, currents, time etc.)

If you need a user-defined expression using dynamic variables you can use a .func statement, either with empty parameters () or with a parameter list if you want per-instance control when you use it.

However it is possible to directly specify a behavural inductor component using a special LTspice syntax in terms of the instantanious flux.  See http://ltwiki.org/index.php5?title=The_Arbitrary_Inductor_model

I've knocked together a three part example for you:
  • based on the LTwiki example, but with the unity dI/dt current source bug-fixed* and the max current and sim time parameterised.
  • current dependent inductor (using I1 from part 1), with 1mA AC exitation.
  • simple fixed inductor but in behavioral syntax, also with 1mA AC excitation.

* The duration of the unity dI/dt ramp in the LTwiki example netlist didn't match the simulation length.
« Last Edit: March 09, 2018, 12:25:47 pm by Ian.M »
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #2 on: March 09, 2018, 01:21:05 pm »
Thank you for your respond. I want to define dependance of indtuctance on current according measurements. After interpolation I get curve: y = 2E-11x2 - 3E-09x + 1E-06 where y is Indtuctance of ferit coil and x is Current trough coil. I do not want to describe saturation or anything concenrnig Imax. I measured current  from  60mA to 200mA what is sufficient for my application. Can you give me any advice how to sort it out?
Thank you again.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #3 on: March 09, 2018, 02:54:41 pm »
Behavioural inductors aren't just for handling saturation.

You saw example 2 which was an inductor dependent on an arbitary current, amd exampe 3: flux=0.33*x which is equivalent to a fixed 330mH inductor.  So all you need to do is multiply your equation for the inductance by x to get the flux:

flux=(2E-11*x*x - 3E-09*x + 1E-06)*x
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #4 on: March 12, 2018, 10:32:15 am »
Dear Ian.M thank you very much!!!
Now I get it, so I can carry on to solve other tasks.
Have a nice day.
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #5 on: March 13, 2018, 12:27:09 pm »
Hi Ian.M,

at first sight it looks like it really works  so I was very happy but now I realize that it does not work properly. I compare it with other fixed inductor 1uH and they are the same even when I use definition of flux=(2E-11*x*x - 3E-09*x + 1E-06)*x  - this expression should vary according to current, but it is always the same. By resistor in front of inductor I change the value of current and no matter the value of inductance it is always 1uH. Can you help me with this problem?

Thank you in advance.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #6 on: March 13, 2018, 05:59:53 pm »
I assure you it does vary, however your coefficients only produce a 0.3% variation in inductance between 0 and 1A.

I've attached a zipped sim and plot with your behavioural inductor and a fixed 1uH inductor in series (with ground in between) that clearly shows the difference with 1KHz excitation and the DC current sweeping between 0 and 5A.
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #7 on: March 14, 2018, 01:37:59 pm »
After reading your message about 0.3% variation I realized that something is wrong with my polynomial because I made measurements for 4 currents and it definately varies more (see attached file) so I recount polynomial and it should be current now. Anyway when I try to make AC analysis it behaves like 1uH inductor (also in attached file) but it should varies around 1.2uH.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #8 on: March 15, 2018, 12:59:28 am »
Don't expect a behavioural inductor to work as you think it should in a .ac analysis.
LTspice does an .op operating point analysis to get the DC conditions then fixes the inductor at whatever value the .op analysis + its flux equation gives:
Quote from: LTspice help
.AC -- Perform an Small Signal AC Analysis Linearized About the DC Operating Point
The small signal(linear) AC portion of LTspice computes the AC complex node voltages as a function of frequency. First, the DC operating point of the circuit is found. Next, linearized small signal models for all of the nonlinear devices in the circuit are found for this operating point. Finally, using independent voltage and current sources as the driving signal, the resultant linearized circuit is solved in the frequency domain over the specified range of frequencies.
Behavioural instances of Sources, Resistors, Capacitors and Inductors only 'do their thing' dynamically in a .tran transient analysis.

Also the PULSE() voltage sources will use their initial value of 0V in the .op analysis so even if there weren't capacitors blocking  DC through the inductors from the voltage source, you still wouldn't see any difference unless you add a true DC bias current through the inductors.

See attached sim and plot.  Edit .param Ibias 10mA to add/remove bias current.
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #9 on: April 04, 2018, 07:38:22 am »
Dear Ian.M sorry for late response, thank you very much, you helped me a lot!  :-+ :-+
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #10 on: April 04, 2018, 08:01:21 am »
You are welcome.

Whoops, I just spotted I missed the {} braces around the value of I2 in the zipped sim from reply#8.   I assume you figured out what was wrong and fixed it, but for future readers, edit the value of I2 to be: {Ibias} before running the sim.
 

Offline RovenikiTopic starter

  • Newbie
  • Posts: 7
  • Country: sk
Re: LTspice - problem with definition of parameter
« Reply #11 on: April 04, 2018, 08:06:42 am »
Yes I figure it out, at least I can sort out something without help :) Now I am working on variable resistor, hope I can solve it soon.

Have a nice day.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: LTspice - problem with definition of parameter
« Reply #12 on: April 04, 2018, 08:36:24 am »
For parameter controlled potentiometers in LTspice, see https://www.eevblog.com/forum/eda/is-there-an-updated-massive-open-source-style-library-for-ltspice/

If you need it to be voltage or current controlled, you'll have to roll your own, probably with a behavioural resistor.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf