KevinOConnor / can2040

Software CAN bus implementation for rp2040 micro-controllers
GNU General Public License v3.0
686 stars 68 forks source link

Pico stops sending can message halfway through, then retries #43

Closed Nate711 closed 1 year ago

Nate711 commented 1 year ago

Hi, I was having no problems when talking between two can transceivers connected to the same pico, but now when I talk to an external device (mg4005 can bus bldc motor), the Pico seems to try to send a message, fails halfway, then retries successfully. Any idea what's going on? Thanks!

Screenshot 2023-06-12 at 10 42 55 PM
KevinOConnor commented 1 year ago

That certainly looks odd. Make sure you are on the very latest can2040 code as there were some recent changes to the handling of transmit messages.

-Kevin

Nate711 commented 1 year ago

Thanks for the response Kevin! I just checked and I'm using the latest main. It seems like I'm able to change how often these errors occur by changing the delay between sending messages. For instance, if I delay 200us between sending two CAN messages, the error rate seems to be low, like 1 in 10. However if I change that to 300us, it becomes maybe 1 in 2. Btw, the code I'm running is this: https://github.com/Nate711/can2040-test/blob/main/apps/mg4005_test.cc

Nate711 commented 1 year ago

I sort of resolved one issue: In addition to the half-formed can messages, the pico would often (~1 in 3 times) repeat even a successfully sent and ACKd message (see below). I reduced this occurrence to maybe 1 in 5 by just removing my print statement that happened every time CAN messages were sent. Oops! I didn't realize the USB comms would add irq latency. Still have fix the half-formed message problem...

Screenshot 2023-06-18 at 1 04 25 AM
Nate711 commented 1 year ago

Update: I removed the actuator and instead made CAN 1 talk to CAN 2 (both have transceivers) to see if the actuator was the issue. It was not. The program I used to test this sent 3 messages over can in a 1khz loop. Sometimes when I run my code, the 2nd message is always repeated, but sometimes if I restart the pico, the messages are totally fine. Maybe you can recreate this issue on your side. My code is: https://github.com/Nate711/can2040-test/blob/main/apps/dual_can_test.cc

Screenshot 2023-06-18 at 1 27 51 AM
KevinOConnor commented 1 year ago

Alas, I wont be able to help with code using can2040. A good test would be to see if you can reproduce the problem using known working code (Klipper) as described at https://github.com/KevinOConnor/can2040/blob/master/docs/Tools.md .

Cheers, -Kevin

github-actions[bot] commented 1 year ago

Hello,

It looks like there hasn't been any recent updates on this github ticket. We prefer to only list tickets as "open" if they are actively being worked on. Feel free to provide an update on this ticket. Otherwise the ticket will be automatically closed in a few days.

Best regards,

~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.