Replicate the Event-Driven Task in External Mode

조회 수: 5 (최근 30일)
Chao-Hwa Chen
Chao-Hwa Chen 2024년 8월 30일
댓글: Chao-Hwa Chen 2024년 9월 18일
I am trying to replicate the simulation results of the event-driven task in external mode. I ran in R2022a. My board is Zedboard. The solver is in fixed step.
After building and running it, it has several warnings, including
Saving external mode simulation output as a single object is not supported because the workspace variable 'out' is not created during model code execution. To suppress the warning, set 'ReturnWorkspaceOutputs' to 'off'.
No data has been selected for uploading.
When I open Data Inspector, the processed data is always zero. How to make the process data to generate the results like simulation?
  댓글 수: 5
Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 6일
I noticed that after "RUN ON HARDWARE" tab appeared, I clicked "Connect" and it failed to connect. Here is at the MATLAB console side:
>> set_param(gcs,'SimulationCommand','connect')
Warning: Timed out waiting for application to start.
> In codertarget.zynq.internal/LinuxShell/waitForAppToStart (line 432)
In codertarget.zynq.internal.extmodeHooks (line 51)
In coder.oneclick/CoderTargetHook/locEvalNoOutput
In coder.oneclick/CoderTargetHook/preExtModeConnectAction
In coder.oneclick.TargetHook.createOneClickObjAndConfigureModelForExtModeConnect
### Starting build procedure for: soc_task_sw
Attempting to establish connection with hostname '192.168.1.214' through port 17725.
Here is at the Simulink console side:
Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. Possible reasons for the failure:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.
Caused by:
An error occurred attempting to open an rtIOStream. More detail may be reported in the MATLAB command window
I shorted the model name to fix the maximum identifier length warning.
Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 10일
Here is another scenario.
After executing "Configure, Build & Deploy", the "Run on Hardware" tab appears. Instead of running "Monitor & Tune" first, I click "Connect" first.
Here is at the MATLAB console side:
### Using the SoC system information from 'C:\TCI\matlab\testTaskMaster23b\soc_prj\socsysinfo.mat'
Warning: Timed out waiting for application to start.
> In codertarget.zynq.internal/LinuxShell/waitForAppToStart (line 432)
In codertarget.zynq.internal.extmodeHooks (line 51)
In coder.oneclick/CoderTargetHook/locEvalNoOutput
In coder.oneclick/CoderTargetHook/preExtModeConnectAction
In coder.oneclick.TargetHook.createOneClickObjAndConfigureModelForExtModeConnect
In coder.internal.toolstrip/HardwareBoardHandler/extModeConnect (line 98)
In coder.internal.toolstrip/HardwareBoardContext/connectModelExtModeHardwareBoardActionCBInternal (line 125)
In coder.internal.toolstrip.HardwareBoardContext.connectModelExtModeHardwareBoardActionCB (line 302)
### Starting build procedure for: soc_task_sw
Here is at the Simulink model console side:
Could not execute target data map file 'soc_task_app_ert_rtw\soc_task_app_targ_data_map' or it does not exist.
Stop the target, delete the soc_task_app executable, rebuild the code, and try again. Note that execution of external mode requires the build directory to be present
The model is shorted to fix the maximum identifier length warning.

댓글을 달려면 로그인하십시오.

채택된 답변

Kautuk Raj
Kautuk Raj 2024년 9월 11일
I understand that you are encountering an error with the External Mode MEX-file 'ext_comm', which indicates a failure to connect to the target.
The error observed "Failed to connect to the target" indicates there is an issue with hardware connectivity.
The following workarounds can be tried to resolve the issue:
1. Check if you have configured the host computer as well as the radio hardware. The following documentation page can be referred to for more information on Guided Host-Radio Hardware setup: https://www.mathworks.com/help/releases/R2022a/supportpkg/xilinxzynqbasedradio/ug/hardware-and-software-requirements.html
2. Call the zynq function from MATLAB command prompt with the following syntax to make sure that MATLAB is set up with the correct physical IP address of the radio hardware.
devzynq = zynq('linux','192.168.3.2','root','root','/tmp');
Further, click on "Monitor & Tune" to check if the issue is resolved.
I trust this will assist you in resolving the connectivity issue.
  댓글 수: 4
Kautuk Raj
Kautuk Raj 2024년 9월 12일
There may be an issue with the hardware (Zedboard) being used, I suggest contacting MathWorks Technical Support for further investigation and troubleshooting at https://www.mathworks.com/support/contact_us.html
Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 12일
편집: Chao-Hwa Chen 2024년 9월 12일
I use your troubleshooting link and but fail to upload attachments. So I call MathWorks and have a representative showing me how to attach my files.Below are the post originally posted in Error or performance issues.
I am trying to replicate the Simulation results of Event-Driven Task at https://www.mathworks.com/help/soc/ug/event-driven-task-example.html. I can replicate the results in simulation (see eventTaskSim.jpg).
However, when I run the Event-Driven Task in external mode on Zedboard by clicking "Monitor & Tune", the Process Data is always zero (see external_sim.jpg). The Simulink console scripts is shown in externalModeScripts.txt.
After that, I try to click Connect under "Monitor & Tune", I experience hardware connection errors. connectMATLABConsole.txt shows the error in the MATLAB console and connectModelConsole.txt shows the error in the model console.
Here are the steps I have done.
(1) Burn an SD card by opening the Add-on Manager to click the Setup in SoC Blockset Support Package for Xilinx Devices and select Zedboard as the hardware board.
(2) Use Manually enter network setting to pass the connection test.
(3) Make sure the top model soc_simpleeventdriventtask_application.slx (truncated to soc_task_app.slx) and referenced model (soc_simpleeventdriventtask_software.slx (truncated to soc_task_sw.slx) select Zedboard as the hardware board.
(4) Click "Configure, Build & Deplay" and select "Build and load for external mode."
(5) Click "Monitor & Tune" to perform simulation in external mode, which has all zeros in Processed data.
(6) Click "Connect" under "Monitor & Tune" to generate errors in both MATLAB and Simulink consoles.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 13일
편집: Chao-Hwa Chen 2024년 9월 13일
However, rather than following Step 2 or Step 3, I did the following:
>> h = zynq;
>> h.openShell('ssh')
In the PuTTY shell, execute the following commands to run the application:
zynq> cd /tmp
zynq> ./soc_simpleeventdriventtask_application.elf
Then go back to soc_simpleeventdriventtask_application.slx and click "Connect" under "Monitor & Tune". After the connection is successful, the icon "Start" appears and click "Start" to start the simulation in external mode.
In short, the elf file has to run first before click "Connect".
Unfortunately, Process Data output is still all zero and the following warnings are still there.
For referenced models, external mode simulations do not support the following:
The use of blocks to view signals from the target application.
Tuning or uploading of model parameters.
Component:Simulink | Category:Model warning
Saving external mode simulation output as a single object is not supported because the workspace variable 'out' is not created during model code execution. To suppress the warning, set 'ReturnWorkspaceOutputs' to 'off'.
Component:Simulink | Category:Model warning
No data has been selected for uploading.
Component:Simulink | Category:Model warning
  댓글 수: 2
Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 16일
In the generated C code, I added printouts for the both the input and the output.
In the function soc_simpleeventdriventtask_application_step1 of file soc_simpleeventdriventtask_application.c, I add printf after rtb_ProcessedData
rtb_ProcessedData = soc_task_app_B.ProcessedData;
(void)printf("Output: %f\n",soc_task_app_B.ProcessedData);
In the function soc_simpleeventdriventtask_application_step1 of file soc_simpleeventdriventtask_application.c, I add printf after
soc_task_app_B.OriginalData = soc_task_app_DW.NextOutput;
(void)printf("Input: %f\n",soc_task_app_DW.NextOutput);
After clicking "Monitor & Tune," I went to the hardware console and printed out the log statements:
Output: 0.000000
Input: 1.164954
Output: 0.000000
Output: 0.000000
Input: 0.626839
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: 0.075080
Output: 0.000000
Output: 0.000000
Input: 0.351607
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: -0.696513
Output: 0.000000
Output: 0.000000
Input: 1.696142
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: 0.059060
Output: 0.000000
Output: 0.000000
Input: 1.797072
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: 0.264069
Output: 0.000000
Output: 0.000000
Input: 0.871673
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: -1.446172
Output: 0.000000
Output: 0.000000
Input: -0.701165
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: 1.245982
Output: 0.000000
Output: 0.000000
Input: -0.638977
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: 0.577350
Output: 0.000000
Output: 0.000000
Input: -0.360030
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: -0.135576
Output: 0.000000
Output: 0.000000
Input: -1.349338
Output: 0.000000
Output: 0.000000
Output: 0.000000
Input: -1.270450
Output: 0.000000
Output: 0.000000
Input: 0.984570
Output: 0.000000
Output: 0.000000
Hope those findings help.
Chao-Hwa Chen
Chao-Hwa Chen 2024년 9월 18일
After further reading the simulation data inspector, the UDPRead is in the waiting mode throughout the simulation. That is why the Processed Data signal is always zero.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Processor Software에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by