-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Improve battery handling #107
base: main
Are you sure you want to change the base?
Conversation
The values given by the ADC are not very accurate. The introduced errors pose a risk for over-voltage on the battery, which in worst case can lead to an explosion. This commit aims to mitigate the above by doing the following: * Adding correction values in order for the reported values to match the real ones * Adding IIR filter (from Jahnkeanater) to get more smooth readings * Adding hysteresis for when to restart charging, to avoid charge/discharge toggling
From other PRs I gather that ADC accuracy is somewhat a hot topic. When I began to look into this, I had +/- 2V fluctuations on voltage readings (mitigated by a capacitor on 3V3). But also after that, the readings could be up to 1V off. Which matters when it comes to charging batteries, avoiding overvoltage. |
I have not changed the hardware and observe high fluctuations of up to 3 V. This results in random mowing aborts, when the voltage seemd to drop for a very short time below the "battery low level". Therefore I think this PR is definently meaningful. For sure a hardware noise reduction would be better. |
I posted a dump from my scope, measuring the 3V3, in openmower-hardware channel yesterday. 5V was ok. Would be interesting to know if the correction values suite everyone or if they have to be tailored. Keeping in mind that perfection isn't required, but I guess at least a precision like +/- 0.1V would be nice. |
I get about 0.2 volts of noise in the GUI. My biggest issue is the noise tripping the over current protection every single time my mower docks. I constantly have to flash the pico firmware to clear the OCP and get the mower to charge. Once it actually starts charging then it's typically 0.8-1.0 amps. I don't see the point of having 7 digits when we realistically only have about 1 decimal point of usable resolution. I'm curious if adding a capacitor to the ADC would help or if the pico just has really noisy ADCs. |
I think I remember reading that the pico has an internal switching power supply that makes the ADC really noisy. "Driving high the SMPS mode pin (GPIO23), to force the power supply into PWM mode, can greatly reduce the inherent ripple of the SMPS at light load, and therefore the ripple on the ADC supply." GP23 on the pico is pad TP4 on the bottom of the board. Also maybe adding a capacitor to the ADC Vref pin might help. |
I think just setting GPIO23 high in software will put the power supply in PWM mode. #75 Never mind looks like PWM mode is slightly worse. Also it seems like olliewalsh was working on a way for the mower to self calibrate when mowing. That seems better than hard coding a correction factor. |
I think this needs a bit more investigation. |
I haven't modified anything on my 0.13.2 mb (apart from adding a capacitor on 3.3V). Believe the pico is generating the 3.3V. |
Default factors are now 1.0, and offsets are 0. Meaning no correction.
The values given by the ADC are not very accurate. The introduced errors pose a risk for over-voltage on the battery, which in worst case can lead to an explosion.
This commit aims to mitigate the above by doing the following: