mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-10 06:23:23 +00:00
RC Robot Tutorial
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -125,6 +125,27 @@ The following images illustrate various PWM duty cycles registered by oscillosco
|
|||||||
|
|
||||||
<br/><br/><br/><br/>
|
<br/><br/><br/><br/>
|
||||||
|
|
||||||
|
Fusion of Software with Hardware
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
On one hand, we have the hardware designed so that the joystic x- and y- axis, and DC motors are wired to the proper GPIOs on the
|
||||||
|
ESP32-C3 WROOM microcontroller. On the other hand, we have the software that reads the joystick x- and y- axis, sends the data
|
||||||
|
to the receiver device, and converts that to PWM values on the receiver device.
|
||||||
|
|
||||||
|
In essense, the direction and speed of the bitByte Rider car is controlled by the two variables. On the remote controller device,
|
||||||
|
the joystic x- and y- axis values are sent to the receiver device in a raw format (i.e. analog voltages, "as-is"). On the receover
|
||||||
|
device, these two values are converted to the two PWM values; one for each pair of DC motors on left and right side.
|
||||||
|
|
||||||
|
When the joystick is pushed forward, the X-axis voltage remains at 1.65V (neutral), while the Y-axis voltage rises to 3.3V. The
|
||||||
|
receiver on the RC car interprets this input and generates 100% PWM duty cycle signals on both sides, driving the car forward at
|
||||||
|
full speed.
|
||||||
|
|
||||||
|
Similarly, when the joystick is pushed fully to the left or right, the X-axis voltage shifts while the Y-axis remains neutral. For a
|
||||||
|
left turn, the receiver translates the signal into 100% PWM on the left-side motors and 0% on the right-side motors, causing the car
|
||||||
|
to pivot. The opposite occurs for a right turn, with 100% PWM on the right and 0% on the left, enabling precise directional control.
|
||||||
|
|
||||||
|
The table below summarizes the reserved GPIOs.
|
||||||
|
|
||||||
+------+-----+---------------------------------------------------------+----------------+
|
+------+-----+---------------------------------------------------------+----------------+
|
||||||
| GPIO | Pin | Function | Notes |
|
| GPIO | Pin | Function | Notes |
|
||||||
+======+=====+=========================================================+================+
|
+======+=====+=========================================================+================+
|
||||||
@@ -143,9 +164,6 @@ The following images illustrate various PWM duty cycles registered by oscillosco
|
|||||||
| 7 | 6 | PWM for counter-clockwise rotation of left-side motors | LEDC_CHANNEL_3 |
|
| 7 | 6 | PWM for counter-clockwise rotation of left-side motors | LEDC_CHANNEL_3 |
|
||||||
+------+-----+---------------------------------------------------------+----------------+
|
+------+-----+---------------------------------------------------------+----------------+
|
||||||
|
|
||||||
Fusion of Software with Hardware
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
The *struct* for storing motors PWM values.
|
The *struct* for storing motors PWM values.
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
@@ -168,7 +168,24 @@ Right DC Motors spin clockwise</p></td>
|
|||||||
<p><span class="caption-text">DC Motor PWM duty cycle 90.8%</span><a class="headerlink" href="#id3" title="Link to this image">¶</a></p>
|
<p><span class="caption-text">DC Motor PWM duty cycle 90.8%</span><a class="headerlink" href="#id3" title="Link to this image">¶</a></p>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br/><br/><br/><br/><table class="docutils align-default">
|
<br/><br/><br/><br/></section>
|
||||||
|
</section>
|
||||||
|
<section id="fusion-of-software-with-hardware">
|
||||||
|
<h2><span class="section-number">2.2. </span>Fusion of Software with Hardware<a class="headerlink" href="#fusion-of-software-with-hardware" title="Link to this heading">¶</a></h2>
|
||||||
|
<p>On one hand, we have the hardware designed so that the joystic x- and y- axis, and DC motors are wired to the proper GPIOs on the
|
||||||
|
ESP32-C3 WROOM microcontroller. On the other hand, we have the software that reads the joystick x- and y- axis, sends the data
|
||||||
|
to the receiver device, and converts that to PWM values on the receiver device.</p>
|
||||||
|
<p>In essense, the direction and speed of the bitByte Rider car is controlled by the two variables. On the remote controller device,
|
||||||
|
the joystic x- and y- axis values are sent to the receiver device in a raw format (i.e. analog voltages, “as-is”). On the receover
|
||||||
|
device, these two values are converted to the two PWM values; one for each pair of DC motors on left and right side.</p>
|
||||||
|
<p>When the joystick is pushed forward, the X-axis voltage remains at 1.65V (neutral), while the Y-axis voltage rises to 3.3V. The
|
||||||
|
receiver on the RC car interprets this input and generates 100% PWM duty cycle signals on both sides, driving the car forward at
|
||||||
|
full speed.</p>
|
||||||
|
<p>Similarly, when the joystick is pushed fully to the left or right, the X-axis voltage shifts while the Y-axis remains neutral. For a
|
||||||
|
left turn, the receiver translates the signal into 100% PWM on the left-side motors and 0% on the right-side motors, causing the car
|
||||||
|
to pivot. The opposite occurs for a right turn, with 100% PWM on the right and 0% on the left, enabling precise directional control.</p>
|
||||||
|
<p>The table below summarizes the reserved GPIOs.</p>
|
||||||
|
<table class="docutils align-default">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="row-odd"><th class="head"><p>GPIO</p></th>
|
<tr class="row-odd"><th class="head"><p>GPIO</p></th>
|
||||||
<th class="head"><p>Pin</p></th>
|
<th class="head"><p>Pin</p></th>
|
||||||
@@ -214,10 +231,6 @@ Right DC Motors spin clockwise</p></td>
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
<section id="fusion-of-software-with-hardware">
|
|
||||||
<h2><span class="section-number">2.2. </span>Fusion of Software with Hardware<a class="headerlink" href="#fusion-of-software-with-hardware" title="Link to this heading">¶</a></h2>
|
|
||||||
<p>The <em>struct</em> for storing motors PWM values.</p>
|
<p>The <em>struct</em> for storing motors PWM values.</p>
|
||||||
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span><span class="w"> </span><span class="nc">motors_rpm</span><span class="w"> </span><span class="p">{</span>
|
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span><span class="w"> </span><span class="nc">motors_rpm</span><span class="w"> </span><span class="p">{</span>
|
||||||
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">motor1_rpm_pwm</span><span class="p">;</span>
|
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">motor1_rpm_pwm</span><span class="p">;</span>
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
# Sphinx build info version 1
|
# Sphinx build info version 1
|
||||||
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
|
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||||
config: 564111c68e4938e1ff35159ef0a02532
|
config: e22baa48f9e7069a3e9b5dc9ddc22300
|
||||||
tags: 62a1e7829a13fc7881b6498c52484ec0
|
tags: 62a1e7829a13fc7881b6498c52484ec0
|
||||||
|
Binary file not shown.
@@ -695,188 +695,6 @@ Right DC Motors spin clockwise
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<table class="docutils align-default">
|
|
||||||
<thead>
|
|
||||||
<tr class="row-odd">
|
|
||||||
<th class="head">
|
|
||||||
<p>
|
|
||||||
GPIO
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="head">
|
|
||||||
<p>
|
|
||||||
Pin
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="head">
|
|
||||||
<p>
|
|
||||||
Function
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="head">
|
|
||||||
<p>
|
|
||||||
Notes
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr class="row-even">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
0
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
16
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
Joystick x-axis
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
ADC1_CH0
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-odd">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
1
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
15
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
Joystick y-axis
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
ADC1_CH1
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-even">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
8
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
5
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
Joystick push button
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
NC
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-odd">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
6
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
4
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
PWM for clockwise rotation of left-side motors
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
LEDC_CHANNEL_1
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-even">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
5
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
3
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
PWM for clockwise rotation of right-side motors
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
LEDC_CHANNEL_0
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-odd">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
4
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
2
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
PWM for counter-clockwise rotation of right-side motors
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
LEDC_CHANNEL_2
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="row-even">
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
7
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
6
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
PWM for counter-clockwise rotation of left-side motors
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
LEDC_CHANNEL_3
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section id="fusion-of-software-with-hardware">
|
<section id="fusion-of-software-with-hardware">
|
||||||
@@ -886,6 +704,211 @@ Right DC Motors spin clockwise
|
|||||||
¶
|
¶
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
<p>
|
||||||
|
On one hand, we have the hardware designed so that the joystic x- and y- axis, and DC motors are wired to the proper GPIOs on the
|
||||||
|
ESP32-C3 WROOM microcontroller. On the other hand, we have the software that reads the joystick x- and y- axis, sends the data
|
||||||
|
to the receiver device, and converts that to PWM values on the receiver device.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
In essense, the direction and speed of the bitByte Rider car is controlled by the two variables. On the remote controller device,
|
||||||
|
the joystic x- and y- axis values are sent to the receiver device in a raw format (i.e. analog voltages, “as-is”). On the receover
|
||||||
|
device, these two values are converted to the two PWM values; one for each pair of DC motors on left and right side.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
When the joystick is pushed forward, the X-axis voltage remains at 1.65V (neutral), while the Y-axis voltage rises to 3.3V. The
|
||||||
|
receiver on the RC car interprets this input and generates 100% PWM duty cycle signals on both sides, driving the car forward at
|
||||||
|
full speed.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Similarly, when the joystick is pushed fully to the left or right, the X-axis voltage shifts while the Y-axis remains neutral. For a
|
||||||
|
left turn, the receiver translates the signal into 100% PWM on the left-side motors and 0% on the right-side motors, causing the car
|
||||||
|
to pivot. The opposite occurs for a right turn, with 100% PWM on the right and 0% on the left, enabling precise directional control.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The table below summarizes the reserved GPIOs.
|
||||||
|
</p>
|
||||||
|
<table class="docutils align-default">
|
||||||
|
<thead>
|
||||||
|
<tr class="row-odd">
|
||||||
|
<th class="head">
|
||||||
|
<p>
|
||||||
|
GPIO
|
||||||
|
</p>
|
||||||
|
</th>
|
||||||
|
<th class="head">
|
||||||
|
<p>
|
||||||
|
Pin
|
||||||
|
</p>
|
||||||
|
</th>
|
||||||
|
<th class="head">
|
||||||
|
<p>
|
||||||
|
Function
|
||||||
|
</p>
|
||||||
|
</th>
|
||||||
|
<th class="head">
|
||||||
|
<p>
|
||||||
|
Notes
|
||||||
|
</p>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="row-even">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
0
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
16
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Joystick x-axis
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
ADC1_CH0
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
1
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
15
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Joystick y-axis
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
ADC1_CH1
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
8
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
5
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Joystick push button
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
NC
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
6
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
4
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
PWM for clockwise rotation of left-side motors
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
LEDC_CHANNEL_1
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
5
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
3
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
PWM for clockwise rotation of right-side motors
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
LEDC_CHANNEL_0
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
4
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
2
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
PWM for counter-clockwise rotation of right-side motors
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
LEDC_CHANNEL_2
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even">
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
7
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
6
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
PWM for counter-clockwise rotation of left-side motors
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
LEDC_CHANNEL_3
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<p>
|
<p>
|
||||||
The
|
The
|
||||||
<em>
|
<em>
|
||||||
|
Reference in New Issue
Block a user