-->
Page 1 of 1

ESP8266_ISR_Servo Library

PostPosted: Tue Feb 18, 2020 1:25 am
by khoih-prog
https://github.com/khoih-prog/ESP8266_ISR_Servo

You can install directly from Arduino Library Manager

https://www.ardu-badge.com/ESP8266_ISR_Servo

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

Why do we need this ISR-based Servo controller?

Imagine you have a system with a mission-critical function, controlling a robot arm or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is blocking the loop() or setup().

So your function might not be executed, and the result would be disastrous.

You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.).

The correct choice is to use a Hardware Timer with Interrupt to call your function.

These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.

Functions using normal software timers, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.

The catch is your function is now part of an ISR (Interrupt Service Routine), and must be `lean / mean`, and follow certain rules. More to read on:

https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/