Skip to content

Commit

Permalink
First attempt at HFI
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Jan 20, 2020
1 parent b3ad0be commit ffbc6eb
Show file tree
Hide file tree
Showing 53 changed files with 432 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== FW 3.67 ===
* Added support for HFI to track motor position at 0 speed without sensors.
* Fixed CAN-bug in VESC Remote.

=== FW 3.66 ===
* Added support for HW 100/250.
* Added uptime terminal command.
Expand Down
10 changes: 6 additions & 4 deletions applications/app_nunchuk.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,13 @@ static THD_FUNCTION(output_thread, arg) {
mc_interface_set_brake_current(current);

// Send brake command to all ESCs seen recently on the CAN bus
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;i++) {
can_status_msg *msg = comm_can_get_status_msg_index(i);
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);

if (msg->id >= 0 && UTILS_AGE_S(msg->rx_time) < MAX_CAN_AGE) {
comm_can_set_current_brake(msg->id, current);
if (msg->id >= 0 && UTILS_AGE_S(msg->rx_time) < MAX_CAN_AGE) {
comm_can_set_current_brake(msg->id, current);
}
}
}
} else {
Expand Down
Binary file modified build_all/100_250/VESC_default.bin
Binary file not shown.
Binary file modified build_all/100_250/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/100_250/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_33k.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_default.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811_33k.bin
Binary file not shown.
Binary file modified build_all/48/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/48/VESC_default.bin
Binary file not shown.
Binary file modified build_all/48/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/48/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/60/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/60/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/60_MK3/VESC_default.bin
Binary file not shown.
Binary file modified build_all/60_MK3/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/60_MK3/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/60_MK3/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/75_300/VESC_default.bin
Binary file not shown.
Binary file modified build_all/75_300/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/75_300/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/75_300/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/75_300_R2/VESC_default.bin
Binary file not shown.
Binary file modified build_all/75_300_R2/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/75_300_R2/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/75_300_R2/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/A200S_V21/VESC_default.bin
Binary file not shown.
Binary file modified build_all/A200S_V22/VESC_default.bin
Binary file not shown.
Binary file modified build_all/AXIOM/VESC_default.bin
Binary file not shown.
Binary file modified build_all/DAS_RS/VESC_default.bin
Binary file not shown.
Binary file modified build_all/HD/VESC_default.bin
Binary file not shown.
Binary file modified build_all/HD/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/HD/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/HD/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/UAVC_OMEGA/VESC_default.bin
Binary file not shown.
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 3
#define FW_VERSION_MINOR 66
#define FW_VERSION_MINOR 67

#include "datatypes.h"

Expand Down
15 changes: 15 additions & 0 deletions confgenerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *
buffer_append_float32_auto(buffer, conf->foc_current_filter_const, &ind);
buffer[ind++] = conf->foc_cc_decoupling;
buffer[ind++] = conf->foc_observer_type;
buffer_append_float32_auto(buffer, conf->foc_hfi_voltage_start, &ind);
buffer_append_float32_auto(buffer, conf->foc_hfi_voltage_run, &ind);
buffer_append_float32_auto(buffer, conf->foc_sl_erpm_hfi, &ind);
buffer_append_uint16(buffer, conf->foc_hfi_start_samples, &ind);
buffer_append_float32_auto(buffer, conf->foc_hfi_obs_ovr_sec, &ind);
buffer_append_int16(buffer, conf->gpd_buffer_notify_left, &ind);
buffer_append_int16(buffer, conf->gpd_buffer_interpol, &ind);
buffer_append_float32_auto(buffer, conf->gpd_current_filter_const, &ind);
Expand Down Expand Up @@ -367,6 +372,11 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c
conf->foc_current_filter_const = buffer_get_float32_auto(buffer, &ind);
conf->foc_cc_decoupling = buffer[ind++];
conf->foc_observer_type = buffer[ind++];
conf->foc_hfi_voltage_start = buffer_get_float32_auto(buffer, &ind);
conf->foc_hfi_voltage_run = buffer_get_float32_auto(buffer, &ind);
conf->foc_sl_erpm_hfi = buffer_get_float32_auto(buffer, &ind);
conf->foc_hfi_start_samples = buffer_get_uint16(buffer, &ind);
conf->foc_hfi_obs_ovr_sec = buffer_get_float32_auto(buffer, &ind);
conf->gpd_buffer_notify_left = buffer_get_int16(buffer, &ind);
conf->gpd_buffer_interpol = buffer_get_int16(buffer, &ind);
conf->gpd_current_filter_const = buffer_get_float32_auto(buffer, &ind);
Expand Down Expand Up @@ -631,6 +641,11 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
conf->foc_current_filter_const = MCCONF_FOC_CURRENT_FILTER_CONST;
conf->foc_cc_decoupling = MCCONF_FOC_CC_DECOUPLING;
conf->foc_observer_type = MCCONF_FOC_OBSERVER_TYPE;
conf->foc_hfi_voltage_start = MCCONF_FOC_HFI_VOLTAGE_START;
conf->foc_hfi_voltage_run = MCCONF_FOC_HFI_VOLTAGE_RUN;
conf->foc_sl_erpm_hfi = MCCONF_FOC_SL_ERPM_HFI;
conf->foc_hfi_start_samples = MCCONF_FOC_HFI_START_SAMPLES;
conf->foc_hfi_obs_ovr_sec = MCCONF_FOC_HFI_OBS_OVR_SEC;
conf->gpd_buffer_notify_left = MCCONF_GPD_BUFFER_NOTIFY_LEFT;
conf->gpd_buffer_interpol = MCCONF_GPD_BUFFER_INTERPOL;
conf->gpd_current_filter_const = MCCONF_GPD_CURRENT_FILTER_CONST;
Expand Down
2 changes: 1 addition & 1 deletion confgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdbool.h>

// Constants
#define MCCONF_SIGNATURE 1671830952
#define MCCONF_SIGNATURE 1722487670
#define APPCONF_SIGNATURE 783041200

// Functions
Expand Down
8 changes: 7 additions & 1 deletion datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ typedef enum {
typedef enum {
FOC_SENSOR_MODE_SENSORLESS = 0,
FOC_SENSOR_MODE_ENCODER,
FOC_SENSOR_MODE_HALL
FOC_SENSOR_MODE_HALL,
FOC_SENSOR_MODE_HFI
} mc_foc_sensor_mode;

// Auxiliary output mode
Expand Down Expand Up @@ -283,6 +284,11 @@ typedef struct {
float foc_current_filter_const;
mc_foc_cc_decoupling_mode foc_cc_decoupling;
mc_foc_observer_type foc_observer_type;
float foc_hfi_voltage_start;
float foc_hfi_voltage_run;
float foc_sl_erpm_hfi;
uint16_t foc_hfi_start_samples;
float foc_hfi_obs_ovr_sec;
// GPDrive
int gpd_buffer_notify_left;
int gpd_buffer_interpol;
Expand Down
15 changes: 15 additions & 0 deletions mcconf/mcconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,21 @@
#ifndef MCCONF_FOC_OBSERVER_TYPE
#define MCCONF_FOC_OBSERVER_TYPE FOC_OBSERVER_ORTEGA_ORIGINAL // Position observer type for FOC
#endif
#ifndef MCCONF_FOC_HFI_VOLTAGE_START
#define MCCONF_FOC_HFI_VOLTAGE_START 25 // HFI voltage at start when resolving ambiguity
#endif
#ifndef MCCONF_FOC_HFI_VOLTAGE_RUN
#define MCCONF_FOC_HFI_VOLTAGE_RUN 5 // HFI voltage during tracking
#endif
#ifndef MCCONF_FOC_SL_ERPM_HFI
#define MCCONF_FOC_SL_ERPM_HFI 700.0 // ERPM above which only the observer is used
#endif
#ifndef MCCONF_FOC_HFI_START_SAMPLES
#define MCCONF_FOC_HFI_START_SAMPLES 50 // Sample this often at start to resolve ambiguity
#endif
#ifndef MCCONF_FOC_HFI_OBS_OVR_SEC
#define MCCONF_FOC_HFI_OBS_OVR_SEC 0.05 // Continue using observer for this long when entering HFI speed
#endif

// GPD
#ifndef MCCONF_GPD_BUFFER_NOTIFY_LEFT
Expand Down
Loading

0 comments on commit ffbc6eb

Please sign in to comment.