mathiasvr / bluejay

:bird: Digital ESC firmware for controlling brushless motors in multirotors
GNU General Public License v3.0
478 stars 48 forks source link

*confusion of demag process #63

Open garlinplus opened 1 year ago

garlinplus commented 1 year ago

Describe the issue

When one commutation is finished,the timer2 counter is set with Wt_ZC_Tout_Start, in order to know whether zero cross check is timeout. But when a new zero cross point checking start,Flag_Demag_Detected is set. And if there is a wrong comparator output, in the function comp_read_wrong_extend_timeout,the timeout check counter timer2 is reset as followed:

comp_read_wrong:
    jb    Flag_Startup_Phase, comp_read_wrong_startup
    jb    Flag_Demag_Detected, comp_read_wrong_extend_timeout

    inc    Temp3                    ; Increment number of OK readings required
    clr    C
    mov    A, Temp3
    subb    A, Temp4
    jc    comp_check_timeout            ; If below initial requirement - take another reading
    sjmp    comp_start                ; Otherwise - go back and restart

comp_read_wrong_startup:
    inc    Temp3                    ; Increment number of OK readings required
    clr    C
    mov    A, Temp3
    subb    A, Temp4                    ; If above initial requirement - do not increment further
    jc    ($+3)
    dec    Temp3

    sjmp    comp_check_timeout            ; Continue to look for good ones

comp_read_wrong_extend_timeout:
    clr    Flag_Demag_Detected            ; Clear demag detected flag
    anl    EIE1, #7Fh                ; Disable Timer3 interrupts
    mov    TMR3CN0, #00h                ; Timer3 disabled and interrupt flag cleared
    jnb    Flag_High_Rpm, comp_read_wrong_low_rpm    ; Branch if not high rpm

    mov    TMR3L, #0                    ; Set timeout to ~1ms
    mov    TMR3H, #-(8 SHL MCU_48MHZ)

As above description, if a wrong comparator out is got when Flag_Demag_Detected is set,the timeout check time must be reset.So whether the timeout check time of Wt_ZC_Tout_Start is not need,it's can be directly set as the value of what comp_read_wrong_extend_timeout set.

Bluejay version

0.16

ESC variant

ah5

PWM frequency

24

DShot bitrate

150

Bidirectional DShot

Off

FC firmware

4.2.9

Motor size

0802

Configurator debug log

no