Skip to content

Commit aad2efb

Browse files
committed
Merge branch 'main' of https://github.com/GyverLibs/uPID
2 parents a50bd47 + fdb9633 commit aad2efb

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

.github/workflows/tg-send.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
name: Telegram Message
3+
on:
4+
release:
5+
types: [published]
6+
jobs:
7+
build:
8+
name: Send Message
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: send telegram message on push
12+
uses: appleboy/telegram-action@master
13+
with:
14+
to: ${{ secrets.TELEGRAM_TO }}
15+
token: ${{ secrets.TELEGRAM_TOKEN }}
16+
disable_web_page_preview: true
17+
message: |
18+
${{ github.event.repository.name }} v${{ github.event.release.tag_name }}
19+
${{ github.event.release.body }}
20+
https://github.com/${{ github.repository }}

README_EN.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
This is an automatic translation, may be incorrect in some places. See sources and examples!
2+
3+
# upid
4+
Easy Universal Library of PID-regulator with optional superstructures over the algorithm
5+
- Limiting output
6+
- Choosing the direction of regulation
7+
- proportional to the error or input change
8+
- differential error or entrance
9+
- Integral component:
10+
- restriction of the integral Back Calculation
11+
- restriction of integration on the saturation of the exit
12+
- The reset integrated when reached the setup
13+
14+
## compatibility
15+
Compatible with all platforms
16+
17+
## Content
18+
- [use] (#usage)
19+
- [versions] (#varsions)
20+
- [installation] (# Install)
21+
- [bugs and feedback] (#fedback)
22+
23+
<a id = "USAGE"> </A>
24+
25+
## Usage
26+
## upid
27+
Standard class.The modes can be changed during the program, the coefficients can be written and read directly in the variables `kp`,` ki`, `kd`.
28+
29+
`` `CPP
30+
upid (uint8_t cfg = 0, uint16_t dt = 30);
31+
32+
Float KP = 0, Ki = 0, KD = 0;
33+
Float KBC = 0;
34+
Float setpoint = 0;
35+
Float Integral = 0;
36+
Float outmax = 255;
37+
Float outmin = 0;
38+
39+
Float getkp ();
40+
Float getki ();
41+
Float getkd ();
42+
43+
VOID Setkp (Float P);
44+
VOID Setki (Float I);
45+
VOID Setkd (Float D);
46+
47+
// Install config
48+
VOID setconfig (Uint8_T NCFG);
49+
50+
// Turn on the flag
51+
VOID setmode (upid_cfg mode);
52+
53+
// Turn off the flag
54+
Void Clearmode (Upid_cfg Mode);
55+
56+
// Install the period of work in MS
57+
VOID setdt (uint16_t ms);
58+
59+
// Calculate (call with a given period).Will return the way out
60+
Float Compute (Float Input);
61+
`` `
62+
63+
## upidfast
64+
Fast and light version: the mode is set in the template at the compilation stage, and the coefficients can only be changed through SET-GET.This version is 20 μs faster - 67 versus 87 μs (AVR 16 MHZ, standard settings).
65+
66+
Also, when creating, you can specify a third-party implementation of `float`, for example, a number with a fixed point (library [fixed] (https://github.com/gyverlibs/fixed)), which will facilitate the code for 1-2 KB and accelerate to 40 μs (for processors without FPU).
67+
68+
`` `CPP
69+
Upidfast <uint8_t cfg = 0, typename float_t = float> (uint16_t dt = 30);
70+
71+
Float_t KBC = 0;
72+
Float_t setpoint = 0;
73+
Float_t Integral = 0;
74+
Float_t outmax = 255;
75+
Float_t outmin = 0;
76+
77+
Float_t getkp ();
78+
Float_t getki ();
79+
Float_t getkd ();
80+
81+
VOID Setkp (float_t p);
82+
VOID Setki (float_t i);
83+
VOID Setkd (float_t d);
84+
85+
// Install the period of work in the MS (performed for a long time!)
86+
VOID setdt (uint16_t ms);
87+
88+
// Calculate (call with a given period).Will return the way out
89+
Float_t Compute (Float_T Input);
90+
`` `
91+
92+
### Settings
93+
The regime of the regulator is built from constants separated by `|`, for example:
94+
95+
`` `CPP
96+
Upid pid (d_input | p_measure | pid_reverse);
97+
pid.setconfig (d_input | p_measure);
98+
pid.clearmode (p_measure);
99+
100+
Upidfast <d_input |P_measure |PID_REVERSE> PIDFAST;
101+
`` `
102+
103+
## proportional
104+
One option out of two:
105+
106+
- `p_error` (by default) - proportional to the error.The classic version of the P-component
107+
- `p_measure` - proportional to the entrance (depends on` d_input`) or error (depending on `d_error`).Changes the logic of the regulator, well suited for integrating processes - for example, the regulator controls the speed (signal to the motor), and the input is given a position (encoder on this motor)
108+
109+
### Integral
110+
You can choose in any combination, but `` I_BACK_CALC` is analCranberries `i_saturate` and turning them together does not make sense:
111+
112+
- `I_SATURATE` - *Conditional integration *, disconnecting integration when saturating the output (` Outmax` and `Outmin` must be configured)
113+
- `I_Back_calc` - *Back Calculation *, a smart restriction of integration when saturating the output (` outmax` and `Outmin` should be configured).It works slower than `` _SATURATE`.The intensity is regulated by the CoEF -M `KBC` - first you need to choose it equal to` ki`, then change and look behind the reaction of the system
114+
- `I_Reset` - automatic discharge integral when reached the setup
115+
116+
> By "saturation of the exit", it means his departure from the `` (out .. outmax) `` `` `Outmar, in ordinary PID, the integral sum begins to grow uncontrolled in one direction and then returns for a long time - the so -called*Windup*.The library offers several options for solving this problem
117+
118+
### differential
119+
One option out of two:
120+
121+
- `D_ERROR` (by default) - differentiation of error.The classic version of D-component
122+
- `d_input` - the differentiation of the entrance.The less impact of noise, the complete absence of casting in D when changing the setting.If the setting often changes and you need more dynamic behavior of the system in response to this - it is better to use `d_error`
123+
124+
### Direction
125+
One option out of two:
126+
127+
- `pid_forward` (default) - direct regulator, the regulator’s output should increase the entrance (for example, heating power control, the temperature to the regulator input)
128+
- `pid_reverse` - the return regulator, the regulator output should reduce the entrance (for example, cooling power control, the temperature to the regulator input)
129+
130+
### Examples
131+
`` `CPP
132+
#include <upid.h>
133+
134+
Consta int dt = 30;
135+
Upid pid (d_input | _saturate);
136+
// upidfast <d_input |I_SATURATE> pid;
137+
138+
VOID setup () {
139+
// pid.kp = 10;
140+
// pid.ki = 20;
141+
// pid.kd = 5;
142+
143+
Pid.Setkp (10);
144+
Pid.Setki (20);
145+
Pid.Setkd (5);
146+
147+
// pid.kbc = 0.1;
148+
Pid.Setdt (DT);
149+
Pid.outmax = 255;
150+
pid.outmin = -255;
151+
152+
Pid.Setpoint = setting;
153+
}
154+
155+
VOID loop () {
156+
Float Result = Pid.compute
157+
apply (result);
158+
DELAY (DT);
159+
}
160+
`` `
161+
162+
<a ID = "Versions"> </a>
163+
164+
## versions
165+
- V1.0
166+
167+
<a id = "Install"> </a>
168+
## Installation
169+
- The library can be found by the name ** upid ** and installed through the library manager in:
170+
- Arduino ide
171+
- Arduino ide v2
172+
- Platformio
173+
- [download library] (https://github.com/gyverlibs/upid/archive/refs/heads/main.zip). Zip archive for manual installation:
174+
- unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64)
175+
- unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32)
176+
- unpack and put in *documents/arduino/libraries/ *
177+
- (Arduino id) Automatic installation from. Zip: * sketch/connect the library/add .Zip library ... * and specify downloaded archive
178+
- Read more detailed instructions for installing libraries[here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
179+
### Update
180+
- I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added
181+
- through the IDE library manager: find the library how to install and click "update"
182+
- Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors!
183+
184+
<a id = "Feedback"> </a>
185+
186+
## bugs and feedback
187+
Create ** Issue ** when you find the bugs, and better immediately write to the mail [alex@alexgyver.ru] (mailto: alex@alexgyver.ru)
188+
The library is open for refinement and your ** pull Request ** 'ow!
189+
190+
When reporting about bugs or incorrect work of the library, it is necessary to indicate:
191+
- The version of the library
192+
- What is MK used
193+
- SDK version (for ESP)
194+
- version of Arduino ide
195+
- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code
196+
- what code has been loaded, what work was expected from it and toCranberries he works in reality
197+
- Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code

0 commit comments

Comments
 (0)