Can LTspice do this? - Page 1
Forum section: electronics / general

author: c4757p
author_rank: Super Contributor
timestamp: December 21, 2012, 05:09:27 am
content: Any LTspice wizards out there? Here's what I'd like to do: I have a circuit that takes quite a while to simulate. I'd like to somehow script this: Step value from 300K to 600K, run transient for 140ms, compute average current from V1 between 130ms and 140ms. I want the average current draw for each step value. Is there any way to set this up and let it run on its own for a long time, or do I need to use a command line SPICE and do it manually?

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: December 21, 2012, 05:44:06 am
content: Yes, you can do that. Can you post your model for a single resistor?I will try and modify for a range of resistors.Jay_Diddy_B

author: c4757p
author_rank: Super Contributor
timestamp: December 21, 2012, 05:56:16 am
content: Oh, never mind, I figured it out. (Shouldn't post when I'm this sleep-deprived, really, I just look stupid.) I knew how to do it all along.If anyone else is curious, here's what I did:Code:.MEAS TRAN IV1 AVG I(V1) TRIG AT=130m TARG AT=140m.STEP PARAM R 300K 600K 50KAlong with a .STEP command. Forgot all about TRIG AT/TARG AT...

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: December 21, 2012, 06:01:51 am
content: This is what I came up with:It is essentially the same thing.Jay_Diddy_B

author: nicknails
author_rank: Regular Contributor
timestamp: March 25, 2013, 04:40:24 pm
content: Going to commandeer this thread instead of making a new one....Is it possible to take an IC and re-arrange the pins? I'm using one of LT's SO-8 IC's and I'd like to re-arrange the pins to make my schematic look a little cleaner. Is this possible?

author: codeboy2k
author_rank: Super Contributor
timestamp: March 25, 2013, 08:59:06 pm
content: I also often add .SAVE commands if the circuit is large and I am only interested in something particular like voltage and current of a particular node. This only saves the specified node data and nothing else, preventing it from making HUGE disk files of all data points, which can sometimes exceed 100GBFuthermore, you can improve the calculation accuracy with a .OPTIONS command to increase the number of digits retained to 15, similar to single vs. double precision math. This may not always be necessary, but when doing .MEAS statements involving division, or trig functions, I like to set the option on.I like to set START params and END params so that I can add multiple .MEAS statements that all start and end at the same time, and only have to change it in one place if needed, instead of on every .MEAS statement.The TRIG AT= and TARG AT= of the .MEAS statements are powerful, but not needed if you only care about time based start and end points. For this you can just use FROM <start> TO <end>. I've shown both examples.Code:.MEAS START PARAM 130ms.MEAS END PARAM 140ms.STEP PARAM R 300K 600K 50K.OPTIONS numdgt=15.SAVE V(V1), I(V1).MEAS IV1 AVG I(V1) TRIG AT=START TARG AT=END.MEAS P AVG V(V1)*I(V1) FROM START TO ENDFinally, if you change the .TRANS statement to save only the data between 130ms and 140ms, as in J_Diddy's example, then you only have 10ms of data, and this screws up the .MEAS statements. They can no longer START at 130ms and END at 140ms (since you only have 10ms of data). For this, you have to change the START and END to 0ms and 10ms (or simply leave them off to include the entire range of saved data).This point of LTSPICE really annoys me, but it sorta makes some sense.

author: c4757p
author_rank: Super Contributor
timestamp: March 25, 2013, 09:06:38 pm
content: Quote from: nicknails on March 25, 2013, 04:40:24 pmYou can edit the parts directly. Just open them, edit, and save, preferably under a different name.Quote from: codeboy2k on March 25, 2013, 08:59:06 pmThat is nice.