Skip to content

Commit

Permalink
Rebase Alka Improve startup low kv motors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKlimaj committed Nov 19, 2024
1 parent 2c03c52 commit b95d4b2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Inc/targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@
#define USE_DRV8328_NFAULT
#define NFAULT_PORT GPIOB
#define NFAULT_PIN LL_GPIO_PIN_5
#define TARGET_MIN_BEMF_COUNTS 4
#endif

#ifdef RHINO80A_F051
Expand Down Expand Up @@ -3331,7 +3332,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
4 changes: 2 additions & 2 deletions Inc/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
update this file for new releases
*/
#define VERSION_MAJOR 2
#define VERSION_MINOR 16
#define VERSION_MINOR 17

#define EEPROM_VERSION 2
#define EEPROM_VERSION 2
6 changes: 3 additions & 3 deletions Mcu/f051/Inc/comparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#define COMPARATOR_H_
#endif /* COMPARATOR_H_ */

#define COMP_PA0 0b1100001
#define COMP_PA4 0b1000001
#define COMP_PA5 0b1010001
#define COMP_PA0 0b1100101
#define COMP_PA4 0b1000101
#define COMP_PA5 0b1010101

#include "main.h"

Expand Down
7 changes: 5 additions & 2 deletions Mcu/g071/Src/peripherals.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void MX_COMP1_Init(void)
COMP_InitStruct.OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
COMP_InitStruct.OutputBlankingSource = LL_COMP_BLANKINGSRC_TIM1_OC5;
LL_COMP_Init(COMP1, &COMP_InitStruct);
LL_COMP_SetPowerMode(COMP1, LL_COMP_POWERMODE_HIGHSPEED);
LL_COMP_SetPowerMode(COMP1, LL_COMP_POWERMODE_MEDIUMSPEED);
LL_COMP_SetCommonWindowMode(__LL_COMP_COMMON_INSTANCE(COMP1),
LL_COMP_WINDOWMODE_DISABLE);
LL_COMP_SetCommonWindowOutput(__LL_COMP_COMMON_INSTANCE(COMP1),
Expand Down Expand Up @@ -202,7 +202,7 @@ void MX_COMP2_Init(void)
COMP_InitStruct.OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
COMP_InitStruct.OutputBlankingSource = LL_COMP_BLANKINGSRC_TIM1_OC5;
LL_COMP_Init(COMP2, &COMP_InitStruct);
LL_COMP_SetPowerMode(COMP2, LL_COMP_POWERMODE_HIGHSPEED);
LL_COMP_SetPowerMode(COMP2, LL_COMP_POWERMODE_MEDIUMSPEED);
LL_COMP_SetCommonWindowMode(__LL_COMP_COMMON_INSTANCE(COMP2),
LL_COMP_WINDOWMODE_DISABLE);
LL_COMP_SetCommonWindowOutput(__LL_COMP_COMMON_INSTANCE(COMP2),
Expand Down Expand Up @@ -822,4 +822,7 @@ void enableCorePeripherals()
NVIC_SetPriority(EXTI4_15_IRQn, 2);
NVIC_EnableIRQ(EXTI4_15_IRQn);
EXTI->IMR1 |= (1 << 15);
#ifdef USE_PULSE_OUT
LL_GPIO_SetPinMode(RPM_PULSE_PORT, RPM_PULSE_PIN, LL_GPIO_MODE_OUTPUT);
#endif
}
16 changes: 11 additions & 5 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,9 @@ void commutate()
}
__enable_irq();
changeCompInput();
if (average_interval > 2500) {
old_routine = 1;
}
// if (average_interval > 2500) {
// old_routine = 1;
// }
bemfcounter = 0;
zcfound = 0;
commutation_intervals[step - 1] = commutation_interval; // just used to calulate average
Expand Down Expand Up @@ -1540,7 +1540,7 @@ void zcfoundroutine()
enableCompInterrupts(); // enable interrupt
}
} else {
if (commutation_interval < 1300) {
if (zero_crosses > 30) {
old_routine = 0;
enableCompInterrupts(); // enable interrupt
}
Expand Down Expand Up @@ -1811,7 +1811,13 @@ int main(void)
input_ready = 0;
}
#endif

if(zero_crosses < 5){
min_bemf_counts_up = TARGET_MIN_BEMF_COUNTS * 2;
min_bemf_counts_down = TARGET_MIN_BEMF_COUNTS * 2;
}else{
min_bemf_counts_up = TARGET_MIN_BEMF_COUNTS;
min_bemf_counts_down = TARGET_MIN_BEMF_COUNTS;
}
RELOAD_WATCHDOG_COUNTER();
e_com_time = ((commutation_intervals[0] + commutation_intervals[1] + commutation_intervals[2] + commutation_intervals[3] + commutation_intervals[4] + commutation_intervals[5]) + 4) >> 1; // COMMUTATION INTERVAL IS 0.5US INCREMENTS
if (eepromBuffer.variable_pwm) {
Expand Down

0 comments on commit b95d4b2

Please sign in to comment.