Commit 42928674 authored by Luiz-Fernando Lavado-Villa's avatar Luiz-Fernando Lavado-Villa
Browse files

Made changes to the measurements to take into account the sequence in the new...

Made changes to the measurements to take into account the sequence in the new board. Also made changes on the current mode functions which are operational in open loop.
parent db4190bc
......@@ -41,4 +41,4 @@ board = nucleo_g474re
# Supported upload protocols: mbed, stlink, jlink
upload_protocol = stlink
#debug_tool = jlink
debug_tool = stlink
......@@ -28,8 +28,9 @@
* @author Clément Foucher <clement.foucher@laas.fr>
*/
#include "opalib_pid.h"
#include "opalib_quick_start.h"
// #include "opalib_pid.h"
// #include "opalib_quick_start.h"
// #include "leg.h"
//#include "data_conversion.h"
// void data_parameters_init(){
......@@ -71,16 +72,70 @@
// }
// void fixed_duty_init(){
// uint16_t pwm_pulse_width = 0;
// uint16_t pwm_period = 0;
// uint16_t pwm_phase_shift = 0;
// pwm_period = leg_period();
// pwm_pulse_width = 0.5*pwm_period;
// pwm_phase_shift = pwm_period / 2;
// leg_set(TIMA, pwm_pulse_width, 0);
// leg_set(TIMB, pwm_pulse_width, pwm_phase_shift);
// }
// void main(void)
// {
// // uint32_t interruption_length = 50; // length of the interruption micro-seconds
// // opalib_quick_start_init_voltage(pid_calculation_and_pwm_update, interruption_length);
// // float32_t target_voltage = 12;
// // float32_t kp = -0.00000235;
// // float32_t ki = -0.117;
// // float32_t kd = 0.0;
// // pid_init_buck(target_voltage, kp, ki, kd);
// // opalib_quick_start_launch_task();
// fixed_duty_init();
// }
#include <stdio.h>
#include "opalib_quick_start.h"
#include "opalib_pid_current_mode.h"
#include "data_acquisition.h"
#include "dac.h"
// void fixed_current_task()
// {
// dac_function_update_reset(dac1, 1, reset_value);
// dac_function_update_reset(dac3, 1, reset_value);
// }
void main(void)
{
uint32_t interruption_length = 50; // length of the interruption micro-seconds
opalib_quick_start_init_voltage(pid_calculation_and_pwm_update, interruption_length);
float32_t target_voltage = 12;
float32_t kp = -0.00000235;
float32_t ki = -0.117;
float32_t kd = 0.0;
opalib_quick_start_init_current(opalib_pid_current_periodic_task, 50);
opalib_pid_current_init(15, 0.077, 4653.0, 0.0);
pid_init_buck(target_voltage, kp, ki, kd);
opalib_quick_start_launch_task();
}
printf("Go\n");
}
\ No newline at end of file
......@@ -8,6 +8,6 @@
lib_deps=
quick_start=https://gitlab.laas.fr/owntech/power-api/opalib-quick-start.git
pid_voltage=https://gitlab.laas.fr/owntech/power-api/opalib-pid.git
pid_voltage=https://gitlab.laas.fr/owntech/power-api/opalib-pid.git
# pid_voltage_luiz = https://gitlab.laas.fr/lflavado/opalib-pid.git#new_acquisition_code
# pid_current=https://gitlab.laas.fr/owntech/power-api/opalib-pid-current-mode.git
pid_current=https://gitlab.laas.fr/owntech/power-api/opalib-pid-current-mode.git
......@@ -103,6 +103,7 @@ void hrtim_cm_init()
LL_HRTIM_TIM_SetCompare1(HRTIM1, LL_HRTIM_TIMER_A, 544);
LL_HRTIM_TIM_SetCompareMode(HRTIM1, LL_HRTIM_TIMER_A, LL_HRTIM_COMPAREUNIT_2, LL_HRTIM_COMPAREMODE_REGULAR);
LL_HRTIM_TIM_SetCompare2(HRTIM1, LL_HRTIM_TIMER_A, 100);
// LL_HRTIM_TIM_SetCompare2(HRTIM1, LL_HRTIM_TIMER_A, 500);
LL_HRTIM_TIM_SetCompare3(HRTIM1, LL_HRTIM_TIMER_A, 1360);
LL_HRTIM_TIM_SetCompare4(HRTIM1, LL_HRTIM_TIMER_A, 10880);
LL_HRTIM_TIM_SetCompareMode(HRTIM1, LL_HRTIM_TIMER_A, LL_HRTIM_COMPAREUNIT_4, LL_HRTIM_COMPAREMODE_REGULAR);
......@@ -115,7 +116,8 @@ void hrtim_cm_init()
LL_HRTIM_DT_SetFallingSign(HRTIM1, LL_HRTIM_TIMER_A, LL_HRTIM_DT_FALLING_POSITIVE);
LL_HRTIM_OUT_SetPolarity(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUT_POSITIVE_POLARITY);
LL_HRTIM_OUT_SetOutputSetSrc(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUTPUTSET_TIMCMP1);
LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTSET_EEV_5);
LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTSET_EEV_4); // rectification for changing
// LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTSET_EEV_5);
LL_HRTIM_OUT_SetIdleMode(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUT_NO_IDLE);
LL_HRTIM_OUT_SetIdleLevel(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUT_IDLELEVEL_INACTIVE);
LL_HRTIM_OUT_SetFaultState(HRTIM1, LL_HRTIM_OUTPUT_TA1, LL_HRTIM_OUT_FAULTSTATE_NO_ACTION);
......@@ -161,6 +163,7 @@ void hrtim_cm_init()
LL_HRTIM_TIM_SetCompare1(HRTIM1, LL_HRTIM_TIMER_B, 544);
LL_HRTIM_TIM_SetCompareMode(HRTIM1, LL_HRTIM_TIMER_B, LL_HRTIM_COMPAREUNIT_2, LL_HRTIM_COMPAREMODE_REGULAR);
LL_HRTIM_TIM_SetCompare2(HRTIM1, LL_HRTIM_TIMER_B, 100);
// LL_HRTIM_TIM_SetCompare2(HRTIM1, LL_HRTIM_TIMER_B, 500);
LL_HRTIM_TIM_SetCompare3(HRTIM1, LL_HRTIM_TIMER_B, 1360);
LL_HRTIM_TIM_SetCompare4(HRTIM1, LL_HRTIM_TIMER_B, 10880);
LL_HRTIM_TIM_SetCompareMode(HRTIM1, LL_HRTIM_TIMER_B, LL_HRTIM_COMPAREUNIT_4, LL_HRTIM_COMPAREMODE_REGULAR);
......@@ -173,10 +176,11 @@ void hrtim_cm_init()
LL_HRTIM_DT_SetFallingSign(HRTIM1, LL_HRTIM_TIMER_B, LL_HRTIM_DT_FALLING_POSITIVE);
LL_HRTIM_OUT_SetPolarity(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_POSITIVE_POLARITY);
LL_HRTIM_OUT_SetOutputSetSrc(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUTPUTSET_TIMCMP1);
LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTRESET_EEV_4);
// LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTRESET_EEV_4);
LL_HRTIM_OUT_SetOutputResetSrc(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUTPUTRESET_TIMCMP4|LL_HRTIM_OUTPUTRESET_EEV_5); // small correction related to hrtim external event
LL_HRTIM_OUT_SetIdleMode(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_NO_IDLE);
LL_HRTIM_OUT_SetIdleLevel(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_IDLELEVEL_INACTIVE);
LL_HRTIM_OUT_SetFaultState(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_FAULTSTATE_NO_ACTION);
LL_HRTIM_OUT_SetFaultState(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_FAULTSTATE_NO_ACTION);
LL_HRTIM_OUT_SetChopperMode(HRTIM1, LL_HRTIM_OUTPUT_TB1, LL_HRTIM_OUT_CHOPPERMODE_DISABLED);
LL_HRTIM_OUT_SetPolarity(HRTIM1, LL_HRTIM_OUTPUT_TB2, LL_HRTIM_OUT_POSITIVE_POLARITY);
LL_HRTIM_OUT_SetOutputSetSrc(HRTIM1, LL_HRTIM_OUTPUT_TB2, LL_HRTIM_OUTPUTSET_NONE);
......
......@@ -7,12 +7,12 @@
/*******/
&adc1 {
pinctrl-0 = <&adc1_in6_pc0 &adc1_in7_pc1 &adc1_in8_pc2 &adc1_in9_pc3>;
pinctrl-0 = <&adc1_in6_pc0 &adc1_in7_pc1 &adc1_in8_pc2 &adc1_in9_pc3 &adc1_in12_pb1>;
status = "okay";
};
&adc2 {
pinctrl-0 = <&adc2_in1_pa0 &adc2_in2_pa1 &adc2_in3_pa6>;
pinctrl-0 = <&adc2_in1_pa0 &adc2_in2_pa1 >;
status = "okay";
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment