STM Nucleo CAN Read and CAN Write blocks not working

조회 수: 7 (최근 30일)
Joris Bonnema
Joris Bonnema 2021년 6월 25일
답변: nguyen nhan tinh 2023년 1월 23일
Hello,
I am trying to make a Nucleo H743ZI2 communicate over CAN, and programming it via Simulink. For this I have installed the 'Simulink Coder Support Package for STMicroelectronics Nucleo Boards', and also the 'Vehicle Network Toolbox'. Connected to the Nucleo I've got an MCP2551 CAN transceiver, where the receive pin is connected to Nucleo pin PB8, and the transmit pin to PB9. It's powered with 5V from the Nucleo as well. A resistor connects the Rs pin from the transceiver to GND.
The problem is that both CAN Read and CAN Write blocks do not seem to do anything. On the other end of the simple CAN network I am using an Arduino Nano with an MCP2515 chip to read and send out CAN messages. With MBED, I got the Nucleo to read CAN messages sent by the Arduino, to confirm that the hardware works. At the same time, I am able to connect with Simulink to the Nucleo, make the user LEDs blink and also read out signals via the external mode.
I have gone through all the hardware settings a million times, so I am confident that settings like baudrate, com ports, send and receive IDs etc. are set correctly. I do have a small question related to this: are 'module' 0 and 1 specified in the CAN Read and CAN Write blocks the same as CAN0(default) and CAN1 in the Hardware board settings? I have both set to 0.
I have measured the CAN signals with an oscilloscope, which shows some weird behavior. The Arduino sends a CAN message every 0.5 seconds, but when programming the Nucleo through Simulink instead of MBED, the same bit sequence of what appears to be a CAN message is repeated every 200us. This also happens when programming the Nucleo with Simulink if no CAN blocks are used. So somehow the effect of coding with Simulink affects the CAN network, which MBED does not do.
When making the Nucleo write a message and using the Arduino to read it, it does not receive any messages. Measuring the canbus with the oscilloscope reveals a single bit is being sent every sample time (from the constants that I'm sending), but no proper messages. The CAN Write block status however gives 1, so it is clearly (trying to) write.
It would be greatly appreciate if anyone can help me out with this. I can only attach 1 picture, so I posted an image of the test model. I always comment either the CAN Read block or the CAN Write block out, for simplicity's sake.
  댓글 수: 2
Joris Bonnema
Joris Bonnema 2021년 6월 25일
I also already tried to use the CAN blocks from the Vehicle Network Toolbox, but I could not figure out how to add the Nucleo board as a CAN channel to the list.
Adrsch3p
Adrsch3p 2022년 5월 11일
Hi Joris, have you got any solution to this?

댓글을 달려면 로그인하십시오.

답변 (1개)

nguyen nhan tinh
nguyen nhan tinh 2023년 1월 23일
@Joris Bonnema I have a solution in here

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by