Skip to content

Commit

Permalink
[Config] Add new fields for PBRS settings
Browse files Browse the repository at this point in the history
Updated confgenerator.* files by using VESC Tool --> Developer -->
Export Configuration Parser
  • Loading branch information
kubark42 committed Feb 13, 2022
1 parent caa68c0 commit 661c79c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
12 changes: 12 additions & 0 deletions confgenerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *
buffer_append_uint16(buffer, conf->foc_hfi_start_samples, &ind);
buffer_append_float32_auto(buffer, conf->foc_hfi_obs_ovr_sec, &ind);
buffer[ind++] = conf->foc_hfi_samples;
buffer_append_float32_auto(buffer, conf->foc_prbs_voltage, &ind);
buffer_append_float32_auto(buffer, conf->foc_prbs_current, &ind);
buffer[ind++] = conf->foc_prbs_channel;
buffer[ind++] = conf->foc_prbs_mode;
buffer[ind++] = conf->foc_offsets_cal_on_boot;
buffer_append_float32_auto(buffer, conf->foc_offsets_current[0], &ind);
buffer_append_float32_auto(buffer, conf->foc_offsets_current[1], &ind);
Expand Down Expand Up @@ -484,6 +488,10 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c
conf->foc_hfi_start_samples = buffer_get_uint16(buffer, &ind);
conf->foc_hfi_obs_ovr_sec = buffer_get_float32_auto(buffer, &ind);
conf->foc_hfi_samples = buffer[ind++];
conf->foc_prbs_voltage = buffer_get_float32_auto(buffer, &ind);
conf->foc_prbs_current = buffer_get_float32_auto(buffer, &ind);
conf->foc_prbs_channel = buffer[ind++];
conf->foc_prbs_mode = buffer[ind++];
conf->foc_offsets_cal_on_boot = buffer[ind++];
conf->foc_offsets_current[0] = buffer_get_float32_auto(buffer, &ind);
conf->foc_offsets_current[1] = buffer_get_float32_auto(buffer, &ind);
Expand Down Expand Up @@ -851,6 +859,10 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
conf->foc_hfi_start_samples = MCCONF_FOC_HFI_START_SAMPLES;
conf->foc_hfi_obs_ovr_sec = MCCONF_FOC_HFI_OBS_OVR_SEC;
conf->foc_hfi_samples = MCCONF_FOC_HFI_SAMPLES;
conf->foc_prbs_voltage = MCCONF_FOC_PRBS_VOLTAGE;
conf->foc_prbs_current = MCCONF_FOC_PRBS_CURRENT;
conf->foc_prbs_channel = MCCONF_FOC_PRBS_CHANNEL;
conf->foc_prbs_mode = MCCONF_FOC_PRBS_MODE;
conf->foc_offsets_cal_on_boot = MCCONF_FOC_OFFSETS_CAL_ON_BOOT;
conf->foc_offsets_current[0] = MCCONF_FOC_OFFSETS_CURRENT_0;
conf->foc_offsets_current[1] = MCCONF_FOC_OFFSETS_CURRENT_1;
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 1018325777
#define MCCONF_SIGNATURE 2944609449
#define APPCONF_SIGNATURE 3733512279

// Functions
Expand Down
18 changes: 18 additions & 0 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ typedef enum {
HFI_SAMPLES_32
} foc_hfi_samples;

typedef enum {
PRBS_CHANNEL_D = 0,
PRBS_CHANNEL_Q,
PRBS_CHANNEL_DQ,
} foc_prbs_channel_enum;

typedef enum {
PRBS_MODE_OFF = 0,
PRBS_MODE_CURRRENT,
PRBS_MODE_VOLTAGE,
} foc_prbs_mode_enum;

typedef enum {
BMS_TYPE_NONE = 0,
BMS_TYPE_VESC
Expand Down Expand Up @@ -418,6 +430,12 @@ typedef struct {
uint16_t foc_hfi_start_samples;
float foc_hfi_obs_ovr_sec;
foc_hfi_samples foc_hfi_samples;

float foc_prbs_voltage;
float foc_prbs_current;
foc_prbs_channel_enum foc_prbs_channel;
foc_prbs_mode_enum foc_prbs_mode;

bool foc_offsets_cal_on_boot;
float foc_offsets_current[3];
float foc_offsets_voltage[3];
Expand Down
12 changes: 12 additions & 0 deletions mcconf/mcconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@
#ifndef MCCONF_FOC_HFI_SAMPLES
#define MCCONF_FOC_HFI_SAMPLES HFI_SAMPLES_16 // Samples per motor revolution for HFI
#endif
#ifndef MCCONF_FOC_PRBS_VOLTAGE
#define MCCONF_FOC_PRBS_VOLTAGE 3 //
#endif
#ifndef MCCONF_FOC_PRBS_CURRENT
#define MCCONF_FOC_PRBS_CURRENT 1 //
#endif
#ifndef MCCONF_FOC_PRBS_CHANNEL
#define MCCONF_FOC_PRBS_CHANNEL PRBS_CHANNEL_D //
#endif
#ifndef MCCONF_FOC_PRBS_MODE
#define MCCONF_FOC_PRBS_MODE PRBS_MODE_OFF //
#endif
#ifndef MCCONF_FOC_OFFSETS_CAL_ON_BOOT
#define MCCONF_FOC_OFFSETS_CAL_ON_BOOT true // Measure offsets every boot
#endif
Expand Down

0 comments on commit 661c79c

Please sign in to comment.