100% sure its not the interrupts. The problem is with the way I use the zero cross time to predict when to commutate.
- Reset timer T on commutation
- Look for zero cross time Tcross
- Predict next commutation time and set the compare value for T: Tcommutate = Tcurrent + B* (2 * Tcross - Tcurrent)
Tcurrent is the previous/current Timer T compare value, Tcommutate is the new Timer T compare value, Tcross is the measured zero cross time in counts. B is a scale factor, .25 seems to work.
I'm sure there is a better way to predict the correct commutation time but I have no idea what that is. The app notes are really good about finding the zero cross and explaining the commutation cycle, but they are not so good on the exact algorithm. Most of them just say Tcommutate = 2*Tcross.
This is the motor running. The green and blue are the hall signals. Go figure the hall signals are not aligned with where the motor needs to commutate, guess that explains why it won't run in sensored mode. Guess that's a cheap motor for ya. But every motor should run sensorless :( I would appreciate any hints about how to predict the correct commutation time.
![]()
![]()