Skip to content

Commit

Permalink
Include PII flap control
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Dec 6, 2019
1 parent a62bdd5 commit 9e503dc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
43 changes: 38 additions & 5 deletions src/Controllers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,45 @@ SUBROUTINE FlapControl(avrSWAP, CntrPar, LocalVar, objInst)
TYPE(ControlParameters), INTENT(INOUT) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
TYPE(ObjectInstances), INTENT(INOUT) :: objInst

! Internal Variables
Integer(4) :: K
REAL(4) :: rootMOOP_F(3)
REAL(4) :: RootMyb_Vel(3)
REAL(4), SAVE :: RootMyb_Last(3)
REAL(4) :: RootMyb_VelErr(3)

! Flap control
IF (CntrPar%Flp_Mode == 1) THEN
LocalVar%Flp_Angle(1) = CntrPar%Flp_Angle
LocalVar%Flp_Angle(2) = CntrPar%Flp_Angle
LocalVar%Flp_Angle(3) = CntrPar%Flp_Angle
IF (CntrPar%Flp_Mode > 1) THEN
IF ((LocalVar%iStatus == 0) .and. (CntrPar%Flp_Mode == 1)) THEN
RootMyb_Last(1) = 0 - LocalVar%rootMOOP(1)
RootMyb_Last(2) = 0 - LocalVar%rootMOOP(2)
RootMyb_Last(3) = 0 - LocalVar%rootMOOP(3)
ELSEIF (CntrPar%Flp_Mode == 1) THEN
LocalVar%Flp_Angle(1) = CntrPar%Flp_Angle
LocalVar%Flp_Angle(2) = CntrPar%Flp_Angle
LocalVar%Flp_Angle(3) = CntrPar%Flp_Angle
! IF (MOD(LocalVar%Time,10.0) == 0) THEN
! LocalVar%Flp_Angle(1) = LocalVar%Flp_Angle(1) + 1
! LocalVar%Flp_Angle(2) = LocalVar%Flp_Angle(2) + 1
! LocalVar%Flp_Angle(3) = LocalVar%Flp_Angle(3) + 1
! ENDIF
ELSEIF (CntrPar%Flp_Mode == 2) THEN
DO K = 1,3
! LPF Blade root bending moment (tau = 0.1, critically damped to attempt to mitigate phase delays)
RootMOOP_F(K) = SecLPFilter(LocalVar%rootMOOP(K),LocalVar%DT,62.8319, 0.7,LocalVar%iStatus, .FALSE.,objInst%instLPF)
! Find derivative and derivative error of blade root bending moment
RootMyb_Vel(K) = (RootMOOP_F(K) - RootMyb_Last(K))/LocalVar%DT
RootMyb_VelErr(K) = 0 - RootMyb_Vel(K)!LocalVar%rootMOOP(K)
! Find flap angle
! LocalVar%Flp_Angle(K) = PIController(RootMyb_VelErr(K), CntrPar%Flp_Kp, CntrPar%Flp_Ki, -10.0, 10.0, LocalVar%DT, 0.0, .FALSE., objInst%instPI)
LocalVar%Flp_Angle(K) = PIIController(RootMyb_VelErr(K), 0 - LocalVar%Flp_Angle(K), CntrPar%Flp_Kp, CntrPar%Flp_Ki, 0.05, -10.0, 10.0, LocalVar%DT, 0.0, .FALSE., objInst%instPI)
! Add some integral gain to encourage zero flap angle
! LocalVar%Flp_Angle(K) = LocalVar%Flp_Angle(K) + PIController(0 - LocalVar%Flp_Angle(K), 0.0, 0.01, -10.0, 10.0, LocalVar%DT, 0.0, .FALSE., objInst%instPI)
! Saturation Limits
! LocalVar%Flp_Angle(K) = saturate(LocalVar%Flp_Angle(K),-10.0, 10.0)
RootMyb_Last(K) = RootMOOP_F(K)
ENDDO
ENDIF
! Send to AVRSwap
avrSWAP(120) = LocalVar%Flp_Angle(1)
avrSWAP(121) = LocalVar%Flp_Angle(2)
Expand Down
8 changes: 5 additions & 3 deletions src/ROSCO_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ MODULE ROSCO_Types
REAL(4) :: SD_MaxPit ! Maximum blade pitch angle to initiate shutdown, [rad]
REAL(4) :: SD_CornerFreq ! Cutoff Frequency for first order low-pass filter for blade pitch angle, [rad/s]

INTEGER(4) :: Flp_Mode ! Flap actuator mode {0: off, 1: fixed flap position}
REAL(4) :: Flp_Angle ! Flp_Angle - Blade flap angle (degrees)

INTEGER(4) :: Flp_Mode ! Flap actuator mode {0: off, 1: fixed flap position, 2: PI flap control}
REAL(4) :: Flp_Angle ! Fixed flap angle (degrees)
REAL(4) :: Flp_Kp ! PI flap control proportional gain
REAL(4) :: Flp_Ki ! PI flap control integral gain

REAL(4) :: PC_RtTq99 ! 99% of the rated torque value, using for switching between pitch and torque control, [Nm].
REAL(4) :: VS_MaxOMTq ! Maximum torque at the end of the below-rated region 2, [Nm]
REAL(4) :: VS_MinOMTq ! Minimum torque at the beginning of the below-rated region 2, [Nm]
Expand Down
2 changes: 2 additions & 0 deletions src/ReadSetParameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ SUBROUTINE ReadControlParameterFileSub(CntrPar)
!------------ Flaps ------------
READ(UnControllerParameters, *)
READ(UnControllerParameters, *) CntrPar%Flp_Angle
READ(UnControllerParameters, *) CntrPar%Flp_Kp
READ(UnControllerParameters, *) CntrPar%Flp_Ki
! END OF INPUT FILE

!------------------- CALCULATED CONSTANTS -----------------------
Expand Down

0 comments on commit 9e503dc

Please sign in to comment.