Live CAN message from Simulink to App Designer

5 views (last 30 days)
Hi all,
I am having issue with both Simulink and App designer due to Arduino Hardware limitation.
So my new approach is to read live CAN message via Simulink and bring that data to App designer.
I was able to run the simulation but it is running as just 'start' not 'monitor and tune' by using this code
set_param(app.ModelName,'SimulationCommand','Start')
Is there a way to programatically run 'monitor and tune' so I can run simulink via App Designer on Arduino?
Thanks!
  3 Comments
Min
Min on 1 Jul 2024
I am having an interesting error.
Warning:Non-scalar data in first argument to set_param is detected.
Only first handle in the matrix is processed.
simulink_root does not have a parameter named 'SimulationCommand'
Any reason why it isn't grabing the simulationcommand?
Thanks!
Min
Min on 1 Jul 2024
Another thing I found is that when I run it as "monitor and tune" the Simulink Model runs perfectly fine.
When I try to run the model as "Connect" it does not run but says
"Error:External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP internal error: timeout expired, in response to XCP CONNECT command"
Not sure what is causing this.
Thanks!

Sign in to comment.

Accepted Answer

Umar
Umar on 1 Jul 2024
Hi Min, Let me tackle your comments one at a time. So, for the first one that you mentioned,
I am having an interesting error.
Warning:Non-scalar data in first argument to set_param is detected. Only first handle in the matrix is processed. simulink_root does not have a parameter named 'SimulationCommand'
Any reason why it isn't grabing the simulationcommand?
In my opinion, when you receive the warning "Non-scalar data in the first argument to set_param is detected," it indicates that the function is expecting scalar data but is receiving non-scalar data, such as a matrix or cell array. To address this issue, ensure that the input to set_param is a scalar value.
Now, regarding the 'SimulationCommand' parameter not being recognized, double-check the spelling and case sensitivity of the parameter name. Make sure that 'SimulationCommand' is the correct parameter name for the block you are trying to modify. Additionally, verify that the block you are targeting supports the 'SimulationCommand' parameter.
Problem number 2, Another thing I found is that when I run it as "monitor and tune" the Simulink Model runs perfectly fine. When I try to run the model as "Connect" it does not run but says "Error:External Mode Open Protocol Connect command failed Caused by: Could not connect to target application: XCP internal error: timeout expired, in response to XCP CONNECT command" Not sure what is causing this.
In order to troubleshoot this problem, you may want to check the network configuration and ensure that there are no issues with connectivity. Additionally, it's important to verify that the target application is properly configured to accept connections from XCP. This may involve checking the settings within the target application and ensuring that it is set up to communicate with XCP without any restrictions or limitations.
Furthermore, it could be beneficial to review the system requirements for running the Simulink model in "Connect" mode. There may be specific hardware or software requirements that need to be met in order for the connection to be established successfully. In some cases, updating or reinstalling relevant drivers or software components may also help resolve communication issues between the target application and XCP.
Let me know if you further assistance.
  2 Comments
Min
Min on 2 Jul 2024
Hi Umar,
I was able to resolve the issue with some external help.
Found out that I was calling a = arduino from the script which was causing the arduino to overlap with the simulink connection. This was one of the problems.
Also, I have to follow a this script to run as monitor and tune mode.
set_param(app.ModelName,'SimulationMode','external');
set_param(app.ModelName,'SimulationCommand','connect');
set_param(app.ModelName,'SimulationCommand','start');
Without calling it as external and have it run will impact the simulink to run in a different mode.
Thanks!
Umar
Umar on 2 Jul 2024
Glad to find out that your problem is resolved. Happy 4th of July.

Sign in to comment.

More Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!