diff --git a/README.md b/README.md index 872a773..bb23ba3 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ So suggestions on how to improve things and bug reports are always much apprecia The wiki is also work in progress and will be updated to be as comprehensive as possible. ------------ -![rotating gif of RP2040-Decoder](https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/rotating.gif) +
+ Image 1 + Image 2 +
diff --git a/Software/CV.h b/Software/CV.h index 3f5f7c2..c600836 100644 --- a/Software/CV.h +++ b/Software/CV.h @@ -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 // diff --git a/Software/core0.c b/Software/core0.c index 21b362a..1ccc261 100644 --- a/Software/core0.c +++ b/Software/core0.c @@ -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(); diff --git a/Software/core1.c b/Software/core1.c index c6d3094..85abf53 100644 --- a/Software/core1.c +++ b/Software/core1.c @@ -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; } diff --git a/Software/core1.h b/Software/core1.h index 49498cc..555bde3 100644 --- a/Software/core1.h +++ b/Software/core1.h @@ -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; /** diff --git a/Software/shared.c b/Software/shared.c index a8965f5..ce0308b 100644 --- a/Software/shared.c +++ b/Software/shared.c @@ -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; diff --git a/docs/sphinx/source/gs/getting_started.rst b/docs/sphinx/source/gs/getting_started.rst index 4ef9afb..716da0b 100644 --- a/docs/sphinx/source/gs/getting_started.rst +++ b/docs/sphinx/source/gs/getting_started.rst @@ -21,10 +21,12 @@ In case you are ordering from JLCPCB it is recommended to use the `Fabrication-T If you got a RP2040-Decoder with USB the easiest way to get the RP2040-Decoder up and running is to just use the precompiled .uf2 file in the latest `release `_ and skip to :ref:`flashing_the_software`. However sometimes you might want to build by yourself, be it for debugging or to make your own modifications to the source code. -The easiest way to do this is to just use `Visual Studio Code `_ and the Raspberry Pi Pico extension. +The easiest way to do this is to just use `Visual Studio Code `_ and the `Raspberry Pi Pico extension `_. The `official documentation `_ of the Pi Pico does a great job of explaining this in detail. -Note: If you are building for Hardware Rev 0.3 or below change the board defintion in your CMakeLists.txt file to: "RP2040-Decoder-board-legacy.h" +.. note:: + - Make sure to choose the correct board definition file in your CMakeLists.txt file for example ``RP2040-Decoder-board-Rev-1_0`` for Hardware Rev 1.0. + - In VSCode open the "Software" subdirectory for the extension to detect you project automatically. .. _flashing_the_software: