Go Back   Home > Forums > >

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Installing and using LTspice IV (now including LTXVII). From beginner to advanced.
Installing and using LTspice IV (now including LTXVII). From beginner to advanced.
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools
Old 17th September 2021, 07:55 AM   #3071
edbarx is offline edbarx  Europe
diyAudio Member
 
edbarx's Avatar
 
Join Date: May 2018
Location: Maltese Archipelago
The constant current source is not properly set up to mimic the action of a BJT as the current cannot reverse direction. I tried several nested if statement but they did not work as planned. It seems there is a programmatic error (bug) in LTSpice. I tried several forms of nesting without success.

The statement goes like this:
Code:
if (T, A, if(U, B, C))
Explanation:
If T is true, execute A, if T is untrue execute the last if statement. This is executed by first checking U for truth, if true B is executed, if false C is executed.
__________________
Any fool can make things bigger, more complex, and more violent. It takes a touch of a genius, and a lot of courage, to move in the opposite direction. [Albert Einstein]
  Reply With Quote
Old 18th September 2021, 04:52 PM   #3072
edbarx is offline edbarx  Europe
diyAudio Member
 
edbarx's Avatar
 
Join Date: May 2018
Location: Maltese Archipelago
I would like to draw the attention of anyone interested in nested if statements that all my attempts failed on LTSpice. My advice is not to waste time, especially, if you are a student.

An ideal BJT may be constructed from two resistors and a current source. A resistor is used for the emitter-base junction and a current source with a parallel resistor is used to simulate transistor action. Obviously, the current source and its parallel resistor have to be programmed to behave like a transistor.

The programming is this:
Code:
Value for R2:
R=if(I(R1)*100*10000<=12, 1G, 1n)

Value parameter for B1:
I=if(I(R1)>=0, 100*I(R1), 0)
I am attaching a screenshot.
Attached Images
File Type: png 2021-09-18-190343_1366x717_scrot.png (63.4 KB, 113 views)
__________________
Any fool can make things bigger, more complex, and more violent. It takes a touch of a genius, and a lot of courage, to move in the opposite direction. [Albert Einstein]

Last edited by edbarx; 18th September 2021 at 05:04 PM.
  Reply With Quote
Old 23rd September 2021, 02:15 PM   #3073
b_force is offline b_force  Europe
diyAudio Member
 
b_force's Avatar
 
Join Date: Jan 2004
Little question about a simple TS391 I am trying to get to work in LTSpice.

Usually this is all straight forward, but I just get bogus results with an extremely simple comparator circuit.

I got the spice model from here;
Index of /Spice_Model_CD/Vendor List/STMicroelectronics/Standard Linear ICs/Spice

I also tried to model from ST's website;
TS391 - Low power, single voltage comparator - STMicroelectronics

As a symbol I just used the standard UniversalOpamp2 symbol and edit the pins to the one stated in the Spice file;

* 1 INVERTING INPUT
* 2 NON-INVERTING INPUT
* 3 OUTPUT
* 4 POSITIVE POWER SUPPLY
* 5 NEGATIVE POWER SUPPLY
.SUBCKT TS391 1 2 3 4 5

I am a little lost and confused, anyone a working model out there?
__________________
www.oneworldconcepts.com | www.soundprojects.com
"-There is no such thing as free beer in physics, everything is a compromise."
  Reply With Quote
Old 23rd September 2021, 02:19 PM   #3074
b_force is offline b_force  Europe
diyAudio Member
 
b_force's Avatar
 
Join Date: Jan 2004
Ok, that was quick from myself.

This is rather silly from the SPICE model.
It only work on 5V (or lower), while the datasheet clearly says it can be used up to 36V.

Anyway to change this?
__________________
www.oneworldconcepts.com | www.soundprojects.com
"-There is no such thing as free beer in physics, everything is a compromise."
  Reply With Quote
Old 23rd September 2021, 03:27 PM   #3075
Ray Waters is offline Ray Waters  United States
diyAudio Member
 
Join Date: Nov 2010
Location: Kansas
Quote:
Originally Posted by b_force View Post
I also tried to model from ST's website;
TS391 - Low power, single voltage comparator - STMicroelectronics

As a symbol I just used the standard UniversalOpamp2 symbol and edit the pins to the one stated in the Spice file;

* 1 INVERTING INPUT
* 2 NON-INVERTING INPUT
* 3 OUTPUT
* 4 POSITIVE POWER SUPPLY
* 5 NEGATIVE POWER SUPPLY
.SUBCKT TS391 1 2 3 4 5
The ST TS391 SPICE model uses the same pin order as the LTspice opamp2 symbol so you didn't need to edit either the model or the symbol's pin order. The model file appears to use node numbers instead of sequential numbers and this can be confusing, but it is the order that matters, not the actual numbers. The non-inverting input is pin 1, and the inverting input is pin 2. I think you have these reversed.

Don't change either the SPICE model file or the opamp2 symbol file and your simulation should work.
  Reply With Quote
Old 23rd September 2021, 03:51 PM   #3076
b_force is offline b_force  Europe
diyAudio Member
 
b_force's Avatar
 
Join Date: Jan 2004
This list is from the spice model itself, I didn't change anything.

The standard opamp didn't work with it at all.
__________________
www.oneworldconcepts.com | www.soundprojects.com
"-There is no such thing as free beer in physics, everything is a compromise."
  Reply With Quote
Old 23rd September 2021, 04:12 PM   #3077
Ray Waters is offline Ray Waters  United States
diyAudio Member
 
Join Date: Nov 2010
Location: Kansas
I'm not familiar with that chip so I can't comment on whether the model works or not. I was only offering an observation that the pin order in the model (see below) matches the pin order in the opamp2 symbol. The non-inverting input is listed first, followed by the inverting input. This is the opposite of what you show in your post #3073.

Sorry this wasn't helpful.

*-----------------------------------------------------------------------------------------
* TS391 spice macromodel
* CONNECTIONS : (corrected feb/17)
* 2 NON-INVERTING INPUT
* 1 INVERTING INPUT
* 44 POSITIVE POWER SUPPLY
* 55 NEGATIVE POWER SUPPLY
* 30 OUTPUT
*
************************************************** ********
.SUBCKT TS391 2 1 44 55 30
  Reply With Quote
Old 29th September 2021, 11:04 AM   #3078
martyh is online now martyh  United States
diyAudio Member
 
Join Date: Feb 2004
Location: Wisconsin
Installing and using LTspice IV (now including LTXVII). From beginner to advanced.
Sorry if I missed this in a previous post. Is there an easy way to notch out a fundamental out of a waveform on a circuit output and display the distortion waveform in the same window as the output. I have tried adding the trace output-(input*gain) and I end up with a residual that is primarily the fundamental. I think I was pretty accurate with the settings and the circuit I am trying it on only has a couple of degrees of phase shift at mid band so not sure what went wrong or how to fix it.
Thanks
Marty
  Reply With Quote
Old 29th September 2021, 11:44 AM   #3079
b_force is offline b_force  Europe
diyAudio Member
 
b_force's Avatar
 
Join Date: Jan 2004
Quote:
Originally Posted by martyh View Post
Sorry if I missed this in a previous post. Is there an easy way to notch out a fundamental out of a waveform on a circuit output and display the distortion waveform in the same window as the output. I have tried adding the trace output-(input*gain) and I end up with a residual that is primarily the fundamental. I think I was pretty accurate with the settings and the circuit I am trying it on only has a couple of degrees of phase shift at mid band so not sure what went wrong or how to fix it.
Thanks
Marty
You mean in LTSpice?

I would just make a little notch circuit, with something like a LC
No idea if that can also be done with some kind of expression (probably it can)
__________________
www.oneworldconcepts.com | www.soundprojects.com
"-There is no such thing as free beer in physics, everything is a compromise."
  Reply With Quote
Old 29th September 2021, 11:49 AM   #3080
martyh is online now martyh  United States
diyAudio Member
 
Join Date: Feb 2004
Location: Wisconsin
Installing and using LTspice IV (now including LTXVII). From beginner to advanced.
Yes, sorry for not being clear. I'm trying to do it in LT spice
  Reply With Quote

Reply


Installing and using LTspice IV (now including LTXVII). From beginner to advanced.Hide this!Advertise here!
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[LTSpice] Beginner - help with capacitor multiplier? bugbear Power Supplies 17 11th November 2016 11:18 PM
Meistersinger VFA-200, A beginnerís first try in LTSpice nattawa Solid State 34 29th January 2016 01:58 PM
Including a C- winding on a filament transformer AllenB Tubes / Valves 2 8th May 2014 05:17 AM
Need help installing LTSpice rif Software Tools 4 30th May 2013 01:59 AM


New To Site? Need Help?

All times are GMT. The time now is 11:12 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 13.64%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Copyright ©1999-2021 diyAudio
Wiki