External Mode on a custom MCU for signal recording

4 ビュー (過去 30 日間)
Arne
Arne 2023 年 9 月 28 日
回答済み: Hari 2024 年 2 月 12 日
Is there an example project that demonstrates how to use external mode in serial from a custom target? In this project, Simulink is only responsible for a small task and cannot be built or deployed. The goal is to establish a read-only connection from Simulink to view signals on the log points within Simulink. Most examples assume that the target is controlled entirely by Simulink code, but in this case, only a few tasks are controlled by Simulink in real-time, while the rest are wrapped in an RTOS. How can I still connect via UART to Simulink for debugging while other tasks are running on the target?
All documentation assumes that the code comes with a support package for the target and is uploaded and compiled from within Simulink. However, using this approach leads to the wrong compiler being used and my other code not being implemented, and the RTOS is not running. Therefore, this is not an option. Since External Mode is only a server-client architecture, there should be some examples or explanations on how to integrate it. Why can't I find any resources for this? In my case, I don't need to tune parameters; reading signals and displaying them in Simulink is sufficient. I also don't want to start or stop; I would prefer to hook into the running application.

回答 (1 件)

Hari
Hari 2024 年 2 月 12 日
Hi Arne,
I understand that you want to use external mode in serial from a custom target, where Simulink controls only a subset of tasks while the rest are managed by an RTOS. You want to establish a read-only connection to view signals on log points within Simulink, without deploying or building Simulink-controlled code.
You can manually implement a communication protocol between your target system and Simulink using UART. You can then create a custom Simulink block to receive data over UART and display it in Simulink for debugging. Here is the pseudo code to do that:
% Custom Simulink block to receive data over UART
function customUARTBlock(block)
% Set block parameters
block.NumInputPorts = 0;
block.NumOutputPorts = 1;
block.OutputPort(1).DataTypeID = 0; % double data type
block.SampleTimes = [0, 0]; % Sample time
% Define outputs
block.OutputPort(1).Dimensions = 1;
block.OutputPort(1).SamplingMode = 'Sample';
% Register methods
block.RegBlockMethod('Outputs', @Output);
end
function Output(block)
% Receive data over UART
data = receiveDataOverUART(); % Your UART receiving function
% Output received data
block.OutputPort(1).Data = data;
end
Refer to the documentation of Simulink's S-Function Builder for creating custom blocks in Simulink.
Hope this helps!

カテゴリ

Help Center および File ExchangePrepare Model Inputs and Outputs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by