PULSE: correct timing in case of phase != 0
This commit is contained in:
parent
413d0ff103
commit
39fccad193
|
|
@ -49,6 +49,7 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
double phase;
|
double phase;
|
||||||
double deltat;
|
double deltat;
|
||||||
double basephase;
|
double basephase;
|
||||||
|
double tshift;
|
||||||
#endif
|
#endif
|
||||||
double time = 0.; //hvogt
|
double time = 0.; //hvogt
|
||||||
double basetime = 0;
|
double basetime = 0;
|
||||||
|
|
@ -83,7 +84,8 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
/* compute equivalent delta time and add to time */
|
/* compute equivalent delta time and add to time */
|
||||||
deltat = (phase / (2 * M_PI)) * PER;
|
deltat = (phase / (2 * M_PI)) * PER;
|
||||||
time += deltat;
|
time += deltat;
|
||||||
TD -= deltat;
|
tshift = TD - deltat;
|
||||||
|
while (tshift < 0) tshift += PER;
|
||||||
#endif
|
#endif
|
||||||
/* gtri - end - wbk - add PHASE parameter */
|
/* gtri - end - wbk - add PHASE parameter */
|
||||||
|
|
||||||
|
|
@ -96,49 +98,49 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
if( time <= 0 || time >= TR + PW + TF) {
|
if( time <= 0 || time >= TR + PW + TF) {
|
||||||
if(ckt->CKTbreak && SAMETIME(time,0)) {
|
if(ckt->CKTbreak && SAMETIME(time,0)) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TR +TD);
|
error = CKTsetBreak(ckt,basetime + TR + tshift);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if(ckt->CKTbreak && SAMETIME(TR+PW+TF,time) ) {
|
} else if(ckt->CKTbreak && SAMETIME(TR+PW+TF,time) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + PER + TD);
|
error = CKTsetBreak(ckt,basetime + PER + tshift);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if (ckt->CKTbreak && (time == -TD) ) {
|
} else if (ckt->CKTbreak && (time == -tshift) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD);
|
error = CKTsetBreak(ckt,basetime + tshift);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if (ckt->CKTbreak && SAMETIME(PER,time) ) {
|
} else if (ckt->CKTbreak && SAMETIME(PER,time) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD + TR + PER);
|
error = CKTsetBreak(ckt,basetime + tshift + TR + PER);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
}
|
}
|
||||||
} else if ( time >= TR && time <= TR + PW) {
|
} else if ( time >= TR && time <= TR + PW) {
|
||||||
if(ckt->CKTbreak && SAMETIME(time,TR) ) {
|
if(ckt->CKTbreak && SAMETIME(time,TR) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+TR + PW);
|
error = CKTsetBreak(ckt,basetime + tshift + TR + PW);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if(ckt->CKTbreak && SAMETIME(TR+PW,time) ) {
|
} else if(ckt->CKTbreak && SAMETIME(TR+PW,time) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+TR + PW + TF);
|
error = CKTsetBreak(ckt,basetime + tshift + TR + PW + TF);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
}
|
}
|
||||||
} else if (time > 0 && time < TR) {
|
} else if (time > 0 && time < TR) {
|
||||||
if(ckt->CKTbreak && SAMETIME(time,0) ) {
|
if(ckt->CKTbreak && SAMETIME(time,0) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+TR);
|
error = CKTsetBreak(ckt,basetime + tshift + TR);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if(ckt->CKTbreak && SAMETIME(time,TR)) {
|
} else if(ckt->CKTbreak && SAMETIME(time,TR)) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+TR + PW);
|
error = CKTsetBreak(ckt,basetime + tshift + TR + PW);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
}
|
}
|
||||||
} else { /* time > TR + PW && < TR + PW + TF */
|
} else { /* time > TR + PW && < TR + PW + TF */
|
||||||
if(ckt->CKTbreak && SAMETIME(time,TR+PW) ) {
|
if(ckt->CKTbreak && SAMETIME(time,TR+PW) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+TR + PW +TF);
|
error = CKTsetBreak(ckt,basetime + tshift+TR + PW +TF);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if(ckt->CKTbreak && SAMETIME(time,TR+PW+TF) ) {
|
} else if(ckt->CKTbreak && SAMETIME(time,TR+PW+TF) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TD+PER);
|
error = CKTsetBreak(ckt,basetime + tshift + PER);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue