Update README; Update Getting Started page; Move panic() on FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE to core1; Implement k_ff feed forward factor via CV_47;

This commit is contained in:
gab-k committed 2025-01-05 11:43:29 +01:00
1 parent 93455218e8
commit a2b1233c4e
7 files changed
+19 -22

No files matched your search

+1 -2
View File
@@ -62,9 +62,8 @@ uint8_t CV_ARRAY_DEFAULT [CV_ARRAY_SIZE] = {
0b00000000, //CV_44 -
0b00000000, //CV_45 -
0b00000000, //CV_46 -
// TODO: Update controller CVs and implement/redefine k_ff in the speed controller initialization
// Speed controller - Configuration /////////////////////////////////////////////////////////////////////////////////
0b00110010, //CV_47 - Feed-forward gain k_ff = CV_47/10000 Default = 50 -> 0.005 //
0b11100110, //CV_47 - Feed-forward factor k_ff in % = CV_47/255 Default = 230 -> 0.902 = 90.2% //
0b00001010, //CV_48 - PID Control low pass filter time constant (tau) in ms //
0b00000101, //CV_49 - PID Control sampling time t in ms //
0b00011001, //CV_50 - PID Control I_Factor = CV_50/10 Default = 25 -> 2.5 //
-8
View File
@@ -784,15 +784,7 @@ int main() {
while (!flash_safe_execute_core_init_done) {
watchdog_update();
}
busy_wait_ms(100);
// Check for error calling flash_safe_execute_core_init() on core1
if(get_error_state() & FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE){
panic("Error calling flash_safe_execute_core_init() on core1!"); //TODO: test
}
// Check CV array for factory state of flash or missing ADC offset setup
cv_setup_check();
+8 -8
View File
@@ -180,8 +180,8 @@ void controller_startup_mode(controller_parameter_t *const ctrl_par) {
ctrl_par->startup.base_pwm_arr_i = (ctrl_par->startup.base_pwm_arr_i+1)%BASE_PWM_ARR_LEN;
// Set ramp_up_mode flag to true
ctrl_par->mode = PID_MODE;
// multiply with constant value of 0.9 and set as current feed forward value for pid mode
ctrl_par->feed_fwd = 0.9f * (float)ctrl_par->startup.level;
// Multiply with k_ff constant and set as current feed forward value
ctrl_par->feed_fwd = ctrl_par->startup.k_ff * (float)ctrl_par->startup.level;
}
}
@@ -229,7 +229,6 @@ void controller_pid_mode(controller_parameter_t *const ctrl_par) {
}
// General controller function gets called every x milliseconds where x is CV_49 i.e. sampling time (pid->t)
// TODO: Consider fixed point arithmetic to improve performance...
void controller_general(controller_parameter_t * ctrl_par) {
// Change in direction -> reset previous derivative, error and integral parts and pwm_base_done
const bool direction_changed = get_direction_of_speed_step(speed_step_target) !=
@@ -275,11 +274,16 @@ void init_controller(controller_parameter_t *const ctrl_par) {
LOG(1, "Motor controller initialization...\n")
// General controller variables
ctrl_par->mode = STARTUP_MODE;
ctrl_par->measurement = 0.0f;
ctrl_par->measurement_prev = 0.0f;
ctrl_par->measurement_corrected = 0.0f;
ctrl_par->setpoint = 0;
ctrl_par->feed_fwd = 0;
// Startup controller variables
ctrl_par->startup.level = 0;
ctrl_par->startup.base_pwm_arr_i = 0;
ctrl_par->startup.k_ff = (float) CV_ARRAY_FLASH[46]/255;
for (int i = 0; i < BASE_PWM_ARR_LEN; ++i) {
ctrl_par->startup.base_pwm_arr[i] = 0;
}
@@ -331,11 +335,6 @@ void init_controller(controller_parameter_t *const ctrl_par) {
ctrl_par->pid.k_p_m_1 = (ctrl_par->pid.k_p_y_1 - ctrl_par->pid.k_p_y_0) / ctrl_par->pid.k_p_x_1;
ctrl_par->pid.k_p_m_2 = (ctrl_par->pid.k_p_y_2 - ctrl_par->pid.k_p_y_1) / ctrl_par->pid.k_p_x_2;
// General Controller initialization
ctrl_par->measurement = 0.0f;
ctrl_par->measurement_prev = 0.0f;
ctrl_par->measurement_corrected = 0.0f;
ctrl_par->setpoint = 0;
LOG(1, "Motor controller initialization done!\n")
}
@@ -356,6 +355,7 @@ void core1_entry() {
flash_safe_execute_core_init_done = flash_safe_execute_core_init();
if (flash_safe_execute_core_init_done != true){
set_error(FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE);
panic("Error calling flash_safe_execute_core_init() on core1!");
return;
}
+1
View File
@@ -42,6 +42,7 @@ typedef struct startup_parameters_t {
uint16_t level; /**< Latest level */
uint16_t base_pwm_arr[BASE_PWM_ARR_LEN]; /**< base pwm ring buffer array */
uint16_t base_pwm_arr_i; /**< base pwm ring buffer array index */
float k_ff; /**< Feed forward factor */
}startup_parameters_t;
/**
+1 -1
View File
@@ -6,7 +6,7 @@
#include "shared.h"
// TODO: Implement enum typedef for speed steps, also getter and setter functions checking validity of speed step values.
// TODO: Implement getter and setter functions for speed steps, checking validity of speed step values.
speed_step_t speed_step_target = SPEED_STEP_REVERSE_STOP;
speed_step_t speed_step_target_prev = SPEED_STEP_REVERSE_STOP;
bool cv_setup_check_done = false;