Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adafruit RP2040 CAN Bus Feather??? #1

Open
karu2003 opened this issue Dec 1, 2024 · 17 comments
Open

Adafruit RP2040 CAN Bus Feather??? #1

karu2003 opened this issue Dec 1, 2024 · 17 comments

Comments

@karu2003
Copy link

karu2003 commented Dec 1, 2024

Hi, have you tried adapting your project for Adafruit RP2040 CAN Bus Feather?
https://www.adafruit.com/product/5724 there is another crystal and other gpios.

@trnila
Copy link
Owner

trnila commented Dec 1, 2024

Hello, unfortunately I dont have this board for testing.
I see you are already having branch, so you can let me know once its working or you are having some issue.

@karu2003
Copy link
Author

karu2003 commented Dec 2, 2024

I have not worked with RP2040. And I do not know all the features of the SPI interface. I changed the SPI settings and changed the quartz frequency. It does not work. I need a speed of 1000000. I connected two CAN interfaces and connected them on a cable. I checked who transmits and who receives. Your adapter transmits five... CANsend, and then goes into nirvana. I look messages on another CAN. Candump does not work at all.

@trnila
Copy link
Owner

trnila commented Dec 2, 2024

I will take a look, i have ordered the board.

@trnila
Copy link
Owner

trnila commented Dec 5, 2024

Got it working on latest master. Can you try flashing gs_usb_ADAFRUIT_CAN_FEATHER.uf2 firmware?

@karu2003
Copy link
Author

karu2003 commented Dec 6, 2024

thank you. the cansend, candump works. it seems that extended packages are not supported. DroneCan Gui does not see anything.

sudo ip link set can1 up type can bitrate 1000000

You can run two copies of DroneCan Gui on different interfaces and connect them with a cable.

@trnila
Copy link
Owner

trnila commented Dec 6, 2024

29bit extended message ids are supported, but CAN-FD with up 64 bytes of payload is not supported with MCP25625 chip. So you can send just standard CAN frames with payload up to 8 bytes.

@karu2003
Copy link
Author

karu2003 commented Dec 6, 2024

I don't use CAN-FD. Just run DroneCan Gui. You won't see anything. DroneCan word only extended message ids.

@trnila
Copy link
Owner

trnila commented Dec 8, 2024

There was issue in USB communication with received CAN frames - they should be sent individually and not batched.
Can you retry latest master?

@karu2003
Copy link
Author

karu2003 commented Dec 8, 2024

On my PEAK I see that a new node has appeared. But on rp2040-can-mcp2515 I don't see the PEAK node or other devices. :(

@karu2003
Copy link
Author

karu2003 commented Dec 8, 2024

PXL_20241208_182015346.MP.jpg

@trnila
Copy link
Owner

trnila commented Dec 8, 2024

can you try setting MCP2515_TX_BUFS to 1 in main.c?

dronecan splits bigger messages into several CAN messages with same CAN ID and the sent order is important to join messages

@karu2003
Copy link
Author

karu2003 commented Dec 9, 2024

I tried buffer 1 and both one. nothing is visible. I think the problem is not in transmission, but in reception. Maybe the timing is not set correctly?

@trnila
Copy link
Owner

trnila commented Dec 9, 2024

Can you reflash with modification again and verify if you are receiving messages via candump when dronecan is running? Is there any error output when running dronegui from terminal?
Can you also run tests?

$ RP2040_IFACE=can0 TEST_IFACE=can2 pytest -v

change can0 and can2 to match your setup. There should be no fail.

and stress testing for both directions:

$ make -C tests stress && ./tests/stress can0 can2
$ make -C tests stress && ./tests/stress can2 can0

I had around 4000 messages per second, and buffer= should not increase. Its a number of messages that werent received at all.

@karu2003
Copy link
Author

FAILED tests/hw_test.py::test_msgids[rp2040_receiver-0x1-extended] - assert None
FAILED tests/hw_test.py::test_msgids[rp2040_receiver-0x42-extended] - assert None
FAILED tests/hw_test.py::test_msgids[rp2040_receiver-0x7ff-extended] - assert None
FAILED tests/hw_test.py::test_msgids[rp2040_receiver-0x800-extended] - assert None
FAILED tests/hw_test.py::test_msgids[rp2040_receiver-0x1fffffff-extended] - assert None
FAILED tests/hw_test.py::test_bitrates[rp2040_receiver-125000] - AttributeError: 'NoneType' object has no attribute 'arbitration_id'
FAILED tests/hw_test.py::test_bitrates[rp2040_receiver-250000] - AttributeError: 'NoneType' object has no attribute 'arbitration_id'
FAILED tests/hw_test.py::test_bitrates[rp2040_receiver-500000] - AttributeError: 'NoneType' object has no attribute 'arbitration_id'

@trnila
Copy link
Owner

trnila commented Dec 12, 2024

hmm, did you just change MCP2515_TX_BUFS to 1?

Are all these tests failing everytime or randomly? Is it reproducible if you reconnect it in usb? maybe without hubs etc...

@karu2003
Copy link
Author

everytime, without hubs. :(

@trnila
Copy link
Owner

trnila commented Dec 20, 2024

Sorry about delay, but I am still not able to reproduce any issue on two hardwares I have :(

Tests cannot receive extended frames - this is really strange. Can you check CAN bus termination? you should be able to measure 60 ohm between HIGH and LOW. There should be 120 Ohm resistor on both furthest ends of the bus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants