0% found this document useful (0 votes)
130 views11 pages

Crowbar Prot 1

This document contains code for a Crowbar_prot_1 component in PSCAD. The code defines the component's dynamic and output subroutines. It initializes variables and indices, transfers values between storage arrays, configures models, and contains logic to control power electronic switches based on input signals and voltage thresholds. The component monitors and controls a crowbar protection circuit.

Uploaded by

kuchow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views11 pages

Crowbar Prot 1

This document contains code for a Crowbar_prot_1 component in PSCAD. The code defines the component's dynamic and output subroutines. It initializes variables and indices, transfers values between storage arrays, configures models, and contains logic to control power electronic switches based on input signals and voltage thresholds. The component monitors and controls a crowbar protection circuit.

Uploaded by

kuchow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 11

!

=======================================================================
! Generated by : PSCAD v4.6.2.0
!
! Warning: The content of this file is automatically generated.
! Do not modify, as any changes made here will be lost!
!-----------------------------------------------------------------------
! Component : Crowbar_prot_1
! Description :
!-----------------------------------------------------------------------

!=======================================================================

SUBROUTINE Crowbar_prot_1Dyn(S1o, Blk, Ecap, Vdc_crowbar_on, &


& Vdc_crowbar_off)

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 'emtstor.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's2.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'fnames.h'
INCLUDE 'radiolinks.h'
INCLUDE 'matlab.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

! SUBR EMTDC_XHBUFF ! 'Interpolated Buffer with Hysteresis'

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments
INTEGER, INTENT(IN) :: Blk
REAL, INTENT(IN) :: Ecap
REAL, INTENT(IN) :: Vdc_crowbar_on
REAL, INTENT(IN) :: Vdc_crowbar_off
INTEGER, INTENT(OUT) :: S1o

! Electrical Node Indices

! Control Signals
INTEGER IT_1, IT_2, IT_3, S1
REAL Idc, Icrowbar(3)

! Internal Variables
REAL RVD2_1(2)

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER ISTOI, ISTOF, IT_0 ! Storage Indices
INTEGER ICX, IPGB ! Control/Monitoring
INTEGER ISUBS, SS(1), IBRCH(1), INODE ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Dsdyn <-> Dsout transfer index storage

NTXFR = NTXFR + 1

TXFR(NTXFR,1) = NSTOL
TXFR(NTXFR,2) = NSTOI
TXFR(NTXFR,3) = NSTOF
TXFR(NTXFR,4) = NSTOC

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

ISTOI = NSTOI
NSTOI = NSTOI + 6
ISTOF = NSTOF
NSTOF = NSTOF + 7
IPGB = NPGB
NPGB = NPGB + 1
ICX = NCX
NCX = NCX + 1
INODE = NNODE + 2
NNODE = NNODE + 12
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

! Initialize Subsystem Mapping

ISUBS = NSUBS + 0
NSUBS = NSUBS + 1

DO IT_0 = 1,1
SS(IT_0) = SUBS(ISUBS + IT_0)
END DO

! Initialize Branch Mapping.

IBRCH(1) = NBRCH(SS(1))
NBRCH(SS(1)) = NBRCH(SS(1)) + 14
!---------------------------------------
! Transfers from storage arrays
!---------------------------------------
IT_1 = STOI(ISTOI + 3)
IT_2 = STOI(ISTOI + 4)
IT_3 = STOI(ISTOI + 5)
S1 = STOI(ISTOI + 6)
Idc = STOF(ISTOF + 4)

! Array (1:3) quantities...


DO IT_0 = 1,3
Icrowbar(IT_0) = STOF(ISTOF + 4 + IT_0)
END DO

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Configuration of Models
!---------------------------------------

IF ( TIMEZERO ) THEN
FILENAME = 'Crowbar_prot_1.dta'
CALL EMTDC_OPENFILE
SECTION = 'DATADSD:'
CALL EMTDC_GOTOSECTION
ENDIF
!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 70:[buffer] Hysteresis Buffer


!
CALL EMTDC_XHBUFF(0,0,Ecap,Vdc_crowbar_on,Vdc_crowbar_off,RVD2_1)
IT_3 = NINT(RVD2_1(1))
!

! 80:[inv] Interpolated Logic Inverter


IF (IT_3 .NE. 0) THEN
IT_2 = 0
ELSE
IT_2 = 1
ENDIF

! 90:[var_switch] Two State Switch 'Filter parameters (manual)'


IT_1 = NINT(CX(CXMAP(ICX+1)))

! 100:[logic_mult] Multiple Input Logic Gate


!
! Multi input OR gate
!
IF ( (IT_2 .NE. 0) .OR. (Blk .NE. 0) .OR. (IT_1 .NE. 0) ) THEN
S1 = 1
ELSE
S1 = 0
ENDIF

! 120:[pgb] Output Channel 'S1'


PGB(IPGB+1) = REAL(S1)

! 130:[peswitch] Power electronic switch


! Power Electronic Switch Model: IGBT
CALL COMPONENT_ID(ICALL_NO,1145549591)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+3), S1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,930025485)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+5), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1830592735)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+7), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1287148718)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+9), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,468876494)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+1), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,382215391)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+4), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1391776734)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+6), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,965270762)
CALL PESWITCH1_EXE(SS(1), (IBRCH(1)+8), 1, 0.0)

!---------------------------------------
! Feedbacks and transfers to storage
!---------------------------------------

STOI(ISTOI + 2) = Blk
STOF(ISTOF + 1) = Ecap
STOF(ISTOF + 2) = Vdc_crowbar_on
STOF(ISTOF + 3) = Vdc_crowbar_off
STOI(ISTOI + 3) = IT_1
STOI(ISTOI + 4) = IT_2
STOI(ISTOI + 5) = IT_3
STOI(ISTOI + 6) = S1
STOF(ISTOF + 4) = Idc

! Array (1:3) quantities...


DO IT_0 = 1,3
STOF(ISTOF + 4 + IT_0) = Icrowbar(IT_0)
END DO

!---------------------------------------
! Transfer to Exports
!---------------------------------------
S1o = S1

!---------------------------------------
! Close Model Data read
!---------------------------------------

IF ( TIMEZERO ) CALL EMTDC_CLOSEFILE


RETURN
END

!=======================================================================

SUBROUTINE Crowbar_prot_1Out()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 'emtstor.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's2.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'fnames.h'
INCLUDE 'radiolinks.h'
INCLUDE 'matlab.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

REAL VBRANCH ! Voltage across the branch

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Electrical Node Indices

! Control Signals
REAL Idc, Icrowbar(3)

! Internal Variables
INTEGER IVD1_1

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER ISTOL, ISTOI, ISTOF, ISTOC, IT_0 ! Storage Indices
INTEGER ISUBS, SS(1), IBRCH(1), INODE ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Dsdyn <-> Dsout transfer index storage

NTXFR = NTXFR + 1

ISTOL = TXFR(NTXFR,1)
ISTOI = TXFR(NTXFR,2)
ISTOF = TXFR(NTXFR,3)
ISTOC = TXFR(NTXFR,4)

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

NPGB = NPGB + 1
NCX = NCX + 0
INODE = NNODE + 2
NNODE = NNODE + 12
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

! Initialize Subsystem Mapping

ISUBS = NSUBS + 0
NSUBS = NSUBS + 1

DO IT_0 = 1,1
SS(IT_0) = SUBS(ISUBS + IT_0)
END DO

! Initialize Branch Mapping.

IBRCH(1) = NBRCH(SS(1))
NBRCH(SS(1)) = NBRCH(SS(1)) + 14
!---------------------------------------
! Transfers from storage arrays
!---------------------------------------

Idc = STOF(ISTOF + 4)

! Array (1:3) quantities...


DO IT_0 = 1,3
Icrowbar(IT_0) = STOF(ISTOF + 4 + IT_0)
END DO

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Configuration of Models
!---------------------------------------

IF ( TIMEZERO ) THEN
FILENAME = 'Crowbar_prot_1.dta'
CALL EMTDC_OPENFILE
SECTION = 'DATADSO:'
CALL EMTDC_GOTOSECTION
ENDIF
!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 50:[ammeter] Current Meter 'Idc'


Idc = ( CBR((IBRCH(1)+2), SS(1)))

! 60:[multimeter] Multimeter
IVD1_1 = NRTCF
NRTCF = NRTCF + 5
Icrowbar(1) = (-CBR((IBRCH(1)+10), SS(1)))
Icrowbar(2) = (-CBR((IBRCH(1)+11), SS(1)))
Icrowbar(3) = (-CBR((IBRCH(1)+12), SS(1)))

!---------------------------------------
! Feedbacks and transfers to storage
!---------------------------------------

STOF(ISTOF + 4) = Idc

! Array (1:3) quantities...


DO IT_0 = 1,3
STOF(ISTOF + 4 + IT_0) = Icrowbar(IT_0)
END DO

!---------------------------------------
! Close Model Data read
!---------------------------------------

IF ( TIMEZERO ) CALL EMTDC_CLOSEFILE


RETURN
END

!=======================================================================

SUBROUTINE Crowbar_prot_1Dyn_Begin()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'radiolinks.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments

! Electrical Node Indices

! Control Signals

! Internal Variables

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER IT_0 ! Storage Indices
INTEGER ICX ! Control/Monitoring
INTEGER ISUBS, SS(1), IBRCH(1), INODE ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

ICX = NCX
NCX = NCX + 1
INODE = NNODE + 2
NNODE = NNODE + 12
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

! Initialize Subsystem Mapping

ISUBS = NSUBS + 0
NSUBS = NSUBS + 1

DO IT_0 = 1,1
SS(IT_0) = SUBS(ISUBS + IT_0)
END DO
! Initialize Branch Mapping.

IBRCH(1) = NBRCH(SS(1))
NBRCH(SS(1)) = NBRCH(SS(1)) + 14
!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 70:[buffer] Hysteresis Buffer

! 80:[inv] Interpolated Logic Inverter

! 90:[var_switch] Two State Switch 'Filter parameters (manual)'

! 120:[pgb] Output Channel 'S1'

! 130:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(3, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.0001, 1000000.0, 100000.0, 100000.0, 0.0&
&, 0.0)

RETURN
END

!=======================================================================
SUBROUTINE Crowbar_prot_1Out_Begin()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'radiolinks.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments

! Electrical Node Indices

! Control Signals

! Internal Variables
INTEGER IVD1_1

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER IT_0 ! Storage Indices
INTEGER ISUBS, SS(1), IBRCH(1), INODE ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

NCX = NCX + 0
INODE = NNODE + 2
NNODE = NNODE + 12
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0
! Initialize Subsystem Mapping

ISUBS = NSUBS + 0
NSUBS = NSUBS + 1

DO IT_0 = 1,1
SS(IT_0) = SUBS(ISUBS + IT_0)
END DO

! Initialize Branch Mapping.

IBRCH(1) = NBRCH(SS(1))
NBRCH(SS(1)) = NBRCH(SS(1)) + 14
!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 60:[multimeter] Multimeter
IVD1_1 = NRTCF
NRTCF = NRTCF + 5

RETURN
END

You might also like