vedderb / bldc

The VESC motor control firmware
2.25k stars 1.38k forks source link

Reverse button not read with ADC2 regen braking with ADC and UART - solution suggested #765

Open Rich235 opened 2 months ago

Rich235 commented 2 months ago

Vn 6.06 and lower, in bldc/applications/app_adc.c, line 304, I believe the following config is missing:

config.ctrl_type == ADC_CTRL_TYPE_CURRENT_REV_BUTTON_BRAKE_ADC ||

and so the reverse button input is never used for this configuration as rev_button = !palReadPad(HW_ICU_GPIO, HW_ICU_PIN); never gets executed. Pls see here: https://vesc-project.com/node/1499#comment-12470 where I've built on dk-odense's previous observation on this.

This mean there is no ability to reverse when using ADC and UART (ADC1 throttle, ADC2 brake, servo pin reverse button) in this mode.

I've made this change locally and uploaded the firmware and confirmed it now works. This mode is necessary for using VESC in a car with forward, reverse and fully variable regenerative braking on the brake pedal and using UART to display information on a dash screen.

I'm sorry I don't know how to competently make a pull request for this tiny update. I've attached the updated file where the additional setting is added to line 305 for reference.

Hopefully this update can be made. Also, I've not checked what other modes are missing from the reverse button setting here.

Thank you for fantastic VESC code and tools, it truly is an amazing creation.

Regards, Richard. app_adc.zip