I want to determine what input voltage makes a unity gain amplifier gain exceed the spec limits of +/- 2%. So I sweep the input voltage, calculate the gain and use the following functions:
upper limit: min(cross(clip((VS("/OUT") / VS("/IN")) 1 3.6) 1.02 1 "rising" nil nil nil) cross(clip((VS("/OUT") / VS("/IN")) 1 3.6) 0.98 1 "falling" nil nil nil) 3.6)
lower limit: max(cross(clip(VS("/OUT")/VS("/IN") 0 2) 1.02 1 "falling" nil nil nil ) cross(clip(VS("/OUT")/VS("/IN") 0 2) 0.98 1 "rising" nil nil nil ) 0)
This all works if the cross functions return -nil for cases where the gain never crosses the threshold. But sometimes the cross function returns -nil, and sometimes it fails to evaluate. For example. If VS("/OUT")/VS("/IN") has values from 1.01 to 1.00, then the function checking for a crossing at 1.02 will return -nil, but the function checking for a crossing at 0.98 fails to evaluate and I get no answer. I can not determine what makes the cross function fail instead of returning -nil.
Is there any way to make this function work reliably?
Is there a better way to find these limits knowing that the gain function may never go out of limit for some corners.
Thanks in advance for the help