Section 8: ESP32 Dual Core Setup
The advanced features such as StallGuard can be purchased in our PDF guide here. |
Before we go further into FastAccelStepper, let’s set up the dual core capability of the ESP32, because it may confuse you in the sketch. Here is the basic overview.
The ESP32 has two cores. For best performance, we need the motor functions to run on one core, and the WiFi functions to run on the other core.
By default, all Arduino code runs on Core 1 (including the WiFi processes). So, we will create Core 0. To create Core 0, we do this:
xTaskCreatePinnedToCore( MotorTask , "MotorTask" , 1024 * 4 , NULL , 3 , NULL , 0); |
Next, let’s create the function to run on this core, it needs to be named MotorTask because that’s what we named it above.
Here we have our function running in a loop on core 0 only. This is where the motor will run, ensuring it only runs on Core 0. The while(true) creates an infinite loop.
void MotorTask(void *pvParameters) {
while(true) {
NEXT SECTION: 9
Course Sections:
- Section 0: Background
- Section 1: Hardware Setup
- Section 2: Stepper Motor Basics
- Section 3: Power Requirements
- Section 4: Arduino Setup
- Section 5: Understanding Trinamic Drivers
- Section 6: TMCStepper Library
- Section 7: FastAccelStepper Library
- Section 8: ESP32 Dual Core Setup
- Section 9: Motor Setup
- Section 10: Understanding Positioning
Advanced Sections: