start hw version define split

This commit is contained in:
Oskar Weigl
2017-09-18 21:16:49 -07:00
parent f5d9bf94b3
commit b75f3130ff
4 changed files with 28 additions and 34 deletions
-19
View File
@@ -1,22 +1,3 @@
{
"files.associations": {
"stm32f4xx_hal.h": "c",
"spi.h": "c",
"gpio.h": "c",
"type_traits": "cpp",
"utility": "c",
"low_level.h": "cpp",
"motor.h": "cpp",
"math.h": "c",
"encoder.h": "cpp",
"xutility": "c",
"usb_commands.h": "cpp",
"sensorless.h": "cpp",
"usbd_cdc_if.h": "c",
"drv8301.h": "c",
"adc.h": "c",
"configuration.h": "cpp",
"utils.h": "cpp"
},
"C_Cpp.clang_format_style": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0 }"
}
+3
View File
@@ -52,6 +52,9 @@
/* USER CODE BEGIN Includes */
#define HW_VERSION_MAJOR 3
#define HW_VERSION_MINOR 3
/* USER CODE END Includes */
/* Private define ------------------------------------------------------------*/
+7
View File
@@ -86,6 +86,7 @@ ASM_SOURCES = \
# binaries
#######################################
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
AS = arm-none-eabi-gcc -x assembler-with-cpp
CP = arm-none-eabi-objcopy
AR = arm-none-eabi-ar
@@ -116,11 +117,14 @@ C_INCLUDES += -IMotorControl
# compile gcc flags
ASFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CXXFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
CXXFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -std=c99 -MD -MP -MF .dep/$(@F).d
CXXFLAGS += -std=c++14 -MD -MP -MF .dep/$(@F).d
#######################################
# LDFLAGS
@@ -141,6 +145,9 @@ all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of C++ objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
+18 -15
View File
@@ -41,20 +41,20 @@ static float elec_rad_per_enc = POLE_PAIRS * 2 * M_PI * (1.0f / (float)ENCODER_C
// TODO: For nice encapsulation, consider not having the motor objects public
Motor_t motors[] = {
{ // M0
.control_mode = CTRL_MODE_VELOCITY_CONTROL, //see: Motor_control_mode_t
.control_mode = CTRL_MODE_POSITION_CONTROL, //see: Motor_control_mode_t
.enable_step_dir = false, //auto enabled after calibration
.counts_per_step = 2.0f,
.error = ERROR_NO_ERROR,
.pos_setpoint = 0.0f,
.pos_gain = 20.0f, // [(counts/s) / counts]
// .vel_setpoint = 40000.0f,
.vel_setpoint = 800.0f,
// .vel_gain = 15.0f / 10000.0f, // [A/(counts/s)]
.vel_gain = 15.0f / 200.0f, // [A/(rad/s)]
// .vel_integrator_gain = 10.0f / 10000.0f, // [A/(counts/s * s)]
.vel_integrator_gain = 0.0f, // [A/(rad/s * s)]
.vel_setpoint = 0.0f,
// .vel_setpoint = 800.0f, <sensorless example>
.vel_gain = 15.0f / 10000.0f, // [A/(counts/s)]
// .vel_gain = 15.0f / 200.0f, // [A/(rad/s)] <sensorless example>
.vel_integrator_gain = 10.0f / 10000.0f, // [A/(counts/s * s)]
// .vel_integrator_gain = 0.0f, // [A/(rad/s * s)] <sensorless example>
.vel_integrator_current = 0.0f, // [A]
.vel_limit = 80000.0f, // [counts/s]
.vel_limit = 20000.0f, // [counts/s]
.current_setpoint = 0.0f, // [A]
.calibration_current = 10.0f, // [A]
.phase_inductance = 0.0f, // to be set by measure_phase_inductance
@@ -84,7 +84,7 @@ Motor_t motors[] = {
.shunt_conductance = 1.0f/0.0005f, //[S]
.phase_current_rev_gain = 0.0f, // to be set by DRV8301_setup
.current_control = {
// .current_lim = 75.0f, //[A] // Note: consistent with 40v/v gain
// .current_lim = 75.0f, //[A] // Note: consistent with 40v/v gain, TODO: auto limit from gain settings
.current_lim = 10.0f, //[A]
.p_gain = 0.0f, // [V/A] should be auto set after resistance and inductance measurement
.i_gain = 0.0f, // [V/As] should be auto set after resistance and inductance measurement
@@ -94,9 +94,9 @@ Motor_t motors[] = {
.final_v_alpha = 0.0f,
.final_v_beta = 0.0f,
},
// .rotor_mode = ROTOR_MODE_ENCODER,
// .rotor_mode = ROTOR_MODE_SENSORLESS,
// .rotor_mode = ROTOR_MODE_RUN_ENCODER_TEST_SENSORLESS,
.rotor_mode = ROTOR_MODE_SENSORLESS,
.rotor_mode = ROTOR_MODE_ENCODER,
.encoder = {
.encoder_timer = &htim3,
.encoder_offset = 0,
@@ -127,7 +127,7 @@ Motor_t motors[] = {
.timing_log = {0},
},
{ // M1
.control_mode = CTRL_MODE_VELOCITY_CONTROL, //see: Motor_control_mode_t
.control_mode = CTRL_MODE_POSITION_CONTROL, //see: Motor_control_mode_t
.enable_step_dir = false, //auto enabled after calibration
.counts_per_step = 2.0f,
.error = ERROR_NO_ERROR,
@@ -144,8 +144,8 @@ Motor_t motors[] = {
.phase_resistance = 0.0f, // to be set by measure_phase_resistance
.motor_thread = 0,
.thread_ready = false,
.enable_control = false,
.do_calibration = false,
.enable_control = true,
.do_calibration = true,
.calibration_ok = false,
.motor_timer = &htim8,
.next_timings = {TIM_1_8_PERIOD_CLOCKS/2, TIM_1_8_PERIOD_CLOCKS/2, TIM_1_8_PERIOD_CLOCKS/2},
@@ -167,7 +167,7 @@ Motor_t motors[] = {
.shunt_conductance = 1.0f/0.0005f, //[S]
.phase_current_rev_gain = 0.0f, // to be set by DRV8301_setup
.current_control = {
// .current_lim = 75.0f, //[A] // Note: consistent with 40v/v gain
// .current_lim = 75.0f, //[A] // Note: consistent with 40v/v gain, TODO: auto limit from gain settings
.current_lim = 10.0f, //[A]
.p_gain = 0.0f, // [V/A] should be auto set after resistance and inductance measurement
.i_gain = 0.0f, // [V/As] should be auto set after resistance and inductance measurement
@@ -200,6 +200,9 @@ Motor_t motors[] = {
.V_alpha_beta_memory = {0.0f, 0.0f}, // [V]
.pm_flux_linkage = 1.58e-3f, // [V / (rad/s)] { 5.51328895422 / (<pole pairs> * <rpm/v>) }
.estimator_good = false,
.spin_up_current = 10.0f, // [A]
.spin_up_acceleration = 400.0f, // [rad/s^2]
.spin_up_target_vel = 400.0f, // [rad/s]
},
.timing_log_index = 0,
.timing_log = {0}