Bladed 4.4 dll controller in ServoDyn v1.03


i want to use my Bladed dll controller in Fast. I have some questions, i hope you can help me.

At first is the DLL_InFile the file which is named “DISCON.f90” for the 5MW Baseline turbine? If yes, why it is named “DISCON.IN”?
The second question is about DLL_ProcName with the file named “DISCON”. Which file is that?

Is there anything to change in my controller.dll or in the two other files, so that I can use my controller.dll?

Best Regards

Kemal Kartal from germany

Dear Kemel,

DLL_InFile should not refer to DISCON.f90. Instead, DLL_InFile is the name of the input file that the DLL controller would call to read in parameters (if needed). The baseline controller for the NREL 5-MW turbine does not use an input file, so “DISCON.IN” does not actually exist for this turbine. If you wrote your own controller, I assume you would know if a DLL_InFile needs to be set to something specific.

DLL_ProcName is the name of the procedure (SUBROUTINE) that FAST will call. For the baseline controller for the NREL 5-MW turbine, this SUBROUTINE is called DISCON, as found in the DISCON.f90 source file. DLL_ProcName is usually set to “DISCON”.

I hope that clarifies things.

Best regards,

Sorry for my very late comment. I have a simple dll controller for bladed in c++, produced in Visual studio. What is necessary to change that i can use the controller in Openfast?

Maybe this (attachment) help you. These are the necessary steps to write a controller in Visual studio for bladed in c++

Dear Kemal,

I’m not sure that any changes are required to use this controller DLL in OpenFAST. Did you run into a problem when you tried to use the DLL in OpenFAST; if so, what was the problem?

Best regards,

Thank you for your fast answer. I get this error:

FAST_InitializeAll:SrvD_Init:BladedInterface_Init:The dynamic library C:\openfast\build\reg_tests\glue-codes\openfast\5MW_Land_DLL_WTurb\DiscreteController/Debug/Discre teController.dll could not be loaded. Check that the file exists in the specified location and that it is compiled for 64-bit applications.

It is compiled in win32 like the description in the bladed manual. This is my bladed interface in the servodyn.dat file:

Is there no need to add a openfast library in the visual studio solution?

Dear Kemal,

You can’t mix addressing schemes. It sounds like you’ve compiled OpenFAST in 64 bit, but your DLL in 32 bit. Either recompile OpenFAST in 32 bit or the DLL in 64 bit and try again.

Best regards,

Dear Jason,

I tried to use the controller in 32 bit openfast and get this message:
Do you have a solution? It does not matter, that I write the controller in c++ and not in fortran?

By the way, thank you for your help!

Dear Kemal,

That error message is not very descriptive. What is stated in the command prompt before this error? Can your 32-bit compiled version of OpenFAST with one of the sample models from the r-test without error?

OpenFAST, without modification, should be able to use controller DLLs based on Fortran- or C-based source code.

Best regards,

Dear Jason,

my model with the servodyn file “NRELOffshrBsline5MW_Onshore_ServoDyn.dat” is running how you can see.

I change only the path to my dll and it produces this:

Best regards

Dear Kemal,

Looking closer at your posts, I’m guessing you are using the newer controller API that was recently introduced in Bladed, not the original controller API that is supported by FAST and OpenFAST. (The current version of Bladed supports both controller APIs, but FAST / OpenFAST only support the original API). If you have a C-based controller, your interface should be:

extern "C" void DISCON(float *avrSWAP, int *aviFAIL, char * accINFILE, char * avcOUTNAME, char * avcMSG);

Best regards,

Thank you very much, you find the problem. Till today, i have never heard about that old style controller.
I am trying to build an old style controller and I have a question about the basic form of the code.
I write a very simple pith and torque controller for windspeeds above rated power windspeed, see below! I want to know, if the basic structure is right or is some code missing?

SUBROUTINE DISCON ( avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG ) BIND (C, NAME='DISCON') USE, INTRINSIC :: ISO_C_Binding !--------------------- IMPLICIT NONE #ifndef IMPLICIT_DLLEXPORT !DEC$ ATTRIBUTES DLLEXPORT :: DISCON !GCC$ ATTRIBUTES DLLEXPORT :: DISCON #endif !--------------------- REAL(C_FLOAT), INTENT(INOUT) :: avrSWAP (*) INTEGER(C_INT), INTENT(INOUT) :: aviFAIL CHARACTER(KIND=C_CHAR), INTENT(IN) :: accINFILE (NINT(avrSWAP(50))) CHARACTER(KIND=C_CHAR), INTENT(IN) :: avcOUTNAME(NINT(avrSWAP(51))) CHARACTER(KIND=C_CHAR), INTENT(INOUT) :: avcMSG (NINT(avrSWAP(49))) !--------------------- REAL(4), PARAMETER :: rated_power = 3700000 REAL(4), PARAMETER :: kp = 0.25000 REAL(4), PARAMETER :: kd = 1.50000 !--------------------- REAL(4) :: pitchrate REAL(4) :: rpm, rpm_diff, torque REAL(4) :: M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, d !--------------------- INTEGER(4) :: iStatus INTEGER(4) :: I CHARACTER(SIZE(avcOUTNAME)-1):: RootName !--------------------- iStatus = NINT( avrSWAP(1) ) !--------------------- rpm = avrSWAP(21) !--------------------- RootName = TRANSFER( avcOUTNAME(1:LEN(RootName)), RootName ) I = INDEX(RootName,C_NULL_CHAR) - 1 IF ( I > 0 ) RootName = RootName(1:I) !--------------------- aviFAIL = 0 !--------------------- rpm_diff = rpm - 1.30875 M10 = M9 M9 = M8 M8 = M7 M7 = M6 M6 = M5 M5 = M4 M4 = M3 M3 = M2 M2 = M1 M1 = rpm_diff d = ((M1-M10) + (M1-M9) + (M1-M8) + (M1-M7) + (M1-M6) + (M1-M5) + (M1-M4) + (M1-M3) + (M1-M2)) / 9 !--------------------- torque= rated_power/rpm pitchrate=rpm_diff*kp pitchrate=pitchrate+d*kd !--------------------- avrSWAP(55) = 0 ! Pitch override: 0=yes avrSWAP(46) = pitchrate avrSWAP(35) = 1 ! Generator contactor status: 1=main (high speed) variable-speed generator avrSWAP(56) = 0 ! Torque override: 0=yes avrSWAP(47) = torque ! Demanded generator torque !--------------------- END SUBROUTINE DISCON

Dear Kemal,

I haven’t reviewed your source code in detail, but you definitely have the right idea. NREL has provided Fortran-based source code examples of Bladed-style DLL controllers (for land-based and offshore variations of the NREL 5-MW baseline turbine) in the r-test of OpenFAST.

Best regards,

I do not why, but i can not use my controller. The turbine uses direct drive, so i changeyour 5MW controller, that it works direct drively. I want to change the generator parameters of the 5MW baseline controller into a 3.7MW controller, can you help me? I try to use my table input in servodyn, but it does not work.

[code]---------------------- BLADED INTERFACE TORQUE-SPEED LOOK-UP TABLE -------------
9 DLL_NumTrq - Record 26: No. of points in torque-speed look-up table {0 = none and use the optimal mode parameters; nonzero = ignore the optimal mode PARAMETERs by setting Record 16 to 0.0} (-) [used only with Bladed Interface]

GenSpd_TLU GenTrq_TLU
(rpm) (Nm)
3.1 43000
4.7 138000
6 339000
7 625000
8.5 926000
10 1.28E+09
11.3 1.70E+09
12.4 2.19E+09
12.5 2.84E+09[/code]

What other changes are needed?

Dear Kemal,

The Bladed-style DLL controllers for the NREL 5-MW baseline turbine models do not support the torque-speed table look-up feature you are attempting to use (that is, the date specified in the table is passed to the DLL through the interface, but the data is not used by the DLL).

Instead, the Bladed-style DLL controllers for the NREL 5-MW baseline models implement the torque-speed curve using data specified within the source file of the controller. You can, of course, adopt the parameters / gains of the NREL 5-MW baseline controller to be appropriate for a 3.7-MW turbine, but this will take some work. I would start by reviewing how the parameters / gains of the NREL 5-MW baseline controller were derived. The controller and its parameters / gains are documented in section 7 of the NREL 5-MW specifications report:

Best regards,

Dear Kemal,

Last year you have discussed with Mr. Jason about the calling issue in openfast.

I am just wondering how you dealt with that problem as I am also facing a similar issue like lot of files with unknown routines.
I am trying to run with external controller dll and facing the problem. Attaching the snap shot for your ready reference.

@Mr. Jason: Can you suggest something?


Dear Sachin,

The error is too generic to be useful. You’d have to compile and run in debug mode to really understand what is going on here. Do you only get this error for certain cases? Does disabling modules or features eliminate the error?

Best regards,

Dear Sachin,

I have two questions:

  1. Is your model running whitout the controller?
  2. You have a Bladed >4.4 controller or Bladed <4.4 controller

Best regards