Skip to content

Commit

Permalink
Improve startup low kv motors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlkaMotors committed Nov 19, 2024
1 parent 03809ba commit ef2ec01
Show file tree
Hide file tree
Showing 20 changed files with 1,238 additions and 111 deletions.
173 changes: 167 additions & 6 deletions Inc/targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,39 @@
#define ADC_CHANNEL_VOLTAGE ADC_CHANNEL_6
#endif



#ifdef AT32DEVBIGPROP_F421
#define FIRMWARE_NAME "AT32 BigProp"
#define FILE_NAME "AT32DEVBIGPROP_F421"
#define DEAD_TIME 80
#define HARDWARE_GROUP_AT_C
//#define HARDWARE_GROUP_AT_045
#define USE_SERIAL_TELEMETRY
#define RAMP_SPEED_LOW_RPM 1
#define RAMP_SPEED_HIGH_RPM 2
#define PHASE_A_COMP 0x400000E5 // pa0 // works for polling mode
#define PHASE_B_COMP 0x400000C5 // pa4
#define PHASE_C_COMP 0x400000D5 // pa5
#define USE_SERIAL_TELEMETRY
#define TARGET_VOLTAGE_DIVIDER 74
#define MILLIVOLT_PER_AMP 45
#define CURRENT_OFFSET 529 // mv
#define TARGET_MIN_BEMF_COUNTS 5
#endif

#ifdef JHEMCU_F421
#define FIRMWARE_NAME "JHEMCU_F421 "
#define FILE_NAME "JHEMCU_F421"
#define DEAD_TIME 80
#define HARDWARE_GROUP_AT_B
#define HARDWARE_GROUP_AT_045
#define USE_SERIAL_TELEMETRY
#define ADC_CHANNEL_CURRENT ADC_CHANNEL_3
#define ADC_CHANNEL_VOLTAGE ADC_CHANNEL_6
#define TARGET_MIN_BEMF_COUNTS 3
#endif

#ifdef FLASHHOBBY_F421
#define FIRMWARE_NAME "FH F421 "
#define FILE_NAME "FLASHHOBBY_F421"
Expand Down Expand Up @@ -877,6 +910,29 @@

/*****************************************************AT32F415 targets ************************************************/

#ifdef ARK_4IN1_F051
#define FILE_NAME "ARK_4IN1_F051"
#define FIRMWARE_NAME "ARK 4IN1"
#define DEAD_TIME 45
#define HARDWARE_GROUP_F0_B
#define MILLIVOLT_PER_AMP 10
#define CURRENT_OFFSET 25 // millivolts
#define TARGET_VOLTAGE_DIVIDER 210
#define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_6
#define VOLTAGE_ADC_PIN LL_GPIO_PIN_6
#define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_3
#define CURRENT_ADC_PIN LL_GPIO_PIN_3
#define USE_SERIAL_TELEMETRY
#define USE_DRV8328_NSLEEP
#define NSLEEP_PORT GPIOA
#define NSLEEP_PIN LL_GPIO_PIN_15
#define USE_DRV8328_NFAULT
#define NFAULT_PORT GPIOB
#define NFAULT_PIN LL_GPIO_PIN_5
#define TARGET_MIN_BEMF_COUNTS 4
#endif


#ifdef PB450_F051
#define FILE_NAME "PB450_F051"
#define FIRMWARE_NAME "PB450_F051 "
Expand Down Expand Up @@ -1260,6 +1316,7 @@
#endif



//#ifdef GEN_64K_G071
//#define FILE_NAME "GEN_64K_G071"
//#define FIRMWARE_NAME "G071 64kESC "
Expand All @@ -1271,6 +1328,19 @@
//#define SIXTY_FOUR_KB_MEMORY
//#endif

#ifdef JUPITER_80_G071
#define FILE_NAME "JUPITER_80_G071"
#define FIRMWARE_NAME "JUPITER G071"
#define DEAD_TIME 60
#define MILLIVOLT_PER_AMP 20
#define CURRENT_OFFSET 0
#define HARDWARE_GROUP_G0_L
#define USE_SERIAL_TELEMETRY
#define SIXTY_FOUR_KB_MEMORY

#endif


#ifdef GEN_64K_G071
#define FILE_NAME "GEN_64K_G071"
#define FIRMWARE_NAME "G071 64kESC "
Expand All @@ -1280,7 +1350,8 @@
#define HARDWARE_GROUP_G0_A
#define USE_SERIAL_TELEMETRY
#define SIXTY_FOUR_KB_MEMORY
#define MIN_BEMF_COUNTS 5
#define TARGET_MIN_BEMF_COUNTS 4

#endif

#ifdef ST_G0_03_N_G071
Expand Down Expand Up @@ -1433,10 +1504,17 @@
#define TARGET_STALL_PROTECTION_INTERVAL 9000
#define TARGET_VOLTAGE_DIVIDER 210
#define HARDWARE_GROUP_G0_A
#define USE_SERIAL_TELEMETRY
//#define USE_SERIAL_TELEMETRY
#define USE_PULSE_OUT
#define RPM_PULSE_PORT GPIOB
#define RPM_PULSE_PIN LL_GPIO_PIN_6
#define SIXTY_FOUR_KB_MEMORY
#define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_4
#define CURRENT_ADC_PIN LL_GPIO_PIN_4
#define RAMP_SPEED_LOW_RPM 1
#define RAMP_SPEED_HIGH_RPM 2
#define LOOP_FREQUENCY_HZ 20000
#define TARGET_MIN_BEMF_COUNTS 4
#define USE_LED_STRIP
#endif

Expand Down Expand Up @@ -2446,6 +2524,51 @@

#endif

#ifdef HARDWARE_GROUP_G0_L

#define MCU_G071
#define N_VARIANT
#define USE_TIMER_3_CHANNEL_1
#define INPUT_PIN LL_GPIO_PIN_6
#define INPUT_PIN_PORT GPIOC
#define IC_TIMER_CHANNEL LL_TIM_CHANNEL_CH1
#define IC_TIMER_REGISTER TIM3
#define IC_TIMER_POINTER htim3

#define INPUT_DMA_CHANNEL LL_DMA_CHANNEL_1
#define DMA_HANDLE_TYPE_DEF hdma_tim3_ch1
#define IC_DMA_IRQ_NAME DMA1_Channel1_IRQn

#define PHASE_A_GPIO_LOW LL_GPIO_PIN_15
#define PHASE_A_GPIO_PORT_LOW GPIOB
#define PHASE_A_GPIO_HIGH LL_GPIO_PIN_10
#define PHASE_A_GPIO_PORT_HIGH GPIOA

#define PHASE_B_GPIO_LOW LL_GPIO_PIN_0
#define PHASE_B_GPIO_PORT_LOW GPIOB
#define PHASE_B_GPIO_HIGH LL_GPIO_PIN_9
#define PHASE_B_GPIO_PORT_HIGH GPIOA

#define PHASE_C_GPIO_LOW LL_GPIO_PIN_7
#define PHASE_C_GPIO_PORT_LOW GPIOA
#define PHASE_C_GPIO_HIGH LL_GPIO_PIN_8
#define PHASE_C_GPIO_PORT_HIGH GPIOA

#define PHASE_A_COMP LL_COMP_INPUT_MINUS_IO3 // pa0
#define PHASE_B_COMP LL_COMP_INPUT_MINUS_IO3 // pa2
#define PHASE_C_COMP LL_COMP_INPUT_MINUS_IO2 // pb7

#define PHASE_A_EXTI_LINE LL_EXTI_LINE_17
#define PHASE_A_COMP_NUMBER COMP1

#define PHASE_B_EXTI_LINE LL_EXTI_LINE_18
#define PHASE_B_COMP_NUMBER COMP2

#define PHASE_C_EXTI_LINE LL_EXTI_LINE_18
#define PHASE_C_COMP_NUMBER COMP2

#endif

#ifdef HARDWARE_GROUP_G4_A

#define MCU_G431
Expand Down Expand Up @@ -2989,9 +3112,9 @@
#define PHASE_C_COMP 0x400000D1 // pa5
#endif
#ifdef HARDWARE_GROUP_AT_540
#define PHASE_A_COMP 0x400000D1 // pa5 // works for polling mode
#define PHASE_B_COMP 0x400000C1 // pa4
#define PHASE_C_COMP 0x400000E1 // pa0
#define PHASE_A_COMP 0x400000D5 // pa5 // works for polling mode
#define PHASE_B_COMP 0x400000C5 // pa4
#define PHASE_C_COMP 0x400000E5 // pa0
#endif

#ifdef HARDWARE_GROUP_AT_245
Expand All @@ -3000,6 +3123,8 @@
#define PHASE_C_COMP 0x400000D1 // pa5
#endif



#ifdef HARDWARE_GROUP_L4_A

#define MCU_L431
Expand Down Expand Up @@ -3090,6 +3215,40 @@

#endif

#ifdef HARDWARE_GROUP_L4_C

#define MCU_L431
#define USE_TIMER_15_CHANNEL_1
#define INPUT_PIN LL_GPIO_PIN_2
#define INPUT_PIN_PORT GPIOA
#define IC_TIMER_CHANNEL LL_TIM_CHANNEL_CH1
#define IC_TIMER_REGISTER TIM15
#define IC_TIMER_POINTER htim15
#define INPUT_DMA_CHANNEL LL_DMA_CHANNEL_5
#define DMA_HANDLE_TYPE_DEF hdma_tim15_ch1
#define IC_DMA_IRQ_NAME DMA1_Channel5_IRQn
#define PHASE_A_GPIO_LOW LL_GPIO_PIN_1
#define PHASE_A_GPIO_PORT_LOW GPIOB
#define PHASE_A_GPIO_HIGH LL_GPIO_PIN_10
#define PHASE_A_GPIO_PORT_HIGH GPIOA
#define PHASE_B_GPIO_LOW LL_GPIO_PIN_0
#define PHASE_B_GPIO_PORT_LOW GPIOB
#define PHASE_B_GPIO_HIGH LL_GPIO_PIN_9
#define PHASE_B_GPIO_PORT_HIGH GPIOA
#define PHASE_C_GPIO_LOW LL_GPIO_PIN_7
#define PHASE_C_GPIO_PORT_LOW GPIOA
#define PHASE_C_GPIO_HIGH LL_GPIO_PIN_8
#define PHASE_C_GPIO_PORT_HIGH GPIOA
#define USE_COMP_1
#define PHASE_A_COMP LL_COMP_INPUT_MINUS_IO3 // pa0
#define PHASE_B_COMP LL_COMP_INPUT_MINUS_IO5 // pa5
#define PHASE_C_COMP LL_COMP_INPUT_MINUS_IO4 // pa4
#define COMMON_COMP LL_COMP_INPUT_PLUS_IO3 //pa1
#define CURRENT_SENSE_ADC_PIN LL_GPIO_PIN_3
#define VOLTAGE_SENSE_ADC_PIN LL_GPIO_PIN_6
#define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_8
#define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_11
#endif


#ifdef HARDWARE_GROUP_L4_N
Expand Down Expand Up @@ -3151,7 +3310,9 @@
#define APPLICATION_ADDRESS 0x08001000
#define MAIN_COMP COMP1
#define EXTI_LINE LL_EXTI_LINE_21
#ifndef TARGET_MIN_BEMF_COUNTS
#define TARGET_MIN_BEMF_COUNTS 2
#endif
#define COMPARATOR_IRQ ADC1_COMP_IRQn
#define USE_ADC
#ifndef CURRENT_ADC_PIN
Expand Down Expand Up @@ -3336,7 +3497,7 @@
#define EXTI_LINE LL_EXTI_LINE_22
#endif
#ifdef USE_COMP_1
#define MAIN_COMP COMP2
#define MAIN_COMP COMP1
#define EXTI_LINE LL_EXTI_LINE_21
#endif
#ifndef TARGET_MIN_BEMF_COUNTS
Expand Down
2 changes: 1 addition & 1 deletion Inc/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
update this file for new releases
*/
#define VERSION_MAJOR 2
#define VERSION_MINOR 16
#define VERSION_MINOR 17
4 changes: 2 additions & 2 deletions Keil_Projects/AM32_MultiProject.uvmpw
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<project>
<PathAndName>.\Am32F051.uvprojx</PathAndName>
<NodeIsActive>1</NodeIsActive>
<NodeIsExpanded>1</NodeIsExpanded>
<NodeIsCheckedInBatchBuild>1</NodeIsCheckedInBatchBuild>
</project>

Expand All @@ -29,8 +31,6 @@

<project>
<PathAndName>.\Am32F421.uvprojx</PathAndName>
<NodeIsActive>1</NodeIsActive>
<NodeIsExpanded>1</NodeIsExpanded>
<NodeIsCheckedInBatchBuild>1</NodeIsCheckedInBatchBuild>
</project>

Expand Down
Loading

0 comments on commit ef2ec01

Please sign in to comment.