"Logic" Problem

J

Jim Thompson

Guest
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson
In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
 
On Tue, 18 May 2004 10:07:42 -0700, Tim Wescott
<tim@wescottnospamdesign.com> wrote:

Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.
That's what I first thought of too, unfortunately PSpice does not have
the MOD operator :-(

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
Jim Thompson wrote:

PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18
(P-1) modulo 3

modulo, in this case means discard the upper bits.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
 
On Tue, 18 May 2004 10:07:42 -0700, Tim Wescott
<tim@wescottnospamdesign.com> wrote:

Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.
You CAN build your own "functions" in PSpice. How would you
accomplish MOD using other operators?

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
Jim Thompson wrote:
On Tue, 18 May 2004 10:07:42 -0700, Tim Wescott
tim@wescottnospamdesign.com> wrote:


Jim Thompson wrote:

PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.


You CAN build your own "functions" in PSpice. How would you
accomplish MOD using other operators?

...Jim Thompson
x mod y = x - y * floor(x / y).

This assumes that you have a 'floor' function. If it's all integer
arithmetic you're in luck, as x / y generally returns an integer equal
to floor(x / y).

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
 
Rene Tschaggelar wrote:

Jim Thompson wrote:

PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18


(P-1) modulo 3

modulo, in this case means discard the upper bits.

Rene
Or would, if 3 were an integer exponential of 2. Since it isn't you
have to use a real modulo function of some sort.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
 
On a sunny day (Tue, 18 May 2004 09:43:52 -0700) it happened Jim Thompson
<thegreatone@example.com> wrote in
<vfdka05bivpi097ktml97hidnc22at0nbh@4ax.com>:

PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!
a = input;
b = 0;
for(i = 0; i < 6; i++)
{
if(a == (1 + b) ) result = RED
if(a == (2 + b) ) result = GREEN
if(a == (3 + b) ) result = BLEU

b = b + 3;
}

That will be $59.50 ex tax.
For testing it I charge 150$ / hour.
JP
 
On a sunny day (Tue, 18 May 2004 10:07:42 -0700) it happened Tim Wescott
<tim@wescottnospamdesign.com> wrote in <10akgmj6k68t90d@corp.supernews.com>:

Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc
Shit better then mine :)
JP
 
On a sunny day (Tue, 18 May 2004 10:10:58 -0700) it happened Jim Thompson
<thegreatone@example.com> wrote in
<oqgka0hsqk11b1jv341h8t07e0mf0q8mts@4ax.com>:

On Tue, 18 May 2004 10:07:42 -0700, Tim Wescott
tim@wescottnospamdesign.com> wrote:

Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.

That's what I first thought of too, unfortunately PSpice does not have
the MOD operator :-(
AHA, back to my solution :)
JP
 
This speeds it up a bit, as it exits the loop immediatly
if a match is found:

a = input;
b = 0;
for(i = 0; i < 6; i++)
{
if(a == (1 + b) ) {result = RED; break;}
if(a == (2 + b) ) {result = GREEN; break;}
if(a == (3 + b) ) {result = BLEU; break;}

b = b + 3;
}

JP
 
On Tue, 18 May 2004 10:07:42 -0700, Tim Wescott
<tim@wescottnospamdesign.com> wrote:

Jim Thompson wrote:
PSpice Simulation Problem:

I have a (decimal) parameter (P) that varies from 1 thru 18 in steps
of 1.

With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities, how do I most compactly separate the following events:

P = 1 or 4 or 7 or 10 or 13 or 16

P = 2 or 5 or 8 or 11 or 14 or 17

P = 3 or 6 or 9 or 12 or 15 or 18

Thanks!

...Jim Thompson

In C your code would be most compact with

if (P%3 == 0) ... // 3, 6, 9, etc
if (P%3 == 1) ... // 1, 4, etc
if (P%3 == 2) ... // 2, 5, etc

I don't know if PSpice has a MOD operator (% in C), but you might want
to check.
Tim, Thanks for jogging my memory. You caused me to recall that my
oldest son had written some functions for me. Searching my hard-drive
found them ;-)

*
..FUNC FRACT(X) {(ATAN(TAN(((X+1e-11)-0.5)*PI))/PI+0.5)}
..FUNC TRUNC(X) {((X)-FRACT(X))}
..FUNC ROUND(X) {(TRUNC((X)+0.5))}
..FUNC BIT(X,Y) {(SGN(X-(2**Y)+0.1)+1)/2}
..FUNC MODULO(X,MOD) {(FRACT(X/MOD))*MOD}
..PARAM PI = 3.141593
*

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
On Tue, 18 May 2004 18:21:46 GMT, Jan Panteltje
<pNaonStpealmtje@yahoo.com> wrote:

This speeds it up a bit, as it exits the loop immediatly
if a match is found:

a = input;
b = 0;
for(i = 0; i < 6; i++)
{
if(a == (1 + b) ) {result = RED; break;}
if(a == (2 + b) ) {result = GREEN; break;}
if(a == (3 + b) ) {result = BLEU; break;}

b = b + 3;
}

JP
Why loop in the first place?

IF(N+2)/3 = INT((N+2)/3) THEN Group=1
IF(N+1)/3 = INT((N+1)/3) THEN Group=2
IF(N+0)/3 = INT((N+0)/3) THEN Group=3

in some programming languages you can invert the
backslash to get the same result as above...

IF(N+2)/3 = (N+2)\3 THEN Group=1
IF(N+1)/3 = (N+1)\3 THEN Group=2
IF(N+0)/3 = (N+0)\3 THEN Group=3
 
On a sunny day (Fri, 21 May 2004 15:47:51 GMT) it happened
bschwabe@atlanta.nsc.com (Beau Schwabe) wrote in
<40ae2344.693681163@usenet.nsc.com>:

On Tue, 18 May 2004 18:21:46 GMT, Jan Panteltje
pNaonStpealmtje@yahoo.com> wrote:

This speeds it up a bit, as it exits the loop immediatly
if a match is found:

a = input;
b = 0;
for(i = 0; i < 6; i++)
{
if(a == (1 + b) ) {result = RED; break;}
if(a == (2 + b) ) {result = GREEN; break;}
if(a == (3 + b) ) {result = BLEU; break;}

b = b + 3;
}

JP

Why loop in the first place?

IF(N+2)/3 = INT((N+2)/3) THEN Group=1
IF(N+1)/3 = INT((N+1)/3) THEN Group=2
IF(N+0)/3 = INT((N+0)/3) THEN Group=3
Clever!
Does he have INT?
JP
 
On Fri, 21 May 2004 18:34:37 GMT, Jan Panteltje
<pNaonStpealmtje@yahoo.com> wrote:

On a sunny day (Fri, 21 May 2004 15:47:51 GMT) it happened
bschwabe@atlanta.nsc.com (Beau Schwabe) wrote in
40ae2344.693681163@usenet.nsc.com>:

On Tue, 18 May 2004 18:21:46 GMT, Jan Panteltje
pNaonStpealmtje@yahoo.com> wrote:

This speeds it up a bit, as it exits the loop immediatly
if a match is found:

a = input;
b = 0;
for(i = 0; i < 6; i++)
{
if(a == (1 + b) ) {result = RED; break;}
if(a == (2 + b) ) {result = GREEN; break;}
if(a == (3 + b) ) {result = BLEU; break;}

b = b + 3;
}

JP

Why loop in the first place?

IF(N+2)/3 = INT((N+2)/3) THEN Group=1
IF(N+1)/3 = INT((N+1)/3) THEN Group=2
IF(N+0)/3 = INT((N+0)/3) THEN Group=3
Clever!
Does he have INT?
JP
As originally stated...

"With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities"

....With this I would imagine a relatively simple function such as
INT would be available.
 
On a sunny day (Fri, 21 May 2004 19:05:52 GMT) it happened
bschwabe@atlanta.nsc.com (Beau Schwabe) wrote in
<40ae4f0e.704893501@usenet.nsc.com>:

IF(N+2)/3 = INT((N+2)/3) THEN Group=1
IF(N+1)/3 = INT((N+1)/3) THEN Group=2
IF(N+0)/3 = INT((N+0)/3) THEN Group=3
Clever!
Does he have INT?
JP

As originally stated...

"With only IF-THEN-ELSE, AND (&), OR (|) and Algebraic operator
capabilities"

...With this I would imagine a relatively simple function such as
INT would be available.
yes, but he did no thave modulus either...
JP
 

Welcome to EDABoard.com

Sponsor

Back
Top