How can I have a data store that connect to out of model in Simulink system composer?
2 views (last 30 days)
Show older comments
Hello guys,
i have a project that i want implement on hardware with microcontroller (STM32f103VGT).
part of my project such as control unit, protocol unit , ... is in simulink and other parts such as GUI Control,Hardware control ,... are in other IDE (Keil IDE).
i need a global and shared data store in system composer and connect this data store to other part of project out of MATLAB.
i have a lot of variables and structures that are common between Simulink and other IDE. all variables after reset will back to initial values.
which tool or tools in system composer can help to make a global data store can convert to C code by EMBEDDED Coder?
0 Comments
Answers (1)
Umar
on 30 Jun 2024
Hi Hamid,
The following code snippet demonstrates how to create a global data store in System Composer for your STM32f103VGT project. It includes adding variables, structures, and connecting the data store to components outside MATLAB. Finally, it shows how to export the data store to C code using EMBEDDED Coder for integration with your project.
% Create a global data store in System Composer dataStore = systemcomposer.createDataStore('GlobalDataStore');
% Add variables and structures to the data store variable1 = systemcomposer.createVariable(dataStore, 'Variable1', 'DataType', 'double'); variable2 = systemcomposer.createVariable(dataStore, 'Variable2', 'DataType', 'int'); structure1 = systemcomposer.createStructure(dataStore, 'Structure1'); field1 = systemcomposer.createField(structure1, 'Field1', 'DataType', 'double'); field2 = systemcomposer.createField(structure1, 'Field2', 'DataType', 'int');
% Connect the data store to Simulink and other IDE components systemcomposer.connect(dataStore, 'SimulinkComponent'); systemcomposer.connect(dataStore, 'OtherIDEComponent');
% Generate C code using EMBEDDED Coder systemcomposer.exportToCode(dataStore, 'Target', 'C', 'Coder', 'EMBEDDED Coder');
0 Comments
See Also
Categories
Find more on System Composer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!