Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove power limits after initial run phase is done #166

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Bluejay.asm
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,6 @@ run6:
startup_phase_done:
; Clear startup phase flag & remove pwm limits
clr Flag_Startup_Phase
mov Pwm_Limit_By_Rpm, #255
mov Pwm_Limit, #255 ; Reset temperature level pwm limit
mov Temp_Pwm_Level_Setpoint, #255 ; Reset temperature level setpoint

initial_run_phase:
; If it is a direction change - branch
Expand All @@ -949,6 +946,16 @@ initial_run_phase:

initial_run_phase_done:
clr Flag_Initial_Run_Phase ; Clear initial run phase flag

; Lift startup power restrictions
; Temperature protection acts until this point
; as a max startup power limiter.
; This plus the power limits applied in set_pwm_limit function
; act as a startup power limiter to protect the esc and the motor
; during startup, jams produced after crashes and desyncs recovery
mov Pwm_Limit, #255 ; Reset temperature level pwm limit
mov Temp_Pwm_Level_Setpoint, #255 ; Reset temperature level setpoint

setb Flag_Motor_Started ; Set motor started
jmp run1 ; Continue with normal run

Expand Down
8 changes: 6 additions & 2 deletions src/Modules/Power.asm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ set_pwm_limit_low_rpm:
mov Temp1, Pwm_Limit_Beg

; Exit if startup phase is set
jb Flag_Initial_Run_Phase, set_pwm_limit_low_rpm_exit
jb Flag_Startup_Phase, set_pwm_limit_low_rpm_exit

; Set default pwm limit for other phases
mov Temp1, #0FFh ; Default full power
Expand All @@ -79,9 +79,13 @@ set_pwm_limit_calculate:
mul AB
mov Temp1, A ; Set new limit
xch A, B

; If RPM_PWM_LIMIT < 255 goto set_pwm_limit_check_limit_to_min
jz set_pwm_limit_check_limit_to_min ; Limit to max

mov Temp1, #0FFh
; Limit is bigger than 0xFF -> set max pwm and exit
mov Pwm_Limit_By_Rpm, #0FFh
ret

set_pwm_limit_check_limit_to_min:
clr C
Expand Down