Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
thk_pid_controller
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thk_libs
microcontrollers
thk_pid_controller
Commits
254a3548
Commit
254a3548
authored
2 years ago
by
Orhan-Timo Altan
Browse files
Options
Downloads
Patches
Plain Diff
Angepasst an die Konvention der thk_libs
parent
8a975a02
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+47
-1
47 additions, 1 deletion
README.md
examples/pid_example.ino
+3
-7
3 additions, 7 deletions
examples/pid_example.ino
thk_pid_controller.cpp
+25
-0
25 additions, 0 deletions
thk_pid_controller.cpp
thk_pid_controller.h
+2
-2
2 additions, 2 deletions
thk_pid_controller.h
with
77 additions
and
10 deletions
README.md
+
47
−
1
View file @
254a3548
# BITs PID Controller
# PID Controller
Mit dieser Bibliothek kann ein PID Regler erzeugt werden, der mit Hilfe einer Führungsgröße und dem Ist-Wert die Regelgröße berechnet.
## **Installation:**
Um diese Klassen verwenden zu können, muss dieses Repository geklont und in das Library-Verzeichnis der Arduino-IDE kopiert werden.
<br
/>
<br
/>
## **Anwendung:**
Zur Verwendung siehe zunächst das Beispiel
`pid_example.ino`
<br
/>
<br
/>
**Einbinden der Bibliothek:**
```
Arduino
#include <thk_pid_controller.h>
```
**Instanziieren:**
```
Arduino
thk_PIDController pid_controller(proportional_gain, integrational_gain, differential_gain, setpoint);
```
-
`proportional_gain`
: Proportional Faktor
-
`integrational_gain`
: Integral Faktor
-
`differential_gain`
: Differential Faktor
-
`setpoint`
: Führungsgröße
<br
/>
<br
/>
### **Funktionen:**
**Übergeben einer neuen Führungsgröße an den Regler:**
```
Arduino
pid_controller.set_setpoint(setpoint);
```
**Berechnen der Regelgröße:**
```
Arduino
controlled_variable = pid_controller.compute(input_value);
```
**Zurücksetzen von I- und D-Anteil:**
```
Arduino
pid_controller.reset();
```
This diff is collapsed.
Click to expand it.
examples/example.ino
→
examples/
pid_
example.ino
+
3
−
7
View file @
254a3548
#include
<pid_controller.h>
#include
<
thk_
pid_controller.h>
double
prop_gain
=
0.1
;
double
prop_gain
=
0.1
;
double
int_gain
=
0.1
;
double
int_gain
=
0.1
;
...
@@ -8,7 +8,7 @@ double input_value = 0;
...
@@ -8,7 +8,7 @@ double input_value = 0;
uint8_t
step
=
0
;
uint8_t
step
=
0
;
uint8_t
setpoint
=
50
;
uint8_t
setpoint
=
50
;
PIDController
pid
(
prop_gain
,
int_gain
,
diff_gain
,
0
);
thk_
PIDController
pid
(
prop_gain
,
int_gain
,
diff_gain
,
0
);
void
setup
(){
void
setup
(){
Serial
.
begin
(
115200
);
Serial
.
begin
(
115200
);
...
@@ -17,11 +17,7 @@ void setup(){
...
@@ -17,11 +17,7 @@ void setup(){
void
loop
(){
void
loop
(){
step
++
;
step
++
;
// if (input_value < 70)
// {
// pid.set_setpoint(100);
// }
input_value
=
pid
.
compute
(
input_value
);
input_value
=
pid
.
compute
(
input_value
);
if
(
setpoint
-
input_value
<
0.01
)
if
(
setpoint
-
input_value
<
0.01
)
...
...
This diff is collapsed.
Click to expand it.
pid_controller.cpp
→
thk_
pid_controller.cpp
+
25
−
0
View file @
254a3548
#include
<pid_controller.h>
#include
<
thk_
pid_controller.h>
PIDController
::
PIDController
(
double
Kp
,
double
Ki
,
double
Kd
,
double
setpoint
)
:
Kp
(
Kp
),
Ki
(
Ki
),
Kd
(
Kd
),
setpoint
(
setpoint
)
{}
thk_
PIDController
::
thk_
PIDController
(
double
Kp
,
double
Ki
,
double
Kd
,
double
setpoint
)
:
Kp
(
Kp
),
Ki
(
Ki
),
Kd
(
Kd
),
setpoint
(
setpoint
)
{}
void
PIDController
::
set_setpoint
(
double
setpoint
)
void
thk_
PIDController
::
set_setpoint
(
double
setpoint
)
{
{
this
->
setpoint
=
setpoint
;
this
->
setpoint
=
setpoint
;
}
}
double
PIDController
::
compute
(
double
input_value
)
double
thk_
PIDController
::
compute
(
double
input_value
)
{
{
double
error_value
=
setpoint
-
input_value
;
double
error_value
=
setpoint
-
input_value
;
...
@@ -18,7 +18,7 @@ double PIDController::compute(double input_value)
...
@@ -18,7 +18,7 @@ double PIDController::compute(double input_value)
return
out_p
+
out_i
+
out_d
;
return
out_p
+
out_i
+
out_d
;
}
}
void
PIDController
::
reset
()
void
thk_
PIDController
::
reset
()
{
{
out_i
=
0
;
out_i
=
0
;
out_d
=
0
;
out_d
=
0
;
...
...
This diff is collapsed.
Click to expand it.
pid_controller.h
→
thk_
pid_controller.h
+
2
−
2
View file @
254a3548
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
#include
"Arduino.h"
#include
"Arduino.h"
class
PIDController
class
thk_
PIDController
{
{
public:
public:
PIDController
(
double
Kp
,
double
Ki
,
double
Kd
,
double
setpoint
);
thk_
PIDController
(
double
Kp
,
double
Ki
,
double
Kd
,
double
setpoint
);
double
compute
(
double
input_value
);
double
compute
(
double
input_value
);
void
set_setpoint
(
double
setpoint
);
void
set_setpoint
(
double
setpoint
);
void
reset
();
void
reset
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment