Skip to content

Commit

Permalink
Pos PID fix, AS5047 fix, changed FOC time constant, updated conf gene…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
vedderb committed Feb 27, 2020
1 parent 8ae52e8 commit 5df9246
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
=== FW 4.02 ===
* Position PID fix (most notable on multiturn encoders).
* App balance updates. See https://github.com/vedderb/bldc/pull/138.
* Changed FOC time constant back to 1000 us.
* Do not count AS5047 all ones as fault.

=== FW 4.01 ===
* Leave debug mode on NRF5x after disconnect to avoid excess power consumption before power cycle.
* Added encoder_clear_errors and encoder_clear_multiturn terminal commands.
Expand Down
2 changes: 1 addition & 1 deletion conf_general.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
mcconf_old.l_current_max = i_max;
mcconf_old.l_current_min = -i_max;

float tc = 4000.0;
float tc = 1000.0;
float bw = 1.0 / (tc * 1e-6);
float kp = l * bw;
float ki = r * bw;
Expand Down
2 changes: 1 addition & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// Firmware version
#define FW_VERSION_MAJOR 4
#define FW_VERSION_MINOR 01
#define FW_VERSION_MINOR 02

#include "datatypes.h"

Expand Down
2 changes: 1 addition & 1 deletion confgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Constants
#define MCCONF_SIGNATURE 3632471335
#define APPCONF_SIGNATURE 2964134872
#define APPCONF_SIGNATURE 1232755601

// Functions
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
Expand Down
2 changes: 1 addition & 1 deletion encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void encoder_tim_isr(void) {
spi_end();

spi_val = pos;
if(spi_check_parity(pos) && pos != 0xffff) { // all ones = disconnect
if(spi_check_parity(pos)) {
pos &= 0x3FFF;
last_enc_angle = ((float)pos * 360.0) / 16384.0;
UTILS_LP_FAST(spi_error_rate, 0.0, 1./AS5047_SAMPLE_RATE_HZ);
Expand Down
5 changes: 3 additions & 2 deletions mcpwm_foc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,9 @@ static void run_pid_control_pos(float angle_now, float angle_set, float dt) {


// I-term wind-up protection
utils_truncate_number_abs(&p_term, 1.0);
utils_truncate_number_abs(&i_term, 1.0 - fabsf(p_term));
float p_tmp = p_term;
utils_truncate_number_abs(&p_tmp, 1.0);
utils_truncate_number_abs(&i_term, 1.0 - fabsf(p_tmp));

// Store previous error
prev_error = error;
Expand Down

0 comments on commit 5df9246

Please sign in to comment.