ESP32_C3_ISR_Servo Library

khoih-prog
Posts: 53
Joined: Sat Feb 22, 2020 8:16 pm

ESP32_C3_ISR_Servo Library

Postby khoih-prog » Wed Aug 04, 2021 2:45 pm

ESP32_C3_ISR_Servo Library
How To Install Using Arduino Library Manager

This library enables you to use 1 Hardware Timer on an ESP32_C3-based board to control up to 16 independent servo motors.

The ESP32_C3 timer Interrupt control is different from that of ESP32, at least with the ESP32 core v2.0.0-rc1. That's why this new ESP32_C3_ISR_Servo Library has been created besides ESP32_ISR_Servo Library.

Important Notes:

1. Inside the ISR function, delay() won’t work and the value returned by millis() will not increment. Serial data received while in the ISR function may be lost. You should declare as volatile any variables that you modify within the attached function.

2. Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.

Initial Release v1.1.0

1. Basic 16 ISR-based servo controllers using 1 hardware timer for ESP32_C3.
2. Tested with ESP32 core v2.0.0-rc1 and v1.0.6


Currently Supported Boards

- ESP32_C3-based boards, such as ESP32C3_DEV, etc


Examples:

1. ESP32_C3_ISR_MultiServos
2. ESP32_C3_MultipleRandomServos
3. ESP32_C3_MultipleServos
4. ISR_MultiServos
5. MultipleRandomServos
6. MultipleServos


Example ESP32_C3_ISR_MultiServos on ESP32C3_DEV

The following is the sample terminal output when running example ESP32_C3_ISR_MultiServos to demonstrate how to control multiple Servos using 1 hardware timer.

Code: Select all

Starting ESP32_C3_ISR_MultiServos on ESP32C3_DEV
ESP32_C3_ISR_Servo v1.1.0
[ISR_SERVO] ESP32_C3_FastTimerInterrupt: _timerNo = 3 , _fre = 1000000
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
[ISR_SERVO] Starting  ITimer OK
Setup Servo1 OK
Setup Servo2 OK
Servo1 pos = 0, Servo2 pos = 180
Servo1 pos = 30, Servo2 pos = 150
Servo1 pos = 60, Servo2 pos = 120
Servo1 pos = 90, Servo2 pos = 90
Servo1 pos = 120, Servo2 pos = 60
Servo1 pos = 150, Servo2 pos = 30
Servo1 pos = 180, Servo2 pos = 0

Who is online

Users browsing this forum: No registered users and 12 guests