Worst Case with Tempco Function

All,

We managed to modify the Worse Case function from analog.com and add some additional functionality.

The instructions are in the wct.sp file. (Change the extension from txt to whatever you prefer)

It’s already exposed some unexpected issues. If you find a problem let me know. I’ve only tested it with .op so far.

HVreg_WC example.qsch (11.6 KB)
wct .txt (4.3 KB)

2 Likes

@kgaler nice, but ends up with:
Fatal error: Could not open file “wct.sp”
Not sure if this is a QSPICE bug or something else at work here. I saved the file wct.txt and renamed it to wct.sp, in the same directory with HVreg_WC example.qsch.

The only way this works is to remove the .inc wct.sp statement (commented out) and paste in the schematic the content of the wct.sp file:

.param dT_hot = MaxTemp - Tnom
.param dT_cold = Tnom - MinTemp
.param numruns = 2**num_of_indexed_func_calls
.step param run 0 numruns 1

.func wct(nom, tol_pos, tol_neg, tc_pos, tc_neg, index) 
+ if( run == numruns, 
    + if(nom == 0, find_avg_nom(nom), nom),              ; if last run and nom == 0, use calculated nom
    + if( nom == 0,                                                ; else all other runs
        + if( binary(run, index),                                  ; Limits mode
            + tol_pos * (1 + tc_err_high(tc_pos)), 
            + tol_neg * (1 - tc_err_low(tc_neg)) 
        + ),  
        + if( binary(run, index),                                  ; Tolerance Mode
            + nom * (1 + per2err(tol_pos)) * (1 + tc_err_high(tc_pos)), 
            + nom * (1 - per2err(tol_neg)) * (1 - tc_err_low(tc_neg)) 
        + ) 
    + )
+ )

.func find_avg_nom(nom) tol_neg+((tol_pos-tol_neg)/2)
.func tc_err_high(tco) dT_hot * ppm2err(tco)
.func tc_err_low(tco) dT_cold * ppm2err(tco)
.func per2err(tol) abs(tol)/1e2
.func ppm2err(tc) abs(tc)/1e6
; Returns a 0 or 1 integer, 0 = low mode, 1 = high mode
.func binary(run, index) floor(run/(2**index)) - 2*floor(run/(2**(index+1)))

Interesting, works fine on both of our machines here. Try putting both files on your desktop and see if that works. Must be some sort of path issue…

Ken

@kgaler , thanks for looking into this one. Probably is a “long name” or something like that bug. I saved this test file in a long path [C:\Users.…\work\01_projects_QSPICE\009_Worse_Case_function]


… nope. I placed the files in [C:\work\test], and I got the same error. Probably is because I installed as “regular user” and not admin (company policy). Anyway, I understood the example. Hopefully is a bug that will be cleared out soon.