bldc icon indicating copy to clipboard operation
bldc copied to clipboard

SAFETY RISK: lisp app-disable-output causes ADC app to be locked to a certain speed

Open 1zun4 opened this issue 2 years ago • 2 comments

So, I experienced the following and I still have to confirm this correctly, but from what I could tell it seems app-disable-output will block the ADC code and cause the motor to continue running at the last throttle value.

https://github.com/vedderb/bldc/blob/4e0288d37f203b58acacd735df81ce397319102f/applications/app_adc.c#L319C1-L323C4

If the ADC app is disabled it will not run any set-current, set-rpm etc functions and therefore it stays at this value (and I am not sure if there is any timeout applied, I do not think so...)

It also does not help to override the values to zero first, like this:

(if (or (= off 1) (= lock 1))
            (if (not (app-is-output-disabled)) ; Disable output when scooter is turned off
                {
                    (app-adc-override 0 0)
                    (app-adc-override 1 0)
                    (app-disable-output -1)
                }
                
            )
            (if (app-is-output-disabled) ; Enable output when scooter is turned on
                (app-disable-output 0)
            )
)

What I have not tried yet is setting the current-rel to 0 myself, before disabling the app.

1zun4 avatar Sep 20 '23 09:09 1zun4

(app-disable-output) will stop the app from sending further motor commands, but if the motor is already running it will keep running. You can use set-current 0 afterwards to stop the motor if you do not want it to keep running. Maybe it is better to update app-disable-output so that the motor is released after using it.

vedderb avatar Sep 23 '23 15:09 vedderb

Yes that would make sense. I also think that below the app_is_output_disabled, it does the same with timeout_has_timeout, so it might keep running there as well?

https://github.com/vedderb/bldc/blob/4e0288d37f203b58acacd735df81ce397319102f/applications/app_adc.c#L319C1-L327C4

1zun4 avatar Sep 23 '23 15:09 1zun4