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:
1 parent
93455218e8
commit
a2b1233c4e
7 files changed
+19
-22
No files matched your search
@@ -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.
|
The wiki is also work in progress and will be updated to be as comprehensive as possible.
|
||||||
|
|
||||||
------------
|
------------
|
||||||

|
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<img src="https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/top.png" alt="Image 1" style="width: 50%;"/>
|
||||||
|
<img src="https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/bottom.png" alt="Image 2" style="width: 50%;"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
+1
-2
@@ -62,9 +62,8 @@ uint8_t CV_ARRAY_DEFAULT [CV_ARRAY_SIZE] = {
|
|||||||
0b00000000, //CV_44 -
|
0b00000000, //CV_44 -
|
||||||
0b00000000, //CV_45 -
|
0b00000000, //CV_45 -
|
||||||
0b00000000, //CV_46 -
|
0b00000000, //CV_46 -
|
||||||
// TODO: Update controller CVs and implement/redefine k_ff in the speed controller initialization
|
|
||||||
// Speed controller - Configuration /////////////////////////////////////////////////////////////////////////////////
|
// 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 //
|
0b00001010, //CV_48 - PID Control low pass filter time constant (tau) in ms //
|
||||||
0b00000101, //CV_49 - PID Control sampling time t 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 //
|
0b00011001, //CV_50 - PID Control I_Factor = CV_50/10 Default = 25 -> 2.5 //
|
||||||
|
|||||||
@@ -784,15 +784,7 @@ int main() {
|
|||||||
while (!flash_safe_execute_core_init_done) {
|
while (!flash_safe_execute_core_init_done) {
|
||||||
watchdog_update();
|
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
|
// Check CV array for factory state of flash or missing ADC offset setup
|
||||||
cv_setup_check();
|
cv_setup_check();
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -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;
|
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
|
// Set ramp_up_mode flag to true
|
||||||
ctrl_par->mode = PID_MODE;
|
ctrl_par->mode = PID_MODE;
|
||||||
// multiply with constant value of 0.9 and set as current feed forward value for pid mode
|
// Multiply with k_ff constant and set as current feed forward value
|
||||||
ctrl_par->feed_fwd = 0.9f * (float)ctrl_par->startup.level;
|
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)
|
// 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) {
|
void controller_general(controller_parameter_t * ctrl_par) {
|
||||||
// Change in direction -> reset previous derivative, error and integral parts and pwm_base_done
|
// 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) !=
|
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")
|
LOG(1, "Motor controller initialization...\n")
|
||||||
// General controller variables
|
// General controller variables
|
||||||
ctrl_par->mode = STARTUP_MODE;
|
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;
|
ctrl_par->feed_fwd = 0;
|
||||||
|
|
||||||
// Startup controller variables
|
// Startup controller variables
|
||||||
ctrl_par->startup.level = 0;
|
ctrl_par->startup.level = 0;
|
||||||
ctrl_par->startup.base_pwm_arr_i = 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) {
|
for (int i = 0; i < BASE_PWM_ARR_LEN; ++i) {
|
||||||
ctrl_par->startup.base_pwm_arr[i] = 0;
|
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_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;
|
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")
|
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();
|
flash_safe_execute_core_init_done = flash_safe_execute_core_init();
|
||||||
if (flash_safe_execute_core_init_done != true){
|
if (flash_safe_execute_core_init_done != true){
|
||||||
set_error(FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE);
|
set_error(FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE);
|
||||||
|
panic("Error calling flash_safe_execute_core_init() on core1!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ typedef struct startup_parameters_t {
|
|||||||
uint16_t level; /**< Latest level */
|
uint16_t level; /**< Latest level */
|
||||||
uint16_t base_pwm_arr[BASE_PWM_ARR_LEN]; /**< base pwm ring buffer array */
|
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 */
|
uint16_t base_pwm_arr_i; /**< base pwm ring buffer array index */
|
||||||
|
float k_ff; /**< Feed forward factor */
|
||||||
}startup_parameters_t;
|
}startup_parameters_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#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 = SPEED_STEP_REVERSE_STOP;
|
||||||
speed_step_t speed_step_target_prev = SPEED_STEP_REVERSE_STOP;
|
speed_step_t speed_step_target_prev = SPEED_STEP_REVERSE_STOP;
|
||||||
bool cv_setup_check_done = false;
|
bool cv_setup_check_done = false;
|
||||||
|
|||||||
@@ -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 <https://github.com/gab-k/RP2040-Decoder/releases>`_ and skip to :ref:`flashing_the_software`.
|
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 <https://github.com/gab-k/RP2040-Decoder/releases>`_ 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.
|
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 <https://code.visualstudio.com/>`_ and the Raspberry Pi Pico extension.
|
The easiest way to do this is to just use `Visual Studio Code <https://code.visualstudio.com/>`_ and the `Raspberry Pi Pico extension <https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico>`_.
|
||||||
The `official documentation <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_ of the Pi Pico does a great job of explaining this in detail.
|
The `official documentation <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_ 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:
|
.. _flashing_the_software:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user