[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coupling vs secondary voltage chart



Original poster: "Antonio Carlos M. de Queiroz" <acmdq@xxxxxxxxxx>

Tesla list wrote:
Original poster: Terry Fritz <teslalist@xxxxxxxxxxxxxxxxxxxxxxx>
Hi Steve,
I am using primary feedback.
==========
for (T1 = T1_start; T1 <= T1_stop; T1 = T1 + T1_inc)
  {
  if (X0[4] >= 0) Vin=Vrail; else Vin=-Vrail;   //inputs Vin for DRSSTC case
  if (T1 > DwellTime) Vin = 0.0;
.
.
.
==========

Looking at the code, I see a (small) problem:

/* X1=X0+(dt/2)*[A]*X0+(dt/2)*B*(vin(t0)+vin(t0+dt)) */
      for (j=1; j<6; j++) {
        X1[j]=X0[j];
        for (k=1; k<6; k++) X1[j]+=(T1_inc/2)*(A[j][k]*X0[k]);
        X1[j]+=(T1_inc/2)*B[j]*(Vin+Vin);
      }

The "Vin+Vin" should be something as "LastVin + NewVin".
In this way there is an integration error added at each transition.
A better version could be something as:
LastVin=0;
...
Compute NewVin
In the j loop: ...LastVin+NewVin...
At the end of the time loop:
LastVin=NewVin;

The term T1_inc/2 could be precomputed. But probably code optimization
already does this.

Antonio Carlos M. de Queiroz