I working on project and I am trying to get two STM32F767 Nucleo-144 to communicate through CAN bus. Nevertheless I cannot get them to communicate, I made the following circuit using MCP2551 :
https://drive.google.com/open?id=1GnbpI ... K_Wzlt8DIk
I flashed micropython using Dfuse from STMicroelectronics. The following code is on the transmitting microcontroller:
The following code is on the receiving microcontroller:
Code: Select all
# main.py import pyb from pyb import CAN led = pyb.LED(3) while True: led.toggle() pyb.delay(500) can = CAN(1, CAN.NORMAL, extframe=True, prescaler=8, sjw=4, bs1=13, bs2=13) can.send('1', 123) pyb.delay(500)
I was connecting to the wrong pins on the Nucleo-144 in the beginning but this seems to be fixed, I was also using the Analog read pins of an Arduino UNO to check the voltages on the CAN bus and the RX TX of both controllers. I Also tried to make the Nucleo-144 communicate with the Arduino UNO using the MCP2515 as shown on the picture below:
Code: Select all
# main.py -- put your code here! import pyb from pyb import CAN led = pyb.LED(3) aled = pyb.LED(2) while True: try: can = CAN(1, CAN.LOOPBACK, extframe=True, prescaler=8, sjw=4, bs1=13, bs2=13) (idr, isRTR, filterMatchIndex, telegram) = can.recv(0) if idr == 123 : aled.toggle() else: print("NOT working") except: led.toggle()
https://drive.google.com/open?id=1_gD6p ... KEOfU6ZlxP
Communication between two Arduinos is fine because they use the same libraries but even after playing around with the bit timing I did not manage to get the Arduino to read the right message and the right ID from the Nucleo board because I did not manage to find information on the bit timing from the mcp_can.h libraries.
https://drive.google.com/open?id=1WZuel ... 6DaoSxw1Q4
https://drive.google.com/open?id=1Ay_OM ... UVx0p-zO_Y
Something that I noticed is when I connect both Nucleo boards on the CAN bus in ''NORMAL'' mode with the command can = CAN(1, CAN.NORMAL, extframe=True, prescaler=8, sjw=4, bs1=13, bs2=13), then the CAN bus is silent having CANH and CANL remaining at 2.5V.
I would really appreciate some advice to continue on this project.