This commit is contained in:
2025-07-05 23:34:06 -04:00
parent 53583d17a2
commit 09a256a7d8
3 changed files with 31 additions and 9 deletions

View File

@@ -27,18 +27,25 @@ Based on this constraint, the RC car can only move front, back, and turn/rotate
.. admonition:: What is PWM?
**PWM** (Pulse Width Modulation) is a technique used to simulate analog voltage levels using ddiscrete igital signals. It works by rapidly switching a
digital pin between HIGH (on) and LOW (off) states at a fixed frequency (often, at base frequency of 5 kHz). The duty cycle—the percentage of time the signal is HIGH in one
cycle determines the effective voltage delivered to a device.
**PWM** stands for Pulse Width Modulation. It is a technique used to simulate analog voltage levels using discrete digital signals. It works by
rapidly switching a digital GPIO pin between HIGH (on) and LOW (off) states at a fixed frequency (often, at base frequency of 5 kHz).
The duty cycle—the percentage of time the signal is HIGH in one cycle determines the effective voltage delivered to a device.
A higher duty cycle increases the motor speed, and a lower duty cycle decreases the motor speed. This allows for fine-grained speed control
without needing analog voltage regulators.
A pair of PWM channels are required for defining rotation speed and direction of the DC motors on each side.
A pair of PWM channels are used per DC motor for defining their rotation speed and direction on each side.
In particular, **GPIO6** and **GPIO5** provide PWM to the left- and right- side DC motors to rotate in a **clockwise** direction.
Similarly, **GPIO4** and **GPIO7** provide PWM to the left- and right- side DC motors to rotate in a **counter-clockwise** direction.
Changing PWM on each channel determines the speed and direction of the RC car.
+-----------+-------+----------+
| GPIO Num. | State | Function |
+===========+=======+==========+
| GPIO6 | PWM | Forward |
| GPIO4 | | |
+-----------+-------+----------+
The following images illustrate various PWM duty cycles registered by oscilloscope (duty cycles 0%, 48% and 91%, resp.).
.. figure:: _static/ESP-IDF_Robot_PWM_Duty-0.bmp

View File

@@ -52,16 +52,31 @@ Consequently, only four PWM channels are sufficient for controlling the directio
Based on this constraint, the RC car can only move front, back, and turn/rotate left and right. Any other movements are not possible (i.e. diagonal or sideways).</p>
<div class="admonition-what-is-pwm admonition">
<p class="admonition-title">What is PWM?</p>
<p><strong>PWM</strong> (Pulse Width Modulation) is a technique used to simulate analog voltage levels using ddiscrete igital signals. It works by rapidly switching a
digital pin between HIGH (on) and LOW (off) states at a fixed frequency (often, at base frequency of 5 kHz). The duty cycle—the percentage of time the signal is HIGH in one
cycle determines the effective voltage delivered to a device.</p>
<p><strong>PWM</strong> stands for Pulse Width Modulation. It is a technique used to simulate analog voltage levels using discrete digital signals. It works by
rapidly switching a digital GPIO pin between HIGH (on) and LOW (off) states at a fixed frequency (often, at base frequency of 5 kHz).
The duty cycle—the percentage of time the signal is HIGH in one cycle determines the effective voltage delivered to a device.</p>
<p>A higher duty cycle increases the motor speed, and a lower duty cycle decreases the motor speed. This allows for fine-grained speed control
without needing analog voltage regulators.</p>
</div>
<p>A pair of PWM channels are required for defining rotation speed and direction of the DC motors on each side.
<p>A pair of PWM channels are used per DC motor for defining their rotation speed and direction on each side.
In particular, <strong>GPIO6</strong> and <strong>GPIO5</strong> provide PWM to the left- and right- side DC motors to rotate in a <strong>clockwise</strong> direction.
Similarly, <strong>GPIO4</strong> and <strong>GPIO7</strong> provide PWM to the left- and right- side DC motors to rotate in a <strong>counter-clockwise</strong> direction.
Changing PWM on each channel determines the speed and direction of the RC car.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>GPIO Num.</p></th>
<th class="head"><p>State</p></th>
<th class="head"><p>Function</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>GPIO6
GPIO4</p></td>
<td><p>PWM</p></td>
<td><p>Forward</p></td>
</tr>
</tbody>
</table>
<p>The following images illustrate various PWM duty cycles registered by oscilloscope (duty cycles 0%, 48% and 91%, resp.).</p>
<figure class="align-default" id="id1">
<img alt="_images/ESP-IDF_Robot_PWM_Duty-0.bmp" src="_images/ESP-IDF_Robot_PWM_Duty-0.bmp" />

File diff suppressed because one or more lines are too long