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

4 views (last 30 days)
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.

Answers (1)

Animesh
Animesh on 9 May 2023
Edited: Animesh on 9 May 2023
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 Comments
William
William on 2 Jun 2023
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?\

Sign in to comment.

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!