Skip to content

Commit

Permalink
Merge branch 'vedderb:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSpintend authored Aug 6, 2022
2 parents c7d1c65 + b334247 commit 3094a43
Show file tree
Hide file tree
Showing 116 changed files with 7,573 additions and 858 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- mxlemming
- ortega with flux linkage tracking
- mxlemming with flux linkage tracking
* AS5x47 encoder support: https://github.com/vedderb/bldc/pull/511

=== FW 5.03 ===
* Fixed inductance measurement bug.
Expand Down
19 changes: 12 additions & 7 deletions applications/app_balance.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,15 @@ static bool check_faults(bool ignoreTimers){
}

// Switch partially open and stopped
if((switch_state == HALF || switch_state == OFF) && abs_erpm < balance_conf.fault_adc_half_erpm){
if(ST2MS(current_time - fault_switch_half_timer) > balance_conf.fault_delay_switch_half || ignoreTimers){
state = FAULT_SWITCH_HALF;
return true;
if(!balance_conf.fault_is_dual_switch) {
if((switch_state == HALF || switch_state == OFF) && abs_erpm < balance_conf.fault_adc_half_erpm){
if(ST2MS(current_time - fault_switch_half_timer) > balance_conf.fault_delay_switch_half || ignoreTimers){
state = FAULT_SWITCH_HALF;
return true;
}
} else {
fault_switch_half_timer = current_time;
}
} else {
fault_switch_half_timer = current_time;
}

// Check pitch angle
Expand Down Expand Up @@ -675,7 +677,10 @@ static THD_FUNCTION(balance_thread, arg) {
if(adc1 > balance_conf.fault_adc1 && adc2 > balance_conf.fault_adc2){
switch_state = ON;
}else if(adc1 > balance_conf.fault_adc1 || adc2 > balance_conf.fault_adc2){
switch_state = HALF;
if (balance_conf.fault_is_dual_switch)
switch_state = ON;
else
switch_state = HALF;
}else{
switch_state = OFF;
}
Expand Down
3 changes: 3 additions & 0 deletions applications/appconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@
#ifndef APPCONF_BALANCE_FAULT_ADC_HALF_ERPM
#define APPCONF_BALANCE_FAULT_ADC_HALF_ERPM 1000
#endif
#ifndef APPCONF_BALANCE_FAULT_IS_DUAL_SWITCH
#define APPCONF_BALANCE_FAULT_IS_DUAL_SWITCH false
#endif
#ifndef APPCONF_BALANCE_TILTBACK_DUTY_ANGLE
#define APPCONF_BALANCE_TILTBACK_DUTY_ANGLE 10.0
#endif
Expand Down
12 changes: 9 additions & 3 deletions comm/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,12 @@ void commands_process_packet(unsigned char *data, unsigned int len,
nrf_driver_pause(6000);
}

#ifdef USE_LISPBM
if (packet_id == COMM_LISP_ERASE_CODE) {
lispif_restart(false, false);
}
#endif

uint16_t flash_res = flash_helper_erase_code(packet_id == COMM_QMLUI_ERASE ? CODE_IND_QML : CODE_IND_LISP);

int32_t ind = 0;
Expand Down Expand Up @@ -1637,7 +1643,7 @@ int commands_printf(const char* format, ...) {

int len_to_print = (len < (PRINT_BUFFER_SIZE - 1)) ? len + 1 : PRINT_BUFFER_SIZE;

if(len > 0) {
if (len > 0) {
commands_send_packet_last_blocking((unsigned char*)print_buffer, len_to_print);
}

Expand All @@ -1659,12 +1665,12 @@ int commands_printf_lisp(const char* format, ...) {

int len_to_print = (len < (PRINT_BUFFER_SIZE - 1)) ? len + 1 : PRINT_BUFFER_SIZE;

if(len > 0) {
if (len > 0) {
if (print_buffer[len_to_print - 1] == '\n') {
len_to_print--;
}

commands_send_packet_last_blocking((unsigned char*)print_buffer, len_to_print);
commands_send_packet((unsigned char*)print_buffer, len_to_print);
}

chMtxUnlock(&print_mutex);
Expand Down
2 changes: 1 addition & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 6
#define FW_VERSION_MINOR 00
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 53
#define FW_TEST_VERSION_NUMBER 56

#include "datatypes.h"

Expand Down
4 changes: 4 additions & 0 deletions confgenerator.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is autogenerated by VESC Tool

#include <string.h>
#include "buffer.h"
#include "conf_general.h"
#include "confgenerator.h"
Expand Down Expand Up @@ -310,6 +311,7 @@ int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration
buffer_append_uint16(buffer, conf->app_balance_conf.fault_delay_switch_half, &ind);
buffer_append_uint16(buffer, conf->app_balance_conf.fault_delay_switch_full, &ind);
buffer_append_uint16(buffer, conf->app_balance_conf.fault_adc_half_erpm, &ind);
buffer[ind++] = conf->app_balance_conf.fault_is_dual_switch;
buffer_append_float16(buffer, conf->app_balance_conf.tiltback_duty_angle, 100, &ind);
buffer_append_float16(buffer, conf->app_balance_conf.tiltback_duty_speed, 100, &ind);
buffer_append_float16(buffer, conf->app_balance_conf.tiltback_duty, 1000, &ind);
Expand Down Expand Up @@ -703,6 +705,7 @@ bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration
conf->app_balance_conf.fault_delay_switch_half = buffer_get_uint16(buffer, &ind);
conf->app_balance_conf.fault_delay_switch_full = buffer_get_uint16(buffer, &ind);
conf->app_balance_conf.fault_adc_half_erpm = buffer_get_uint16(buffer, &ind);
conf->app_balance_conf.fault_is_dual_switch = buffer[ind++];
conf->app_balance_conf.tiltback_duty_angle = buffer_get_float16(buffer, 100, &ind);
conf->app_balance_conf.tiltback_duty_speed = buffer_get_float16(buffer, 100, &ind);
conf->app_balance_conf.tiltback_duty = buffer_get_float16(buffer, 1000, &ind);
Expand Down Expand Up @@ -1080,6 +1083,7 @@ void confgenerator_set_defaults_appconf(app_configuration *conf) {
conf->app_balance_conf.fault_delay_switch_half = APPCONF_BALANCE_FAULT_DELAY_SWITCH_HALF;
conf->app_balance_conf.fault_delay_switch_full = APPCONF_BALANCE_FAULT_DELAY_SWITCH_FULL;
conf->app_balance_conf.fault_adc_half_erpm = APPCONF_BALANCE_FAULT_ADC_HALF_ERPM;
conf->app_balance_conf.fault_is_dual_switch = APPCONF_BALANCE_FAULT_IS_DUAL_SWITCH;
conf->app_balance_conf.tiltback_duty_angle = APPCONF_BALANCE_TILTBACK_DUTY_ANGLE;
conf->app_balance_conf.tiltback_duty_speed = APPCONF_BALANCE_TILTBACK_DUTY_SPEED;
conf->app_balance_conf.tiltback_duty = APPCONF_BALANCE_TILTBACK_DUTY;
Expand Down
4 changes: 2 additions & 2 deletions confgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <stdbool.h>

// Constants
#define MCCONF_SIGNATURE 3188187738
#define APPCONF_SIGNATURE 992988844
#define MCCONF_SIGNATURE 2217312675
#define APPCONF_SIGNATURE 2551442059

// Functions
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
Expand Down
5 changes: 4 additions & 1 deletion datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ typedef enum {
FAULT_CODE_ENCODER_NO_MAGNET,
FAULT_CODE_ENCODER_MAGNET_TOO_STRONG,
FAULT_CODE_PHASE_FILTER,
FAULT_CODE_ENCODER_FAULT,
} mc_fault_code;

typedef enum {
Expand Down Expand Up @@ -188,7 +189,8 @@ typedef enum {
SENSOR_PORT_MODE_SINCOS,
SENSOR_PORT_MODE_TS5700N8501,
SENSOR_PORT_MODE_TS5700N8501_MULTITURN,
SENSOR_PORT_MODE_MT6816_SPI
SENSOR_PORT_MODE_MT6816_SPI,
SENSOR_PORT_MODE_AS5x47U_SPI
} sensor_port_mode;

typedef struct {
Expand Down Expand Up @@ -777,6 +779,7 @@ typedef struct {
uint16_t fault_delay_switch_half;
uint16_t fault_delay_switch_full;
uint16_t fault_adc_half_erpm;
bool fault_is_dual_switch;
float tiltback_duty_angle;
float tiltback_duty_speed;
float tiltback_duty;
Expand Down
Loading

0 comments on commit 3094a43

Please sign in to comment.