I am working on simple a stateflow using an Arudino Uno but I keep running into an error

3 次查看(过去 30 天)
I continue to receive this error message "The generated code exceeds the available memory on the processor. It uses 141.4% of available program memory and 46.6% of available Data memory", but my code is the exact same as other people in my class. It is a simple stateflow mechanism with two motor control subsystems. I even rebuild the code to simplify it, yet I still receive this error message.

回答(1 个)

Animesh
Animesh 2023-5-9
编辑:Animesh 2023-5-9
Hi Ryan,
I understand that you are trying to deploy a stateflow code on an Arduino Uno, but the generated code is exceeding available memory on the processor.
This error may occur because there may not be enough program memory on the target to properly execute the model in External mode.
Note that the Arduino Uno has 2 KB of SRAM for data, stack, and heap combined. https://docs.arduino.cc/learn/programming/memory-guide Note: this link is not published by MathWorks. Therefore, it is easy to run into memory limits on the Uno in external mode.
Some of the common factors that influence the SRAM used (the heap memory usage) and strategies that can be used to address the external mode memory constraints are listed below:
  1. Number of signals being logged: Having too many signal logging blocks can overload the memory on the Arduino. Thus, reducing the number of signals being logged at once can help.
  2. Size of the External Mode buffer: This value determines how many samples are collected in the External Mode buffer before transmitting them back to Simulink.
  3. Choice of solver: Continuous solvers use more memory than discrete solvers. Additionally, there are several continuous solver options, which you view under Configuration Parameters > Solver. Hence, if possible, use a discrete instead of a continuous solver. Or if you must use a continuous solver, choose the lowest order solver that meets your requirements. Note that the higher order solvers have higher numbers (e.g. ode8 is a higher order solver than ode5).
  4. Complexity of the model: Increasing the complexity of the model uses more memory on the Arduino. So, reducing the model complexity can help.
By implementing these suggestions, it may be possible to reduce the memory requirements of the model to fit under the constraints of the Arduino (Uno).
I hope this helps.
  2 个评论
William
William 2023-6-2
his issue is sram though, his issue is program memory. what do you do in the case where the program memory is exceeded? i see others running stateflow simulink programs on their arduinos of similar depth to my program (which isnt much) and theres run fine. Do you have any suggestions?\

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by