Logical Functions - revisited

About the writer: Harvey Morehouse is a contractor/consultant with many years of experience using circuit analysis programs. His primary activities are in Reliability, Safety, Testability and Circuit Analysis. He may be reached at harvey.annie@verizon.net. Simple questions for which I know the answer are free. Complex questions, especially where I am ignorant of the answers, are costly!!!

Summary: In previous articles I showed how to create logical expressions. Here is another way.

Nonlinear Source 'u' element:

According to the definition of the uramp function, and I quote, ""uramp" is the integral of the unit step. The unit step is one if its argument is greater than zero and zero if its argument is less than zero. The ramp function (uramp) is 0 for argument values less than zero and equal to the argument for argument values greater than zero.

Despite the misleading title, implying an integral, the uramp function returns the value of the argument when it is greater than zero. Thus, in some cases, where the 'test' is to return the value of the test when it is greater than zero, the uramp function can save some typing, and resultant errors. In other words, where an expression is to be logically,

If f(a)>0 then f(a), then one can use a nonlinear source with the voltage or current as applicable v=uramp(f(a)).

The following circuit illustrates this:


Figure 1
uramp function test circuit


The netlist for the test circuit is:

uramptest.ckt
************************
* B2 Spice
************************
* B2 Spice default format (same as Berkeley Spice 3F format)
***** main circuit
B1 N1 0 v=uramp(v(n3))
B2 N2 0 v=uramp(v(n4))
V1 N3 0 DC 0 SIN( 0 1 1k 0 0)
V2 N4 0 DC 0 PULSE( -1 1 .5m 1u 1u .25m 1m)
R1 N3 0 1K
R2 N4 0 1K

.TRAN 10u 5m 0 1u uic
.IC
.END

The resultant output is shown in Figure 2 following:


Figure 2
uramp function test output


Although not clear from the picture, the input at N4 overlaps the output at N2.

I was misled by the 'ramp' part of the uramp name, actually intending to use it for another purpose; however, the intended purpose can be attained in other manners. Notice several other things. Besides being useful for logic expressions, this also functions as an ideal diode with no voltage drop.

It pays to muck around with the library functions!!!!