mirror of https://github.com/rusefi/bldc.git
update hwconf to new hardware version (hw7)
This commit is contained in:
parent
f6baa653ea
commit
786cf09889
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#define SPEED_STEP 0.05
|
#define SPEED_STEP 0.05
|
||||||
#define SPEED_MAX 1.00
|
#define SPEED_MAX 1.00
|
||||||
#define SPEED_MIN 0.20
|
#define SPEED_MIN 0.10
|
||||||
#define SPEED_OFF 0.00
|
#define SPEED_OFF 0.00
|
||||||
|
|
||||||
//private variables
|
//private variables
|
||||||
|
@ -60,6 +60,9 @@ void app_custom_start(void) {
|
||||||
// Start the dv thread
|
// Start the dv thread
|
||||||
chThdCreateStatic(dpv_thread_wa, sizeof(dpv_thread_wa), NORMALPRIO, dpv_thread, NULL);
|
chThdCreateStatic(dpv_thread_wa, sizeof(dpv_thread_wa), NORMALPRIO, dpv_thread, NULL);
|
||||||
|
|
||||||
|
hw_start_i2c();
|
||||||
|
app_uartcomm_start(UART_PORT_COMM_HEADER);
|
||||||
|
app_uartcomm_start(UART_PORT_BUILTIN);
|
||||||
chSysLock();
|
chSysLock();
|
||||||
chVTSetI(&dpv_vt, MS2ST(1), update, NULL);
|
chVTSetI(&dpv_vt, MS2ST(1), update, NULL);
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
|
@ -122,7 +125,6 @@ static THD_FUNCTION(dpv_thread, arg) {
|
||||||
static systime_t last_time = 0;
|
static systime_t last_time = 0;
|
||||||
static float motorSpeed_val_ramp = 0.0;
|
static float motorSpeed_val_ramp = 0.0;
|
||||||
float ramp_time;
|
float ramp_time;
|
||||||
|
|
||||||
if ( ! palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN)) {
|
if ( ! palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN)) {
|
||||||
motorSpeed=targetSpeed;
|
motorSpeed=targetSpeed;
|
||||||
} else {
|
} else {
|
||||||
|
@ -138,9 +140,9 @@ static THD_FUNCTION(dpv_thread, arg) {
|
||||||
last_time = chVTGetSystemTimeX();
|
last_time = chVTGetSystemTimeX();
|
||||||
motorSpeed = motorSpeed_val_ramp;
|
motorSpeed = motorSpeed_val_ramp;
|
||||||
}
|
}
|
||||||
mc_interface_set_duty(utils_map(motorSpeed, 0, 1.0, 0, mcconf->l_max_duty));
|
//mc_interface_set_pid_speed(motorSpeed*mcconf->l_max_erpm);
|
||||||
// mc_interface_set_pid_speed(motorSpeed*mcconf->l_max_erpm);
|
mc_interface_set_duty(motorSpeed*mcconf->l_max_duty);
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(5);
|
||||||
// Reset the timeout
|
// Reset the timeout
|
||||||
timeout_reset();
|
timeout_reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,8 @@
|
||||||
#include "lora/lora.h"
|
#include "lora/lora.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Threads
|
|
||||||
THD_FUNCTION(mag_thread, arg);
|
THD_FUNCTION(mag_thread, arg);
|
||||||
static THD_WORKING_AREA(mag_thread_wa, 256);
|
static THD_WORKING_AREA(mag_thread_wa, 512);
|
||||||
static bool mag_thread_running = false;
|
static bool mag_thread_running = false;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
@ -56,7 +55,6 @@ static const I2CConfig i2cfg = {
|
||||||
STD_DUTY_CYCLE
|
STD_DUTY_CYCLE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void hw_init_gpio(void) {
|
void hw_init_gpio(void) {
|
||||||
// GPIO clock enable
|
// GPIO clock enable
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
||||||
|
@ -144,8 +142,6 @@ void hw_init_gpio(void) {
|
||||||
0,
|
0,
|
||||||
terminal_cmd_doublepulse);
|
terminal_cmd_doublepulse);
|
||||||
#endif
|
#endif
|
||||||
//start uart for log
|
|
||||||
//app_uartcomm_start(UART_PORT_COMM_HEADER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hw_setup_adc_channels(void) {
|
void hw_setup_adc_channels(void) {
|
||||||
|
@ -221,7 +217,6 @@ void hw_start_i2c(void) {
|
||||||
PAL_STM32_OTYPE_OPENDRAIN |
|
PAL_STM32_OTYPE_OPENDRAIN |
|
||||||
PAL_STM32_OSPEED_MID1 |
|
PAL_STM32_OSPEED_MID1 |
|
||||||
PAL_STM32_PUDR_PULLUP);
|
PAL_STM32_PUDR_PULLUP);
|
||||||
|
|
||||||
i2cStart(&HW_I2C_DEV, &i2cfg);
|
i2cStart(&HW_I2C_DEV, &i2cfg);
|
||||||
i2c_running = true;
|
i2c_running = true;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +255,6 @@ void hw_try_restore_i2c(void) {
|
||||||
PAL_STM32_OTYPE_OPENDRAIN |
|
PAL_STM32_OTYPE_OPENDRAIN |
|
||||||
PAL_STM32_OSPEED_MID1 |
|
PAL_STM32_OSPEED_MID1 |
|
||||||
PAL_STM32_PUDR_PULLUP);
|
PAL_STM32_PUDR_PULLUP);
|
||||||
|
|
||||||
palSetPad(HW_I2C_SCL_PORT, HW_I2C_SCL_PIN);
|
palSetPad(HW_I2C_SCL_PORT, HW_I2C_SCL_PIN);
|
||||||
palSetPad(HW_I2C_SDA_PORT, HW_I2C_SDA_PIN);
|
palSetPad(HW_I2C_SDA_PORT, HW_I2C_SDA_PIN);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
// HW properties
|
// HW properties
|
||||||
#define HW_HAS_3_SHUNTS
|
#define HW_HAS_3_SHUNTS
|
||||||
#define HW_HAS_PHASE_SHUNTS
|
#define HW_HAS_PHASE_SHUNTS
|
||||||
//#define HW_HAS_PHASE_FILTERS
|
#define HW_HAS_PHASE_FILTERS
|
||||||
#define INVERTED_SHUNT_POLARITY
|
#define INVERTED_SHUNT_POLARITY
|
||||||
#define HW_HAS_NO_CAN
|
#define HW_HAS_NO_CAN
|
||||||
#define HW_HAS_LORA
|
#define HW_HAS_LORA
|
||||||
|
@ -151,13 +151,13 @@
|
||||||
#define HW_UART_RX_PORT GPIOB
|
#define HW_UART_RX_PORT GPIOB
|
||||||
#define HW_UART_RX_PIN 11
|
#define HW_UART_RX_PIN 11
|
||||||
|
|
||||||
//#define HW_UART_P_BAUD 115200
|
#define HW_UART_P_BAUD 115200
|
||||||
//#define HW_UART_P_DEV SD4
|
#define HW_UART_P_DEV SD4
|
||||||
//#define HW_UART_P_GPIO_AF GPIO_AF_UART4
|
#define HW_UART_P_GPIO_AF GPIO_AF_UART4
|
||||||
//#define HW_UART_P_TX_PORT GPIOC
|
#define HW_UART_P_TX_PORT GPIOC
|
||||||
//#define HW_UART_P_TX_PIN 10
|
#define HW_UART_P_TX_PIN 10
|
||||||
//#define HW_UART_P_RX_PORT GPIOC
|
#define HW_UART_P_RX_PORT GPIOC
|
||||||
//#define HW_UART_P_RX_PIN 11
|
#define HW_UART_P_RX_PIN 11
|
||||||
|
|
||||||
// ICU Peripheral for servo decoding
|
// ICU Peripheral for servo decoding
|
||||||
#define HW_USE_SERVO_TIM4
|
#define HW_USE_SERVO_TIM4
|
||||||
|
@ -225,16 +225,16 @@
|
||||||
#ifdef HW_HAS_LORA
|
#ifdef HW_HAS_LORA
|
||||||
#define HW_LORA_SPI_DEV SPID1
|
#define HW_LORA_SPI_DEV SPID1
|
||||||
#define HW_LORA_SPI_GPIO_AF GPIO_AF_SPI1
|
#define HW_LORA_SPI_GPIO_AF GPIO_AF_SPI1
|
||||||
#define HW_LORA_SPI_PORT_NSS GPIOA
|
#define HW_LORA_SPI_PORT_NSS GPIOB
|
||||||
#define HW_LORA_SPI_PIN_NSS 4
|
#define HW_LORA_SPI_PIN_NSS 3
|
||||||
#define HW_LORA_SPI_PORT_SCK GPIOA
|
#define HW_LORA_SPI_PORT_SCK GPIOB
|
||||||
#define HW_LORA_SPI_PIN_SCK 5
|
#define HW_LORA_SPI_PIN_SCK 6
|
||||||
#define HW_LORA_SPI_PORT_MOSI GPIOA
|
#define HW_LORA_SPI_PORT_MOSI GPIOB
|
||||||
#define HW_LORA_SPI_PIN_MOSI 7
|
#define HW_LORA_SPI_PIN_MOSI 4
|
||||||
#define HW_LORA_SPI_PORT_MISO GPIOA
|
#define HW_LORA_SPI_PORT_MISO GPIOB
|
||||||
#define HW_LORA_SPI_PIN_MISO 6
|
#define HW_LORA_SPI_PIN_MISO 5
|
||||||
#define HW_LORA_SPI_PORT_DIO0 GPIOC
|
#define HW_LORA_SPI_PORT_DIO0 GPIOB
|
||||||
#define HW_LORA_SPI_PIN_DIO0 5
|
#define HW_LORA_SPI_PIN_DIO0 12
|
||||||
#define HW_LORA_SPI_PORT_RESET GPIOB
|
#define HW_LORA_SPI_PORT_RESET GPIOB
|
||||||
#define HW_LORA_SPI_PIN_RESET 2
|
#define HW_LORA_SPI_PIN_RESET 2
|
||||||
#endif
|
#endif
|
||||||
|
@ -252,14 +252,14 @@
|
||||||
|
|
||||||
|
|
||||||
// Override dead time. See the stm32f4 reference manual for calculating this value.
|
// Override dead time. See the stm32f4 reference manual for calculating this value.
|
||||||
#define HW_DEAD_TIME_NSEC 660.0
|
#define HW_DEAD_TIME_NSEC 360.0
|
||||||
|
|
||||||
// Default setting overrides
|
// Default setting overrides
|
||||||
#ifndef MCCONF_L_MIN_VOLTAGE
|
#ifndef MCCONF_L_MIN_VOLTAGE
|
||||||
#define MCCONF_L_MIN_VOLTAGE 12.0 // Minimum input voltage
|
#define MCCONF_L_MIN_VOLTAGE 12.0 // Minimum input voltage
|
||||||
#endif
|
#endif
|
||||||
#ifndef MCCONF_L_MAX_VOLTAGE
|
#ifndef MCCONF_L_MAX_VOLTAGE
|
||||||
#define MCCONF_L_MAX_VOLTAGE 50.0 // Maximum input voltage
|
#define MCCONF_L_MAX_VOLTAGE 57.0 // Maximum input voltage
|
||||||
#endif
|
#endif
|
||||||
#ifndef MCCONF_DEFAULT_MOTOR_TYPE
|
#ifndef MCCONF_DEFAULT_MOTOR_TYPE
|
||||||
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
|
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
#define HW_LIM_CURRENT -120.0, 120.0
|
#define HW_LIM_CURRENT -120.0, 120.0
|
||||||
#define HW_LIM_CURRENT_IN -120.0, 120.0
|
#define HW_LIM_CURRENT_IN -120.0, 120.0
|
||||||
#define HW_LIM_CURRENT_ABS 0.0, 160.0
|
#define HW_LIM_CURRENT_ABS 0.0, 160.0
|
||||||
#define HW_LIM_VIN 12.0, 50.0
|
#define HW_LIM_VIN 12.0, 60.0
|
||||||
#define HW_LIM_ERPM -200e3, 200e3
|
#define HW_LIM_ERPM -200e3, 200e3
|
||||||
#define HW_LIM_DUTY_MIN 0.0, 0.1
|
#define HW_LIM_DUTY_MIN 0.0, 0.1
|
||||||
#define HW_LIM_DUTY_MAX 0.0, 0.99
|
#define HW_LIM_DUTY_MAX 0.0, 0.99
|
||||||
|
|
Loading…
Reference in New Issue