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

Battery Compatibility #4

Open
mehalter opened this issue Sep 2, 2020 · 19 comments
Open

Battery Compatibility #4

mehalter opened this issue Sep 2, 2020 · 19 comments

Comments

@mehalter
Copy link
Contributor

mehalter commented Sep 2, 2020

How is power handled on the m60 board to provide integration with the nRF52840 module? I am excited to get my prototype board and am trying to figure out what sort of battery is appropriate and if I need to use some form of buck/boost circuit or if that sort of logic is being built into the m60 circuit when providing the JST connection.

@mehalter
Copy link
Contributor Author

mehalter commented Sep 2, 2020

For more information, I was currently looking at batteries similar to this one: 3.7V 2400mAh Polymer Li-po battery

@xiongyihui
Copy link
Contributor

The battery with 3p JST 1.25mm connector in the link is likely compatible with M60. M60 has a built-in battery charger. It requires the battery has a NTC pin.

image

@mehalter
Copy link
Contributor Author

@xiongyihui I finally got the battery in and I am getting some weird behavior. If I plug the battery in without the USB plugged in, I don't get any power to the board at all even when I plug in the USB cable. If I have the USB cable in and the keyboard on, and then plug in the battery I can get it to stay on, but I don't have any indication that the battery is charging. Do you think this is an issue with the batteries compatibility? Is there any way I could go about debugging this issues? It is the battery linked above with the 3p JST 1.25mm connector. Thanks again for your help!

@mehalter
Copy link
Contributor Author

Also when I have the keyboard on and then plug in the battery, printing self.battery.level shows it at 0. Which makes me think the battery is just fully discharged and needs to be charged, but I don't have any indication if the battery is being read at all

@xiongyihui
Copy link
Contributor

When we plug the battery in without the USB plugged in, the keyboard is on power off mode. We can press the ON/OFF button at the back of keyboard to power on it.

@mehalter
Copy link
Contributor Author

I tried that, when I have the battery plugged in and plug in the USB-C cable, the ON/OFF button does not do anything

@xiongyihui
Copy link
Contributor

When USB is connected, quickly pressing the ON/OFF will reset the keyboard, long press (more than 3 seconds) will trigger the bootloader of the keyboard.

To read battery level, we should use battery_level() instead, as self.battery.level may not be updated in time.

@mehalter
Copy link
Contributor Author

Hm, whenever I have the battery plugged in, I am getting no power at all. Pressing the ON/OFF or holding it doesn't do anything. I get not drive showing up on my computer or anything. The second I unplug the battery, the board begins to be powered like normal

@xiongyihui
Copy link
Contributor

Be careful! Make sure the positive and negative terminals of a battery are correct. You can find + and - beside the JST connector.

@mehalter
Copy link
Contributor Author

Ah that was the issue, the JST connector was wired up backwards to the board! Now thatthis is working correctly, what is the proper way to mount the keyboard over USB with the battery connected? When I have the battery in, the board doesn't show up when I plug it into my computer

@mehalter
Copy link
Contributor Author

nevermind, I believe this issue had something to do with the cable. I tried another one and it is working as intended! Thanks for helping me out!

@mehalter
Copy link
Contributor Author

@xiongyihui I realized that the issue I was experiencing here was not just the cable I was using, it seems like the keyboard doesn't get recognized as a USB device when I have the battery plugged in and I use a USB-C to USB-C cable to plug into my computer's USB-C port. It works fine when I use a USB-C to USB-A and then plug it into a normal USB port. Is there any reason that this would be happening? I checked with several cables on several operating systems with the same result.

@mehalter mehalter reopened this Sep 25, 2020
@xiongyihui
Copy link
Contributor

Does the USB-C port support charging the computer? It may be an issue of USB-C power manager.

@mehalter
Copy link
Contributor Author

Ah the USB-C port does support charging, that may be the issue. Also is there a way to calibrate the battery level indication? I have my keyboard plugged in the entire time and the battery level never goes above 6 or 7 when I add some print statements to the __init__.py file. It is a 2400mAh LiPo battery and want to be able to accurately check how charged it is.

@xiongyihui
Copy link
Contributor

To calibrate the battery level, we can change the mapping between battery voltage and battery level at:

BATTERY_LIMIT = 3100 # Cutoff voltage [mV].
BATTERY_FULLLIMIT = 4190 # Full charge definition [mV].
BATTERY_DELTA = 10 # mV between each element in the SoC vector.
BATTERY_VOLTAGE = (
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 13, 13, 14, 15, 16,
18, 19, 22, 25, 28, 32, 36, 40, 44, 47, 51, 53, 56, 58, 60, 62, 64, 66, 67, 69,
71, 72, 74, 76, 77, 79, 81, 82, 84, 85, 85, 86, 86, 86, 87, 88, 88, 89, 90, 91,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 100
)
battery_in = analogio.AnalogIn(microcontroller.pin.P0_02)
def battery_level():
# (3300 * 2 * battery.value) >> 16
voltage = (3300 * battery_in.value) >> 15
i = (voltage - BATTERY_LIMIT) // BATTERY_DELTA
if i >= len(BATTERY_VOLTAGE):
i = len(BATTERY_VOLTAGE) - 1
elif i < 0:
i = 0
return BATTERY_VOLTAGE[i]

@mehalter
Copy link
Contributor Author

Cool, that's what I was looking at. Is there a good way to calculate the battery limit? It looks like with a full battery charge my BATTERY_FULLLIMIT = 3520 and I want to make sure that I get a good idea of what the limit should be. Although it looks like it is measuring voltage out, so should the battery limit stay the same because there is a minimum operating voltage of 3.1V?

@mehalter
Copy link
Contributor Author

Also how was the BATTERY_VOLTAGE array found, it doesn't seem evenly distributed and i want to make sure i have a good array there for an accurate reading

@mehalter
Copy link
Contributor Author

For now I have just set the BATTERY_FULLLIMIT = 3520 and BATTERY_DELTA = 10 to get it close to the same number of steps as what is currently in the code, 105 steps vs 109, but I don't think that is the correct way to set it up

@BrianPugh
Copy link

For future revisions of the boards, it would be nice to have an additional 10k resistor plus a solder-bridge to bypass the NTC thermistor for batteries that don't have this. I just soldered a resistor to the test points so I could use a 2-wire lipo:

IMG_5725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants