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
- New Servo Easing feature easily controlled with only 2 parameters
- New Servo Easing examples and simulations
- For the ESP32, enable use of gpio pins 25 and 26 for pwm
- Improved attach functions
@@ -10,18 +10,28 @@ This library wraps the ESP32 Arduino framework's [ledc](https://github.com/espre
10
10
11
11
PWM can be inverted, phase shifted and asynchronously aligned with the timing of other pwm channels.
12
12
13
-
Servo read and write functions are included that work with *float* values for more precise control. An optionally inverted servo pwm feature allows using a simple NPN or N-Channel MOSFET driver for the servo's control signal.
13
+
Servo Easing is fully integrated into the servo write and attach functions. Only 2 parameters give complete control over the speed and the easing characteristic of the servo. The method used for easing is a [Normalized Tunable Sigmoid](https://www.desmos.com/calculator/ejkcwglzd1) ([reference](https://dhemery.github.io/DHE-Modules/technical/sigmoid/)). An optionally inverted servo pwm feature allows using a simple NPN or N-Channel MOSFET driver for the servo's control signal.
14
14
15
-
Also included are non blocking Tone and Note functions that include *duration* and *interval* parameters.
15
+
#### Servo Easing
16
16
17
-
### Coming Soon...
17
+
Just 2 easing parameters (speed and easing constant) for unlimited control ...
-[](https://wokwi.com/projects/360276061783595009)[Servo Easing](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite/blob/main/examples/Servo-Easing.ino) Controls three servos with different easing settings
32
+
33
+
-[](https://wokwi.com/projects/355852275661848577)[ESP32_C3_6_Servo_Knob](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite/blob/main/examples/ESP32_C3_6_Servo_Knob.ino) Potentiometer control of 6 servos on an ESP32-C3
34
+
25
35
-[](https://wokwi.com/projects/349232255258853970)[16 PWM Fade](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite/blob/main/examples/ESP32_Fade16/ESP32_Fade16.ino) ESP32 fading 16 pairs of LEDs
26
36
27
37
-[](https://wokwi.com/projects/349978851105833554)[14 PWM Fade 2 Servo](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite/blob/main/examples/ESP32_Fade_Servo/ESP32_Fade_Servo.ino) ESP32 fading 14 pairs of LEDs and controlling 2 servo motors
@@ -54,11 +64,11 @@ Also included are non blocking Tone and Note functions that include *duration* a
54
64
55
65
56
66
57
-
| Board | PWM Pins | PWM, Duty and Phase Channels | Frequency and Resolution Channels |
@@ -149,16 +159,20 @@ This process is automatic - the servo pin will be attached to the next free chan
149
159
150
160
```c++
151
161
pwm.writeServo(pin, value)
162
+
pwm.writeServo(pin, value, speed, ke)
152
163
```
153
164
154
165
##### Parameters
155
166
156
167
-**pin** The pin number which (if necessary) will be attached to the next free channel *(uint8_t)*
157
168
-**value** This value is converted to the pwm duty. See above table for range and units *(float)
169
+
-**speed** This value has units degrees/second (float). For example, if `speed` is set to 100 deg/s and the servo position value is changed from 0 to 180 deg, then the servo will take 1.8 sec (1800 ms) to complete its travel. Its motion (response) will be determined by `ke`,
170
+
-**ke** Servo easing constant for a [Normalized Tunable Sigmoid](https://www.desmos.com/calculator/ejkcwglzd1). A `ke` value of 0.0 represents a linear response. As you increase `ke`, this increases the steepness of a sigmoid response. When `ke` is 1.0, normal "instantaneous" servo response is enabled and the speed parameter is ignored.
158
171
159
172
##### Returns
160
173
161
-
The pwm duty value *(uint32_t)*
174
+
- If the servo easing constant `ke` is 1.0 (default) then the pwm duty value *(uint32_t)* is returned.
175
+
- If `ke` is less than 1.0, then a normalized float value (0.0 to 1.0) is returned. This represents the programmed servo position from start to stop as it moves over time. When the returned value reaches 0.5, this represents both 50% travel and 50% time duration, no matter what easing constant is set.
162
176
163
177
164
178
@@ -283,11 +297,12 @@ This function allows auto-attaching a pin to the first available channel if only
283
297
**Syntax**
284
298
285
299
```c++
286
-
attach(pin) // auto attach to first open channel
287
-
attach(pin, ch, invert) // attach to ch, optional invert
attach(pin, ch, minUs, defUs, maxUs) // attach to ch with servo limits
304
+
attach(pin, ch, minUs, defUs, maxUs, speed, ke) // as above with speed, easing constant
305
+
attach(pin, ch, minUs, defUs, maxUs, speed, ke, invert) // as above with invert
291
306
```
292
307
293
308
##### Parameters
@@ -302,6 +317,10 @@ attach(pin, ch, minUs, defUs, maxUs, invert) // attach to ch, servo limits and i
302
317
303
318
- **maxUs** Maximum timer width in microseconds *(uint16_t)*
304
319
320
+
- **speed** This servo easing parameter has units degrees/second (float). For example, if `speed` is set to 100 deg/s and the servo position value is changed from 0 to 180 deg, then the servo will take 1.8 sec (1800 ms) to complete its travel. Its motion (response) will be determined by `ke`,
321
+
322
+
- **ke** Servo easing constant for a [Normalized Tunable Sigmoid](https://www.desmos.com/calculator/ejkcwglzd1). A `ke` value of 0.0 represents a linear response. As you increase `ke`, this increases the steepness of a sigmoid response. When `ke` is 1.0, normal "instantaneous" servo response is enabled and the speed parameter is ignored.
323
+
305
324
- **invert** Inverts the PWM output. Allows using a simpler driver for higher voltage servo control. Only one NPN transistor or N-Channel MOSFET needed. No additional latency added as found with software inversion because the inverted pulse remains at the start of the refresh period rather than being flipped to the end of the refresh period *(bool)*.
0 commit comments