Hardware in the loop

Hi all,
I can easily run the open loop (FAST v8) in Matlab/Simulink but when I run it in the real-time environment in Matlab it gives me these two errors including “LINK : fatal error LNK1104: cannot open file ‘FAST_SFunc.obj’”, and “NMAKE : fatal error U1077”. Has anyone encountered such errors? The details of the errors are as follows:

LINK : fatal error LNK1104: cannot open file ‘FAST_SFunc.obj’
NMAKE : fatal error U1077: ‘“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\link.EXE”’ : return code ‘0x450’
Stop.
The make command returned an error of 2

Error(s) encountered while building “FAST_model_only”
Component:Simulink | Category:Block diagram error

Thanks,
Best regards,
Sina

Dear Sina,

My understanding is that there are options in MATLAB/Simulink for running real-time simulations, but I’m not very familiar with these. If your existing FAST / OpenFAST model within MATLAB/Simulink already runs faster than real time (or can be simplified a bit to do so), I would guess it would possible to use it for real-time applications, but you’d have to check MATLAB/Simulink documentation for information on how to do that.

A similar question was discussed in the following forum topics, but I’m not sure where the work ended up:

The FAST v7 interface to LabView was used for real-time implementation, but this functionality has not yet been ported to FAST v8 or OpenFAST. It was up to the user to set up the FAST v7 model so that it would run faster than real time without the interface to LabView enabled. LabView would then wait before calling FAST v7 again so that the simulation was real time. NREL used the LabView interface to link FAST v7 with the actual controller implemented on the physical CART wind turbine tested at NREL (in a hardware in the loop mode), so that the controller could be tested before using it on the real CART. This capability is discussed a bit in the following forum topic:

Best regards,

Dear Dr. Jonkman,

Thank you very much for your respond and very helpful links. I read them and found the source of the problem. To illustrate, to make a real-time there is a header file (simstruc.h) in Matlab that should be used for C S-function level 2. This header file itself, includes other header files depending on compiling a MEX file or Simulink Coder product for a real-time application. There is header file termed “matrix.h” which is included for MEX file compilation; on the other hand, there is another one for real-time called “rt_matrx.h”. The problem is that some variables are defined in them differently (same name but with different definition). So, it seems it is not possible to compile a MEX file while in the real-time application because of the conflict between these two header files. When I run FAST in real-time environment it gives me a lot of errors that one of which for example is as follows:

“C:\Program Files\MATLAB\R2019b\extern\include\matrix.h(143): error C2371: ‘mxArray’: redefinition; different basic types
C:\Program Files\MATLAB\R2019b\rtw\c\src\rt_matrx.h(41): note: see declaration of ‘mxArray’”

To solve this problem, I think I shouldn’t compile the MEX file to avoid this conflict. Is there any way to run FAST in Simulink without using the MEX? Or is there exist any other solution for it?

Thanks
Best regards,
Sina

Dear Sina,

Thanks for the summary, which contains details I’m not familiar with. Sorry, but I’m not aware of other ways to interface FAST with Simulink.

Best regards,

Dear Dr. Jonkman,
Thanks again for your response. Yes, it is not directly related to the control section in FAST. Maybe, I should ask this any other forum sections. What about " Computer-Aided Engineering Software Tools" section? Do you know is there anybody to reply in it?
Thanks
Best regards,
Sina

Dear Sina,

I would guess most users of this forum check all of the forum categories, so, I don’t think there would be much benefit to posting the same question twice.

Best regards,

hello, i have just joined this NREL forum and i want to build a SCADA w/ HIL servers! very exciting, but i know nothing about it. Where should i read/post on this website to learn more and ask questions?

Dear @Ian.White,

I’m not sure what you mean by “SCADA w/ HIL servers”, but there have been several topics on this forum about hardware in the loop and software in the loop involving coupling OpenFAST with hardware.

Best regards,

1 Like

thanks for the response! so i want to purchase something like Simulink Real-Time - MATLAB and i want to configure my grid in the digital twin software/gui, and then export the settings to field devices… i’ve heard this is possible, is anyone out there doing that? thanks again and i’ll search around the site for OpenFAST… another quick question: for HIL, is the link i provided proprietary? is there an open-source option? i’m trying to research which system is best to purchase…

Dear @Ian.White,

I’ve not personally done this with Simulink Real Time, certainly this has been discussed here on this forum and on the OpenFAST GitHub repository (Issues · OpenFAST/openfast · GitHub, OpenFAST/openfast · Discussions · GitHub). At NREL, we developed similar real-time HIL approaches via the FAST-LabView interface.

Best regards

1 Like

ok, awesome! i will take a look at FAST-Labview… as a non-engineer consumer, the MATLAB product page is overwhelming… lot of software solutions out there… ok good stuff, i will take a look in the areas and links that you have provided, thanks! and thanks for helping everyone on this site! very technical forum, i don’t understand it, but i can see amazing collaboration and that is very inspiring, thanks!