From 840146c7553a01c51b143eb68aff4a56220da487 Mon Sep 17 00:00:00 2001 From: "I. Tomita" Date: Mon, 20 Oct 2025 18:55:53 +0300 Subject: [PATCH 1/3] Add advanced bit rate documentation --- content/components/canbus/esp32_can.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/content/components/canbus/esp32_can.md b/content/components/canbus/esp32_can.md index 68c78ca75a..777704a0a7 100644 --- a/content/components/canbus/esp32_can.md +++ b/content/components/canbus/esp32_can.md @@ -20,6 +20,10 @@ canbus: rx_pin: GPIOXX can_id: 4 bit_rate: 50kbps + advanced_bit_rate: + prescaler: 80 + tseg_1: 15 + tseg_2: 4 on_frame: ... ``` @@ -32,7 +36,7 @@ canbus: - **tx_queue_len** (*Optional*, int): Length of TX queue, 0 to disable. - **tx_enqueue_timeout** (*Optional*, [Time](#config-time)): Maximum time to wait when the TX queue is full before dropping the message (by default, this is set to the time it takes to send 10 CAN messages at the given bit rate). - +- **advanced_bit_rate** (*Optional*): When present, overrides the bit_rate setting and allows fine tunning of the bit rate. - All other options from [Canbus](#config-canbus). {{< anchor "esp32-can-bit-rate" >}} @@ -62,6 +66,16 @@ The following table lists the bit rates supported by the component for ESP32 var | 800KBPS | x | x | x | x | x | x | | 1000KBPS | x | x | x | x | x | x | +## Advanced bit rate option +- **prescaler** (**Required**, int): Prescaler to compute the time quanta. +- **tseg_1** (**Required**, int): An integer between 1 and 16. +- **tseg_2** (**Required**, int): An integer between 1 and 8. + +The bit rate is computed as: +$$bit\_rate = {{80 MHz} \over prescaler * (1 + tseg\_1 + tseg\_2)}$$ + +**tseg_1** and **tseg_2** control the moment the signal is being sampled. + ## Wiring options 5V CAN transceivers are cheap and generate compliant levels. If you power your From e0a5001155753505390c511a3fab4422373901fd Mon Sep 17 00:00:00 2001 From: "I. Tomita" Date: Mon, 20 Oct 2025 18:57:09 +0300 Subject: [PATCH 2/3] Fix formula --- content/components/canbus/esp32_can.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/components/canbus/esp32_can.md b/content/components/canbus/esp32_can.md index 777704a0a7..8bc96bfae5 100644 --- a/content/components/canbus/esp32_can.md +++ b/content/components/canbus/esp32_can.md @@ -72,7 +72,7 @@ The following table lists the bit rates supported by the component for ESP32 var - **tseg_2** (**Required**, int): An integer between 1 and 8. The bit rate is computed as: -$$bit\_rate = {{80 MHz} \over prescaler * (1 + tseg\_1 + tseg\_2)}$$ +$$bit_rate = {{80 MHz} \over prescaler * (1 + tseg_1 + tseg_2)}$$ **tseg_1** and **tseg_2** control the moment the signal is being sampled. From dc66a3a2abcd2d974f04436782fcbac7b530dc8d Mon Sep 17 00:00:00 2001 From: "I. Tomita" Date: Mon, 20 Oct 2025 19:02:29 +0300 Subject: [PATCH 3/3] Fix formatting; Fix formula --- content/components/canbus/esp32_can.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/components/canbus/esp32_can.md b/content/components/canbus/esp32_can.md index 8bc96bfae5..00b10eb5d4 100644 --- a/content/components/canbus/esp32_can.md +++ b/content/components/canbus/esp32_can.md @@ -67,12 +67,14 @@ The following table lists the bit rates supported by the component for ESP32 var | 1000KBPS | x | x | x | x | x | x | ## Advanced bit rate option + - **prescaler** (**Required**, int): Prescaler to compute the time quanta. - **tseg_1** (**Required**, int): An integer between 1 and 16. - **tseg_2** (**Required**, int): An integer between 1 and 8. The bit rate is computed as: -$$bit_rate = {{80 MHz} \over prescaler * (1 + tseg_1 + tseg_2)}$$ + +$$bit\\_rate = {{80 MHz} \over prescaler * (1 + tseg\\_1 + tseg\\_2)}$$ **tseg_1** and **tseg_2** control the moment the signal is being sampled.