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
{{ message }}
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This library enables you to use `1 Hardware Timer` on an ESP8266-based board to control up to `16 independent servo motors`.
10
+
---
11
+
---
11
12
12
-
***Why do we need this ISR-based Servo controller?***
13
+
### Version v1.0.2
13
14
14
-
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().
15
+
1. Add example using [Blynk] (http://docs.blynk.cc/) to control servos.
16
+
2. Change example names to avoid duplication.
17
+
18
+
#### Version v1.0.1
19
+
20
+
1. Basic 16 ISR-based servo controllers using 1 hardware timer for ESP8266.
21
+
22
+
---
23
+
24
+
This library enables you to use **1 Hardware Timer** on an ESP8266-based board to control up to **16 independent servo motors**.
25
+
26
+
27
+
#### Why do we need this ISR-based Servo controller?
28
+
29
+
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().
15
30
16
31
So your function might not be executed, and the result would be disastrous.
17
32
18
33
You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.).
19
34
20
-
The correct choice is to use a Hardware Timer with Interrupt to call your function.
35
+
The correct choice is to use a **Hardware Timer with Interrupt** to call your function.
36
+
37
+
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.
38
+
39
+
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.
40
+
41
+
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:
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.
47
+
### Important Notes:
23
48
24
-
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.
49
+
1. Inside the attached function, delay() won’t work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.
25
50
26
-
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:
51
+
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.
1. Inside the attached function, `delay()` won’t work and the value returned by `millis()` will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.
56
+
## Prerequisite
32
57
33
-
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`.
58
+
1.[`Arduino IDE 1.8.12+` for Arduino](https://www.arduino.cc/en/Main/Software)
59
+
2.[`ESP8266 core 2.7.3+` for Arduino](https://github.com/esp8266/Arduino#installing-with-boards-manager) for ESP8266 boards.
34
60
35
-
### Installation
61
+
---
36
62
37
-
It's better to use `Arduino Library Manager` to install this library.
63
+
## Installation
38
64
39
-
Otherwise, you can install it using the following steps:
65
+
### Use Arduino Library Manager
40
66
41
-
1. Navigate to (https://github.com/khoih-prog/ESP8266_ISR_Servo) page.
67
+
The best and easiest way is to use `Arduino Library Manager`. Search for `ESP8266_ISR_Servo`, then select / install the latest version.
68
+
You can also use this link [](https://www.ardu-badge.com/ESP8266_ISR_Servo) for more detailed instructions.
69
+
70
+
### Manual Install
71
+
72
+
Another way to install is to:
73
+
74
+
1. Navigate to [ESP8266_ISR_Servo](https://github.com/khoih-prog/ESP8266_ISR_Servo) page.
42
75
2. Download the latest release `ESP8266_ISR_Servo-master.zip`.
43
76
3. Extract the zip file to `ESP8266_ISR_Servo-master` directory
44
-
4. Copy whole folder to Arduino libraries' directory such as `.Arduino/libraries/ESP8266_ISR_Servo-master`.
77
+
4. Copy whole `ESP8266_ISR_Servo-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
3. Install **ESP8266_ISR_Servo** library by using [Library Manager](https://docs.platformio.org/en/latest/librarymanager/). Search for ESP8266_ISR_Servo in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
84
+
4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html)
85
+
86
+
---
45
87
46
-
### More useful Information
88
+
## More useful Information
89
+
90
+
The **ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler**. They're only better than UNO / Mega.
47
91
48
-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
49
92
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
50
-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
51
-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
93
+
94
+
The timer1's 23-bit counter can terribly count only up to 8,388,607. So the timer1 maximum interval is very short.
95
+
96
+
Using 256 prescaler, **maximum timer1 interval is only 26.843542 seconds !!!**
52
97
53
98
The timer1 counters can be configured to support automatic reload.
54
99
55
-
### New from v1.0.1
100
+
---
101
+
102
+
## New from v1.0.1
56
103
57
104
1. Add functions `getPosition()` and `getPulseWidth()`
58
105
2. Optimize the code
@@ -72,11 +119,15 @@ This non-being-blocked important feature is absolutely necessary for mission-cri
72
119
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
73
120
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
sentence=This library enables you to use 1 Hardware Timer on an ESP8266 to control 16 or more servo motors.
7
-
paragraph=Now these new 16 ISR-based Servo controllers just use one ESP8266 Hardware Timer. The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions / tasks. This important feature is absolutely necessary for mission-critical tasks.
6
+
sentence=This library enables you to use Interrupt from Hardware Timers on an ESP8266 to control servo motors.
7
+
paragraph=This library enables you to use 1 Hardware Timer on an ESP8266-based board to control up to 16 or more servo motors.
8
8
category=Timing Control Device Time Timer Servo Interrupt esp8266
0 commit comments