Does LTSpice have the facility for acting on logical combinations of parameters

Thread Starter

bordonbert

Joined Feb 21, 2012
51
Hi guys,

I have a complex .op with control of a number of switches and component values on a simple selection for a parameter CTRL which can be 1, 2, 3 or 4. I'm doing this with statements like:

.param V1=table(CTRL, 1, 0V, 2, 0V, 3, 5V, 4, 5V)

to switch for, for example, CTRL==(1 OR 2) or (3 OR 4). (Yes it simplifies but there are other combinations elsewhere.) I would like to include another parameter say BST as 0 or 1 to that. It currently means that I have to do the following:

.param V1=table(CTRL, 1, 0V, 2, 0V, 3, 5V, 4, 5V, 5, 5V, 6, 0V, 7, 5V, 8, 0V)

I now need 8 values to represent all of the possible combinations. Of course it is sensible that I should simply act on a logical combination of the two parameters using something like AND(CTRL==1, BST==0). Is there any way this is possible in LTSpice?

I have read the manual and can't find anything, likewise I've spent a day looking on the internet and can find advanced and undocumented procedures and functions but nothing that seems to touch on this.
 

Alec_t

Joined Sep 17, 2013
15,149
As long as parameters are defined before RUN, LTspice can resolve logical combinations of them.
For example, if you have the directive ".params a=1 b=1 c=0 d=1", then a behavioural voltage source with output V=(a&b)|(c&d) will give the appropriate "1" out.
 

Thread Starter

bordonbert

Joined Feb 21, 2012
51
Wonderful! Thanks Alec that is exactly the answer I was looking for. I should have thought to try the simple "&" and "|" symbology but I was convinced it would be more textual so couldn't get past "AND" and "OR". It's working beautifully now with setting my 2 variables and selecting combinations of the two as I need. Thank you.
 
Top