-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Bug] Reported current usage is very high #665
Comments
Thanks for reporting. I am able to reproduce the issue. The battery voltage is reading too high as well (this could be a side-effect of the incorrect current reading since the current is used in the voltage calculatoin). |
Reviewing the git history shows there was a major update in the STM32L4 HAL that was included when we updated to a newer version of MicroPython. No Pybricks code changed. So HAL library changes are likely the cause. I hacked in a function to read the ADC registers to see what is different. adc, common = hub.battery.reg()
print('ADC')
print(*("{:02x}: {:02x}".format(i, x) for i, x in enumerate(adc)), sep='\n')
print('ADC_COMMON')
print(*("{:02x}: {:02x}".format(i, x) for i, x in enumerate(common)), sep='\n') Which produces the following diff: --- <v3.1.0>
+++ <v3.2.0b1>
@@ -63,7 +63,7 @@
3d: 00
3e: 00
3f: 00
-40: b1
+40: b3
41: 03
42: 00
43: 00
@@ -98,7 +98,7 @@
60: 00
61: 00
62: 00
-63: 00
+63: c4
64: 00
65: 00
66: 00
@@ -175,7 +175,7 @@
ad: 00
ae: 00
af: 00
-b0: 00
+b0: 0c
b1: 00
b2: 00
b3: 00
@@ -196,7 +196,7 @@
09: 00
0a: 83
0b: 00
-0c: b1
+0c: b3
0d: 03
0e: 00
0f: 00
|
The STM32L4Cube HAL was updated via upstream MicroPython and contains significant changes to the ADC code. Apparently, this code is less forgiving of zero-values for certain parameters. This fixes the issue by ensuring that we initialize all parameters to a valid value. Fixes: pybricks/support#665
The STM32L4Cube HAL was updated via upstream MicroPython and contains significant changes to the ADC code. Apparently, this code is less forgiving of zero-values for certain parameters. This fixes the issue by ensuring that we initialize all parameters to a valid value. Fixes: pybricks/support#665
The fix turned out to be trivial. After the fix:
|
I confirm that the issue was fixed. Thanks! |
Describe the bug
On Technic Hub running pybricks 3.2.0b1(Build #1765):
The battery current as reported by
hub.battery.current()
is too high and it looks like it's a reporting error because at that value the unit should be getting warm. I'm not noticing a faster discharge of the batteries. When connecting motors they run a bit slower like when batteries are not fully charged but nothing like when on almost empty batteries.To reproduce
Connect Technic Hub with nothing attached. Run:
Output:
Expected behavior
current load in the ~80mA (when comparing to a unit with Lego firmware installed)
The text was updated successfully, but these errors were encountered: