docs: restructure MCPWM programming guide

This commit is contained in:
morris
2026-07-23 23:53:06 +08:00
parent 53c8b9402d
commit 13777d2d93
66 changed files with 10976 additions and 2643 deletions

View File

@@ -1,26 +0,0 @@
{
"signal": [
{
"name": "origin",
"wave": "0...1.....0...",
"node": "....a.....b..."
},
{
"name": "pwm_A",
"wave": "0....1....0...",
"node": ".....c....."
},
{
"name": "pwm_B",
"wave": "0...1......0..",
"node": "...........d.."
}
],
"edge": [
"a|->c RED",
"b|->d FED"
],
"head": {
"text": "Active High"
}
}

View File

@@ -1,27 +0,0 @@
{
"signal": [
{
"name": "origin",
"wave": "0...1.....0...",
"node": "....a.e...b..."
},
{
"name": "pwm_A",
"wave": "0....1....0...",
"node": ".....c....."
},
{
"name": "pwm_B",
"wave": "1...0......1..",
"node": "......f....d.."
}
],
"edge": [
"a|->c RED",
"b|->d FED",
"e<->f Invert"
],
"head": {
"text": "Active High, Complementary"
}
}

View File

@@ -1,28 +0,0 @@
{
"signal": [
{
"name": "origin",
"wave": "0...1.....0...",
"node": "....a..ef.b..."
},
{
"name": "pwm_A",
"wave": "1....0....1...",
"node": ".....c.g..."
},
{
"name": "pwm_B",
"wave": "1...0......1..",
"node": "........h..d.."
}
],
"edge": [
"a|->c RED",
"b|->d FED",
"e<->g Invert",
"f<->h Invert"
],
"head": {
"text": "Active Low"
}
}

View File

@@ -1,27 +0,0 @@
{
"signal": [
{
"name": "origin",
"wave": "0...1.....0...",
"node": "....a..e..b..."
},
{
"name": "pwm_A",
"wave": "1....0....1...",
"node": ".....c.f..."
},
{
"name": "pwm_B",
"wave": "0...1......0..",
"node": "...........d.."
}
],
"edge": [
"a|->c RED",
"b|->d FED",
"e<->f Invert"
],
"head": {
"text": "Active Low, Complementary"
}
}

View File

@@ -1,28 +0,0 @@
{
"signal": [
{
"name": "origin_A",
"wave": "0...1.....0..."
},
{
"name": "origin_B",
"wave": "0...1.....0...",
"node": "..........a..."
},
{
"name": "pwm_A",
"wave": "0...1.....0..."
},
{
"name": "pwm_B",
"wave": "0...1......0..",
"node": "...........b..."
}
],
"edge": [
"a|->b FED"
],
"head": {
"text": "FED on B, Bypass A"
}
}

View File

@@ -1,28 +0,0 @@
{
"signal": [
{
"name": "origin_A",
"wave": "0...1.....0...",
"node": "....a........."
},
{
"name": "origin_B",
"wave": "0...1.....0..."
},
{
"name": "pwm_A",
"wave": "0....1....0...",
"node": ".....b....."
},
{
"name": "pwm_B",
"wave": "0...1.....0..."
}
],
"edge": [
"a|->b RED"
],
"head": {
"text": "RED on A, Bypass B"
}
}

View File

@@ -1,29 +0,0 @@
{
"signal": [
{
"name": "origin_A",
"wave": "0...1.....0..."
},
{
"name": "origin_B",
"wave": "0...1.....0...",
"node": "....a.....b..."
},
{
"name": "pwm_A",
"wave": "0...1.....0..."
},
{
"name": "pwm_B",
"wave": "0....1.....0..",
"node": ".....c.....d..."
}
],
"edge": [
"a|->c RED",
"b|->d FED"
],
"head": {
"text": "Bypass A, RED + FED on B"
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "01..0..1..0."
},
{
"name": "pwm_B",
"wave": "0..1..0..1.."
}
],
"head": {
"text": "Dual Edge Asymmetric Waveform, Active Low"
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "0.1..0...1..0.."
},
{
"name": "pwm_B",
"wave": "0..10.....10..."
}
],
"head": {
"text": "Dual Edge Symmetric Waveform, Active Low"
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "01..0...1..0"
},
{
"name": "pwm_B",
"wave": "1.01.....01."
}
],
"head": {
"text": "Dual Edge Symmetric Waveform, Complementary"
}
}

View File

@@ -1,59 +0,0 @@
blockdiag mcpwm_overview {
default_fontsize = 18;
node_width = 130;
node_height = 100;
default_group_color = lightgrey;
mcpwm_timers [label = "MCPWM\nTimer", stacked];
timer_sync [label = "Timer Sync", stacked];
timer_sync <-> mcpwm_timers;
mcpwm_capture_timer [label = "MCPWM\nCapture Timer"];
mcpwm_capture_channels [label = "MCPWM\nCapture Chan", stacked];
mcpwm_capture_gpio [label = "Cap\nGPIO", shape = minidiamond];
mcpwm_capture_timer -> mcpwm_capture_channels;
mcpwm_capture_channels <- mcpwm_capture_gpio;
timer_sync -> mcpwm_capture_timer;
gpio_sync [label = "Sync\nGPIO", shape = minidiamond];
gpio_sync -> mcpwm_timers;
gpio_sync -> mcpwm_capture_timer;
mcpwm_compares [label = "MCPWM\nComparators", stacked];
mcpwm_generators [label = "MCPWM\nGenerators", stacked];
mcpwm_dead_time [label = "Dead Time"];
mcpwm_carrier [label = "Carrier\nModulation"];
mcpwm_brake [label = "Brake"];
pwma [label = "PWM_A", shape = minidiamond];
pwmb [label = "PWM_B", shape = minidiamond];
stub [shape = none];
mcpwm_timers -> mcpwm_generators;
mcpwm_timers -> mcpwm_compares;
mcpwm_compares -> mcpwm_generators [folded];
mcpwm_generators -> mcpwm_dead_time;
mcpwm_dead_time -> mcpwm_carrier;
mcpwm_carrier -> mcpwm_brake;
mcpwm_brake -> stub;
stub -> pwma, pwmb;
mcpwm_generators -> mcpwm_carrier;
mcpwm_generators -> mcpwm_brake;
mcpwm_generators -> stub;
gpio_faults [label = "Fault\nGPIO", shape = minidiamond];
mcpwm_brake <- gpio_faults [folded];
group {
label = "MCPWM Operators";
mcpwm_compares, mcpwm_generators, mcpwm_dead_time, mcpwm_carrier, mcpwm_brake;
}
group {
label = "MCPWM Capture";
mcpwm_capture_timer, mcpwm_capture_channels, mcpwm_capture_gpio;
}
group {
label = "MCPWM Sync";
gpio_sync, timer_sync;
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "0.1..0..1..0..1..0..1..0.."
},
{
"name": "pwm_B",
"wave": "01.....0.....1.....0.....1"
}
],
"head": {
"text": "Pulse Placement Asymmetric Waveform"
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "01....0..1....0..1"
},
{
"name": "pwm_B",
"wave": "01..0....1..0....1"
}
],
"head": {
"text": "Single Edge Asymmetric Waveform, Active High"
}
}

View File

@@ -1,15 +0,0 @@
{
"signal": [
{
"name": "pwm_A",
"wave": "10....1..0....1..0"
},
{
"name": "pwm_B",
"wave": "10..1....0..1....0"
}
],
"head": {
"text": "Single Edge Asymmetric Waveform, Active Low"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

95
docs/_static/mcpwm/brake_cbc_ost.svg vendored Normal file
View File

@@ -0,0 +1,95 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 370" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="370" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">CBC vs. OST Brake Behavior</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(50, 55)">
<!-- ===== Timeline ===== -->
<!-- X-axis: 0 to 560px = 14 PWM periods (40px per period) -->
<!-- Row baselines at translate offsets 40/80/120/160, low at y=20, high at y=0 -->
<!-- Subtle period gridlines -->
<g stroke="#e0e0e0" stroke-width="1" opacity="0.5">
<line x1="0" y1="40" x2="0" y2="180"/>
<line x1="40" y1="40" x2="40" y2="180"/>
<line x1="80" y1="40" x2="80" y2="180"/>
<line x1="120" y1="40" x2="120" y2="180"/>
<line x1="160" y1="40" x2="160" y2="180"/>
<line x1="200" y1="40" x2="200" y2="180"/>
<line x1="240" y1="40" x2="240" y2="180"/>
<line x1="280" y1="40" x2="280" y2="180"/>
<line x1="320" y1="40" x2="320" y2="180"/>
<line x1="360" y1="40" x2="360" y2="180"/>
<line x1="400" y1="40" x2="400" y2="180"/>
<line x1="440" y1="40" x2="440" y2="180"/>
<line x1="480" y1="40" x2="480" y2="180"/>
<line x1="520" y1="40" x2="520" y2="180"/>
<line x1="560" y1="40" x2="560" y2="180"/>
</g>
<!-- ===== Braked windows ===== -->
<rect x="200" y="120" width="200" height="20" fill="#fce4ec" opacity="0.6"/>
<text x="300" y="134" text-anchor="middle" font-size="9" fill="#c62828">braked</text>
<rect x="200" y="160" width="280" height="20" fill="#fce4ec" opacity="0.6"/>
<text x="340" y="174" text-anchor="middle" font-size="9" fill="#c62828">still braked</text>
<!-- ===== PWM reference signal ===== -->
<text x="-8" y="62" text-anchor="end" font-size="11" fill="#333" font-weight="600">PWM</text>
<g transform="translate(0, 40)">
<polyline points="0,0 20,0 20,20 40,20 40,0 60,0 60,20 80,20 80,0 100,0 100,20 120,20 120,0 140,0 140,20 160,20 160,0 180,0 180,20 200,20 200,0 220,0 220,20 240,20 240,0 260,0 260,20 280,20 280,0 300,0 300,20 320,20 320,0 340,0 340,20 360,20 360,0 380,0 380,20 400,20 400,0 420,0 420,20 440,20 440,0 460,0 460,20 480,20 480,0 500,0 500,20 520,20 520,0 540,0 540,20 560,20" fill="none" stroke="#1e88e5" stroke-width="2"/>
</g>
<!-- ===== fault signal ===== -->
<text x="-8" y="102" text-anchor="end" font-size="11" fill="#333" font-weight="600">fault</text>
<g transform="translate(0, 80)">
<polyline points="0,20 200,20 200,0 350,0 350,20 560,20" fill="none" stroke="#e53935" stroke-width="2"/>
</g>
<!-- ===== CBC output ===== -->
<text x="-8" y="142" text-anchor="end" font-size="11" fill="#333" font-weight="600">CBC</text>
<g transform="translate(0, 120)">
<polyline points="0,0 20,0 20,20 40,20 40,0 60,0 60,20 80,20 80,0 100,0 100,20 120,20 120,0 140,0 140,20 160,20 160,0 180,0 180,20 200,20 400,20 400,0 420,0 420,20 440,20 440,0 460,0 460,20 480,20 480,0 500,0 500,20 520,20 520,0 540,0 540,20 560,20" fill="none" stroke="#00897b" stroke-width="2"/>
</g>
<!-- ===== OST output ===== -->
<text x="-8" y="182" text-anchor="end" font-size="11" fill="#333" font-weight="600">OST</text>
<g transform="translate(0, 160)">
<polyline points="0,0 20,0 20,20 40,20 40,0 60,0 60,20 80,20 80,0 100,0 100,20 120,20 120,0 140,0 140,20 160,20 160,0 180,0 180,20 200,20 480,20 480,0 500,0 500,20 520,20 520,0 540,0 540,20 560,20" fill="none" stroke="#f57c00" stroke-width="2"/>
</g>
<!-- ===== Event annotations ===== -->
<!-- fault asserted -->
<line x1="200" y1="40" x2="200" y2="180" stroke="#e53935" stroke-width="1.5" stroke-dasharray="4,4"/>
<text x="200" y="30" text-anchor="middle" font-size="10" fill="#c62828" font-weight="600">fault asserted</text>
<!-- fault cleared -->
<line x1="350" y1="40" x2="350" y2="180" stroke="#1e88e5" stroke-width="1.5" stroke-dasharray="4,4"/>
<text x="350" y="30" text-anchor="middle" font-size="10" fill="#1565c0" font-weight="600">fault cleared</text>
<!-- CBC recovery -->
<line x1="400" y1="40" x2="400" y2="185" stroke="#43a047" stroke-width="1.5" stroke-dasharray="4,4"/>
<text x="400" y="198" text-anchor="middle" font-size="9" fill="#2e7d32">CBC recovers here</text>
<!-- OST recovery -->
<line x1="480" y1="40" x2="480" y2="185" stroke="#43a047" stroke-width="1.5" stroke-dasharray="4,4"/>
<text x="480" y="212" text-anchor="middle" font-size="9" fill="#2e7d32">OST recovers (software)</text>
<!-- ===== Bottom note ===== -->
<text x="280" y="236" text-anchor="middle" font-size="9" fill="#777">Shaded region: output held at the brake level, which is LOW in this example</text>
<!-- ===== Right-hand labels ===== -->
<g transform="translate(592, 0)">
<text x="0" y="58" font-size="9" fill="#888">Runs continuously</text>
<text x="0" y="98" font-size="9" fill="#888">Active while asserted</text>
<text x="0" y="132" font-size="9" fill="#888">Brakes while fault is active,</text>
<text x="0" y="144" font-size="9" fill="#888">recovers at next boundary</text>
<text x="0" y="172" font-size="9" fill="#888">Stays braked after fault clears,</text>
<text x="0" y="184" font-size="9" fill="#888">resumes only after software recovery</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,75 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 330" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="caparrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
<marker id="caparrow2" markerWidth="8" markerHeight="6" refX="0" refY="3" orient="auto">
<polygon points="8,0 0,3 8,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="330" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">Capture: Measure a Pulse Width</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(70, 55)">
<!-- input signal -->
<text x="-12" y="44" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">input</text>
<polyline points="0,30 130,30 130,10 330,10 330,30 500,30" fill="none" stroke="#1e88e5" stroke-width="2"/>
<!-- edge node dots and labels a, b -->
<circle cx="130" cy="10" r="3" fill="#1e88e5"/>
<circle cx="330" cy="30" r="3" fill="#1e88e5"/>
<text x="130" y="0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="700">a (rising)</text>
<text x="330" y="46" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="700">b (falling)</text>
<!-- capture pulses -->
<text x="-12" y="114" text-anchor="end" font-size="11" fill="#e53935" font-weight="600">capture</text>
<line x1="0" y1="100" x2="500" y2="100" stroke="#e53935" stroke-width="1.5"/>
<polyline points="130,100 130,80 142,80 142,100" fill="none" stroke="#e53935" stroke-width="2"/>
<polyline points="330,100 330,80 342,80 342,100" fill="none" stroke="#e53935" stroke-width="2"/>
<text x="136" y="72" text-anchor="middle" font-size="10" fill="#e53935" font-weight="700">t1</text>
<text x="336" y="72" text-anchor="middle" font-size="10" fill="#e53935" font-weight="700">t2</text>
<!-- timer free-running counter -->
<text x="-12" y="190" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">timer</text>
<!-- continuous rising ramp: the counter counts up without ever stopping -->
<line x1="0" y1="200" x2="500" y2="200" stroke="#43a047" stroke-width="1" opacity="0.35"/>
<line x1="0" y1="200" x2="500" y2="70" stroke="#43a047" stroke-width="2"/>
<!-- latched values at t1 / t2 lie on the same continuous ramp -->
<circle cx="130" cy="166" r="3.5" fill="#43a047"/>
<circle cx="330" cy="114" r="3.5" fill="#43a047"/>
<text x="130" y="158" text-anchor="middle" font-size="9" fill="#43a047">cnt_t1</text>
<text x="330" y="106" text-anchor="middle" font-size="9" fill="#43a047">cnt_t2</text>
<text x="490" y="205" text-anchor="end" font-size="9" fill="#888">counts continuously</text>
<!-- dashed drop lines: edge -> captured timestamp -> latched timer value -->
<line x1="130" y1="10" x2="130" y2="166" stroke="#999" stroke-width="1" stroke-dasharray="3,3"/>
<line x1="330" y1="30" x2="330" y2="132" stroke="#999" stroke-width="1" stroke-dasharray="3,3"/>
<!-- width annotation -->
<line x1="130" y1="240" x2="130" y2="252" stroke="#333" stroke-width="1"/>
<line x1="330" y1="240" x2="330" y2="252" stroke="#333" stroke-width="1"/>
<line x1="130" y1="246" x2="330" y2="246" stroke="#333" stroke-width="1"/>
<text x="230" y="268" text-anchor="middle" font-size="12" fill="#333" font-weight="600">width = t2 - t1</text>
<!-- rising / falling labels -->
<line x1="130" y1="130" x2="180" y2="130" stroke="#1e88e5" stroke-width="1"/>
<text x="188" y="134" font-size="10" fill="#1e88e5">rising@t1</text>
<line x1="330" y1="130" x2="380" y2="130" stroke="#1e88e5" stroke-width="1"/>
<text x="388" y="134" font-size="10" fill="#1e88e5">falling@t2</text>
<!-- legend -->
<g transform="translate(560, 0)">
<text x="0" y="24" font-size="9" fill="#888">Input pulse under test</text>
<text x="0" y="74" font-size="9" fill="#888">Capture fires a pulse on</text>
<text x="0" y="84" font-size="9" fill="#888">each configured edge and</text>
<text x="0" y="94" font-size="9" fill="#888">latches the timer count</text>
<text x="0" y="154" font-size="9" fill="#888">Capture timer counts freely</text>
<text x="0" y="164" font-size="9" fill="#888">at resolution_hz ticks/s</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,82 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 370" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="370" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">Carrier Modulation</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(75, 55)">
<!-- ===== Timeline ===== -->
<!-- X-axis: 0 to 450px = 150 us (3 px/us). Carrier period 10 us = 30 px; base period 50 us = 150 px -->
<!-- Row baselines at translate offsets 40/80/120, low at y=20, high at y=0 -->
<!-- Subtle carrier-period gridlines -->
<g stroke="#e0e0e0" stroke-width="1" opacity="0.5">
<line x1="0" y1="40" x2="0" y2="140"/>
<line x1="30" y1="40" x2="30" y2="140"/>
<line x1="60" y1="40" x2="60" y2="140"/>
<line x1="90" y1="40" x2="90" y2="140"/>
<line x1="120" y1="40" x2="120" y2="140"/>
<line x1="150" y1="40" x2="150" y2="140"/>
<line x1="180" y1="40" x2="180" y2="140"/>
<line x1="210" y1="40" x2="210" y2="140"/>
<line x1="240" y1="40" x2="240" y2="140"/>
<line x1="270" y1="40" x2="270" y2="140"/>
<line x1="300" y1="40" x2="300" y2="140"/>
<line x1="330" y1="40" x2="330" y2="140"/>
<line x1="360" y1="40" x2="360" y2="140"/>
<line x1="390" y1="40" x2="390" y2="140"/>
<line x1="420" y1="40" x2="420" y2="140"/>
<line x1="450" y1="40" x2="450" y2="140"/>
</g>
<!-- ===== Base PWM signal (50% duty) ===== -->
<text x="-8" y="62" text-anchor="end" font-size="11" fill="#333" font-weight="600">PWM</text>
<g transform="translate(0, 40)">
<polyline points="0,0 150,0 150,20 300,20 300,0 450,0" fill="none" stroke="#1e88e5" stroke-width="2"/>
</g>
<!-- ===== Carrier signal ===== -->
<text x="-8" y="102" text-anchor="end" font-size="11" fill="#333" font-weight="600">carrier</text>
<g transform="translate(0, 80)">
<polyline points="0,0 15,0 15,20 30,20 30,0 45,0 45,20 60,20 60,0 75,0 75,20 90,20 90,0 105,0 105,20 120,20 120,0 135,0 135,20 150,20 150,0 165,0 165,20 180,20 180,0 195,0 195,20 210,20 210,0 225,0 225,20 240,20 240,0 255,0 255,20 270,20 270,0 285,0 285,20 300,20 300,0 315,0 315,20 330,20 330,0 345,0 345,20 360,20 360,0 375,0 375,20 390,20 390,0 405,0 405,20 420,20 420,0 435,0 435,20 450,20" fill="none" stroke="#00897b" stroke-width="2"/>
</g>
<!-- ===== Modulated output ===== -->
<!-- Base-low window (150..300 px) shaded: no chopping there -->
<rect x="150" y="120" width="150" height="20" fill="#f5f5f5" opacity="0.8"/>
<text x="225" y="134" text-anchor="middle" font-size="9" fill="#888">no carrier while base is low</text>
<text x="-8" y="142" text-anchor="end" font-size="11" fill="#333" font-weight="600">modulated</text>
<g transform="translate(0, 120)">
<polyline points="0,0 60,0 60,20 75,20 75,0 90,0 90,20 105,20 105,0 120,0 120,20 135,20 135,0 150,0 150,20 300,20 300,0 315,0 315,20 330,20 330,0 345,0 345,20 360,20 360,0 375,0 375,20 390,20 390,0 405,0 405,20 420,20 420,0 435,0 435,20 450,20" fill="none" stroke="#f57c00" stroke-width="2"/>
</g>
<!-- ===== First-pulse annotation ===== -->
<line x1="60" y1="40" x2="60" y2="145" stroke="#f57c00" stroke-width="1.5" stroke-dasharray="4,4"/>
<text x="60" y="30" text-anchor="middle" font-size="10" fill="#ef6c00" font-weight="600">first pulse</text>
<!-- ===== Time axis ===== -->
<text x="0" y="225" text-anchor="middle" font-size="9" fill="#999">0</text>
<text x="150" y="225" text-anchor="middle" font-size="9" fill="#999">50 µs</text>
<text x="300" y="225" text-anchor="middle" font-size="9" fill="#999">100 µs</text>
<text x="450" y="225" text-anchor="middle" font-size="9" fill="#999">150 µs</text>
<!-- ===== Bottom note ===== -->
<text x="225" y="246" text-anchor="middle" font-size="9" fill="#777">The first pulse is held HIGH for first_pulse_duration_us</text>
<text x="225" y="258" text-anchor="middle" font-size="9" fill="#777">(20 µs = 2 carrier periods) before normal chopping resumes.</text>
<!-- ===== Right-hand labels ===== -->
<g transform="translate(480, 0)">
<text x="0" y="58" font-size="9" fill="#888">50% duty, 50 µs period</text>
<text x="0" y="98" font-size="9" fill="#888">100 kHz, 50% duty</text>
<text x="0" y="132" font-size="9" fill="#888">Carrier gated by base PWM;</text>
<text x="0" y="144" font-size="9" fill="#888">first pulse stretched to 20 µs</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

139
docs/_static/mcpwm/compare_event.svg vendored Normal file
View File

@@ -0,0 +1,139 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 420" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="420" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">Compare Event: Timer + Comparator + Generator</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(64, 55)">
<!-- X-axis: 0 to 500px = 50 ticks (10px per tick) -->
<!-- Clock signal -->
<text x="-8" y="72" text-anchor="end" font-size="11" fill="#333" font-weight="600">clk</text>
<g transform="translate(0, 60)">
<polyline points="0,20 0,0 10,0 10,20 20,20 20,0 30,0 30,20 40,20 40,0 50,0 50,20 60,20 60,0 70,0 70,20 80,20 80,0 90,0 90,20 100,20 100,0 110,0 110,20 120,20 120,0 130,0 130,20 140,20 140,0 150,0 150,20 160,20 160,0 170,0 170,20 180,20 180,0 190,0 190,20 200,20 200,0 210,0 210,20 220,20 220,0 230,0 230,20 240,20 240,0 250,0 250,20 260,20 260,0 270,0 270,20 280,20 280,0 290,0 290,20 300,20 300,0 310,0 310,20 320,20 320,0 330,0 330,20 340,20 340,0 350,0 350,20 360,20 360,0 370,0 370,20 380,20 380,0 390,0 390,20 400,20 400,0 410,0 410,20 420,20 420,0 430,0 430,20 440,20 440,0 450,0 450,20 460,20 460,0 470,0 470,20 480,20 480,0 490,0 490,20 500,20 500,0" fill="none" stroke="#666" stroke-width="1.5"/>
</g>
<!-- Count Bus (decimal values every 5 ticks) -->
<text x="-8" y="112" text-anchor="end" font-size="11" fill="#333" font-weight="600">count</text>
<g transform="translate(0, 90)">
<rect x="-8" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="0" y="20" text-anchor="middle" font-size="10" fill="#1565c0">0</text>
<rect x="42" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="50" y="20" text-anchor="middle" font-size="10" fill="#1565c0">5</text>
<rect x="92" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="100" y="20" text-anchor="middle" font-size="10" fill="#1565c0">10</text>
<!-- Compare match at tick 15 -->
<rect x="142" y="0" width="16" height="30" fill="#fff3e0" stroke="#ff9800" stroke-width="2" rx="2"/>
<text x="150" y="20" text-anchor="middle" font-size="10" fill="#e65100" font-weight="700">15</text>
<rect x="192" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="200" y="20" text-anchor="middle" font-size="10" fill="#1565c0">20</text>
<rect x="242" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="250" y="20" text-anchor="middle" font-size="10" fill="#1565c0">25</text>
<rect x="292" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="300" y="20" text-anchor="middle" font-size="10" fill="#1565c0">30</text>
<rect x="342" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="350" y="20" text-anchor="middle" font-size="10" fill="#1565c0">35</text>
<rect x="392" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="400" y="20" text-anchor="middle" font-size="10" fill="#1565c0">40</text>
<rect x="442" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="450" y="20" text-anchor="middle" font-size="10" fill="#1565c0">45</text>
<!-- Peak: count reaches 50, then reload -->
<rect x="492" y="0" width="16" height="30" fill="#fff3e0" stroke="#ffb74d" stroke-width="1.5" rx="2"/>
<text x="500" y="20" text-anchor="middle" font-size="10" fill="#e65100" font-weight="700">50</text>
</g>
<!-- cmp_match signal -->
<text x="-8" y="155" text-anchor="end" font-size="10" fill="#333" font-weight="600">cmp_match</text>
<g transform="translate(0, 135)">
<line x1="0" y1="20" x2="500" y2="20" stroke="#ff9800" stroke-width="1.5"/>
<!-- Pulse at tick 15 -->
<polyline points="150,20 150,0 160,0 160,20" fill="none" stroke="#ff9800" stroke-width="1.5"/>
</g>
<!-- TEZ signal -->
<text x="-8" y="195" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEZ</text>
<g transform="translate(0, 175)">
<line x1="0" y1="20" x2="500" y2="20" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse at count = 0 -->
<polyline points="0,20 0,0 10,0 10,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse on reload (count returns to 0) -->
<polyline points="500,20 500,0 510,0 510,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
</g>
<!-- TEP signal -->
<text x="-8" y="235" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEP</text>
<g transform="translate(0, 215)">
<line x1="0" y1="20" x2="500" y2="20" stroke="#1e88e5" stroke-width="1.5"/>
<polyline points="480,20 480,0 500,0 500,20" fill="none" stroke="#1e88e5" stroke-width="1.5"/>
</g>
<!-- PWM Output -->
<text x="-8" y="275" text-anchor="end" font-size="11" fill="#333" font-weight="600">PWM</text>
<g transform="translate(0, 255)">
<!-- Action: set high on TEZ, set low on compare match -->
<!-- tick 0-15: high, tick 15-50: low, tick 50: high again -->
<polyline points="0,0 150,0" fill="none" stroke="#43a047" stroke-width="1.5"/>
<polyline points="150,0 150,20" fill="none" stroke="#43a047" stroke-width="1.5"/>
<polyline points="150,20 500,20" fill="none" stroke="#43a047" stroke-width="1.5"/>
<polyline points="500,20 500,0" fill="none" stroke="#43a047" stroke-width="1.5"/>
</g>
<!-- Period bracket -->
<g transform="translate(0, 320)">
<line x1="0" y1="0" x2="0" y2="12" stroke="#999" stroke-width="1"/>
<line x1="500" y1="0" x2="500" y2="12" stroke="#999" stroke-width="1"/>
<line x1="0" y1="6" x2="500" y2="6" stroke="#999" stroke-width="1"/>
<text x="250" y="30" text-anchor="middle" font-size="12" fill="#555">period = 50 ticks</text>
</g>
<!-- Relation lines -->
<g transform="translate(0, 0)">
<!-- Compare match at tick 15 → cmp_match pulse → PWM falling edge -->
<line x1="150" y1="100" x2="150" y2="135" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<line x1="150" y1="155" x2="150" y2="255" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<!-- TEZ → PWM rising edge -->
<line x1="0" y1="195" x2="0" y2="255" stroke="#e53935" stroke-width="1" stroke-dasharray="4,4"/>
<!-- TEZ on reload → PWM rising edge -->
<line x1="500" y1="195" x2="500" y2="255" stroke="#e53935" stroke-width="1" stroke-dasharray="4,4"/>
<!-- Duty cycle annotation: PWM high from tick 0 to tick 15 -->
<line x1="0" y1="284" x2="0" y2="292" stroke="#43a047" stroke-width="1"/>
<line x1="150" y1="284" x2="150" y2="292" stroke="#43a047" stroke-width="1"/>
<line x1="0" y1="288" x2="150" y2="288" stroke="#43a047" stroke-width="1"/>
<text x="75" y="308" text-anchor="middle" font-size="11" fill="#43a047" font-weight="600">duty = 15 ticks (30 %)</text>
<!-- Cmp threshold annotation -->
<line x1="160" y1="128" x2="200" y2="128" stroke="#ff9800" stroke-width="1"/>
<text x="210" y="132" font-size="11" fill="#e65100">cmp_ticks = 15</text>
</g>
<!-- Signal labels -->
<g transform="translate(580, 0)">
<text x="0" y="75" font-size="9" fill="#888">Timer clock source</text>
<text x="0" y="115" font-size="9" fill="#888">Counter value (decimal)</text>
<text x="0" y="153" font-size="9" fill="#888">Pulse when count = cmp_ticks</text>
<text x="0" y="193" font-size="9" fill="#888">Pulse when counter = 0</text>
<text x="0" y="233" font-size="9" fill="#888">Pulse when counter = peak</text>
<text x="0" y="273" font-size="9" fill="#888">PWM: set high on TEZ,</text>
<text x="0" y="283" font-size="9" fill="#888">set low on cmp_match</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 244" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="244" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Basic Dead-Time Effect (Active High)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 120,66 120,46 300,46 300,66 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,112 100,112 100,92 320,92 320,112 500,112" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="100" y1="10" x2="120" y2="56" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="33.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
<line x1="300" y1="10" x2="320" y2="102" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="56.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
<text x="450.0" y="232" text-anchor="middle" font-size="10" fill="#888888">Rising edge of pwm_A delayed; falling edge of pwm_B delayed.</text>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,28 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 244" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="244" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Complementary PWM with Dead Time (Active High)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 120,66 120,46 300,46 300,66 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,112 0,92 100,92 100,112 320,112 320,92 500,92 500,112" fill="none" stroke="#1e88e5" stroke-width="2"/>
<rect x="100" y="-4" width="20" height="134" fill="#ffcdd2" opacity="0.55"/>
<rect x="100" y="-4" width="20" height="134" fill="none" stroke="#e53935" stroke-width="1" stroke-dasharray="3,3"/>
<text x="110.0" y="-12" text-anchor="middle" font-size="10" fill="#c62828" font-weight="600">dead time</text>
<rect x="300" y="-4" width="20" height="134" fill="#ffcdd2" opacity="0.55"/>
<rect x="300" y="-4" width="20" height="134" fill="none" stroke="#e53935" stroke-width="1" stroke-dasharray="3,3"/>
<text x="310.0" y="-12" text-anchor="middle" font-size="10" fill="#c62828" font-weight="600">dead time</text>
<line x1="100" y1="10" x2="120" y2="56" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="33.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
<line x1="300" y1="10" x2="320" y2="102" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="56.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
<text x="450.0" y="232" text-anchor="middle" font-size="10" fill="#888888">pwm_A delays its rising edge; pwm_B is the inverted falling-edge-delayed copy.</text>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 244" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="244" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Basic Dead-Time Effect (Active Low)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 0,46 120,46 120,66 300,66 300,46 500,46 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,112 0,92 100,92 100,112 320,112 320,92 500,92 500,112" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="100" y1="10" x2="120" y2="56" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="33.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
<line x1="300" y1="10" x2="320" y2="102" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="56.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
<text x="450.0" y="232" text-anchor="middle" font-size="10" fill="#888888">Same delay resources; polarity inverted after the delay stage.</text>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,28 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 244" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="244" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Complementary PWM with Dead Time (Active Low)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 0,46 120,46 120,66 300,66 300,46 500,46 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,112 100,112 100,92 320,92 320,112 500,112" fill="none" stroke="#1e88e5" stroke-width="2"/>
<rect x="100" y="-4" width="20" height="134" fill="#ffcdd2" opacity="0.55"/>
<rect x="100" y="-4" width="20" height="134" fill="none" stroke="#e53935" stroke-width="1" stroke-dasharray="3,3"/>
<text x="110.0" y="-12" text-anchor="middle" font-size="10" fill="#c62828" font-weight="600">dead time</text>
<rect x="300" y="-4" width="20" height="134" fill="#ffcdd2" opacity="0.55"/>
<rect x="300" y="-4" width="20" height="134" fill="none" stroke="#e53935" stroke-width="1" stroke-dasharray="3,3"/>
<text x="310.0" y="-12" text-anchor="middle" font-size="10" fill="#c62828" font-weight="600">dead time</text>
<line x1="100" y1="10" x2="120" y2="56" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="33.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
<line x1="300" y1="10" x2="320" y2="102" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="56.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
<text x="450.0" y="232" text-anchor="middle" font-size="10" fill="#888888">Same timing resources; output polarity inverted after the delay stage.</text>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,20 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 290" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="290" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">FED on B, A Bypasses Dead Time</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_A</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_B</text>
<polyline points="0,66 100,66 100,46 300,46 300,66 500,66" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,112 100,112 100,92 300,92 300,112 500,112" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="152" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,158 100,158 100,138 320,138 320,158 500,158" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="300" y1="56" x2="320" y2="148" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="102.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,20 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 290" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="290" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">RED on A, B Bypasses Dead Time</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_A</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_B</text>
<polyline points="0,66 100,66 100,46 300,46 300,66 500,66" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,112 120,112 120,92 300,92 300,112 500,112" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="152" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,158 100,158 100,138 300,138 300,158 500,158" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="100" y1="10" x2="120" y2="102" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="56.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 290" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="290" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Bypass A, RED + FED on B</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
<marker id="arre53935" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#e53935"/></marker>
<marker id="arr1e88e5" markerWidth="7" markerHeight="7" refX="7" refY="3.5" orient="auto"><polygon points="0,0 7,3.5 0,7" fill="#1e88e5"/></marker>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_A</text>
<polyline points="0,20 100,20 100,0 300,0 300,20 500,20" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#757575" font-weight="600">origin_B</text>
<polyline points="0,66 100,66 100,46 300,46 300,66 500,66" fill="none" stroke="#757575" stroke-width="2"/>
<text x="-12" y="106" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,112 100,112 100,92 300,92 300,112 500,112" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="152" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,158 120,158 120,138 320,138 320,158 500,158" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="100" y1="56" x2="120" y2="148" stroke="#e53935" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arre53935)"/>
<text x="110.0" y="102.0" text-anchor="middle" font-size="10" fill="#e53935" font-weight="600">RED</text>
<line x1="300" y1="56" x2="320" y2="148" stroke="#1e88e5" stroke-width="1.2" stroke-dasharray="3,3" marker-end="url(#arr1e88e5)"/>
<text x="310.0" y="102.0" text-anchor="middle" font-size="10" fill="#1e88e5" font-weight="600">FED</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Dual-Edge Asymmetric PWM (Complementary)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,20 150,20 150,0 350,0 350,20 500,20" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,66 0,46 150,46 150,66 350,66 350,46 500,46 500,66" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp_a</text>
<line x1="350" y1="-4" x2="350" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="350" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp_b</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">gen_a and gen_b use opposite compare actions.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,20 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Center-Aligned PWM</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#333333" font-weight="600">count</text>
<line x1="0" y1="20" x2="250" y2="0" stroke="#8e24aa" stroke-width="2"/>
<line x1="250" y1="0" x2="500" y2="20" stroke="#8e24aa" stroke-width="2"/>
<line x1="500" y1="0" x2="500" y2="20" stroke="#8e24aa" stroke-width="1" stroke-dasharray="3,3"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 150,66 150,46 350,46 350,66 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
<line x1="350" y1="-4" x2="350" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="350" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">High while counting up to cmp, low while counting down past it.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Complementary Center-Aligned PWM (No Dead Time)</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,20 150,20 150,0 350,0 350,20 500,20" fill="none" stroke="#43a047" stroke-width="2"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#1e88e5" font-weight="600">pwm_B</text>
<polyline points="0,66 0,46 150,46 150,66 350,66 350,46 500,46 500,66" fill="none" stroke="#1e88e5" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
<line x1="350" y1="-4" x2="350" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="350" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">Logical complement only; not yet safe for a power stage.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 186 KiB

78
docs/_static/mcpwm/phase_shift.svg vendored Normal file
View File

@@ -0,0 +1,78 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 370" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="0" orient="auto">
<polygon points="0,-3 8,0 0,3" fill="#555"/>
</marker>
</defs>
<rect width="900" height="370" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">PWM Phase Shift — 90° Lag</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(50, 55)">
<!-- ===== Timeline ===== -->
<!-- X-axis: 0 to 600px = 200 ticks (3 px/tick). Period = 100 ticks = 300 px. -->
<!-- Row baselines at translate offsets 40/80, low at y=20, high at y=0 -->
<!-- Subtle period gridlines -->
<g stroke="#e0e0e0" stroke-width="1" opacity="0.5">
<line x1="0" y1="40" x2="0" y2="100"/>
<line x1="150" y1="40" x2="150" y2="100"/>
<line x1="300" y1="40" x2="300" y2="100"/>
<line x1="450" y1="40" x2="450" y2="100"/>
<line x1="600" y1="40" x2="600" y2="100"/>
</g>
<!-- Period labels -->
<text x="150" y="34" text-anchor="middle" font-size="9" fill="#999">Period 1</text>
<text x="450" y="34" text-anchor="middle" font-size="9" fill="#999">Period 2</text>
<!-- ===== PWM_A signal ===== -->
<text x="-8" y="62" text-anchor="end" font-size="11" fill="#333" font-weight="600">PWM_A</text>
<rect x="-6" y="52" width="10" height="10" rx="2" fill="#1e88e5"/>
<g transform="translate(0, 40)">
<polyline points="0,20 0,0 150,0 150,20 300,20 300,0 450,0 450,20 600,20" fill="none" stroke="#1e88e5" stroke-width="2.5"/>
</g>
<!-- ===== PWM_B signal ===== -->
<text x="-8" y="102" text-anchor="end" font-size="11" fill="#333" font-weight="600">PWM_B</text>
<rect x="-6" y="92" width="10" height="10" rx="2" fill="#f57c00"/>
<g transform="translate(0, 80)">
<polyline points="0,20 75,20 75,0 225,0 225,20 375,20 375,0 525,0 525,20 600,20" fill="none" stroke="#f57c00" stroke-width="2.5"/>
</g>
<!-- ===== Phase shift arrow ===== -->
<line x1="0" y1="126" x2="75" y2="126" stroke="#555" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<line x1="75" y1="126" x2="0" y2="126" stroke="#555" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<text x="37.5" y="122" text-anchor="middle" font-size="10" fill="#555" font-weight="600">25 ticks = 90°</text>
<text x="37.5" y="140" text-anchor="middle" font-size="9" fill="#777" font-style="italic">PWM_B lags PWM_A</text>
<!-- ===== Time axis ===== -->
<g stroke="#ddd" stroke-width="1">
<line x1="0" y1="158" x2="600" y2="158"/>
</g>
<g font-size="9" fill="#999" text-anchor="middle">
<text x="0" y="172">0</text>
<text x="75" y="172">25</text>
<text x="150" y="172">50</text>
<text x="225" y="172">75</text>
<text x="300" y="172">100</text>
<text x="375" y="172">125</text>
<text x="450" y="172">150</text>
<text x="525" y="172">175</text>
<text x="600" y="172">200</text>
</g>
<text x="600" y="158" font-size="9" fill="#999" text-anchor="start" dy="-2"> ticks</text>
<!-- ===== Bottom note ===== -->
<text x="300" y="195" text-anchor="middle" font-size="9" fill="#777">PWM period = 100 ticks, 50% duty cycle. A 25-tick offset produces a 90° phase shift.</text>
<!-- ===== Right-hand labels ===== -->
<g transform="translate(640, 0)">
<text x="0" y="58" font-size="9" fill="#888">50% duty, period = 100 ticks</text>
<text x="0" y="98" font-size="9" fill="#888">Starts 25 ticks after PWM_A</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,19 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Pulse Placement Inside the Period</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#333333" font-weight="600">count</text>
<line x1="0" y1="20" x2="500" y2="0" stroke="#8e24aa" stroke-width="2"/>
<line x1="500" y1="0" x2="500" y2="20" stroke="#8e24aa" stroke-width="1" stroke-dasharray="3,3"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 150,66 150,46 350,46 350,66 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp_a</text>
<line x1="350" y1="-4" x2="350" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="350" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp_b</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">cmp_a opens the pulse, cmp_b closes it.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,17 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Single-Edge Asymmetric PWM, Active High</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#333333" font-weight="600">count</text>
<line x1="0" y1="20" x2="500" y2="0" stroke="#8e24aa" stroke-width="2"/>
<line x1="500" y1="0" x2="500" y2="20" stroke="#8e24aa" stroke-width="1" stroke-dasharray="3,3"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 0,46 150,46 150,66 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">Set high at timer zero, low at the comparator.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,17 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 198" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<rect width="900" height="198" fill="#ffffff" rx="8"/>
<text x="450.0" y="30" text-anchor="middle" font-size="14" fill="#333333" font-weight="700">Single-Edge Asymmetric PWM, Active Low</text>
<line x1="170" y1="38" x2="730" y2="38" stroke="#ddd" stroke-width="1"/>
<defs>
</defs>
<g transform="translate(70, 66)">
<text x="-12" y="14" text-anchor="end" font-size="11" fill="#333333" font-weight="600">count</text>
<line x1="0" y1="20" x2="500" y2="0" stroke="#8e24aa" stroke-width="2"/>
<line x1="500" y1="0" x2="500" y2="20" stroke="#8e24aa" stroke-width="1" stroke-dasharray="3,3"/>
<text x="-12" y="60" text-anchor="end" font-size="11" fill="#43a047" font-weight="600">pwm_A</text>
<polyline points="0,66 150,66 150,46 500,46 500,66" fill="none" stroke="#43a047" stroke-width="2"/>
<line x1="150" y1="-4" x2="150" y2="84" stroke="#ff9800" stroke-width="1" stroke-dasharray="4,4"/>
<text x="150" y="-12" text-anchor="middle" font-size="10" fill="#ff9800">cmp = 15</text>
</g>
<text x="450.0" y="186" text-anchor="middle" font-size="10" fill="#888888">Set low at the period boundary, high at the comparator.</text>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

127
docs/_static/mcpwm/timer_up_count.svg vendored Normal file
View File

@@ -0,0 +1,127 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 370" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="370" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">Up-Counting Timer Timing Diagram</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(50, 55)">
<!-- ===== Parameters ===== -->
<!-- X-axis: 0 to 500px = 50 ticks (10px per tick) -->
<!-- Signal height: 36px per signal, start at y=50 -->
<!-- Clock signal -->
<text x="-8" y="72" text-anchor="end" font-size="11" fill="#333" font-weight="600">clk</text>
<g transform="translate(0, 60)">
<polyline points="0,20 0,0 10,0 10,20 20,20 20,0 30,0 30,20 40,20 40,0 50,0 50,20 60,20 60,0 70,0 70,20 80,20 80,0 90,0 90,20 100,20 100,0 110,0 110,20 120,20 120,0 130,0 130,20 140,20 140,0 150,0 150,20 160,20 160,0 170,0 170,20 180,20 180,0 190,0 190,20 200,20 200,0 210,0 210,20 220,20 220,0 230,0 230,20 240,20 240,0 250,0 250,20 260,20 260,0 270,0 270,20 280,20 280,0 290,0 290,20 300,20 300,0 310,0 310,20 320,20 320,0 330,0 330,20 340,20 340,0 350,0 350,20 360,20 360,0 370,0 370,20 380,20 380,0 390,0 390,20 400,20 400,0 410,0 410,20 420,20 420,0 430,0 430,20 440,20 440,0 450,0 450,20 460,20 460,0 470,0 470,20 480,20 480,0 490,0 490,20 500,20 500,0" fill="none" stroke="#666" stroke-width="1.5"/>
</g>
<!-- ===== Count Bus (decimal values) ===== -->
<text x="-8" y="112" text-anchor="end" font-size="11" fill="#333" font-weight="600">count</text>
<g transform="translate(0, 90)">
<!-- Value at every 5 ticks, decimal -->
<rect x="-8" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="0" y="20" text-anchor="middle" font-size="10" fill="#1565c0">0</text>
<rect x="42" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="50" y="20" text-anchor="middle" font-size="10" fill="#1565c0">5</text>
<rect x="92" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="100" y="20" text-anchor="middle" font-size="10" fill="#1565c0">10</text>
<rect x="142" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="150" y="20" text-anchor="middle" font-size="10" fill="#1565c0">15</text>
<rect x="192" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="200" y="20" text-anchor="middle" font-size="10" fill="#1565c0">20</text>
<rect x="242" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="250" y="20" text-anchor="middle" font-size="10" fill="#1565c0">25</text>
<rect x="292" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="300" y="20" text-anchor="middle" font-size="10" fill="#1565c0">30</text>
<rect x="342" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="350" y="20" text-anchor="middle" font-size="10" fill="#1565c0">35</text>
<rect x="392" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="400" y="20" text-anchor="middle" font-size="10" fill="#1565c0">40</text>
<rect x="442" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="450" y="20" text-anchor="middle" font-size="10" fill="#1565c0">45</text>
<!-- Peak: count reaches 50, then reload -->
<rect x="492" y="0" width="16" height="30" fill="#fff3e0" stroke="#ffb74d" stroke-width="1.5" rx="2"/>
<text x="500" y="20" text-anchor="middle" font-size="10" fill="#e65100" font-weight="700">50</text>
<rect x="524" y="0" width="86" height="30" fill="#fce4ec" stroke="#e57373" stroke-width="1.5" rx="2"/>
<text x="567" y="20" text-anchor="middle" font-size="10" fill="#c62828">reset / reload</text>
<rect x="622" y="0" width="16" height="30" fill="#e8f5e9" stroke="#81c784" stroke-width="1.5" rx="2"/>
<text x="630" y="20" text-anchor="middle" font-size="10" fill="#2e7d32">0</text>
</g>
<!-- ===== TEZ Signal ===== -->
<text x="-8" y="152" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEZ</text>
<g transform="translate(0, 130)">
<!-- Baseline low -->
<line x1="0" y1="20" x2="500" y2="20" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse at period start (count = 0) -->
<polyline points="0,20 0,0 10,0 10,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse on reload (count returns to 0) -->
<polyline points="626,20 626,0 634,0 634,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
</g>
<!-- ===== TEP Signal ===== -->
<text x="-8" y="192" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEP</text>
<g transform="translate(0, 170)">
<!-- Baseline low -->
<line x1="0" y1="20" x2="500" y2="20" stroke="#1e88e5" stroke-width="1.5"/>
<!-- Pulse at peak (count = 50) -->
<polyline points="498,20 498,0 504,0 504,20" fill="none" stroke="#1e88e5" stroke-width="1.5"/>
</g>
<!-- ===== Waveform (sawtooth) ===== -->
<text x="-8" y="232" text-anchor="end" font-size="11" fill="#333" font-weight="600">wave</text>
<g transform="translate(0, 210)">
<!-- Sawtooth: rise 0 -> 50 across one period, reset at the period boundary, then rise again -->
<polyline points="0,20 500,0 500,20 630,15" fill="none" stroke="#8e24aa" stroke-width="2"/>
</g>
<!-- ===== Period bracket ===== -->
<g transform="translate(0, 250)">
<line x1="0" y1="0" x2="0" y2="12" stroke="#999" stroke-width="1"/>
<line x1="500" y1="0" x2="500" y2="12" stroke="#999" stroke-width="1"/>
<line x1="0" y1="6" x2="500" y2="6" stroke="#999" stroke-width="1"/>
<text x="250" y="30" text-anchor="middle" font-size="12" fill="#555">auto-reload period = 50 ticks</text>
</g>
<!-- ===== Annotation: relation lines ===== -->
<g transform="translate(0, 0)">
<!-- Count=0 → TEZ -->
<line x1="0" y1="120" x2="0" y2="150" stroke="#e53935" stroke-width="1" stroke-dasharray="4,4"/>
<!-- Count=50 → TEP -->
<line x1="500" y1="120" x2="500" y2="190" stroke="#1e88e5" stroke-width="1" stroke-dasharray="4,4"/>
<!-- Peak marker -->
<line x1="500" y1="60" x2="500" y2="250" stroke="#ffb74d" stroke-width="1" stroke-dasharray="6,4" opacity="0.5"/>
<text x="500" y="50" text-anchor="middle" font-size="9" fill="#e65100">peak</text>
</g>
<!-- Signal labels on the right -->
<g transform="translate(660, 0)">
<text x="0" y="75" font-size="9" fill="#888">Timer clock source</text>
<text x="0" y="115" font-size="9" fill="#888">Counter value (decimal)</text>
<text x="0" y="155" font-size="9" fill="#888">Pulse when counter = 0</text>
<text x="0" y="195" font-size="9" fill="#888">Pulse when counter = peak</text>
<text x="0" y="235" font-size="9" fill="#888">Sawtooth: count 0 to 50, then reset</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -0,0 +1,122 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 370" font-family="'DejaVu Sans Mono', 'Consolas', 'Liberation Mono', monospace">
<defs>
<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0,0 8,3 0,6" fill="#555"/>
</marker>
</defs>
<rect width="900" height="370" fill="#ffffff" rx="8"/>
<!-- Title -->
<text x="450" y="32" text-anchor="middle" font-size="14" fill="#333" font-weight="700">Up-Down Counting Timer Timing Diagram</text>
<line x1="180" y1="40" x2="720" y2="40" stroke="#ddd" stroke-width="1"/>
<g transform="translate(50, 55)">
<!-- ===== Parameters ===== -->
<!-- X-axis: 0 to 500px = 50 ticks (10px per tick) -->
<!-- Peak at 25: 50 ticks total, up 0→25 (250px), down 25→0 (250px) -->
<!-- Clock signal -->
<text x="-8" y="72" text-anchor="end" font-size="11" fill="#333" font-weight="600">clk</text>
<g transform="translate(0, 60)">
<polyline points="0,20 0,0 10,0 10,20 20,20 20,0 30,0 30,20 40,20 40,0 50,0 50,20 60,20 60,0 70,0 70,20 80,20 80,0 90,0 90,20 100,20 100,0 110,0 110,20 120,20 120,0 130,0 130,20 140,20 140,0 150,0 150,20 160,20 160,0 170,0 170,20 180,20 180,0 190,0 190,20 200,20 200,0 210,0 210,20 220,20 220,0 230,0 230,20 240,20 240,0 250,0 250,20 260,20 260,0 270,0 270,20 280,20 280,0 290,0 290,20 300,20 300,0 310,0 310,20 320,20 320,0 330,0 330,20 340,20 340,0 350,0 350,20 360,20 360,0 370,0 370,20 380,20 380,0 390,0 390,20 400,20 400,0 410,0 410,20 420,20 420,0 430,0 430,20 440,20 440,0 450,0 450,20 460,20 460,0 470,0 470,20 480,20 480,0 490,0 490,20 500,20 500,0" fill="none" stroke="#666" stroke-width="1.5"/>
</g>
<!-- ===== Count Bus (decimal values, up then down) ===== -->
<text x="-8" y="112" text-anchor="end" font-size="11" fill="#333" font-weight="600">count</text>
<g transform="translate(0, 90)">
<!-- Rising segment: 0 → 25 -->
<rect x="-8" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="0" y="20" text-anchor="middle" font-size="10" fill="#1565c0">0</text>
<rect x="42" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="50" y="20" text-anchor="middle" font-size="10" fill="#1565c0">5</text>
<rect x="92" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="100" y="20" text-anchor="middle" font-size="10" fill="#1565c0">10</text>
<rect x="142" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="150" y="20" text-anchor="middle" font-size="10" fill="#1565c0">15</text>
<rect x="192" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="200" y="20" text-anchor="middle" font-size="10" fill="#1565c0">20</text>
<!-- Peak: count reaches 25 -->
<rect x="242" y="0" width="16" height="30" fill="#fff3e0" stroke="#ffb74d" stroke-width="1.5" rx="2"/>
<text x="250" y="20" text-anchor="middle" font-size="10" fill="#e65100" font-weight="700">25</text>
<!-- Falling segment: 20 → 0 -->
<rect x="292" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="300" y="20" text-anchor="middle" font-size="10" fill="#1565c0">20</text>
<rect x="342" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="350" y="20" text-anchor="middle" font-size="10" fill="#1565c0">15</text>
<rect x="392" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="400" y="20" text-anchor="middle" font-size="10" fill="#1565c0">10</text>
<rect x="442" y="0" width="16" height="30" fill="#e3f2fd" stroke="#90caf9" stroke-width="1" rx="2"/>
<text x="450" y="20" text-anchor="middle" font-size="10" fill="#1565c0">5</text>
<!-- End of cycle: back to 0, then the next cycle counts up again -->
<rect x="492" y="0" width="16" height="30" fill="#e8f5e9" stroke="#81c784" stroke-width="1.5" rx="2"/>
<text x="500" y="20" text-anchor="middle" font-size="10" fill="#2e7d32">0</text>
</g>
<!-- ===== TEZ Signal ===== -->
<text x="-8" y="152" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEZ</text>
<g transform="translate(0, 130)">
<line x1="0" y1="20" x2="500" y2="20" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse at cycle start (count = 0) -->
<polyline points="0,20 0,0 10,0 10,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
<!-- Pulse at cycle end (count returns to 0) -->
<polyline points="490,20 490,0 500,0 500,20" fill="none" stroke="#e53935" stroke-width="1.5"/>
</g>
<!-- ===== TEP Signal ===== -->
<text x="-8" y="192" text-anchor="end" font-size="11" fill="#333" font-weight="600">TEP</text>
<g transform="translate(0, 170)">
<line x1="0" y1="20" x2="500" y2="20" stroke="#1e88e5" stroke-width="1.5"/>
<!-- Pulse at peak (count = 25) -->
<polyline points="240,20 240,0 260,0 260,20" fill="none" stroke="#1e88e5" stroke-width="1.5"/>
</g>
<!-- ===== Waveform (triangle) ===== -->
<text x="-8" y="232" text-anchor="end" font-size="11" fill="#333" font-weight="600">wave</text>
<g transform="translate(0, 210)">
<!-- Triangle: rise 0 -> 25, fall 25 -> 0, then rise again for the next cycle -->
<polyline points="0,20 250,0 500,20 630,10" fill="none" stroke="#8e24aa" stroke-width="2"/>
</g>
<!-- ===== Period bracket ===== -->
<g transform="translate(0, 250)">
<line x1="0" y1="0" x2="0" y2="12" stroke="#999" stroke-width="1"/>
<line x1="500" y1="0" x2="500" y2="12" stroke="#999" stroke-width="1"/>
<line x1="0" y1="6" x2="500" y2="6" stroke="#999" stroke-width="1"/>
<text x="250" y="30" text-anchor="middle" font-size="12" fill="#555">auto-reload period = 50 ticks (peak = 25)</text>
</g>
<!-- ===== Annotation: relation lines ===== -->
<g transform="translate(0, 0)">
<!-- Count=0 → TEZ -->
<line x1="0" y1="120" x2="0" y2="150" stroke="#e53935" stroke-width="1" stroke-dasharray="4,4"/>
<line x1="500" y1="120" x2="500" y2="150" stroke="#e53935" stroke-width="1" stroke-dasharray="4,4"/>
<!-- Count=25 → TEP -->
<line x1="250" y1="120" x2="250" y2="190" stroke="#1e88e5" stroke-width="1" stroke-dasharray="4,4"/>
<!-- Peak marker -->
<line x1="250" y1="60" x2="250" y2="250" stroke="#ffb74d" stroke-width="1" stroke-dasharray="6,4" opacity="0.5"/>
<text x="250" y="50" text-anchor="middle" font-size="9" fill="#e65100">peak</text>
</g>
<!-- Signal labels on the right -->
<g transform="translate(545, 0)">
<text x="0" y="75" font-size="9" fill="#888">Timer clock source</text>
<text x="0" y="115" font-size="9" fill="#888">Counter value (decimal), up then down</text>
<text x="0" y="155" font-size="9" fill="#888">Pulse when counter = 0</text>
<text x="0" y="195" font-size="9" fill="#888">Pulse when counter = peak</text>
<text x="0" y="235" font-size="9" fill="#888">Triangle: count 0 to 25, back to 0</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.1 KiB