Send CAN messages from MATLAB to ECU with PEAK device
17 ビュー (過去 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;
0 件のコメント
回答 (1 件)
Alexey Molchanov
2022 年 2 月 9 日
You need to set up correct speed for CAN interface before use it.
1 件のコメント
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 Center および File Exchange で Communications Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!