From 725d4a09714c85a71196c4484cccd61894d6595e Mon Sep 17 00:00:00 2001 From: Manush Date: Wed, 23 Oct 2024 00:22:13 -0400 Subject: [PATCH 1/9] Equation for Can Traffic --- docs/docs/can-traffic.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 docs/docs/can-traffic.md diff --git a/docs/docs/can-traffic.md b/docs/docs/can-traffic.md new file mode 100644 index 000000000..489c16edc --- /dev/null +++ b/docs/docs/can-traffic.md @@ -0,0 +1,38 @@ +--- +title: Calculating CAN traffic on a bus +--- + + + +In order to calculate the CAN load, we must declare a few variables and their importance within the CANbus protocol. + +1. Baud: (kbaud) + +The baud rate is the rate at which data is transfered in a communication channel (like CAN). For example, 9600 Baud rate is 9600 bits per second + +2. Frequency (Hz) + +Frequency in the CANbus refers to how many CAN frames (or messages) are transmitted per second. So the greater the frequency, the more bits transferred, increasing the bus load. + +3. Total Data Per Cycle + +Total data per cycle includes all the bits transmitted in one CAN message. This includes not only the payload but overhead bits like start of frame, CRC, acknowledgement, control field etc. + + + +## The bus load is determined by: + +![Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{\text{Number%20of%20Bits%20per%20Frame}%20\times%20\text{Number%20of%20Frames%20per%20Second}}{\text{CAN%20Speed}}%20\times%20100) + +![Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{\text{Total%20Bits%20per%20Second}}{\text{CAN%20Speed}}%20\times%20100) + +## Sample calculation: + +Total data/cycle: 1524 (bits per cycle) + +Frequency: 200 (cycles per second) + +Baud Rate: 500 kbaud (500,000 bits transferred per second) + +![Solved Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{1,524%20\times%20200}{500,000}%20\times%20100%20=%2060.96\%) + From 4ecb224b0b01f09007afb65d45ada27e07e12253 Mon Sep 17 00:00:00 2001 From: Manush Date: Mon, 28 Oct 2024 15:10:39 -0400 Subject: [PATCH 2/9] moves cantraffic into firmware folder --- docs/docs/{ => firmware}/can-traffic.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/docs/{ => firmware}/can-traffic.md (100%) diff --git a/docs/docs/can-traffic.md b/docs/docs/firmware/can-traffic.md similarity index 100% rename from docs/docs/can-traffic.md rename to docs/docs/firmware/can-traffic.md From 1b3b78f06d012c9067b5334d3f5a50eb854fa52b Mon Sep 17 00:00:00 2001 From: Manush Date: Tue, 29 Oct 2024 18:32:48 -0400 Subject: [PATCH 3/9] Updated CAN traffic equation and added new Javascript file for support --- docs/docs/firmware/can-traffic.md | 42 +++++++++++++++---------- docs/docs/firmware/javascripts/katex.js | 12 +++++++ docs/mkdocs.yml | 9 +++++- 3 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 docs/docs/firmware/javascripts/katex.js diff --git a/docs/docs/firmware/can-traffic.md b/docs/docs/firmware/can-traffic.md index 489c16edc..fc2dd22cb 100644 --- a/docs/docs/firmware/can-traffic.md +++ b/docs/docs/firmware/can-traffic.md @@ -1,38 +1,46 @@ ---- -title: Calculating CAN traffic on a bus ---- +# Calculating CAN traffic +In order to calculate the CAN load, we must declare a few variables and their importance within the CAN protocol. -In order to calculate the CAN load, we must declare a few variables and their importance within the CANbus protocol. - -1. Baud: (kbaud) +## Baud (kbaud) The baud rate is the rate at which data is transfered in a communication channel (like CAN). For example, 9600 Baud rate is 9600 bits per second -2. Frequency (Hz) +## Frequency (Hz) -Frequency in the CANbus refers to how many CAN frames (or messages) are transmitted per second. So the greater the frequency, the more bits transferred, increasing the bus load. +Frequency is the number of messages transmitted per second for each message type. Different messages can have different frequencies. -3. Total Data Per Cycle +This variation affects the total bits transferred and, in turn, the bus load. To calculate bits per second, consider each message’s frequency and whether their lengths differ. -Total data per cycle includes all the bits transmitted in one CAN message. This includes not only the payload but overhead bits like start of frame, CRC, acknowledgement, control field etc. +## Total Data Per Cycle +Total data per cycle includes all the bits transmitted in one CAN message. This includes the payload and overhead bits like the start of frame, CRC, acknowledgment, control field, etc. +## The bus load is determined by -## The bus load is determined by: +$$ +\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i\right) +$$ -![Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{\text{Number%20of%20Bits%20per%20Frame}%20\times%20\text{Number%20of%20Frames%20per%20Second}}{\text{CAN%20Speed}}%20\times%20100) +$$ +\text{Bus Load (%)} = \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100 +$$ -![Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{\text{Total%20Bits%20per%20Second}}{\text{CAN%20Speed}}%20\times%20100) +## Sample calculation -## Sample calculation: +**Given**: -Total data/cycle: 1524 (bits per cycle) +Battery Status: Frequency = 100Hz, Length = 400 bits -Frequency: 200 (cycles per second) +Motor Control: Frequency = 50Hz, Length = 100 bits Baud Rate: 500 kbaud (500,000 bits transferred per second) -![Solved Bus Load Formula](https://latex.codecogs.com/png.latex?\text{Bus%20Load%20(\%)}%20=%20\frac{1,524%20\times%20200}{500,000}%20\times%20100%20=%2060.96\%) +$$ +\text{Total Bits Per Second} = (100 \times 400) + (50 \times 100) = 40,000 + 5,000 = 45,000 \text{ bits per second} +$$ +$$ +\text{Bus Load} = \left(\frac{45,000}{500,000}\right) \times 100 = 9\% +$$ diff --git a/docs/docs/firmware/javascripts/katex.js b/docs/docs/firmware/javascripts/katex.js new file mode 100644 index 000000000..a5f871323 --- /dev/null +++ b/docs/docs/firmware/javascripts/katex.js @@ -0,0 +1,12 @@ +document$.subscribe(({ body }) => { + + + renderMathInElement(body, { + delimiters: [ + { left: "$$", right: "$$", display: true }, + { left: "$", right: "$", display: false }, + { left: "\\(", right: "\\)", display: false }, + { left: "\\[", right: "\\]", display: true } + ], + }) + }) \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 039a2765c..cbac98c0e 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -33,6 +33,10 @@ theme: extra_css: - stylesheets/extra.css +extra_javascript: + - javascripts/mathjax.js + - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js + copyright: Copyright © McMaster Formula Electric plugins: @@ -73,7 +77,7 @@ plugins: markdown_extensions: - admonition - - abbr + # - abbr - attr_list - md_in_html - pymdownx.details @@ -91,6 +95,8 @@ markdown_extensions: base_path: - !relative - !relative $docs_dir/../ + - pymdownx.arithmatex: + generic: true repo_url: https://github.com/macformula/racecar repo_name: macformula/racecar @@ -123,6 +129,7 @@ nav: - firmware/architecture.md - firmware/project-structure/index.md - firmware/compile-project.md + - firmware/can-traffic.md - Glossary: glossary.md watch: From da2e4fc326c25645e5515d23fdd053df4a3b12ee Mon Sep 17 00:00:00 2001 From: Manush Date: Mon, 4 Nov 2024 13:36:01 -0500 Subject: [PATCH 4/9] message --- docs/docs/assets/canbusdiagram.svg | 1 + docs/docs/firmware/can-traffic.md | 70 ++++++++++++++----- docs/{docs/firmware => }/javascripts/katex.js | 2 - docs/mkdocs.yml | 6 +- 4 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 docs/docs/assets/canbusdiagram.svg rename docs/{docs/firmware => }/javascripts/katex.js (99%) diff --git a/docs/docs/assets/canbusdiagram.svg b/docs/docs/assets/canbusdiagram.svg new file mode 100644 index 000000000..b5f857c75 --- /dev/null +++ b/docs/docs/assets/canbusdiagram.svg @@ -0,0 +1 @@ +Standard CAN frameSOFIDRTRControlDataCRCACKEOF111160-641627Start ofFrameStandardIdentifierRemote Trans-mission RequestCyclic RedundancyCheckAcknow-ledgementEnd of Frame#bits \ No newline at end of file diff --git a/docs/docs/firmware/can-traffic.md b/docs/docs/firmware/can-traffic.md index fc2dd22cb..89dd004bd 100644 --- a/docs/docs/firmware/can-traffic.md +++ b/docs/docs/firmware/can-traffic.md @@ -3,44 +3,78 @@ In order to calculate the CAN load, we must declare a few variables and their importance within the CAN protocol. -## Baud (kbaud) +## Baud The baud rate is the rate at which data is transfered in a communication channel (like CAN). For example, 9600 Baud rate is 9600 bits per second -## Frequency (Hz) +## Frequency -Frequency is the number of messages transmitted per second for each message type. Different messages can have different frequencies. +The frequency of a message, expressed in (Hz), is how often a message is transmitted per second. Different messages can have different frequencies. -This variation affects the total bits transferred and, in turn, the bus load. To calculate bits per second, consider each message’s frequency and whether their lengths differ. +This variation affects the total bits transmitted and, in turn, the bus load. To calculate bits per second, consider each message’s frequency and whether their lengths differ. -## Total Data Per Cycle +## Message Length -Total data per cycle includes all the bits transmitted in one CAN message. This includes the payload and overhead bits like the start of frame, CRC, acknowledgment, control field, etc. +The message length in a CAN frame can be calculated as a function of the data length. This calculation includes several fixed fields and a variable data field, which changes based on the message's data content. -## The bus load is determined by +![CAN Frame Diagram](../assets/canbusdiagram.svg) -$$ -\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i\right) -$$ +*Figure: CAN Bus Frame Diagram. Source: [CSS Electronics CAN Bus Tutorial](https://www.csselectronics.com/pages/can-bus-simple-intro-tutorial#can-bus-frames)* -$$ -\text{Bus Load (%)} = \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100 -$$ +Each CAN frame consists of several fields with fixed bit lengths, plus a variable-length data field. Here’s the breakdown: + +- **Start of Frame (SOF)**: 1 bit +- **Identifier (ID)**: 11 bits for standard frames or 29 bits for extended frames +- **Remote Transmission Request (RTR)**: 1 bit +- **Control (DLC)**: 6 bits +- **Data**: Variable length, 8 bits per byte, depending on data length \( x \) +- **CRC**: 16 bits +- **ACK**: 2 bits +- **End of Frame (EOF)**: 7 bits + +**Calculation for fixed portion(\(a\))** : (\( 1 + 11 + 1 + 6 + 16 + 2 + 7 = 44\)) bits + +**Variable Portion (b)**: The data field adds 8 bits for each byte of data. So, \( b = 8 \). + +**Bit Stuffing**: To ensure synchronization, CAN adds around 20% bit stuffing to the frame length. Including bit stuffing, the approximate formulas are: + +- **For a Standard Frame**: \( M(x) \approx 44 + 10x \) bits + +### Final Formula + +A message with data length of \( x \) bytes requires up to \( a + bx \) bits. ## Sample calculation **Given**: -Battery Status: Frequency = 100Hz, Length = 400 bits +Baud Rate: 500 kbaud (500,000 bits transferred per second) -Motor Control: Frequency = 50Hz, Length = 100 bits +|Message Length| Data Length| Frequency (Hz)| +|--------------|------------|---------------| +|Battery Status| 8 | 100 | +|Motor Control| 5 | 50 | -Baud Rate: 500 kbaud (500,000 bits transferred per second) +Let \(M_1\) represent data length in bytes: + +$$ +\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i\right) +$$ + +$$ +\text{Total Bits Per Second} = (M_1 \times 8 \, \text{bits/byte} \times F_1) + (M_2 \times 8 \, \text{bits/byte} \times F_2) +$$ + +$$ +\text{Total Bits Per Second} = (8 \times 8 \times 100) + (5 \times 8 \times 50) = 6400 + 2000 = 8400 \, \text{bits per second} +$$ + +## Calculating Bus Load $$ -\text{Total Bits Per Second} = (100 \times 400) + (50 \times 100) = 40,000 + 5,000 = 45,000 \text{ bits per second} +\text{Bus Load}\%= \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100\% $$ $$ -\text{Bus Load} = \left(\frac{45,000}{500,000}\right) \times 100 = 9\% +\text{Bus Load} = \left(\frac{8400}{500,000}\right) \times 100\% = 1.7\% $$ diff --git a/docs/docs/firmware/javascripts/katex.js b/docs/javascripts/katex.js similarity index 99% rename from docs/docs/firmware/javascripts/katex.js rename to docs/javascripts/katex.js index a5f871323..3828300a7 100644 --- a/docs/docs/firmware/javascripts/katex.js +++ b/docs/javascripts/katex.js @@ -1,6 +1,4 @@ document$.subscribe(({ body }) => { - - renderMathInElement(body, { delimiters: [ { left: "$$", right: "$$", display: true }, diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index cbac98c0e..35c4f18a7 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -32,10 +32,12 @@ theme: extra_css: - stylesheets/extra.css + - https://unpkg.com/katex@0/dist/katex.min.css extra_javascript: - - javascripts/mathjax.js - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js + - https://unpkg.com/katex@0/dist/katex.min.js + - https://unpkg.com/katex@0/dist/contrib/auto-render.min.js copyright: Copyright © McMaster Formula Electric @@ -96,7 +98,7 @@ markdown_extensions: - !relative - !relative $docs_dir/../ - pymdownx.arithmatex: - generic: true + generic: true repo_url: https://github.com/macformula/racecar repo_name: macformula/racecar From 70ec9348a2db4777683a90db27c6d17fdceebe34 Mon Sep 17 00:00:00 2001 From: BlakeFreer Date: Mon, 4 Nov 2024 17:11:30 -0500 Subject: [PATCH 5/9] Moves assets into a designated folder --- .../{assets => firmware/can-traffic/img}/canbusdiagram.svg | 0 .../docs/firmware/{can-traffic.md => can-traffic/index.md} | 7 ++++--- docs/mkdocs.yml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) rename docs/docs/{assets => firmware/can-traffic/img}/canbusdiagram.svg (100%) rename docs/docs/firmware/{can-traffic.md => can-traffic/index.md} (91%) diff --git a/docs/docs/assets/canbusdiagram.svg b/docs/docs/firmware/can-traffic/img/canbusdiagram.svg similarity index 100% rename from docs/docs/assets/canbusdiagram.svg rename to docs/docs/firmware/can-traffic/img/canbusdiagram.svg diff --git a/docs/docs/firmware/can-traffic.md b/docs/docs/firmware/can-traffic/index.md similarity index 91% rename from docs/docs/firmware/can-traffic.md rename to docs/docs/firmware/can-traffic/index.md index 89dd004bd..3a5267679 100644 --- a/docs/docs/firmware/can-traffic.md +++ b/docs/docs/firmware/can-traffic/index.md @@ -17,9 +17,10 @@ This variation affects the total bits transmitted and, in turn, the bus load. To The message length in a CAN frame can be calculated as a function of the data length. This calculation includes several fixed fields and a variable data field, which changes based on the message's data content. -![CAN Frame Diagram](../assets/canbusdiagram.svg) - -*Figure: CAN Bus Frame Diagram. Source: [CSS Electronics CAN Bus Tutorial](https://www.csselectronics.com/pages/can-bus-simple-intro-tutorial#can-bus-frames)* +
+![](img/canbusdiagram.svg){ width="100%" } +
CAN Bus Frame Diagram. Source: CSS Electronics CAN Bus Tutorial
+
Each CAN frame consists of several fields with fixed bit lengths, plus a variable-length data field. Here’s the breakdown: diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 35c4f18a7..ce225dd7b 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -131,7 +131,7 @@ nav: - firmware/architecture.md - firmware/project-structure/index.md - firmware/compile-project.md - - firmware/can-traffic.md + - firmware/can-traffic/index.md - Glossary: glossary.md watch: From dc4f576895da37a93d745a507f626a29cedbe70b Mon Sep 17 00:00:00 2001 From: Manush Date: Tue, 5 Nov 2024 12:11:01 -0500 Subject: [PATCH 6/9] Implemented tables and removed redundancy --- docs/docs/firmware/can-traffic.md | 59 +++++++++++++------------------ 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/docs/docs/firmware/can-traffic.md b/docs/docs/firmware/can-traffic.md index 89dd004bd..d82c82d14 100644 --- a/docs/docs/firmware/can-traffic.md +++ b/docs/docs/firmware/can-traffic.md @@ -1,7 +1,6 @@ +# Calculating CAN Traffic -# Calculating CAN traffic - -In order to calculate the CAN load, we must declare a few variables and their importance within the CAN protocol. +In order to calculate the CAN load, we must define a few variables related to the CAN protocol. ## Baud @@ -21,28 +20,24 @@ The message length in a CAN frame can be calculated as a function of the data le *Figure: CAN Bus Frame Diagram. Source: [CSS Electronics CAN Bus Tutorial](https://www.csselectronics.com/pages/can-bus-simple-intro-tutorial#can-bus-frames)* -Each CAN frame consists of several fields with fixed bit lengths, plus a variable-length data field. Here’s the breakdown: - -- **Start of Frame (SOF)**: 1 bit -- **Identifier (ID)**: 11 bits for standard frames or 29 bits for extended frames -- **Remote Transmission Request (RTR)**: 1 bit -- **Control (DLC)**: 6 bits -- **Data**: Variable length, 8 bits per byte, depending on data length \( x \) -- **CRC**: 16 bits -- **ACK**: 2 bits -- **End of Frame (EOF)**: 7 bits - -**Calculation for fixed portion(\(a\))** : (\( 1 + 11 + 1 + 6 + 16 + 2 + 7 = 44\)) bits +Each CAN frame consists of several fields with fixed bit lengths, plus a variable-length data field. Let \(x\) be the number of bytes. Here’s the breakdown: -**Variable Portion (b)**: The data field adds 8 bits for each byte of data. So, \( b = 8 \). - -**Bit Stuffing**: To ensure synchronization, CAN adds around 20% bit stuffing to the frame length. Including bit stuffing, the approximate formulas are: - -- **For a Standard Frame**: \( M(x) \approx 44 + 10x \) bits +|Frame Element| Length(bits)| +|--------------|------------| +|Start of Frame (SOF) | 8 | +|Identifier (ID)| 11 | +|Remote Transmission Request (RTR)| 1| +| Control (DLC)| 6| +|Cyclic Redundancy Check (CRC) | 16 | +|Acknowledgement (ACK)| 2 | +|End of Frame (EOF)| 7| +|Data Length| 8 bits per byte with 20% bit stuffing = 9.6x| ### Final Formula -A message with data length of \( x \) bytes requires up to \( a + bx \) bits. +The maximum total frame length is: (\( 1 + 11 + 1 + 6 + 16 + 2 + 7 + 9.6x = 44 + 9.6x\)) bits + +-------------------------------------- ## Sample calculation @@ -50,31 +45,27 @@ A message with data length of \( x \) bytes requires up to \( a + bx \) bits. Baud Rate: 500 kbaud (500,000 bits transferred per second) -|Message Length| Data Length| Frequency (Hz)| -|--------------|------------|---------------| -|Battery Status| 8 | 100 | -|Motor Control| 5 | 50 | - -Let \(M_1\) represent data length in bytes: +|Message Type | Data Length| Frequency (Hz)| Message Length (Bits)| +|--------------|------------|---------------|---------------------| +|Battery Status| 8 | 100 | 44 + 9.6 x 8 = 121| +|Motor Control| 5 | 50 | 44 + 9.6 x 5 = 92| $$ -\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i\right) +\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i \right) $$ $$ -\text{Total Bits Per Second} = (M_1 \times 8 \, \text{bits/byte} \times F_1) + (M_2 \times 8 \, \text{bits/byte} \times F_2) -$$ - -$$ -\text{Total Bits Per Second} = (8 \times 8 \times 100) + (5 \times 8 \times 50) = 6400 + 2000 = 8400 \, \text{bits per second} +\text{Total Bits Per Second} = (121 \times 100) + (92 \times 50) = 12100 + 4600 = 16700 \, \text{bits per second} $$ ## Calculating Bus Load +### The bus load is the previous example can be calculated as: + $$ \text{Bus Load}\%= \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100\% $$ $$ -\text{Bus Load} = \left(\frac{8400}{500,000}\right) \times 100\% = 1.7\% +\text{Bus Load} = \left(\frac{16700}{500,000}\right) \times 100\% = 3.34\% $$ From 80a375b0826b38b5cc60aa4ed199dcb89da62322 Mon Sep 17 00:00:00 2001 From: BlakeFreer Date: Wed, 6 Nov 2024 17:27:24 -0500 Subject: [PATCH 7/9] LaTeX formatting --- docs/docs/firmware/can-traffic/index.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/docs/firmware/can-traffic/index.md b/docs/docs/firmware/can-traffic/index.md index f69071bbe..89e1d6447 100644 --- a/docs/docs/firmware/can-traffic/index.md +++ b/docs/docs/firmware/can-traffic/index.md @@ -36,7 +36,9 @@ Each CAN frame consists of several fields with fixed bit lengths, plus a variabl ### Final Formula -The maximum total frame length is: (\( 1 + 11 + 1 + 6 + 16 + 2 + 7 + 9.6x = 44 + 9.6x\)) bits +The maximum total frame length is: + +\[ 1 + 11 + 1 + 6 + 16 + 2 + 7 + 9.6x = 44 + 9.6x \text{ bits}\] -------------------------------------- @@ -51,13 +53,12 @@ Baud Rate: 500 kbaud (500,000 bits transferred per second) |Battery Status| 8 | 100 | 44 + 9.6 x 8 = 121| |Motor Control| 5 | 50 | 44 + 9.6 x 5 = 92| -$$ -\text{Total Bits Per Second} = \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i \right) -$$ - -$$ -\text{Total Bits Per Second} = (121 \times 100) + (92 \times 50) = 12100 + 4600 = 16700 \, \text{bits per second} -$$ +\begin{align} +\text{Total Bits Per Second} &= \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i \right)\\ +\text{Total Bits Per Second} &= (100\text{ Hz} \times 121\text{ bits}) + (50\text{ Hz}\times 92\text{ bits})\\ +&=(12100 + 4600)\text{ bits per second}\\ +&= 16700\text{ bits per second} +\end{align} ## Calculating Bus Load From a235752b3a81219c751e94d2a2af0a16e729aa11 Mon Sep 17 00:00:00 2001 From: Manush Date: Wed, 6 Nov 2024 19:11:19 -0500 Subject: [PATCH 8/9] Reordered table, and fixed formatting --- docs/docs/firmware/can-traffic/index.md | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/docs/firmware/can-traffic/index.md b/docs/docs/firmware/can-traffic/index.md index 89e1d6447..f6ef68031 100644 --- a/docs/docs/firmware/can-traffic/index.md +++ b/docs/docs/firmware/can-traffic/index.md @@ -23,16 +23,16 @@ The message length in a CAN frame can be calculated as a function of the data le Each CAN frame consists of several fields with fixed bit lengths, plus a variable-length data field. Let \(x\) be the number of bytes. Here’s the breakdown: -|Frame Element| Length(bits)| +|Frame Element| Length (bits)| |--------------|------------| -|Start of Frame (SOF) | 8 | +|Start of Frame (SOF) | 1 | |Identifier (ID)| 11 | |Remote Transmission Request (RTR)| 1| | Control (DLC)| 6| +|Data| 8 bits per byte with 20% bit stuffing = 9.6x| |Cyclic Redundancy Check (CRC) | 16 | |Acknowledgement (ACK)| 2 | |End of Frame (EOF)| 7| -|Data Length| 8 bits per byte with 20% bit stuffing = 9.6x| ### Final Formula @@ -40,6 +40,22 @@ The maximum total frame length is: \[ 1 + 11 + 1 + 6 + 16 + 2 + 7 + 9.6x = 44 + 9.6x \text{ bits}\] +where \(x\) represents the number of bytes in the variable data field. + +-------------------------------------- + +## Total CAN Traffic + +\begin{align} +\text{Total Bits Per Second} &= \sum_{i=1}^n \left(\text{Frequency}_i \times \text{Message Length}_i \right)\\ +\end{align} + +## Total Bus Load + +\begin{align} +\text{Bus Load}\%= \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100\% +\end{align} + -------------------------------------- ## Sample calculation @@ -60,9 +76,7 @@ Baud Rate: 500 kbaud (500,000 bits transferred per second) &= 16700\text{ bits per second} \end{align} -## Calculating Bus Load - -### The bus load is the previous example can be calculated as: +The bus load is the previous example can be calculated as: $$ \text{Bus Load}\%= \frac{\text{Total Bits per Second}}{\text{Baud Rate}} \times 100\% From 21d91dd582b1c2715fe9677ff2aecad383014182 Mon Sep 17 00:00:00 2001 From: BlakeFreer Date: Wed, 6 Nov 2024 19:24:00 -0500 Subject: [PATCH 9/9] Adds abbr extension back --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index ce225dd7b..a72e2aac3 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -79,7 +79,7 @@ plugins: markdown_extensions: - admonition - # - abbr + - abbr - attr_list - md_in_html - pymdownx.details