# Beginner to Simulink and FAST V7

**URL:** <https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292>\
**Category:** Controls\
**Created:** [February 29, 2016, 6:41pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292 "2016-02-29T18:41:34Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![Audrey.Viala](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Audrey.Viala](https://forums.nlr.gov/u/Audrey.Viala)\
**Post date:** [June 30, 2016, 2:23pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/21 "2016-06-30T14:23:41Z")

</div>

Hi Bonnie!

Thank you so much for your help! I have succeded in compiling FAST\_SFun mex file.  
Now, I will try to use it in simulation to see if the problem with Matlab persists.

Best regards.  
Audrey

---

<div class="post-metadata">

**Author:** ![Audrey.Viala](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Audrey.Viala](https://forums.nlr.gov/u/Audrey.Viala)\
**Post date:** [June 30, 2016, 3:18pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/22 "2016-06-30T15:18:03Z")

</div>

Hi Bonnie,

I have looked further the simulation with Simulink and FAST v7 and I have a small question.  
Why the parameter “initialized” decrease from 1 to 0 after a simulation?

I have realized that after setting this parameter to 1 and run again a simulation, there is no problem whereas if I let this parameter with the 0 value Matlab is closed.  
In the file "Read\_FAST\_Input.m we can read:

```auto
Initialized = 1; % Tells S-function if this script ran prior to simulation. 0 = no.
```

Is it the FAST\_SFun which changes this parameter? And why? It seems causing some problems to run a second simulation without setting to 1 after the first one.

I don’t know if I am very clear but I think it can be the origin of my issue with FAST v7 and Simulink simulation.

Regards,  
Audrey

---

<div class="post-metadata">

**Author:** ![Bonnie.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/bonnie.jonkman/32/3230_2.png) [@Bonnie.Jonkman](https://forums.nlr.gov/u/Bonnie.Jonkman)\
**Post date:** [June 30, 2016, 3:27pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/23 "2016-06-30T15:27:53Z")

</div>

The FAST v7 S-Function does change the initialized variable to 0 after initialization. It also checks that it is 1 before it will run. The idea is to make sure you have called Read\_FAST\_Input.m in Matlab each time you start a model, which makes sure the variables in the Matlab workspace are consistent with the internal variables of the S-Function. If you are running the same model again (using the same, unchanged, FAST input file), it should be okay to reset the initialized variable to 1 without running Read\_FAST\_Input. The way it was developed, though, it assumes you use Simsetup.m each time you start a model.

---

<div class="post-metadata">

**Author:** ![Audrey.Viala](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Audrey.Viala](https://forums.nlr.gov/u/Audrey.Viala)\
**Post date:** [July 1, 2016, 1:11pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/24 "2016-07-01T13:11:14Z")

</div>

Hi Bonnie,

Thank you for your explanation.  
With all your instructions I have compiled FAST\_SFunc for both 32 and 64 bits.  
However, when I try to use them, MATLAB is crashed.

I am trying to run a simulation with the NRELOffshrBsline5MW\_OC3Hywind but it does not worked. I don’t really understand what you said in another post: "FAST v7 as distributed does not run the 5MW models. The primary reason is that the Bladed-style DLL controller requires a separate compilation. If you want to run the 5MW model in Simulink, you’ll have to recompile FAST\_SFunc using the appropriate source files for the Bladed Interface. " from [AeroDyn Feedback](http://forums.nlr.gov/t/aerodyn-feedback/57/1)

1. How can I use the appropriate DLL file during the compilation?

I have tried to use the one available in the OC3 file: FAST\_v7.02.00d-bjj\_AeroDyn\_v13.00.02a-bjj\_BladedDLLInterface\_OC3Hywind by remplacing the FAST bladed DLL but the FAST\_SFUNC mex after compilation is the same.  
2) How can I use the three following files included in the OC3 folder?

- FAST\_v7.02.00d-bjj\_AeroDyn\_v13.00.02a-bjj\_BladedDLLInterface\_OC3Hywind  
-DISCON.dll
- DISCON.f90

I feel desperate because I am not able to run a linearization of the OC3 model…  
Thank you very much for your help.  
Audrey

---

<div class="post-metadata">

**Author:** ![Mansour.Alkmim](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Mansour.Alkmim](https://forums.nlr.gov/u/Mansour.Alkmim)\
**Post date:** [December 14, 2016, 11:56pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/25 "2016-12-14T23:56:47Z")

</div>

Dear Bonnie,

I have encountered the same problem as Audrey. I am using Matlab 2016b 64 bits. I have read the FAST v8 Interface to Simulink from README\_FAST8 pdf and did as follows:

- created the FAST\_SFunc.mexw64 using create\_FAST\_SFunc.m
- add %FAST\_v8\bin to MATLAB path

then I tried running the two samples from %Simulink\Samples.

In both cases matlab crashes (with system error). The OpenLoop file gives the following error message:

Error using Run\_OpenLoop (line 30)  
Error while obtaining sizes from MEX S-function ‘FAST\_SFunc’ in ‘OpenLoop/FAST Nonlinear Wind Turbine/S-Function’.  
Caused by:  
Error using Run\_OpenLoop (line 30)  
FatalException

---

<div class="post-metadata">

**Author:** ![Sami.Khan](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Sami.Khan](https://forums.nlr.gov/u/Sami.Khan)\
**Post date:** [February 23, 2017, 12:56pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/26 "2017-02-23T12:56:49Z")

</div>

Hello Everyone,

I am posting on this thread because I have a similar query and I am a beginner with Fast v7.  
I am following a documentation from NREL “Simulation for Wind Turbines Generator - With Fast and Matlab-Simulink Module”  
[url][http://www.nrel.gov/docs/fy14osti/59195.pdf[/url]](http://www.nrel.gov/docs/fy14osti/59195.pdf%5B/url%5D)

During the time I was following the above documentation in the section 4.1.2 I took all the steps necessary to do interface the induction generator in to the Test01\_Sig model, and also make the constant as it is in the documentation.

But when I am trying to run my simulation I get these errors. I don`t know what mistake I am doing.  
Below is the error when I am trying to run the simulation

![]()

Below is the Simulink file related to it and also the m file

![]()  
 ![]()

Regards,  
Sami

 ![3.png](https://europe1.discourse-cdn.com/nrel/original/1X/93883fbce2b340d07df2d0928f9605a403f5209a.png)  
 ![Untitled.png](https://europe1.discourse-cdn.com/nrel/original/1X/ab64b4c0f03cbab008e0fa39d957df26403dbbc5.png)  
 ![2.png](https://europe1.discourse-cdn.com/nrel/original/1X/d94b93502b83dfb33265334ee36dd11b65152b72.png)

---

<div class="post-metadata">

**Author:** ![Jason.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/jason.jonkman/32/3086_2.png) [@Jason.Jonkman](https://forums.nlr.gov/u/Jason.Jonkman)\
**Post date:** [February 23, 2017, 2:22pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/27 "2017-02-23T14:22:22Z")

</div>

Dear Sami,

Your error is regarding a Tmech, which is part of the induction generator model, not provided by NREL. I suggest that you contact the source of this induction generator model for help.

Best regards,

---

<div class="post-metadata">

**Author:** ![Sami.Khan](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Sami.Khan](https://forums.nlr.gov/u/Sami.Khan)\
**Post date:** [February 23, 2017, 2:42pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/28 "2017-02-23T14:42:35Z")

</div>

Dear Jason,

thanks for your quick reply the problem is solved. By completely deleting the tmech and put a constant of 0 instead of it.

Thanks anyways

---

<div class="post-metadata">

**Author:** ![Georgios.Gasparis](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Georgios.Gasparis](https://forums.nlr.gov/u/Georgios.Gasparis)\
**Post date:** [October 12, 2018, 4:47pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/29 "2018-10-12T16:47:56Z")

</div>

Dear All,

I am an MSc student and I am trying to simulate the NREL 5.0 MW Baseline Wind Turbine, including torque and pitch control using Simulink. I have troubles in this procedure, since it is not so clear to me. As I understand, all the information about the controllers is in the DISCON.dll file that is also included in the .zip file found in [url][National Wind Technology Center's Information Portal | Wind Research | NREL](http://wind.nrel.gov/public/jjonkman/NRELOffshrBsline5MW/%5B/url%5D). Please correct me if I am wrong.

In order to use these controllers I run Simsetup.m and then OpenLoop.mdl. I added in the same folder the files: FAST\_SFunc.mexw64, FAST\_Library\_x64.dll and MAP\_x64.dll from FAST v8. I initially used FAST\_SFunc.mexw64 from v7.02, but OpenLoop.mdl gave me errors. Finally, after running OpenLoop.mdl, I derive the following error:

 ![OpenLoop_Error.png](https://europe1.discourse-cdn.com/nrel/original/2X/7/7e304d2e0f5213d3b347bb77136e502ead97af43.png)  
My questions are the following:

1. How can I solve this error?
2. Is any other way to use the information of the DISCON.dll apart from using Simulink?
3. Is it correct to use the files I mentioned before from FAST v8?
4. Since I am simply running the OpenLoop.mdl, should I change anything in it?

Thank you very much for your time!

Best regards,

Georgios

---

<div class="post-metadata">

**Author:** ![Jason.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/jason.jonkman/32/3086_2.png) [@Jason.Jonkman](https://forums.nlr.gov/u/Jason.Jonkman)\
**Post date:** [October 12, 2018, 8:27pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/30 "2018-10-12T20:27:13Z")

</div>

Dear Georgios,

You shouldn’t need to change anything to run the OpenLoop.mdl. Are you running the OpenLoop.mdl distributed with FAST v8 or FAST v7? When you open the FAST\_SFunc block in Simulink, do you see three S-Function parameters (FAST\_InputFileName, TMax, 0), as shown in Figure 9 of the FAST v8 ReadMe file: [wind.nrel.gov/nwtc/docs/README\_FAST8.pdf](https://wind.nrel.gov/nwtc/docs/README_FAST8.pdf) (it should look just like Figure 9 if you are using the OpenLoop.mdl provided with FAST v8)?

Regardless, you don’t need to use the Simulink interface at all if you want to use a controller implemented as a DISCON.dll. The Simulink interface is meant to be used for implementing the controller within Simulink. If you want to use a controller implemented as a DISCON.dll, I would suggest running the FAST executable instead.

Best regards,

---

<div class="post-metadata">

**Author:** ![Georgios.Gasparis](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Georgios.Gasparis](https://forums.nlr.gov/u/Georgios.Gasparis)\
**Post date:** [October 30, 2018, 6:04pm UTC](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292/31 "2018-10-30T18:04:12Z")

</div>

Dear Jason,

My apologies for my late response. Thank you very much for your help. I downloaded and used the already compiled executable file “FAST\_v7.02.00d-bjj\_AeroDyn\_v13.00.02a-bjj\_BladedDLLInterface.exe” from the directory [url][National Wind Technology Center's Information Portal | Wind Research | NREL](https://wind.nrel.gov/public/jjonkman/FAST%5B/url%5D). I also included the “DFORRT.DLL” file in the working directory. It seems that the controller works.

Thank you very much again!

Best regards

Georgios

[Previous page](https://forums.nlr.gov/t/beginner-to-simulink-and-fast-v7/1292.md?page=1)
