dimanche 29 avril 2018

Else if conditional executes although conditions are not true

I'm trying to track a reference in PLECS (power electronics simulation software) with this circuit. C-Script is where I have the code below which basically tells the IGBT devices to open (0) and close (1). However, I can't understand why I get "0" as output when it is clear that the voltage across the capacitor (VCS) is not even close to zero volts, as shows this figure.

int track(double ref, double isb, double vcs) {
    int out;

    if(ref > isb){
        out = 1;
    }
    else if(ref < isb && vcs == 0.0){
            out = 0;
        }

    return out;
}

In C-Script block, signal values may only be accessed by using macros, not by pointer arithmetic. For example, I declared Inputs and Output as follows:

#define REF Input(0) // Reference Current
#define ISB Input(1) // Snubber Output Current
#define VCS Input(2) // Capacitor Voltage
#define IGBT Output(0) // IGBT Firing

Aucun commentaire:

Enregistrer un commentaire