Previous AM was buggy in V(I)SRC: Update to amplitude modulation
with corrected equation.
This commit is contained in:
parent
88d0727d3f
commit
aaaad70991
|
|
@ -239,38 +239,45 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
case AM: {
|
case AM: {
|
||||||
|
|
||||||
double VA, FC, MF, VO, TD;
|
double VO, VA, FM, MD, FC, TD, PHASEM, PHASEC;
|
||||||
double PHASEC, PHASES;
|
|
||||||
double phasec;
|
double phasec;
|
||||||
double phases;
|
double phasem;
|
||||||
|
|
||||||
PHASEC = here->ISRCfunctionOrder > 5
|
PHASEC = here->ISRCfunctionOrder > 6
|
||||||
? here->ISRCcoeffs[5] : 0.0;
|
|
||||||
PHASES = here->ISRCfunctionOrder > 6
|
|
||||||
? here->ISRCcoeffs[6] : 0.0;
|
? here->ISRCcoeffs[6] : 0.0;
|
||||||
|
PHASEM = here->ISRCfunctionOrder > 7
|
||||||
|
? here->ISRCcoeffs[7] : 0.0;
|
||||||
|
|
||||||
/* compute phases in radians */
|
/* compute phases in radians */
|
||||||
phasec = PHASEC * M_PI / 180.0;
|
phasec = PHASEC * M_PI / 180.0;
|
||||||
phases = PHASES * M_PI / 180.0;
|
phasem = PHASEM * M_PI / 180.0;
|
||||||
|
|
||||||
VA = here->ISRCcoeffs[0];
|
VO = here->ISRCcoeffs[0];
|
||||||
VO = here->ISRCcoeffs[1];
|
VA = here->ISRCcoeffs[1];
|
||||||
MF = here->ISRCfunctionOrder > 2
|
FM = here->ISRCfunctionOrder > 2
|
||||||
&& here->ISRCcoeffs[2]
|
&& here->ISRCcoeffs[2]
|
||||||
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
||||||
FC = here->ISRCfunctionOrder > 3
|
MD = here->ISRCfunctionOrder > 3
|
||||||
? here->ISRCcoeffs[3] : 0.0;
|
? here->ISRCcoeffs[3] : 0.5;
|
||||||
TD = here->ISRCfunctionOrder > 4
|
FC = here->ISRCfunctionOrder > 4
|
||||||
&& here->ISRCcoeffs[4]
|
|
||||||
? here->ISRCcoeffs[4] : 0.0;
|
? here->ISRCcoeffs[4] : 0.0;
|
||||||
|
TD = here->ISRCfunctionOrder > 5
|
||||||
|
&& here->ISRCcoeffs[5]
|
||||||
|
? here->ISRCcoeffs[5] : 0.0;
|
||||||
|
|
||||||
|
/* limit the modulation depth */
|
||||||
|
if (MD > 1)
|
||||||
|
MD = 1;
|
||||||
|
else if (MD < 0)
|
||||||
|
MD = 0;
|
||||||
|
|
||||||
time -= TD;
|
time -= TD;
|
||||||
if (time <= 0) {
|
if (time <= 0) {
|
||||||
value = 0;
|
value = 0;
|
||||||
} else {
|
} else {
|
||||||
/* compute waveform value */
|
/* compute waveform value */
|
||||||
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
|
value = VO + VA * (1 + MD * sin(2.0 * M_PI * FM * time + phasem)) *
|
||||||
sin(2.0 * M_PI * FC * time + phases);
|
sin(2.0 * M_PI * FC * time + phasec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -261,38 +261,45 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
case AM: {
|
case AM: {
|
||||||
|
|
||||||
double VA, FC, MF, VO, TD;
|
double VO, VA, FM, MD, FC, TD, PHASEM, PHASEC;
|
||||||
double PHASEC, PHASES;
|
|
||||||
double phasec;
|
double phasec;
|
||||||
double phases;
|
double phasem;
|
||||||
|
|
||||||
PHASEC = here->VSRCfunctionOrder > 5
|
PHASEM = here->VSRCfunctionOrder > 6
|
||||||
? here->VSRCcoeffs[5] : 0.0;
|
|
||||||
PHASES = here->VSRCfunctionOrder > 6
|
|
||||||
? here->VSRCcoeffs[6] : 0.0;
|
? here->VSRCcoeffs[6] : 0.0;
|
||||||
|
PHASEC = here->VSRCfunctionOrder > 7
|
||||||
|
? here->VSRCcoeffs[7] : 0.0;
|
||||||
|
|
||||||
/* compute phases in radians */
|
/* compute phases in radians */
|
||||||
phasec = PHASEC * M_PI / 180.0;
|
phasec = PHASEC * M_PI / 180.0;
|
||||||
phases = PHASES * M_PI / 180.0;
|
phasem = PHASEM * M_PI / 180.0;
|
||||||
|
|
||||||
VA = here->VSRCcoeffs[0];
|
VO = here->VSRCcoeffs[0];
|
||||||
VO = here->VSRCcoeffs[1];
|
VA = here->VSRCcoeffs[1];
|
||||||
MF = here->VSRCfunctionOrder > 2
|
FM = here->VSRCfunctionOrder > 2
|
||||||
&& here->VSRCcoeffs[2]
|
&& here->VSRCcoeffs[2]
|
||||||
? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
||||||
FC = here->VSRCfunctionOrder > 3
|
MD = here->VSRCfunctionOrder > 3
|
||||||
? here->VSRCcoeffs[3] : 0.0;
|
? here->VSRCcoeffs[3] : 0.5;
|
||||||
TD = here->VSRCfunctionOrder > 4
|
FC = here->VSRCfunctionOrder > 4
|
||||||
&& here->VSRCcoeffs[4]
|
|
||||||
? here->VSRCcoeffs[4] : 0.0;
|
? here->VSRCcoeffs[4] : 0.0;
|
||||||
|
TD = here->VSRCfunctionOrder > 5
|
||||||
|
&& here->VSRCcoeffs[5]
|
||||||
|
? here->VSRCcoeffs[5] : 0.0;
|
||||||
|
|
||||||
|
/* limit the modulation depth */
|
||||||
|
if (MD > 1)
|
||||||
|
MD = 1;
|
||||||
|
else if (MD < 0)
|
||||||
|
MD = 0;
|
||||||
|
|
||||||
time -= TD;
|
time -= TD;
|
||||||
if (time <= 0) {
|
if (time <= 0) {
|
||||||
value = 0;
|
value = 0;
|
||||||
} else {
|
} else {
|
||||||
/* compute waveform value */
|
/* compute waveform value */
|
||||||
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
|
value = VO + VA * (1 + MD * sin(2.0 * M_PI * FM * time + phasem)) *
|
||||||
sin(2.0 * M_PI * FC * time + phases);
|
sin(2.0 * M_PI * FC * time + phasec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue