Notifications
Clear all

Strange results with CAN bus

3 Posts
3 Users
1 Likes
188 Views
(@kdemotorsports)
Member
Joined: 7 months ago
Posts: 5
Topic starter  

I've been doing a number of projects with CAN and I'm observing very odd behaviors across different ESP32's. I have a working ESP32S3 based CAN project that reads CAN data from a motorcycle. This seemed to go well so I then had another project where I wanted to create a CAN network and have all the MCU's send / receive with other MCU's. So I opted for more ESP32S3's and couldn't get sending to work at all. No errors just the data either didn't show up or the data showed up and the length of the message was correct but the data was all zero's. I then reverted back to some ESP32-WROOM-32 modules I had laying around and these work fully. Sending and receiving everything is fine. These are the 30 pin dev kits. So I figured ok I'll just use the ESP32-WROOM-32 modules for my projects but wanted a smaller devkit. I ordered a couple of the D1 Mini ESP32 boards. Wired them up exactly the same as the 30 pin dev kits and loaded the same code. No luck, no messages showing up. Sending reports no errors but the data doesn't show up even on one of the 30 pin boards. Now between the ESP32 and the ESP32S3's they do use twai libraries vs the CAN bus libraries. My question though is why is there so much difficulty in getting consistent results between different MCU's? Why are the ESP32S3's ok reading but won't send? Why would two different ESP-WROOM-32 based dev kits behave differently?

 

Any help is greatly appreciated, this has me puzzled.


   
Quote
(@davee)
Member
Joined: 3 years ago
Posts: 1686
 

Hi @kdemotorsports,

  Sorry, it is a very long time since I looked at CAN, and never with ESP32 family, so this is just a stab in the dark with my eyes closed.

Is the problem that the messages are not physically being received without errors? Does the software report timeouts, corrupt messages, and so on, if they occur? Or do the routines simply return at timeout, having failed to capture a valid message? I wondered if the error reporting was sufficiently robust to provide an accurate picture.

I have a 'vague' impression, from some conversations in the distant past, that CAN requires the bit rates to be fairly accurate ... or more precisely, it requires all of the nodes to have closely matched actual bit rates. I am not clear how well the ESP32s being delivered meet these requirements. As you reported different batches and module types behave differently, I wondered if this could be a factor.

Of course, other things, like mismatched terminations, etc. can also mangle the signals and give lots of errors.

Of course, this is 100% speculation on my part ... just suggestions that you might want to check up.

Best wishes and good luck, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

kdemotorsports I have no CAN experience, but the first thing I would look into is if you are using the 'correct' board libraries. What I mean by that is you have specified in the IDE the SPECIFIC board you are using rather than a generic Dev kit. I assume you have checked the board datasheet's to ensure they 'fully' support CAN. 

Another possibility is if they are 'clone' boards then who knows.

I see you mention a different library, that can be dangerous. Try to stick with the larger better known suppliers like Adafruit or Sparkfun.

Screenshot 2024 03 14 at 07.37.50

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote