Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hddtempserial
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleg Nikulin
hddtempserial
Commits
b897dc99
Commit
b897dc99
authored
Jul 06, 2023
by
Oleg Nikulin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Переделан pid
parent
70afe8dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
hddtempserial.ino
hddtempserial/hddtempserial.ino
+22
-13
No files found.
hddtempserial/hddtempserial.ino
View file @
b897dc99
...
...
@@ -156,11 +156,14 @@ uint32_t last_beep_time = 0;
uint32_t
last_poll_time
=
0
;
uint32_t
lastRpmCheck
=
0
;
float
p
[
3
]
=
{};
float
i
[
3
]
=
{};
float
d
[
3
]
=
{};
//
float p[3] = {};
//
float i[3] = {};
//
float d[3] = {};
float
k_p
=
40
;
float
errorIntegral
[
3
]
=
{};
float
prevError
[
3
]
=
{};
float
k_p
=
-
40
;
float
k_i
=
0.005
;
float
k_d
=
0
;
...
...
@@ -325,19 +328,25 @@ void rpm_control() {
for
(
int
group
=
0
;
group
<
3
;
group
++
)
{
//управление скоростью 3-х групп вентиляторов
if
(
controls
[
group
].
copy_from
<
0
||
controls
[
group
].
copy_from
>
2
)
{
uint8_t
duty_cycle
=
0
;
float
pwmDutyCycle
=
ON_DUTY_CYCLE
;
if
(
pc_respond
){
d
[
group
]
=
(
controls
[
group
].
temperature
-
controls
[
group
].
target_temperature
-
p
[
group
])
/
float
(
millis
()
-
lastRpmCheck
);
p
[
group
]
=
controls
[
group
].
temperature
-
controls
[
group
].
target_temperature
;
i
[
group
]
=
i
[
group
]
+
p
[
group
]
*
(
millis
()
-
lastRpmCheck
);
if
(
fabs
(
i
[
group
]
*
k_i
)
>=
i_max
)
{
i
[
group
]
=
i_max
/
k_i
;
}
uint32_t
deltaTime
=
millis
()
-
lastRpmCheck
;
float
error
=
controls
[
group
].
target_temperature
-
controls
[
group
].
temperature
;
//чтобы i не накапливалась
if
(
controls
[
group
].
dutyCycle
<
controls
[
group
].
max_duty_cycle
&&
controls
[
group
].
dutyCycle
<
ON_DUTY_CYCLE
)
errorIntegral
[
group
]
+=
error
*
deltaTime
;
float
errorChangeRate
=
(
error
-
prevError
[
group
])
/
deltaTime
;
prevError
[
group
]
=
error
;
float
p
=
k_p
*
error
;
float
i
=
k_i
*
errorIntegral
[
group
];
float
d
=
k_d
*
errorChangeRate
;
pwmDutyCycle
=
round
(
p
[
group
]
*
k_p
+
i
[
group
]
*
k_i
+
d
[
group
]
*
k_d
)
;
pwmDutyCycle
=
p
+
i
+
d
;
}
set_duty_cycle
(
controls
[
group
],
round
(
pwmDutyCycle
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment