Answer Question
How can I create a comparator using fortran in PSCAD?
I am trying to make a comparison between a measured current with a reference current signal, as follows:
inputs: Imax(a random value), Ia (Ia is the measured current)
outputs: gate1
#LOCAL REAL iref
#LOCAL REAL iup
#LOCAL REAL ilow
iref = $Imax*SIN(TWO_PI*60*TIME)
iup = iref+iref*01
ilow = iref - iref*0.1
IF $I > up
$gate1 = 0
ELSEIF $I < ilow
$gate1 = 1
ENDIF
inputs: Imax(a random value), Ia (Ia is the measured current)
outputs: gate1
#LOCAL REAL iref
#LOCAL REAL iup
#LOCAL REAL ilow
iref = $Imax*SIN(TWO_PI*60*TIME)
iup = iref+iref*01
ilow = iref - iref*0.1
IF $I > up
$gate1 = 0
ELSEIF $I < ilow
$gate1 = 1
ENDIF