Bladed 4.4 dll controller in ServoDyn v1.03

Provide feedback, request enhancements, and get help with wind-turbine computer-aided engineering tools.

Moderators: Bonnie.Jonkman, Jason.Jonkman

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Wed Jun 13, 2018 4:19 pm

Hello,

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

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Wed Jun 13, 2018 4:30 pm

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,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Mon Jul 15, 2019 11:50 am

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++
Attachments
Unbenannt.png
Unbenannt.png (42.52 KiB) Viewed 442 times

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Mon Jul 15, 2019 12:39 pm

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,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Mon Jul 15, 2019 12:56 pm

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

Code: Select all

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:
Unbenannt.JPG
servodyn.dat
Unbenannt.JPG (33.12 KiB) Viewed 438 times


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

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Mon Jul 15, 2019 1:23 pm

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,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Tue Jul 16, 2019 2:16 pm

Dear Jason,

I tried to use the controller in 32 bit openfast and get this message:
Unbenannt.JPG
Unbenannt.JPG (58.59 KiB) Viewed 401 times

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!

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Tue Jul 16, 2019 3:13 pm

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,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Tue Jul 16, 2019 3:36 pm

Dear Jason,

my model with the servodyn file "NRELOffshrBsline5MW_Onshore_ServoDyn.dat" is running how you can see.
NRELOffshrBsline5MW_Onshore_ServoDyn.JPG
NRELOffshrBsline5MW_Onshore_ServoDyn.JPG (132.05 KiB) Viewed 393 times


I change only the path to my dll and it produces this:
own.JPG
own.JPG (155.44 KiB) Viewed 393 times


Best regards

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Tue Jul 16, 2019 8:39 pm

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:

Code: Select all

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

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Wed Jul 17, 2019 3:07 pm

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?

Code: Select all

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

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Wed Jul 17, 2019 3:36 pm

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,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Kemal.Kartal
Posts: 7
Joined: Mon Jan 11, 2016 5:01 am
Organization: self
Location: Germany

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Kemal.Kartal » Tue Jul 23, 2019 3:58 pm

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: Select all

---------------------- 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


What other changes are needed?

Jason.Jonkman
Posts: 4223
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Bladed 4.4 dll controller in ServoDyn v1.03

Postby Jason.Jonkman » Tue Jul 23, 2019 4:23 pm

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: http://www.nrel.gov/docs/fy09osti/38060.pdf.

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov


Return to “Computer-Aided Engineering Software Tools”

Who is online

Users browsing this forum: No registered users and 1 guest