mirror of https://github.com/rusefi/bldc.git
Some fixes for previous PR
This commit is contained in:
commit
c7d11ca431
|
@ -2,6 +2,7 @@
|
|||
* Set motor to FOC mode after successful FOC detection instead of the default type for the hardware.
|
||||
* APP_ADC: Do not send brake command over CAN if config.multi_esc is not set.
|
||||
* APP_PPM: Make pulses invalid if they are above 150 % instead of 120 %.
|
||||
* Introduced a new control mode that allows reverse with hysteria (@ackmaniac port)
|
||||
|
||||
=== FW 3.57 ===
|
||||
* Added CAN status message 5 with input voltage and tachometer data.
|
||||
|
@ -99,7 +100,7 @@
|
|||
* Softer encoder detection.
|
||||
* Better NRF_EXT support.
|
||||
* New more reliable flux linkage measurement.
|
||||
* Simpler to add hardware versions to build system.
|
||||
* Simpler to add hardware versions to build system.
|
||||
* More DAS hardware support.
|
||||
* DRV8323s support.
|
||||
* Initial UAVCAN support.
|
||||
|
|
|
@ -107,6 +107,9 @@
|
|||
#ifndef APPCONF_PPM_TC_MAX_DIFF
|
||||
#define APPCONF_PPM_TC_MAX_DIFF 3000.0
|
||||
#endif
|
||||
#ifndef APPCONF_PPM_MAX_ERPM_FOR_DIR
|
||||
#define APPCONF_PPM_MAX_ERPM_FOR_DIR 4000.0
|
||||
#endif
|
||||
|
||||
// ADC app configureation
|
||||
#ifndef APPCONF_ADC_CTRL_TYPE
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2016 - 2019 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
|
@ -51,6 +51,7 @@ static volatile bool stop_now = true;
|
|||
static volatile ppm_config config;
|
||||
static volatile int pulses_without_power = 0;
|
||||
static float input_val = 0.0;
|
||||
static volatile float direction_hyst = 0;
|
||||
|
||||
// Private functions
|
||||
static void update(void *p);
|
||||
|
@ -64,6 +65,8 @@ void app_ppm_configure(ppm_config *conf) {
|
|||
if (is_running) {
|
||||
servodec_set_pulse_options(config.pulse_start, config.pulse_end, config.median_filter);
|
||||
}
|
||||
|
||||
direction_hyst = config.max_erpm_for_dir * 0.20;
|
||||
#else
|
||||
(void)conf;
|
||||
#endif
|
||||
|
@ -206,8 +209,80 @@ static THD_FUNCTION(ppm_thread, arg) {
|
|||
bool current_mode_brake = false;
|
||||
bool send_current = false;
|
||||
bool send_duty = false;
|
||||
static bool force_brake = true;
|
||||
static int8_t did_idle_once = 0;
|
||||
float rpm_local = mc_interface_get_rpm();
|
||||
float rpm_lowest = rpm_local;
|
||||
|
||||
switch (config.ctrl_type) {
|
||||
case PPM_CTRL_TYPE_CURRENT_BRAKE_REV_HYST:
|
||||
current_mode = true;
|
||||
|
||||
// Hysteresis 20 % of actual RPM
|
||||
if (force_brake) {
|
||||
if (rpm_local < config.max_erpm_for_dir - direction_hyst) { // for 2500 it's 2000
|
||||
force_brake = false;
|
||||
did_idle_once = 0;
|
||||
}
|
||||
} else {
|
||||
if (rpm_local > config.max_erpm_for_dir + direction_hyst) { // for 2500 it's 3000
|
||||
force_brake = true;
|
||||
did_idle_once = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (servo_val >= 0.0) {
|
||||
if (servo_val == 0.0) {
|
||||
// if there was a idle in between then allow going backwards
|
||||
if (did_idle_once == 1 && !force_brake) {
|
||||
did_idle_once = 2;
|
||||
}
|
||||
}else{
|
||||
// accelerated forward or fast enough at least
|
||||
if (rpm_local > -config.max_erpm_for_dir){ // for 2500 it's -2500
|
||||
did_idle_once = 0;
|
||||
}
|
||||
}
|
||||
|
||||
current = servo_val * mcconf->lo_current_motor_max_now;
|
||||
} else {
|
||||
// too fast
|
||||
if (force_brake){
|
||||
current_mode_brake = true;
|
||||
}else{
|
||||
// not too fast backwards
|
||||
if (rpm_local > -config.max_erpm_for_dir) { // for 2500 it's -2500
|
||||
// first time that we brake and we are not too fast
|
||||
if (did_idle_once != 2) {
|
||||
did_idle_once = 1;
|
||||
current_mode_brake = true;
|
||||
}
|
||||
// too fast backwards
|
||||
} else {
|
||||
// if brake was active already
|
||||
if (did_idle_once == 1) {
|
||||
current_mode_brake = true;
|
||||
} else {
|
||||
// it's ok to go backwards now braking would be strange now
|
||||
did_idle_once = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current_mode_brake) {
|
||||
// braking
|
||||
current = fabsf(servo_val * mcconf->lo_current_motor_min_now);
|
||||
} else {
|
||||
// reverse acceleration
|
||||
current = servo_val * fabsf(mcconf->lo_current_motor_min_now);
|
||||
}
|
||||
}
|
||||
|
||||
if (fabsf(servo_val) < 0.001) {
|
||||
pulses_without_power++;
|
||||
}
|
||||
|
||||
break;
|
||||
case PPM_CTRL_TYPE_CURRENT:
|
||||
case PPM_CTRL_TYPE_CURRENT_NOREV:
|
||||
current_mode = true;
|
||||
|
@ -275,8 +350,6 @@ static THD_FUNCTION(ppm_thread, arg) {
|
|||
}
|
||||
|
||||
// Find lowest RPM
|
||||
float rpm_local = mc_interface_get_rpm();
|
||||
float rpm_lowest = rpm_local;
|
||||
if (config.multi_esc) {
|
||||
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;i++) {
|
||||
can_status_msg *msg = comm_can_get_status_msg_index(i);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -67,8 +67,8 @@
|
|||
// Benjamins first HW60 PCB with PB5 and PB6 swapped
|
||||
//#define HW60_VEDDER_FIRST_PCB
|
||||
|
||||
//#define HW_SOURCE "hw_60.c"
|
||||
//#define HW_HEADER "hw_60.h"
|
||||
#define HW_SOURCE "hw_60.c"
|
||||
#define HW_HEADER "hw_60.h"
|
||||
|
||||
//#define HW_SOURCE "hw_r2.c"
|
||||
//#define HW_HEADER "hw_r2.h"
|
||||
|
@ -94,8 +94,8 @@
|
|||
// Second revision with separate UART for NRF51
|
||||
#define HW75_300_REV_2
|
||||
|
||||
#define HW_SOURCE "hw_75_300.c"
|
||||
#define HW_HEADER "hw_75_300.h"
|
||||
//#define HW_SOURCE "hw_75_300.c"
|
||||
//#define HW_HEADER "hw_75_300.h"
|
||||
|
||||
//#define HW_SOURCE "hw_mini4.c"
|
||||
//#define HW_HEADER "hw_mini4.h"
|
||||
|
|
|
@ -172,6 +172,7 @@ int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration
|
|||
buffer[ind++] = conf->app_ppm_conf.multi_esc;
|
||||
buffer[ind++] = conf->app_ppm_conf.tc;
|
||||
buffer_append_float32_auto(buffer, conf->app_ppm_conf.tc_max_diff, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->app_ppm_conf.max_erpm_for_dir, &ind);
|
||||
buffer[ind++] = conf->app_adc_conf.ctrl_type;
|
||||
buffer_append_float32_auto(buffer, conf->app_adc_conf.hyst, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->app_adc_conf.voltage_start, &ind);
|
||||
|
@ -394,6 +395,7 @@ bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration
|
|||
conf->app_ppm_conf.multi_esc = buffer[ind++];
|
||||
conf->app_ppm_conf.tc = buffer[ind++];
|
||||
conf->app_ppm_conf.tc_max_diff = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->app_ppm_conf.max_erpm_for_dir = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->app_adc_conf.ctrl_type = buffer[ind++];
|
||||
conf->app_adc_conf.hyst = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->app_adc_conf.voltage_start = buffer_get_float32_auto(buffer, &ind);
|
||||
|
@ -600,6 +602,7 @@ void confgenerator_set_defaults_appconf(app_configuration *conf) {
|
|||
conf->app_ppm_conf.multi_esc = APPCONF_PPM_MULTI_ESC;
|
||||
conf->app_ppm_conf.tc = APPCONF_PPM_TC;
|
||||
conf->app_ppm_conf.tc_max_diff = APPCONF_PPM_TC_MAX_DIFF;
|
||||
conf->app_ppm_conf.max_erpm_for_dir = APPCONF_PPM_MAX_ERPM_FOR_DIR;
|
||||
conf->app_adc_conf.ctrl_type = APPCONF_ADC_CTRL_TYPE;
|
||||
conf->app_adc_conf.hyst = APPCONF_ADC_HYST;
|
||||
conf->app_adc_conf.voltage_start = APPCONF_ADC_VOLTAGE_START;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
// Constants
|
||||
#define MCCONF_SIGNATURE 503309878
|
||||
#define APPCONF_SIGNATURE 1962523771
|
||||
#define APPCONF_SIGNATURE 1099508905
|
||||
|
||||
// Functions
|
||||
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
|
||||
|
|
|
@ -336,7 +336,8 @@ typedef enum {
|
|||
PPM_CTRL_TYPE_DUTY,
|
||||
PPM_CTRL_TYPE_DUTY_NOREV,
|
||||
PPM_CTRL_TYPE_PID,
|
||||
PPM_CTRL_TYPE_PID_NOREV
|
||||
PPM_CTRL_TYPE_PID_NOREV,
|
||||
PPM_CTRL_TYPE_CURRENT_BRAKE_REV_HYST
|
||||
} ppm_control_type;
|
||||
|
||||
typedef struct {
|
||||
|
@ -356,6 +357,7 @@ typedef struct {
|
|||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
float max_erpm_for_dir;
|
||||
} ppm_config;
|
||||
|
||||
// ADC control types
|
||||
|
|
Loading…
Reference in New Issue