Skip to content

Commit

Permalink
Update debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Aug 11, 2020
1 parent c9f00c4 commit 0d9c3bf
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)

! Debug Outputs
DebugVar%WE_Cp = Cp_op
DebugVar%WE_D = v_m
DebugVar%WE_Vm = v_m
DebugVar%WE_Vt = v_t

ENDIF

Expand Down
5 changes: 3 additions & 2 deletions src/Controllers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ MODULE Controllers

CONTAINS
!-------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE PitchControl(avrSWAP, CntrPar, LocalVar, objInst)
SUBROUTINE PitchControl(avrSWAP, CntrPar, LocalVar, objInst, DebugVar)
! Blade pitch controller, generally maximizes rotor speed below rated (region 2) and regulates rotor speed above rated (region 3)
! PC_State = 0, fix blade pitch to fine pitch angle (PC_FinePit)
! PC_State = 1, is gain scheduled PI controller
! Additional loops/methods (enabled via switches in DISCON.IN):
! Individual pitch control
! Tower fore-aft damping
! Sine excitation on pitch
USE ROSCO_Types, ONLY : ControlParameters, LocalVariables, ObjectInstances
USE ROSCO_Types, ONLY : ControlParameters, LocalVariables, ObjectInstances, DebugVariables

! Inputs
TYPE(ControlParameters), INTENT(INOUT) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
TYPE(ObjectInstances), INTENT(INOUT) :: objInst
TYPE(DebugVariables), INTENT(INOUT) :: DebugVar
! Allocate Variables:
REAL(C_FLOAT), INTENT(INOUT) :: avrSWAP(*) ! The swap array, used to pass data to, and receive data from the DLL controller.
INTEGER(4) :: K ! Index used for looping through blades.
Expand Down
4 changes: 2 additions & 2 deletions src/DISCON.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ SUBROUTINE DISCON(avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG) BIND (C, NAME
! Read avrSWAP array into derived types/variables
CALL ReadAvrSWAP(avrSWAP, LocalVar)
CALL SetParameters(avrSWAP, aviFAIL, accINFILE, ErrMsg, SIZE(avcMSG), CntrPar, LocalVar, objInst, PerfData)
CALL PreFilterMeasuredSignals(CntrPar, LocalVar, objInst)

IF ((LocalVar%iStatus >= 0) .AND. (aviFAIL >= 0)) THEN ! Only compute control calculations if no error has occurred and we are not on the last time step
CALL PreFilterMeasuredSignals(CntrPar, LocalVar, objInst)
CALL ComputeVariablesSetpoints(CntrPar, LocalVar, objInst)

CALL StateMachine(CntrPar, LocalVar)
CALL WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)
CALL SetpointSmoother(LocalVar, CntrPar, objInst)
CALL ComputeVariablesSetpoints(CntrPar, LocalVar, objInst)
CALL VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst)
CALL PitchControl(avrSWAP, CntrPar, LocalVar, objInst)
CALL PitchControl(avrSWAP, CntrPar, LocalVar, objInst, DebugVar)
CALL YawRateControl(avrSWAP, CntrPar, LocalVar, objInst)
CALL FlapControl(avrSWAP, CntrPar, LocalVar, objInst)

Expand Down
3 changes: 1 addition & 2 deletions src/Filters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ SUBROUTINE PreFilterMeasuredSignals(CntrPar, LocalVar, objInst)
LocalVar%FA_AccHPF = HPFilter(LocalVar%FA_Acc, LocalVar%DT, CntrPar%FA_HPFCornerFreq, LocalVar%iStatus, .FALSE., objInst%instHPF)

! Wind Speed Estimator
! LocalVar%We_Vw_F = SecLPFilter(LocalVar%We_Vw, LocalVar%DT, 0.62831, 0.7, LocalVar%iStatus, .FALSE., objInst%instSecLPF)
LocalVar%We_Vw_F = LPFilter(LocalVar%We_Vw, LocalVar%DT, CntrPar%F_LPFCornerFreq/2.0, LocalVar%iStatus, .FALSE., objInst%instLPF)
LocalVar%We_Vw_F = SecLPFilter(LocalVar%WE_Vw,LocalVar%DT,0.21,0.7,LocalVar%iStatus,.FALSE.,objInst%instSecLPF) ! 30 second time constant

! Control commands (used by WSE, mostly)
LocalVar%VS_LastGenTrqF = SecLPFilter(LocalVar%VS_LastGenTrq, LocalVar%dt, CntrPar%F_LPFCornerFreq, 0.7, LocalVar%iStatus, .FALSE., objInst%instSecLPF)
Expand Down
29 changes: 16 additions & 13 deletions src/Functions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -471,30 +471,33 @@ SUBROUTINE Debug(LocalVar, CntrPar, DebugVar, avrSWAP, RootName, size_avcOUTNAME

! Set up Debug Strings and Data
! Note that Debug strings have 10 character limit
nDebugOuts = 12
nDebugOuts = 14
ALLOCATE(DebugOutData(nDebugOuts))
! Header Unit Variable
DebugOutStr1 = 'FA_AccF'; DebugOutUni1 = '(m/s)'; DebugOutData(1) = LocalVar%NacIMU_FA_AccF
DebugOutStr2 = 'WE_Vw'; DebugOutUni2 = '(rad)'; DebugOutData(2) = LocalVar%WE_Vw
DebugOutStr1 = 'FA_AccF'; DebugOutUni1 = '(m/s)'; DebugOutData(1) = LocalVar%NacIMU_FA_AccF
DebugOutStr2 = 'WE_Vw'; DebugOutUni2 = '(rad)'; DebugOutData(2) = LocalVar%WE_Vw
DebugOutStr3 = 'FA_AccR'; DebugOutUni3 = '(rad/s^2)'; DebugOutData(3) = LocalVar%NacIMU_FA_Acc
DebugOutStr4 = 'FA_Acc'; DebugOutUni4 = '(m/s^2)'; DebugOutData(4) = LocalVar%FA_Acc
DebugOutStr5 = 'Fl_Pitcom'; DebugOutUni5 = '(rad)'; DebugOutData(5) = LocalVar%Fl_Pitcom
DebugOutStr6 = 'WE_Cp'; DebugOutUni6 = '(-)'; DebugOutData(6) = DebugVar%WE_Cp
DebugOutStr7 = 'PC_MinPit'; DebugOutUni7 = '(rad)'; DebugOutData(7) = LocalVar%PC_MinPit
DebugOutStr8 = 'SS_dOmF'; DebugOutUni8 = '(rad/s)'; DebugOutData(8) = LocalVar%SS_DelOmegaF
DebugOutStr9 = 'WE_b'; DebugOutUni9 = '(deg)'; DebugOutData(9) = DebugVar%WE_b
DebugOutStr4 = 'FA_Acc'; DebugOutUni4 = '(m/s^2)'; DebugOutData(4) = LocalVar%FA_Acc
DebugOutStr5 = 'Fl_Pitcom'; DebugOutUni5 = '(rad)'; DebugOutData(5) = LocalVar%Fl_Pitcom
DebugOutStr6 = 'WE_Cp'; DebugOutUni6 = '(-)'; DebugOutData(6) = DebugVar%WE_Cp
DebugOutStr7 = 'PC_MinPit'; DebugOutUni7 = '(rad)'; DebugOutData(7) = LocalVar%PC_MinPit
DebugOutStr8 = 'SS_dOmF'; DebugOutUni8 = '(rad/s)'; DebugOutData(8) = LocalVar%SS_DelOmegaF
DebugOutStr9 = 'WE_b'; DebugOutUni9 = '(deg)'; DebugOutData(9) = DebugVar%WE_b
DebugOutStr10 = 'WE_t'; DebugOutUni10 = '(Nm)'; DebugOutData(10) = DebugVar%WE_t
DebugOutStr11 = 'WE_w'; DebugOutUni11 = '(rad/s)'; DebugOutData(11) = DebugVar%WE_w
DebugOutStr12 = 'WE_D'; DebugOutUni12 = '()'; DebugOutData(12) = DebugVar%WE_D
DebugOutStr11 = 'WE_w'; DebugOutUni11 = '(rad/s)'; DebugOutData(11) = DebugVar%WE_w
DebugOutStr12 = 'WE_Vm'; DebugOutUni12 = '()'; DebugOutData(12) = DebugVar%WE_Vm
DebugOutStr14 = 'WE_Vw_F'; DebugOutUni14 = '(m/s)'; DebugOutData(13) = LocalVar%WE_Vw_F

Allocate(DebugOutStrings(nDebugOuts))
Allocate(DebugOutUnits(nDebugOuts))
DebugOutStrings = [CHARACTER(10) :: DebugOutStr1, DebugOutStr2, DebugOutStr3, DebugOutStr4, &
DebugOutStr5, DebugOutStr6, DebugOutStr7, DebugOutStr8, &
DebugOutStr9, DebugOutStr10, DebugOutStr11, DebugOutStr12]
DebugOutStr9, DebugOutStr10, DebugOutStr11, DebugOutStr12, &
DebugOutStr13]
DebugOutUnits = [CHARACTER(10) :: DebugOutUni1, DebugOutUni2, DebugOutUni3, DebugOutUni4, &
DebugOutUni5, DebugOutUni6, DebugOutUni7, DebugOutUni8, &
DebugOutUni9, DebugOutUni10, DebugOutUni11, DebugOutUni12]
DebugOutUni9, DebugOutUni10, DebugOutUni11, DebugOutUni12, &
DebugOutUni13]

! Initialize debug file
IF (LocalVar%iStatus == 0) THEN ! .TRUE. if we're on the first call to the DLL
Expand Down
9 changes: 5 additions & 4 deletions src/ROSCO_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ MODULE ROSCO_Types

TYPE, PUBLIC :: DebugVariables
REAL(4) :: WE_Cp ! Cp that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(4) :: WE_b ! Pitch that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(4) :: WE_w ! Rotor Speed that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(4) :: WE_t ! Torque that WSE uses, for debug purposes [-]
REAL(4) :: WE_D ! Torque that WSE uses, for debug purposes [-]
REAL(4) :: WE_b ! Pitch that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(4) :: WE_w ! Rotor Speed that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(4) :: WE_t ! Torque that WSE uses, for debug purposes [-]
REAL(4) :: WE_Vm ! Torque that WSE uses, for debug purposes [-]
REAL(4) :: WE_Vt ! Torque that WSE uses, for debug purposes [-]
END TYPE DebugVariables

END MODULE ROSCO_Types

0 comments on commit 0d9c3bf

Please sign in to comment.