Macros | Functions | Variables
conf_general.c File Reference
#include "conf_general.h"
#include "ch.h"
#include "eeprom.h"
#include "mcpwm.h"
#include "hw.h"
#include "utils.h"
#include <string.h>
#include "mcconf_outrunner2.h"

Macros

#define MC_DEFAULT_MOTOR_TYPE   MOTOR_TYPE_BLDC
 
#define MCPWM_PWM_MODE   PWM_MODE_SYNCHRONOUS
 
#define MCPWM_MIN_VOLTAGE   8.0
 
#define MCPWM_MAX_VOLTAGE   50.0
 
#define MCPWM_BATTERY_CUT_START   10.0
 
#define MCPWM_BATTERY_CUT_END   8.0
 
#define MCPWM_RPM_MAX   100000.0
 
#define MCPWM_RPM_MIN   -100000.0
 
#define MCPWM_CURRENT_STARTUP_BOOST   0.01
 
#define MCPWM_RPM_LIMIT_NEG_TORQUE   true
 
#define MCPWM_CURR_MAX_RPM_FBRAKE   300
 
#define MCPWM_CURR_MAX_RPM_FBRAKE_CC   1500
 
#define MCPWM_SLOW_ABS_OVERCURRENT   false
 
#define MCPWM_COMM_MODE   COMM_MODE_INTEGRATE
 
#define MCPWM_CYCLE_INT_LIMIT_HIGH_FAC   0.8
 
#define MCPWM_CYCLE_INT_START_RPM_BR   80000.0
 
#define MCPWM_FAULT_STOP_TIME   3000
 
#define MCPWM_LIM_TEMP_FET_START   80.0
 
#define MCPWM_LIM_TEMP_FET_END   100.0
 
#define MCPWM_LIM_TEMP_MOTOR_START   80.0
 
#define MCPWM_LIM_TEMP_MOTOR_END   100.0
 
#define MCPWM_MAX_FB_CURR_DIR_CHANGE   10.0
 
#define MCPWM_MIN_DUTY   0.005
 
#define MCPWM_MAX_DUTY   0.95
 
#define MCPWM_RAMP_STEP   0.02
 
#define MCPWM_RAMP_STEP_RPM_LIMIT   0.0005
 
#define MCPWM_CURRENT_LIMIT_GAIN   0.5
 
#define MCPWM_HALL_ERPM   2000.0
 
#define MCPWM_HALL_TAB_0   -1
 
#define MCPWM_HALL_TAB_1   1
 
#define MCPWM_HALL_TAB_2   3
 
#define MCPWM_HALL_TAB_3   2
 
#define MCPWM_HALL_TAB_4   5
 
#define MCPWM_HALL_TAB_5   6
 
#define MCPWM_HALL_TAB_6   4
 
#define MCPWM_HALL_TAB_7   -1
 
#define EEPROM_BASE_MCCONF   1000
 
#define EEPROM_BASE_APPCONF   2000
 

Functions

void conf_general_init (void)
 
void conf_general_read_app_configuration (app_configuration *conf)
 
bool conf_general_store_app_configuration (app_configuration *conf)
 
void conf_general_read_mc_configuration (mc_configuration *conf)
 
bool conf_general_store_mc_configuration (mc_configuration *conf)
 
bool conf_general_detect_motor_param (float current, float min_rpm, float low_duty, float *int_limit, float *bemf_coupling_k, int8_t *hall_table, int *hall_res)
 

Variables

uint16_t VirtAddVarTab [NB_OF_VAR]
 

Macro Definition Documentation

#define EEPROM_BASE_APPCONF   2000
#define EEPROM_BASE_MCCONF   1000
#define MC_DEFAULT_MOTOR_TYPE   MOTOR_TYPE_BLDC
#define MCPWM_BATTERY_CUT_END   8.0
#define MCPWM_BATTERY_CUT_START   10.0
#define MCPWM_COMM_MODE   COMM_MODE_INTEGRATE
#define MCPWM_CURR_MAX_RPM_FBRAKE   300
#define MCPWM_CURR_MAX_RPM_FBRAKE_CC   1500
#define MCPWM_CURRENT_LIMIT_GAIN   0.5
#define MCPWM_CURRENT_STARTUP_BOOST   0.01
#define MCPWM_CYCLE_INT_LIMIT_HIGH_FAC   0.8
#define MCPWM_CYCLE_INT_START_RPM_BR   80000.0
#define MCPWM_FAULT_STOP_TIME   3000
#define MCPWM_HALL_ERPM   2000.0
#define MCPWM_HALL_TAB_0   -1
#define MCPWM_HALL_TAB_1   1
#define MCPWM_HALL_TAB_2   3
#define MCPWM_HALL_TAB_3   2
#define MCPWM_HALL_TAB_4   5
#define MCPWM_HALL_TAB_5   6
#define MCPWM_HALL_TAB_6   4
#define MCPWM_HALL_TAB_7   -1
#define MCPWM_LIM_TEMP_FET_END   100.0
#define MCPWM_LIM_TEMP_FET_START   80.0
#define MCPWM_LIM_TEMP_MOTOR_END   100.0
#define MCPWM_LIM_TEMP_MOTOR_START   80.0
#define MCPWM_MAX_DUTY   0.95
#define MCPWM_MAX_FB_CURR_DIR_CHANGE   10.0
#define MCPWM_MAX_VOLTAGE   50.0
#define MCPWM_MIN_DUTY   0.005
#define MCPWM_MIN_VOLTAGE   8.0
#define MCPWM_PWM_MODE   PWM_MODE_SYNCHRONOUS
#define MCPWM_RAMP_STEP   0.02
#define MCPWM_RAMP_STEP_RPM_LIMIT   0.0005
#define MCPWM_RPM_LIMIT_NEG_TORQUE   true
#define MCPWM_RPM_MAX   100000.0
#define MCPWM_RPM_MIN   -100000.0
#define MCPWM_SLOW_ABS_OVERCURRENT   false

Function Documentation

bool conf_general_detect_motor_param ( float  current,
float  min_rpm,
float  low_duty,
float *  int_limit,
float *  bemf_coupling_k,
int8_t *  hall_table,
int *  hall_res 
)
void conf_general_init ( void  )
void conf_general_read_app_configuration ( app_configuration conf)

Read app_configuration from EEPROM. If this fails, default values will be used.

Parameters
confA pointer to a app_configuration struct to write the read configuration to.
void conf_general_read_mc_configuration ( mc_configuration conf)

Read mc_configuration from EEPROM. If this fails, default values will be used.

Parameters
confA pointer to a mc_configuration struct to write the read configuration to.
bool conf_general_store_app_configuration ( app_configuration conf)

Write app_configuration to EEPROM.

Parameters
confA pointer to the configuration that should be stored.
bool conf_general_store_mc_configuration ( mc_configuration conf)

Write mc_configuration to EEPROM.

Parameters
confA pointer to the configuration that should be stored.