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
The PID controller is designed to vary its output within a given range. By default this range is 0-255, the Arduino PWM range.
126
127
127
128
#### SetMode
128
129
129
130
```c++
130
-
void QuickPID::SetMode(bool Mode)
131
+
void QuickPID::SetMode(uint8_t Mode)
131
132
```
132
133
133
134
Allows the controller Mode to be set to `MANUAL` (0) or `AUTOMATIC` (non-zero). when the transition from manual to automatic occurs, the controller is automatically initialized.
@@ -143,7 +144,7 @@ Does all the things that need to happen to ensure a bump-less transfer from manu
The PID will either be connected to a DIRECT acting process (+Output leads to +Input) or a REVERSE acting process (+Output leads to -Input.) We need to know which one, because otherwise we may increase the output when we should be decreasing. This is called from the constructor.
@@ -157,8 +158,8 @@ float QuickPID::GetKd()
157
158
float QuickPID::GetKu()
158
159
float QuickPID::GetTu()
159
160
float QuickPID::GetTd()
160
-
bool QuickPID::GetMode()
161
-
bool QuickPID::GetDirection()
161
+
uint8_t QuickPID::GetMode()
162
+
uint8_t QuickPID::GetDirection()
162
163
```
163
164
164
165
These functions query the internal state of the PID. They're here for display purposes.
@@ -171,10 +172,63 @@ int QuickPID::analogReadFast(int ADCpin)
171
172
172
173
A faster configuration of `analogRead()`where a preset of 32 is used. If the architecture definition isn't found, normal `analogRead()`is used to return a value.
173
174
175
+
#### AnalogWrite (PWM and DAC) for ESP32
176
+
177
+
```c++
178
+
void analogWrite(uint8_t pin, uint32_t value)
179
+
```
180
+
181
+
Call this function just like in the standard Arduino framework. It controls up to 9 independent PWM outputs and 2 DAC outputs. The controllable GPIO pins are 2, 4, 13, 14, 16, 17, 27, 32 and 33 for PWM and DAC0 (GPIO25) and DAC1 (GPIO26) for true analog outputs. The default PWM frequency is 5000 Hz and the default resolution is 13-bit (0-8191).
182
+
183
+
#### AnalogWrite Configuration Functions for ESP32
184
+
185
+
```c++
186
+
voidanalogWriteFrequency(float frequency = 5000);
187
+
void analogWriteFrequency(uint8_t pin, float frequency = 5000);
Calling `analogWriteFrequency(frequency)`will set the PWM frequency for all 8 assigned pins. Using `analogWriteFrequency(0)`will detach the 9 assigned pins and set them as input.
193
+
194
+
To independently assign a unique frequency to each PWM pin, use the `analogWriteFrequency(pin, frequency)` function. If the frequency is set to 0, this function will detach the referenced pin and configure it as an input.
195
+
196
+
Calling `analogWriteResolution(resolution)` will set the resolution for all 9 assigned pins. Read more about the [Supported Range of Frequency and Duty Resolution](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html#ledc-api-supported-range-frequency-duty-resolution) here.
197
+
198
+
To independently assign a unique frequency to each PWM pin, use the `analogWriteResolution(pin, resolution)` function. Note that it is required to call this function once prior to using AnalogWrite as this will automatically setup and attach (initialize) the pin.
Copy file name to clipboardExpand all lines: library.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "QuickPID",
3
3
"keywords": "PID, controller, signal",
4
-
"description": "A fast fixed/floating point PID controller with AutoTune and 9 tuning rules to choose from. This controller can automatically determine and set tuning parameters. An added feature is contolling the mix of Proportional on Error to Proportional on Measurement.",
4
+
"description": "A fast fixed/floating point PID controller with AutoTune and 9 tuning rules to choose from. This controller can automatically determine and set tuning parameters. Compatible with most Arduino and ESP32 boards.",
sentence=A fast fixed/floating point PID controller with AutoTune and 9 tuning rules to choose from.
6
-
paragraph=This controller can automatically determine and set tuning parameters. An added feature is contolling the mix of Proportional on Error to Proportional on Measurement.
6
+
paragraph=This controller can automatically determine and set tuning parameters. Compatible with most Arduino and ESP32 boards.
0 commit comments