Maker Pro
Maker Pro

Simulating a variable resistance input with LTSpice?

J

Joerg

Jan 1, 1970
0
Hello Folks,

Got stuck when trying to simulate an NTC. This temperature-variant
resistor will be the only variable input so ".STEP" and stuff do not cut
it because that only overlays multiple curve in an AC or DC simulation.
I want just one curve: Output of my circuit versus varying NTC resistor
value.

Tried to make a voltage dependent resistor this way:

http://www.electro-tech-online.com/...9571000-sine-variable-resistor-ltspice-d2.png

It works but is incredibly slow. Any better ideas?
 
J

Joerg

Jan 1, 1970
0
John said:
Do you need a voltage to resistance converter? That's easy if you have
a multiplier. Interestingly, LT Spice doesn't provide a multiplier
component.

Well, the one in the link works now. Turns out one shall not get too
close to very low values where LTSpice has a hard time. At least it
heats my office :)

When do we get some global warming out here?

This function stuff is pretty cool. For example, it can be used to get
pressure sensor readings from a file into something that electrically
resembles the sensor.
 
F

Fred Bartoli

Jan 1, 1970
0
Joerg a écrit :
Hello Folks,

Got stuck when trying to simulate an NTC. This temperature-variant
resistor will be the only variable input so ".STEP" and stuff do not cut
it because that only overlays multiple curve in an AC or DC simulation.
I want just one curve: Output of my circuit versus varying NTC resistor
value.

Tried to make a voltage dependent resistor this way:

http://www.electro-tech-online.com/...9571000-sine-variable-resistor-ltspice-d2.png


It works but is incredibly slow. Any better ideas?

The way I'd do it is with a B current source (OK, sink).
Basically you measure voltage across the NL resistor nodes (a,b) and
sink a current between these nodes which is your NL function of V(a,b).

That also better handles the R=0 pathological case, because you're less
tempted to allow infinite current flow :)
 
J

Joerg

Jan 1, 1970
0
Jim said:
Get this file...

VVR.zip VOLTAGE VARIABLE RESISTOR SYMBOL/SUBCIRCUIT

On the Subcircuits and Symbols Page of my website.

It's just a text file... all you care about is the "Template" line.

Thanks, will check it out. Got the circuit pretty much done by now but
some day if I get more of those little temp sense projects I want to
pour the Steinhart-Hart equation in there. Then I'd have a true
temperature-variable resistor. LTSpice has the nice feature of being
able to read in a WAV table.
 
J

Joerg

Jan 1, 1970
0
Fred said:
Joerg a écrit :

The way I'd do it is with a B current source (OK, sink).
Basically you measure voltage across the NL resistor nodes (a,b) and
sink a current between these nodes which is your NL function of V(a,b).

That's a good idea. Right now I map a variable voltage source into a
resistor. Works, but leaves one weirdness: kiloohms on the horizontal
scale are labeled kilovolts.

That also better handles the R=0 pathological case, because you're less
tempted to allow infinite current flow :)

I always wondered if there'd be a way to inlude a phssst ... *POOF*
function in LTSpice, with audio effects, sirens and all. That would be
nice to have during a design review :)
 
F

Fred Bartoli

Jan 1, 1970
0
Joerg a écrit :
That's a good idea. Right now I map a variable voltage source into a
resistor. Works, but leaves one weirdness: kiloohms on the horizontal
scale are labeled kilovolts.



I always wondered if there'd be a way to inlude a phssst ... *POOF*
function in LTSpice, with audio effects, sirens and all. That would be
nice to have during a design review :)

Some XSPICE simulators allow you to monitor values during simulation and
do almost whatever you want. The one I use handles wave files, so maybe :)
 
H

Helmut Sennewald

Jan 1, 1970
0
John Larkin said:
Do you need a voltage to resistance converter? That's easy if you have
a multiplier. Interestingly, LT Spice doesn't provide a multiplier
component.

John


Hello John,

LTspice has B-deviecs. They can do a lot of math.
*
** power
/ divide
sin
tanh
exp

See the help pages for B-devices.
The B-device is the best device to implement a NTC-resistor
with it's exponential resistance versus temperature function.

The LTspice Yahoo group provides examples.

Best regards,
Helmut
 
J

Joerg

Jan 1, 1970
0
Jim said:
Hello Folks,

Got stuck when trying to simulate an NTC. This temperature-variant
resistor will be the only variable input so ".STEP" and stuff do not cut
it because that only overlays multiple curve in an AC or DC simulation.
I want just one curve: Output of my circuit versus varying NTC resistor
value.

Tried to make a voltage dependent resistor this way:

http://www.electro-tech-online.com/...9571000-sine-variable-resistor-ltspice-d2.png

It works but is incredibly slow. Any better ideas?

Sorry, Joerg, I misread your need. It's actually quite simple, IF you
can describe the TC with coefficients of T and T^2... make your own
resistor model:

Resistor

General form

R<name> <(+) node> <(-) node> [model name] <value>
+ [TC = <TC1> [,<TC2>]]

TC1, and TC2 are the linear and squared coefficients, respectively.

See the LTspice manual for clarity (the above was pasted from
PSPCREF.pdf)

In the current case it's a whole lot uglier than that, see under
"Inverse of the equation":

http://en.wikipedia.org/wiki/Steinhart–Hart_equation

T (Temperature) must be scooted. I think LTSpice will have a cow when I
try this.
 
J

Joerg

Jan 1, 1970
0
Jim said:
Jim said:
Hello Folks,

Got stuck when trying to simulate an NTC. This temperature-variant
resistor will be the only variable input so ".STEP" and stuff do not cut
it because that only overlays multiple curve in an AC or DC simulation.
I want just one curve: Output of my circuit versus varying NTC resistor
value.

Tried to make a voltage dependent resistor this way:

http://www.electro-tech-online.com/...9571000-sine-variable-resistor-ltspice-d2.png

It works but is incredibly slow. Any better ideas?
Sorry, Joerg, I misread your need. It's actually quite simple, IF you
can describe the TC with coefficients of T and T^2... make your own
resistor model:

Resistor

General form

R<name> <(+) node> <(-) node> [model name] <value>
+ [TC = <TC1> [,<TC2>]]

TC1, and TC2 are the linear and squared coefficients, respectively.

See the LTspice manual for clarity (the above was pasted from
PSPCREF.pdf)
In the current case it's a whole lot uglier than that, see under
"Inverse of the equation":

http://en.wikipedia.org/wiki/Steinhart–Hart_equation

T (Temperature) must be scooted. I think LTSpice will have a cow when I
try this.

Then use a resistance vs temperature table... trivial in PSpice,
probably so in LTspice.

Besides, that smells like unnecessary obfuscation :)

Depends on the client, how much precision they want, how much MIPS is
there, how much RAM is there.

What kind of NTC?

Just the regular kind, silicon-based resistor.

They're usually spec's as R = Ro*e^(beta*(1/T-1/To))

In industry it's usually the 2-term or the 3-term Steinhart-Hart equation.
 
J

Joerg

Jan 1, 1970
0
John said:
Sure, but a canned multiplier component would be handy, without a
bunch of typing. As would an ideal diode. At least they have ideal
opamps.

There are modulators though, regular and I/Q, under special functions.
 
J

Joerg

Jan 1, 1970
0
John said:
Yeah, I saw those. But it would be handy for the occasional user (like
me) to have some basic math functions all boxed up; mul, log, antilog,
clippers, deadband come to mind. Adds and subs are easy... just stack
VCVS's.

They do have a programmable transzorb, which looks to me like a
programmable clipper/deadband of sorts.

I Spice a circuit maybe once a month, if that, so it's a minor
nuisance to prowl through the sometimes-helpful Help to re-learn the
syntax for stuff like this.

I find myself SPICE-ing many hours a week by now. With some of the more
unorthodox circuits there is no other way. Like PWM chips used flat-out
as solenoid drivers and so on.
 
J

Joerg

Jan 1, 1970
0
Jim said:
Thompson's Fundamental Rule #1, Stay away from PhD's, use this
instead....

http://www.efunda.com/designstandards/sensors/thermistors/thermistors_theory.cfm

That ain't the normal thermistor curve. There are some switching types
where there's reversal but those are typically used sans controller, as
triggers, before something goes kablouie.

Do you really have one bad enough to need the high order corrections?

The client asked that they'd like to see at least 12 bits so I figure
they have a reason for that.
 
J

Joerg

Jan 1, 1970
0
Jim said:
In the late '60's I had customers ask me for 16-bit audio for the
sound system of an L1011... asking doesn't make them have a legitimate
reason :)

That was one fine aircraft. The best flight on one was with Air
Caledonian from London to Shannon. With a grand total of about 20
passengers in there ...

Projects are sorta piling up here, this afternoon a new one in the
aerospace field will be discussed. Why is it that you chip guys complain
about a dry market inside the US and us hardware guys are living under a
chunk of domestic projects?
 
J

Joerg

Jan 1, 1970
0
Jim said:
[...]

Projects are sorta piling up here, this afternoon a new one in the
aerospace field will be discussed. Why is it that you chip guys complain
about a dry market inside the US and us hardware guys are living under a
chunk of domestic projects?

I don't know. I'm finally starting to see inquiries from within the
US, but they're coming via my SE Asia connections. Of course,
manufacturing is to be done in mainland China :)

For my consumer market designs that's sometimes also the case. But
aerospace and similar high-end products like that are made right here in
our country.
 
Q

qrk

Jan 1, 1970
0
Hello Folks,

Got stuck when trying to simulate an NTC. This temperature-variant
resistor will be the only variable input so ".STEP" and stuff do not cut
it because that only overlays multiple curve in an AC or DC simulation.
I want just one curve: Output of my circuit versus varying NTC resistor
value.

Tried to make a voltage dependent resistor this way:

http://www.electro-tech-online.com/...9571000-sine-variable-resistor-ltspice-d2.png

It works but is incredibly slow. Any better ideas?

Here's a couple NTC subcircuits I made up for PSpice. LTspice is
compatible with PSpice syntax, so these should work. These respond to
the temperature parameter in Spice. Easiest to use the Beta equation
approximation, but Steinhart-Hart equation is a bit more accurate.

**************************************************
* NTC resistor using the Beta equation: *
* R = Ro * EXP(B*(1/T - 1/298.15)) *
* Requires resistor value at 25 deg C and Beta *
* which can be set in this subcircuit or passed *
* thru the X instantiation. e.g. *
* X1 1 0 THERMISTORntcB PARAMS: Ro=100k B=4300 *
* Schematics component: RntcB *
* By: Mark 26 March 2003 *
**************************************************
* +------------------- NTC resistor terminals
* |
* | +-------- Resistance at 25 deg C
* | | +- Beta value
..SUBCKT THERMISTORntcB 1 2 PARAMS: Ro=10k B=4300
ETHERM 1 3 VALUE={ I(VSENSE)*Ro*EXP(B*(1/(TEMP+273.15)-1/298.15)) }
VSENSE 3 2 DC 0
..ENDS THERMISTORntcB

*********************************************************
* NTC resistor using the Steinhart-Hart equation: *
* 1/T = A + B*ln(R) + C*ln(R)**3 (ugly solution for R) *
* Requires equation coefficients which can be *
* set in this subcircuit or passed thru the *
* X instantiation. e.g. *
* X1 1 0 THERMISTORntcS PARAMS: A=8.215E-4 B=2.111E-4 C=6.716E-8 *
* See Thermistor_Calculator.mcd for coefficient gen *
* Schematics component: RntcS *
* By: Mark 26 March 2003 *
*********************************************************
* +-------------------NTC resistor terminals
* | +------+------+- equation coeffs
coefficients
..SUBCKT THERMISTORntcS 1 2 PARAMS: A=8E-4 B=2E-4 C=7E-8
.PARAM D={ ((1/(TEMP+273.15))-A)/(2*C) }
.PARAM E={ (B/(3*C))**3 }
.PARAM F={ SQRT(D**2+E) }
.PARAM G={ EXP(PWRS(D-F,1/3)+PWRS(D+F,1/3)) }
ETHERM 1 3 VALUE={ I(VSENSE)*G }
VSENSE 3 2 DC 0
..ENDS THERMISTORntcS



Regards,
Mark
 
Q

qrk

Jan 1, 1970
0
Hi Mark, That's the same _standard_ equation I posted, but Joerg
seems to think he has to use Steinhart-Hart... he's fond of generating
3-place simulation "accuracy" from a 2-place data sheet ;-)

...Jim Thompson

If he wants to use Steinhart-Hart equation, I probably have a solver
for the coefficients using Mathcad somewhere. I think I pulled that
off an app note. The beta and S-H equations are pretty close to
another if I recall correctly. That's why I have two different PSpice
components - to please the inner "place".

Coefficients calculation given in this note:
http://www.cornerstonesensors.com/reports/AboutEquation.pdf

Excel solver:
http://www.ilxlightwave.com/appnotes/AN 4 REV02 Thermistor Calibration and Steinhart Hart.pdf
 
J

Joerg

Jan 1, 1970
0
qrk said:
If he wants to use Steinhart-Hart equation, I probably have a solver
for the coefficients using Mathcad somewhere. I think I pulled that
off an app note. The beta and S-H equations are pretty close to
another if I recall correctly. That's why I have two different PSpice
components - to please the inner "place".

If I need it again I'll probably pour it into one large WAV file and
feed that into SPICE. I know that sounds like cheating but then the PC
doesn't have to crunch so much on every run. One value for every 0.5C or
so should suffice.


Thanks, for all the info, Mark. I'll take a look, but this small circuit
had to be done quickly and is now finished.
 
H

Helmut Sennewald

Jan 1, 1970
0
Joerg said:
If I need it again I'll probably pour it into one large WAV file and feed
that into SPICE. I know that sounds like cheating but then the PC doesn't
have to crunch so much on every run. One value for every 0.5C or so should
suffice.



Thanks, for all the info, Mark. I'll take a look, but this small circuit
had to be done quickly and is now finished.


Hello Joerg,

I have sent you an email with an example using the models from Mark..
It's for LTspice of course.

Best regards,
Helmut
 
J

Joerg

Jan 1, 1970
0
Helmut said:
Hello Joerg,

I have sent you an email with an example using the models from Mark..
It's for LTspice of course.

Thanks, Helmut, got it and will try it out this weekend. It was a little
off when I sent the stuff to the client. The method with the formula in
the resistor (controlled via voltage source) that I used yesterday did
the trick but it does leave one weirdness: The x-axis of the plot is now
labeled in kilovolts instead of kiloohms :)
 
H

Helmut Sennewald

Jan 1, 1970
0
Joerg said:
Thanks, Helmut, got it and will try it out this weekend. It was a little
off when I sent the stuff to the client. The method with the formula in
the resistor (controlled via voltage source) that I used yesterday did the
trick but it does leave one weirdness: The x-axis of the plot is now
labeled in kilovolts instead of kiloohms :)

Hello Joerg,

I assumed you want simulate resistance versus temperature.
Do you need it the other way? Temperature(resistance)?

Best regards,
Helmut
 
Top