[Simulink Support Package for Arduino Hardware] CAN Recieve Block issue

13 vues (au cours des 30 derniers jours)
순호 권
순호 권 le 29 Déc 2024
Commenté : 순호 권 le 11 Fév 2025 à 9:06
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.

Réponses (2)

Rishav
Rishav le 13 Jan 2025
Hi 순호 권,
Please refer to the steps mentioned in the following MATLAB Answers post and let me know if that works for you:

Clement
Clement le 11 Fév 2025 à 7:32
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.

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by