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

added 12mhz and CANopen support #84

Merged
merged 6 commits into from
Apr 2, 2023
Merged

Conversation

munzili
Copy link
Contributor

@munzili munzili commented Mar 30, 2023

This pull requests adds

  • CANopen support by setting sample point to 87.5% as close as possible
  • Adding new baudrates 10, 20, 50, 100 and 800kbps where possible
  • Adding 12mhz chips

@munzili munzili changed the title added 2mhz and CANopen support added 12mhz and CANopen support Mar 30, 2023
@munzili
Copy link
Contributor Author

munzili commented Mar 30, 2023

Baudrates calculation was done with:
https://www.kvaser.com/support/calculators/bit-timing-calculator/

@aentinger
Copy link
Member

Hi @munzili ☕ 👋

Thank you for your PR. However, I'm not entirely happy with it, i.e. You've computed different values for baud-rates that are already known to be working, i.e.

Before:

static CanBitRateConfig constexpr BitRate_250kBPS_16MHz  = {0x41, 0xF1, 0x85};

After:

static CanBitRateConfig constexpr BitRate_250kBPS_16MHz  = {0x01, 0xb5, 0x01};

That gives me little confidence in all the other values. Also I frankly don't have the time to manually check all the baud rates. I'm open to accept part of your changes but I'm not going to throw away baud-rates that I happen to know work - unless you take on the work of verifying all those baud rates on real hardware.

Since 12 MHz are new and you seem to want that, why not focus on that first?

@munzili
Copy link
Contributor Author

munzili commented Mar 30, 2023

Well, actually i need 12mhz support AND different baudrates.

if you wish, i change the PR to only support the new baudrates and the 12mhz chip and leave the old values. I tested 12mhz with 20kbps.

The new values should be conform with the CANopen standard based on this document https://www.can-cia.org/fileadmin/resources/documents/proceedings/2003_koppe.pdf by setting the baudrates and the sample point to the values defined in the document

@aentinger
Copy link
Member

if you wish, i change the PR to only support the new baudrates and the 12mhz chip and leave the old values. I tested 12mhz with 20kbps.

That would be an acceptable proposition.

@aentinger
Copy link
Member

Btw. controller type in your online calculator seems to only support MCP2510. Not sure on the difference though. Here seems to be another tool: https://intrepidcs.com/products/free-tools/mb-time-calculator/ . Anything you can do to increase my confidence in this change would be appreciated.

@munzili
Copy link
Contributor Author

munzili commented Mar 30, 2023

https://ww1.microchip.com/downloads/en/Appnotes/00872a.pdf

the MCP2515 is based on MCP2510 but CNF flags are equal except CNF3 7bit but this bit was not setted before too

@aentinger
Copy link
Member

The MCP2515 is based on MCP2510 but CNF flags are equal except CNF3 7bit but this bit was not setted before too

Works for me 👍 . Only the changes for 12 MHz then plus your missing baud rates.

@generationmake
Copy link
Contributor

Hi.
setting the sample point is a nice issue.

I think with the previous settings we have a sample point of 0.75.
In some settings a different sample point might be useful. So I highly support this topic.
But maybe we find a different approach to set the sample point. Unfortunately I havent seen any arduino can driver which supports this issue in a nice way.

@aentinger
Copy link
Member

aentinger commented Mar 31, 2023

So you'd offer to do some testing with these value @generationmake ?

Relevant for our applications are 250k/500k/1MBit/s at 16 MHz.

@github-actions
Copy link

Memory usage change @ 5c0f116

Board flash % RAM for global variables %
arduino:mbed_edge:edge_control 🔺 +64 - +64 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nano33ble 🔺 +64 - +64 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 +66 - +66 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrfox1200 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 +64 - +64 0.0 - 0.0 0 - 0 0.0 - 0.0
rp2040:rp2040:rpipico 🔺 +64 - +72 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/MCP2515-CAN-Sniffer
flash
% examples/MCP2515-CAN-Sniffer
RAM for global variables
% examples/MCP2515-Filter
flash
% examples/MCP2515-Filter
RAM for global variables
% examples/MCP2515-Loopback
flash
% examples/MCP2515-Loopback
RAM for global variables
%
arduino:mbed_edge:edge_control 64 0.01 0 0.0 64 0.01 0 0.0 64 0.01 0 0.0
arduino:mbed_nano:nano33ble 64 0.01 0 0.0 64 0.01 0 0.0 64 0.01 0 0.0
arduino:mbed_nano:nanorp2040connect 66 0.0 0 0.0 66 0.0 0 0.0 66 0.0 0 0.0
arduino:samd:mkr1000 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrfox1200 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrgsm1400 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrnb1500 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrvidor4000 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwan1300 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwan1310 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwifi1010 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrzero 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
esp32:esp32:esp32 64 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0
rp2040:rp2040:rpipico 64 0.0 0 0.0 72 0.0 0 0.0 72 0.0 0 0.0
Click for full report CSV
Board,examples/MCP2515-CAN-Sniffer<br>flash,%,examples/MCP2515-CAN-Sniffer<br>RAM for global variables,%,examples/MCP2515-Filter<br>flash,%,examples/MCP2515-Filter<br>RAM for global variables,%,examples/MCP2515-Loopback<br>flash,%,examples/MCP2515-Loopback<br>RAM for global variables,%
arduino:mbed_edge:edge_control,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0
arduino:mbed_nano:nano33ble,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0
arduino:mbed_nano:nanorp2040connect,66,0.0,0,0.0,66,0.0,0,0.0,66,0.0,0,0.0
arduino:samd:mkr1000,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrfox1200,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrgsm1400,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrnb1500,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrvidor4000,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwan1300,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwan1310,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwifi1010,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrzero,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
esp32:esp32:esp32,64,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0
rp2040:rp2040:rpipico,64,0.0,0,0.0,72,0.0,0,0.0,72,0.0,0,0.0

@munzili
Copy link
Contributor Author

munzili commented Apr 2, 2023

I have restored the original flag definitions

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

Memory usage change @ e059597

Board flash % RAM for global variables %
arduino:mbed_edge:edge_control 🔺 +64 - +64 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nano33ble 🔺 +64 - +64 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 +66 - +66 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7:target_core=cm4 N/A N/A N/A N/A
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:samd:mkr1000 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrfox1200 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 🔺 +64 - +68 +0.02 - +0.03 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 +64 - +64 0.0 - 0.0 0 - 0 0.0 - 0.0
rp2040:rp2040:rpipico 🔺 +64 - +72 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/MCP2515-CAN-Sniffer
flash
% examples/MCP2515-CAN-Sniffer
RAM for global variables
% examples/MCP2515-Filter
flash
% examples/MCP2515-Filter
RAM for global variables
% examples/MCP2515-Loopback
flash
% examples/MCP2515-Loopback
RAM for global variables
%
arduino:mbed_edge:edge_control 64 0.01 0 0.0 64 0.01 0 0.0 64 0.01 0 0.0
arduino:mbed_nano:nano33ble 64 0.01 0 0.0 64 0.01 0 0.0 64 0.01 0 0.0
arduino:mbed_nano:nanorp2040connect 66 0.0 0 0.0 66 0.0 0 0.0 66 0.0 0 0.0
arduino:mbed_portenta:envie_m7:target_core=cm4 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:samd:mkr1000 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrfox1200 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrgsm1400 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrnb1500 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrvidor4000 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwan1300 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwan1310 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrwifi1010 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
arduino:samd:mkrzero 64 0.02 0 0.0 64 0.02 0 0.0 68 0.03 0 0.0
esp32:esp32:esp32 64 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0
rp2040:rp2040:rpipico 64 0.0 0 0.0 72 0.0 0 0.0 72 0.0 0 0.0
Click for full report CSV
Board,examples/MCP2515-CAN-Sniffer<br>flash,%,examples/MCP2515-CAN-Sniffer<br>RAM for global variables,%,examples/MCP2515-Filter<br>flash,%,examples/MCP2515-Filter<br>RAM for global variables,%,examples/MCP2515-Loopback<br>flash,%,examples/MCP2515-Loopback<br>RAM for global variables,%
arduino:mbed_edge:edge_control,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0
arduino:mbed_nano:nano33ble,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0
arduino:mbed_nano:nanorp2040connect,66,0.0,0,0.0,66,0.0,0,0.0,66,0.0,0,0.0
arduino:mbed_portenta:envie_m7:target_core=cm4,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:samd:mkr1000,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrfox1200,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrgsm1400,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrnb1500,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrvidor4000,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwan1300,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwan1310,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrwifi1010,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
arduino:samd:mkrzero,64,0.02,0,0.0,64,0.02,0,0.0,68,0.03,0,0.0
esp32:esp32:esp32,64,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0
rp2040:rp2040:rpipico,64,0.0,0,0.0,72,0.0,0,0.0,72,0.0,0,0.0

Copy link
Member

@aentinger aentinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thank you @munzili ☕ 👋

@aentinger aentinger merged commit ab1141c into 107-systems:main Apr 2, 2023
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

Successfully merging this pull request may close these issues.

3 participants