From 103edb5a08571cd4b7ccf0be5427eb3065666533 Mon Sep 17 00:00:00 2001 From: Simon Kirby Date: Sat, 12 Sep 2015 22:43:15 -0700 Subject: [PATCH] Fast-path timing calculations and raise maximum speed to 312,500eRPM. Previous maximum was about 178,571eRPM. Divide by "pole pairs" to find actual RPM; for example, for a 12N14P motor, divide by (14 / 2) or 7. The trade-off is slightly more code because of the two paths: one for the usual full 24-bit calculations, and one for 16-bit calculations when they are sufficient as a result of the shorter timing period. Note that TIMING_MIN isn't even enforced since 48fe82e8 -- Oops. --- tgy.asm | 104 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 25 deletions(-) diff --git a/tgy.asm b/tgy.asm index 3caf042..790cac5 100644 --- a/tgy.asm +++ b/tgy.asm @@ -254,7 +254,7 @@ .equ TIMING_RANGE1 = 0x4000 ; 4096us per commutation .equ TIMING_RANGE2 = 0x2000 ; 2048us per commutation .equ TIMING_RANGE3 = 0x1000 ; 1024us per commutation -.equ TIMING_MAX = 0x00e0 ; 56us per commutation +.equ TIMING_MAX = 0x0080 ; 32us per commutation (312,500eRPM) .equ TIMEOUT_START = 48000 ; Timeout per commutation for ZC during starting .if !defined(START_DELAY_US) @@ -323,6 +323,7 @@ .equ B_FET = 1 ; if set, B FET is being PWMed .equ C_FET = 2 ; if set, C FET is being PWMed .equ ALL_FETS = (1<