Skip to content

Commit

Permalink
Add option to not use polling mode at low rpm
Browse files Browse the repository at this point in the history
  • Loading branch information
AlkaMotors committed Dec 6, 2024
1 parent 9e76bd9 commit 13bd311
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,11 @@ void commutate()
}
__enable_irq();
changeCompInput();
// if (average_interval > 2500) {
// old_routine = 1;
// }
#ifndef NO_POLLING_START
if (average_interval > 2500) {
old_routine = 1;
}
#endif
bemfcounter = 0;
zcfound = 0;
commutation_intervals[step - 1] = commutation_interval; // just used to calulate average
Expand Down Expand Up @@ -1499,17 +1501,24 @@ void zcfoundroutine()
bad_count = 0;

zero_crosses++;
#ifdef NO_POLLING_START // changes to interrupt mode after 30 zero crosses, does not re-enter
if (zero_crosses > 30) {
old_routine = 0;
enableCompInterrupts(); // enable interrupt
}
#else
if (eepromBuffer.stall_protection || eepromBuffer.rc_car_reverse) {
if (zero_crosses >= 20 && commutation_interval <= 2000) {
old_routine = 0;
enableCompInterrupts(); // enable interrupt
}
} else {
if (zero_crosses > 30) {
if (commutation_interval < 2000) {
old_routine = 0;
enableCompInterrupts(); // enable interrupt
}
}
#endif
}
#ifdef BRUSHED_MODE
void runBrushedLoop()
Expand Down

0 comments on commit 13bd311

Please sign in to comment.