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.
STM Nucleo CAN Read and CAN Write blocks not working
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!