Custom component using Fortran
I am trying to develop a current hysteresis controller using FORTRAN in PSCAD. I am trying to make a comparison between a measured current with the reference current upper band, but it is not working, PSCAD tells me that the measured current is not a parameter, computation or constant.
Inputs are Ia, Imax
Outputs are gate1
The script is appended below:
#LOCAL REAL iref #LOCAL REAL iup #LOCAL REAL ilow iref = $Imax*SIN(TWO_PI*60*TIME) iup = iref + iref*0.1 ilow = iref - iref*0.1 #IF $Ia > iup $gate1 = 0 #ELSE $gate1 = 1 #ENDIF !
Status:
Open Feb 02, 2021 - 04:08 PM
#customcomponent #fortran #hys
1answer
Answer
Feb 02, 2021 - 06:06 PM
So you can't use the selector component?
#BEGIN
RTCI(NRTCI) = $A
NRTCI = NRTCI + 1
#ENDBEGIN
#STORAGE RTCI:1
IF ($Ctrl .EQ. RTCI(NRTCI)) THEN
$Out = $InA
ELSE
$Out = $InB
ENDIF
NRTCI = NRTCI + 1
!
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
By
You should not hash with IF and ELSE IF. For your custom parameters, use simple IF and ELSEIF not #IF ....
By
it did not worked what must I have been doing wrong?
By
#LOCAL REAL iref
#LOCAL REAL iup
#LOCAL REAL ilow
#LOCAL REAL gate
iref = $Imax*SIN(TWO_PI*60*TIME)
iup = iref+iref*0.1
ilow = iref-iref*0.1
IF ($I>iup) THEN
gate = 0
ELSE
gate = 1
ENDIF
$gate1 = gate
By
Thank you Jan, now it worked just fine !
Add New Comment