MATLAB Answers

How to compile a DLL file to be externally configured

4 views (last 30 days)
Diego Medina
Diego Medina on 15 Jan 2018
Hi all,
I'm learning about Embedded coder to automatically generate DLL from Simulink models to be used by 3rd parties.
I'm using the system target file ert_shrlib to obtain the DLL file from Simulink model.
I want to get an externally configurable DLL without using the less input ports as possible.
I have done some tests with simple blocks such as product or gain blocks, to generate DLL.
At this moment, I'm trying to configure a gain block by changing the its value in the workspace without a new compilation process.
I have used SimulinkParameter to set parameters with the storage classes SimulinkGlobal and ExportedGlobal but the DLL looks to be frozen with the gain value used when the DLL was generated.
If I want to change the gain value I need to rebuilt the DLL and this is not acceptable.
If I use the storage class ImportExtern I received an error when the DLL is compiled, saying that the gain value used in the model is undefined.
The SimulinkParameter is defined in the workspace, but in the generated C and H files I don't find any initialization of the gain value and no function to update this value (the gain is declared but not initialized). This is the reason of the error.
I think that I missed to click on some option that I must enable/disable to allow to use the data from workspace when the DLL compiled with the storage class ImportExtern.
Could anyone provide me some advice?
If anyone could provide another different approach to obtain the described behavior I will appreciate to hear about more option.
I have thought about using a header file full of defines to set initial values, but when I load the DLL file using the new header configuration, the gain value does not change from the value used when the DLL was generated.
Thank you in advance.

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!