From 0b90769083411af73eced89826f4ab7cafb3ac9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucher?= <cfoucher@laas.fr> Date: Wed, 2 Mar 2022 17:58:03 +0000 Subject: [PATCH] Correct JSON and unused variables. --- library.json | 9 ++------ src/opalib_control_pid.c | 46 +++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/library.json b/library.json index 725b852..aab097a 100644 --- a/library.json +++ b/library.json @@ -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/" } - + diff --git a/src/opalib_control_pid.c b/src/opalib_control_pid.c index 3d87d6a..7d40b82 100644 --- a/src/opalib_control_pid.c +++ b/src/opalib_control_pid.c @@ -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() { -- GitLab