[Simulink Support Package for Arduino Hardware] CAN Recieve Block issue
13 次查看(过去 30 天)
显示 更早的评论
Hello,
I am a student currently using the Simulink Support Package for Arduino Hardware to implement CAN communication.
The issue I am facing is that the CAN Receive block does not receive any data when messages are sent using an Extended ID. I am using an Arduino MKR WiFi 1010 along with the MKR CAN Shield. My Simulink model is used to send CAN messages to a motor and receive CAN messages from the motor.
The Simulink model (I attach the file.) I created, along with the configurations for the CAN Transmit and CAN Receive blocks, which are shown below. (The Fixed Step Size is set to 0.002.)


To verify the transmitted values, I used a ‘USB to CAN Analyzer’. (link: https://www.seeedstudio.com/USB-CAN-Analyzer-p-2888.html?srsltid=AfmBOooUz103F-Q3hiV6ocaQKvJwR2POvokjnFucYIHxf77tjr7DDkJe) As a result, I confirmed that messages with Extended IDs 0x302 (=770)and 0x2902 (10498) exist on the bus. (0x302: Arduino transmit, 0x2902 Arduino receive)


However, when checking the results from the To Workspace block, I found that no data is being received, unlike what I observed with the USB CAN Analyzer.

To rule out a hardware issue, I also tested with the MATLAB Support Package for Arduino Hardware, and it worked correctly. The MATLAB code (attached) successfully received messages.

clear arduinoMKRObj;
clear rxObj1;
%% MKR
arduinoMKRObj = arduino('COM18','MKR1010','Libraries','CAN')
rxObj1 = canChannel(arduinoMKRObj, 'MKR CAN Shield',"BusSpeed", 1000e3)
runtime = 10; % time to read (s)
tic; % start reading
while toc < runtime
% read data
readMsg = read(rxObj1);
if ~isempty(readMsg)
disp('Data received:');
disp(readMsg);
else
disp('No data received');
end
end
What should I do next? Could this be a Simulink-related issue? Any help would be greatly appreciated.
Thank you.
0 个评论
回答(2 个)
Rishav
2025-1-13
Hi 순호 권,
Please refer to the steps mentioned in the following MATLAB Answers post and let me know if that works for you:
0 个评论
Clement
2025-2-11
Hi @순호 권
Have you tried checking the target hardware resources in the Configuration Parameters (Hardware Settings), and ticked "Allow All Messages" in CAN Properties?
I had the same problem where I stumbled across your question, and it turns out that I hadn't ticked this checkbox when deploying the model the first time around.

另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!