You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- IDF 5.3+ Max = RMT channels + I2S Mux slots (can be combined)
162
+
- I2S Mux requires ESP-IDF ≥5.3 and uses one I2S controller
163
+
- I2S Mux slots are shared: if step/dir/enable all use I2S Mux, each stepper consumes 1-3 slots
164
+
- Step only: up to 32 steppers
165
+
- Step + Dir: up to 16 steppers
166
+
- Step + Dir + Enable: up to 10 steppers
167
+
- I2S Direct channels = number of I2S controllers (experimental)
168
+
- C6 and P4 require IDF ≥5.3 (no IDF 4.x support)
146
169
147
170
#### ESP-IDF version 4.x.y:
148
171
* allows up to 200000 generated steps per second
149
172
* supports up to 14 stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
150
173
* Steppers' command queue depth: 32
151
174
152
175
#### ESP-IDF version >=5.3.0:
153
-
* allows up to 200000 generated steps per second
154
-
* supports up to 8 stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
176
+
* allows up to 200000 generated steps per second for RMT. 40kHz for I2S-MUX.
177
+
* supports up to 8+32 stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
155
178
* Steppers' command queue depth: 32
156
179
157
-
###ESP32S2
180
+
#### ESP32 I2S Mux Driver (ESP-IDF >=5.3.0 only)
158
181
159
-
* reported to work
160
-
* allows up to 200000 generated steps per second ?
161
-
* supports up to four stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
162
-
* Steppers' command queue depth: 32
182
+
The I2S Mux driver provides an alternative approach for driving multiple stepper motors using the ESP32's I2S peripheral. This is especially useful when you need more steppers than RMT channels provide.
163
183
164
-
### ESP32S3
184
+
**Overview:**
185
+
The I2S transmitter outputs a 32-bit data word at 250kHz. Each bit corresponds to one output slot (0-31). These signals can be used in two ways:
165
186
166
-
#### ESP-IDF version 4.x.y:
167
-
* allows up to 200000 generated steps per second ?
168
-
* supports up to eight stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
169
-
* Steppers' command queue depth: 32
187
+
1.**With external demultiplexer**: Connect a decoder IC (e.g., 74HC154, 74HC138 cascade, or shift registers like 74HC595) to the I2S data pin to decode the 32-bit stream into individual output pins for step, direction, and enable signals.
170
188
171
-
#### ESP-IDF version >=5.3.0:
172
-
* allows up to 200000 generated steps per second ?
173
-
* supports up to four stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
174
-
* Steppers' command queue depth: 32
189
+
2.**Direct connection**: Use individual I2S output slots directly as stepper driver inputs. Each slot provides one output signal that toggles at the I2S frame rate.
175
190
176
-
### ESP32C3
191
+
**Key Features:**
192
+
* Up to 32 output pins from a single I2S transmitter
193
+
* I2S runs at 250kHz sample rate (4µs frame time)
194
+
* Step, direction, and enable pins can all use I2S outputs
195
+
* Suitable for applications requiring many coordinated steppers
177
196
178
-
* allows up to 200000 generated steps per second ?
179
-
* supports up to two stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
180
-
* Steppers' command queue depth: 32
197
+
**Limitations:**
198
+
* Requires ESP-IDF 5.3 or later (I2S driver API changed significantly)
199
+
* Minimum speed for I2S Mux is 25µs period (40kHz max step rate)
200
+
* Minimum speed for I2S Direct is 5µs period (200kHz max step rate)
201
+
* Step pulse width is 2.5us for I2S Direct and 4us for I2S MUX
202
+
* I2S Direct: stepper speed adjustable in 1/8us deltas.
203
+
* I2S MUX: stepper speed adjustable in 4us deltas e.g. speed 50us will be 52/48/52/48...
181
204
182
-
### ESP32C6
205
+
**I2S Direct vs I2S Mux:**
206
+
***I2S Mux**: Single I2S transmitter drives up to 32 pins. All pins share the same timing.
207
+
***I2S Direct**: Each stepper gets its own I2S channel. Higher precision timing.
208
+
209
+
**Initialization:**
210
+
```cpp
211
+
// Initialize I2S Mux with data, bclk, and word select pins
The I2S mux uses slot numbers 0-31, which are output on the I2S data line. These can be used in two ways:
226
+
* **With external demultiplexer**: Connect a decoder (e.g., 74HC154, 74HC138 cascade) to the I2S data pin to decode the 32-bit frame into 32 individual output pins for step/direction/enable signals
227
+
* **Direct connection**: Use the I2S data pin directly as a step signal
228
+
229
+
**Testing and Demo Application:**
230
+
A comprehensive platformio test application with web interface is available in `extras/Esp32StepperDemo/`.
231
+
This demonstrates:
232
+
* Configuration of multiple steppers via Web UI
233
+
* Real-time position and status monitoring via WebSocket
234
+
* Each I2S slot can be toggled individually
235
+
* I2S mux pin management
236
+
* serial console 115200 asks at startup for Wifi credentials.
237
+
* Sequence automation (not tested)
238
+
239
+
To build and test:
240
+
```bash
241
+
cd extras/Esp32StepperDemo
242
+
pio run -t upload && pio device monitor
243
+
```
244
+
245
+
This test application was AI crafted....
183
246
184
-
* only from esp-idf >=v5.3.0
185
-
* allows up to 200000 generated steps per second ?
186
-
* supports up to four stepper motors using Step/Direction/Enable Control (Direction and Enable is optional)
187
-
* Steppers' command queue depth: 32
188
247
189
248
### Raspberry pi pico/pico 2
190
249
@@ -316,19 +375,37 @@ For the other stepper motors, the rmt module comes into use.
316
375
317
376
#### ESP-IDF version >=5.3.0:
318
377
319
-
Only rmt module is supported.
378
+
RMT and I2S Mux/Direct drivers are supported. MCPWM/PCNT is not available in ESP-IDF 5.3+.
379
+
380
+
#### I2S Mux Driver Implementation
381
+
382
+
The I2S Mux driver uses the ESP32's I2S transmitter in 16-bit stereo mode at 250kHz sample rate. Each I2S frame (32 bits = 16-bit left + 16-bit right channel) represents one time slot, with each bit corresponding to one output pin.
383
+
384
+
**Technical Details:**
385
+
* Sample rate: 250kHz, giving 4µs per frame (64 ticks at 16MHz reference)
386
+
* 32 output slots per frame, each slot is one bit
387
+
* Bits are transmitted MSB-first within each byte
388
+
* DMA buffers are filled in the I2S TX-done callback
389
+
* Direction and enable pins are stored in a 32-bit state word, written to each frame's data
390
+
391
+
**Timing Considerations:**
392
+
* Minimum step period: 25µs for I2S Mux, 5µs for I2S Direct
393
+
* Direction/enable changes have up to 4µs latency
394
+
* All steppers sharing I2S mux are inherently synchronized (same DMA buffer)
320
395
321
396
#### Both ESP-IDF versions
322
397
A note to `MIN_CMD_TICKS` using mcpwm/pcnt: The current implementation uses one interrupt per command in the command queue. This is much less interrupt rate than for avr. Nevertheless at 200kSteps/s the switch from one command to the next one should be ideally serviced before the next step. This means within 5us. As this cannot be guaranteed, the driver remedies an overrun (at least by design) to deduct the overrun pulses from the next command. The overrun pulses will then be run at the former command's tick rate. For real life stepper application, this should be ok. To be considered for raw access: Do not run many steps at high rate e.g. 200kSteps/s followed by a pause.
323
398
324
-
What are the differences between mcpwm/pcntand rmt ?
399
+
What are the differences between mcpwm/pcnt, rmt, and i2s mux?
|Interrupt rate/stepper | one interrupt per command | min: one interrupt per command, max: one interrupt per 31 steps at high speed | one interrupt per 500µs (all) |
404
+
|Required interrupt response | at high speed: time between two steps | at high speed: time between 31 steps | 500µs for all steppers combined |
405
+
|Module usage | 1 or 2 mcpcms, up to 6 channels of pcnt | rmt | 1 i2s |
|esp32 notes | available pcnt modules can be connected | no pcnt module used, so can be attached to rmt output as realtime position | synchronized outputs |
408
+
|Min step period |~5µs |~5µs |~25µs |
332
409
333
410
If the interrupt load is not an issue, then rmt is the better choice. With rmt the below (multi-axis application) mentioned loss of synchonicity at high speeds can be avoided. The rmt driver is - besides some rmt modules perks - less complex and way more straightforward.
334
411
@@ -338,7 +415,7 @@ One specific note for the rmt: If a direction pin toggle is needed directly afte
338
415
339
416
### ESP32S2
340
417
341
-
This stepper driver uses rmt module.
418
+
This stepper driver uses rmt module only.
342
419
343
420
### ESP32S3
344
421
@@ -347,7 +424,8 @@ The ESP32S3's rmt module is similar to esp32c3 with 4 instead of 2 channels and
347
424
#### ESP-IDF version 4.x.y:
348
425
This stepper driver uses mcpwm/pcnt + rmt modules. Can drive up to 8 motors. Tested with 6 motors (not by me).
349
426
#### ESP-IDF version >=5.3.0:
350
-
This stepper driver uses rmt modules. Can drive up to 4 motors.
427
+
This stepper driver uses rmt modules. Can drive up to 4 motors.
428
+
I2S Mux driver is also available with same capabilities as ESP32 (see ESP32 I2S Mux section above).
0 commit comments