Filter löschen
Filter löschen

Send CAN messages from MATLAB to ECU with PEAK device

15 Ansichten (letzte 30 Tage)
Óscar Poveda
Óscar Poveda am 12 Apr. 2021
Kommentiert: Timothy am 3 Jun. 2024
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;

Antworten (1)

Alexey Molchanov
Alexey Molchanov am 9 Feb. 2022
You need to set up correct speed for CAN interface before use it.
  1 Kommentar
Timothy
Timothy am 3 Jun. 2024
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Communications Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by