Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OPALIB Control PID
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OwnTech
Power API
OPALIB Control PID
Commits
0b907690
Commit
0b907690
authored
3 years ago
by
Clément Foucher
Browse files
Options
Downloads
Patches
Plain Diff
Correct JSON and unused variables.
parent
863a137d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
library.json
+2
-7
2 additions, 7 deletions
library.json
src/opalib_control_pid.c
+20
-26
20 additions, 26 deletions
src/opalib_control_pid.c
with
22 additions
and
33 deletions
library.json
+
2
−
7
View file @
0b907690
...
...
@@ -25,11 +25,6 @@
}
],
"license"
:
"LGPLV2"
,
"homepage"
:
"https://www.owntech.org/"
,
"dependencies"
:
{
"owntech/core"
:
"~1.0"
},
"frameworks"
:
"zephyr"
,
"platforms"
:
"ststm32@14.2.0"
"homepage"
:
"https://www.owntech.org/"
}
This diff is collapsed.
Click to expand it.
src/opalib_control_pid.c
+
20
−
26
View file @
0b907690
...
...
@@ -58,7 +58,6 @@ static uint32_t pid_period_us; // Period duration of the PID calculation l
static
float32_t
prev_pid_out
=
0
.
1
;
// Stores the previous unsaturated output
static
float32_t
pid_out
;
// Stores the current pid_output after saturation and anti windUp (the effective duty cycle)
static
uint32_t
Count_pid_reset
;
// Counter to reset the PID when calculation is off
// Anti-Windup variables
static
float32_t
pid_out_windUp
=
0
.
1
;
// Stores the current pid output after anti windup and before saturation
...
...
@@ -77,11 +76,9 @@ static float32_t saturation_pid_interleaved_high = 1;
// Leg1 PID variables--------------------------------------------------------------------------------------------------------------
static
arm_pid_instance_f32
PID_1_variables
;
// PID structure
static
float32_t
error_pid_1
;
// PID error
static
uint32_t
pid_1_period_us
;
// Period duration of the PID calculation loop in µs (used for Ki calculation)
static
float32_t
prev_pid_1_out
=
0
.
1
;
// Stores the previous unsaturated output
static
float32_t
pid_1_out
;
// Stores the current pid_output after saturation and anti windUp (the effective duty cycle)
static
uint32_t
Count_pid_1_reset
;
// Counter to reset the PID when calculation is off
// Anti-Windup variables
static
float32_t
pid_1_out_windUp
=
0
.
1
;
// Stores the current pid output after anti windup and before saturation
...
...
@@ -100,11 +97,9 @@ static float32_t saturation_pid_leg1_high = 1;
// Leg2 PID variables--------------------------------------------------------------------------------------------------------------
static
arm_pid_instance_f32
PID_2_variables
;
// PID structure
static
float32_t
error_pid_2
;
// PID error
static
uint32_t
pid_2_period_us
;
// Period duration of the PID calculation loop in µs (used for Ki calculation)
static
float32_t
prev_pid_2_out
=
0
.
1
;
// Stores the previous unsaturated output
static
float32_t
pid_2_out
;
// Stores the current pid_output after saturation and anti windUp (the effective duty cycle)
static
uint32_t
Count_pid_2_reset
;
// Counter to reset the PID when calculation is off
// Anti-Windup variables
static
float32_t
pid_2_out_windUp
=
0
.
1
;
// Stores the current pid output after anti windup and before saturation
...
...
@@ -129,7 +124,6 @@ static uint32_t pid_motor_period_us; // Period duration of the PID calcula
static
float32_t
prev_pid_motor_out
=
0
.
1
;
// Stores the previous unsaturated output
static
float32_t
pid_motor_out
;
// Stores the current pid_output after saturation and anti windUp (the effective duty cycle)
static
uint32_t
Count_pid_motor_reset
;
// Counter to reset the PID when calculation is off
// Anti-Windup variables
static
float32_t
pid_motor_out_windUp
=
0
.
1
;
// Stores the current pid output after anti windup and before saturation
...
...
@@ -221,7 +215,7 @@ void opalib_control_init_motor_pid(float32_t kp, float32_t ki, float32_t kd, uin
/**
* This function update the voltage reference of the
* This function update the voltage reference of the
* control task.
*/
...
...
@@ -231,7 +225,7 @@ void opalib_control_update_saturation_interleaved(float32_t new_saturation_value
}
/**
* This function update the voltage reference of the
* This function update the voltage reference of the
* control task.
*/
...
...
@@ -242,7 +236,7 @@ void opalib_control_update_saturation_leg1(float32_t new_saturation_value)
/**
* This function update the voltage reference of the
* This function update the voltage reference of the
* control task.
*/
void
opalib_control_update_saturation_leg2
(
float32_t
new_saturation_value
)
...
...
@@ -251,7 +245,7 @@ void opalib_control_update_saturation_leg2(float32_t new_saturation_value)
}
/**
* This function update the voltage reference of the
* This function update the voltage reference of the
* control task.
*/
...
...
@@ -262,16 +256,16 @@ void opalib_control_update_saturation_motor(float32_t new_saturation_value)
/**
* This function does the PID calculation
* The PID has an anti-windup that permits to avoid
* This function does the PID calculation
* The PID has an anti-windup that permits to avoid
* loosing control.
*/
float32_t
opalib_control_interleaved_pid_calculation
(
float32_t
reference
,
float32_t
measurement
){
if
(
measurement
<=
saturation_interleaved
){
arm_sub_f32
(
&
reference
,
&
measurement
,
&
error_pid
,
1
);
// CALCULATING THE ERROR BASED ON THE REFERENCE
arm_sub_f32
(
&
reference
,
&
measurement
,
&
error_pid
,
1
);
// CALCULATING THE ERROR BASED ON THE REFERENCE
pid_out
=
arm_pid_f32
(
&
PID_variables
,
error_pid
);
// PID CALCULATIONS
if
(
pid_out
>
saturation_pid_interleaved_high
){
...
...
@@ -285,7 +279,7 @@ float32_t opalib_control_interleaved_pid_calculation(float32_t reference, float3
arm_add_f32
(
&
WindUp_mult
,
&
pid_out
,
&
pid_out_windUp
,
1
);
PID_variables
.
state
[
2
]
=
pid_out_windUp
;
pwm_duty_cycle
=
pid_out_windUp
;
pwm_duty_cycle
=
pid_out_windUp
;
prev_pid_out
=
pid_out
;
}
...
...
@@ -293,8 +287,8 @@ float32_t opalib_control_interleaved_pid_calculation(float32_t reference, float3
}
/**
* This function does the PID_1 calculation
* The PID has an anti-windup that permits to avoid
* This function does the PID_1 calculation
* The PID has an anti-windup that permits to avoid
* loosing control.
*/
...
...
@@ -327,8 +321,8 @@ float32_t opalib_control_leg1_pid_calculation(float32_t reference, float32_t mea
/**
* This function does the PID_2 calculation
* The PID has an anti-windup that permits to avoid
* This function does the PID_2 calculation
* The PID has an anti-windup that permits to avoid
* loosing control.
*/
...
...
@@ -360,16 +354,16 @@ float32_t opalib_control_leg2_pid_calculation(float32_t reference, float32_t mea
}
/**
* This function does the PID calculation
* The PID has an anti-windup that permits to avoid
* This function does the PID calculation
* The PID has an anti-windup that permits to avoid
* loosing control.
*/
float32_t
opalib_control_motor_pid_calculation
(
float32_t
reference
,
float32_t
measurement
){
if
(
measurement
<=
saturation_motor
){
arm_sub_f32
(
&
reference
,
&
measurement
,
&
error_pid_motor
,
1
);
// CALCULATING THE ERROR BASED ON THE REFERENCE
arm_sub_f32
(
&
reference
,
&
measurement
,
&
error_pid_motor
,
1
);
// CALCULATING THE ERROR BASED ON THE REFERENCE
pid_motor_out
=
arm_pid_f32
(
&
PID_motor_variables
,
error_pid_motor
);
// PID CALCULATIONS
if
(
pid_motor_out
>
saturation_pid_motor_high
){
...
...
@@ -402,7 +396,7 @@ void opalib_control_motor_pid_ki_update(float32_t new_ki){
/**
* This function resets the states of the pid
* This function resets the states of the pid
*/
void
opalib_control_pid_reset_state
()
{
...
...
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