python-keyboard icon indicating copy to clipboard operation
python-keyboard copied to clipboard

Battery Compatibility

Open mehalter opened this issue 3 years ago • 19 comments

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 avatar Sep 02 '20 14:09 mehalter

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

mehalter avatar Sep 02 '20 14:09 mehalter

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

xiongyihui avatar Sep 03 '20 08:09 xiongyihui

@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 avatar Sep 17 '20 12:09 mehalter

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

mehalter avatar Sep 17 '20 12:09 mehalter

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.

xiongyihui avatar Sep 17 '20 13:09 xiongyihui

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

mehalter avatar Sep 17 '20 13:09 mehalter

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.

xiongyihui avatar Sep 17 '20 13:09 xiongyihui

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

mehalter avatar Sep 17 '20 14:09 mehalter

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

xiongyihui avatar Sep 17 '20 14:09 xiongyihui

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 avatar Sep 17 '20 15:09 mehalter

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 avatar Sep 17 '20 16:09 mehalter

@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 avatar Sep 25 '20 14:09 mehalter

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

xiongyihui avatar Sep 26 '20 05:09 xiongyihui

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.

mehalter avatar Sep 26 '20 17:09 mehalter

To calibrate the battery level, we can change the mapping between battery voltage and battery level at: https://github.com/makerdiary/python-keyboard/blob/017426aeaf0b813888acc54f546bb145bf793a89/keyboard/model/m60.py#L31-L55

xiongyihui avatar Sep 27 '20 02:09 xiongyihui

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 avatar Sep 27 '20 14:09 mehalter

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 avatar Sep 27 '20 14:09 mehalter

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

mehalter avatar Sep 27 '20 14:09 mehalter

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

BrianPugh avatar Jan 01 '21 21:01 BrianPugh