Send CAN messages from MATLAB to ECU with PEAK device

14 次查看(过去 30 天)
Hi!
I am trying to send CAN messages from MATLAB to my connected ECU. I have a PCAN-USB FD (https://www.peak-system.com/PCAN-USB-FD.365.0.html?&L=1), so I start the channel (the third library is installed). Then, I open the database that contain the two message variables. Then, I transmit periodically the messages to this channel. (The code that I am running is below)
The problem is that when the data is transmited, the PEAK device is receiving these messages, but it does not transmit the messages to the CAN bus, for the ECU to receive them.
I don't know if I am doing something wrong, or if there is other way to communicate with my ECU using MATLAB and a PCAN-USB FD.
If someone know something about, it could be so helpful for me.
Thanks in advance.
Óscar.
%CAN TRANSMITED DATA TO THE USB
txCh = canChannel('PEAK-System', 'PCAN_USBBUS1'); % Construct CAN channel connected to specified device
start(txCh);
%%
db = canDatabase('file.dbc'); % Open the database and attach it to the CAN channels
txCh.Database=db;
msg1 = canMessage(db,'ECU_1'); % Definir el mensaje a extraer de .dbc
msg2 = canMessage(db,'ECU_2');
transmitPeriodic(txCh,msg1,'On',0.05); % Transmitir el mensaje a determinada frecuencia
transmitPeriodic(txCh,msg2,'On',0.05);
%%
msg1.Data= data_calculation(50);
msg2.Data = msg1.Data;

回答(1 个)

Alexey Molchanov
Alexey Molchanov 2022-2-9
You need to set up correct speed for CAN interface before use it.
  1 个评论
Timothy
Timothy 2024-6-3
I have the same issue as the orignial post. What do you mean by set up correct speed for CAN interface? The default bit rate should be fine for what Im trying to transmit, yet PCAN is receiving the meassages not transmitting them.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Communications Toolbox 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by