- added shared.c file containing functions that can be accessed from both cores
- revised CV programming especially writing - Core 1 is only started when valid package with correct address is received - Extended addresses are now correctly verified and implemented - Base PWM measurement is now done on core0 and checked for automatically in cv_setup_check() - Moved Motor PWM, GPIO, ADC to core0 - Implemented inverted direction mode (CV_29) according to DCC-Standards - Limited feed-forward parameters y_2 to max_output/y_1 - k_p gain slopes are now calculated on initialization - k_p gain parameters are also in pid parameter struct now - Revised init_pid() - Implemented Packet timeout check (CV_11) - 16Bit and 32Bit CVs now always have the highest bytes as the lowest array index to accommodate get_XXbit_CV() functions
This commit is contained in:
1 parent
f09c4ff136
commit
fd017ea685
8 files changed
+820
-601
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared.h"
|
||||
#include <math.h>
|
||||
|
||||
typedef struct pid_params{
|
||||
// Controller variables - won't change after init
|
||||
float k_i; // Integral gain
|
||||
@@ -20,11 +20,19 @@ typedef struct pid_params{
|
||||
float int_lim_max; // max limit for integrator
|
||||
float int_lim_min; // min limit for integrator
|
||||
float max_output; // max possible pwm output value
|
||||
float k_p_x_1_shift;
|
||||
float k_p_x_1;
|
||||
float k_p_x_2;
|
||||
float k_p_y_0;
|
||||
float k_p_y_1;
|
||||
float k_p_y_2;
|
||||
float k_p_m_1;
|
||||
float k_p_m_2;
|
||||
// Controller variables - might change on runtime
|
||||
float k_p; // Proportional gain
|
||||
float e_prev; // Previous Error
|
||||
float integral_prev; // Previous Integral Value
|
||||
float derivative_prev; // Previous Derivative Value
|
||||
float i_prev; // Previous Integral Value
|
||||
float d_prev; // Previous Derivative Value
|
||||
float measurement_prev; // Previous Measurement
|
||||
float x_1_fwd; // Base Speed; forward direction
|
||||
float x_2_fwd; // High Speed; forward direction
|
||||
@@ -54,13 +62,10 @@ typedef struct pid_params{
|
||||
|
||||
void update_speed_dir(pid_params *pid, uint32_t speed_step_target);
|
||||
bool speed_helper(struct repeating_timer *t);
|
||||
float measure(pid_params *pid,bool direction);
|
||||
void adjust_pwm_level(uint16_t level, pid_params *pid);
|
||||
void update_m(pid_params *pid);
|
||||
void update_y(pid_params *pid,float i);
|
||||
float get_ff_val(pid_params *pid);
|
||||
float get_kp(pid_params *pid);
|
||||
bool pid_control(struct repeating_timer *t);
|
||||
uint16_t measure_base_pwm(pid_params *pid,bool direction);
|
||||
void init_pid(pid_params *pid);
|
||||
void init_motor_pwm(uint8_t gpio);
|
||||
void init_pid(pid_params *pid);
|
||||
Reference in new issue
Block a user