ByteWelder / Decktility

A handheld PC
Creative Commons Attribution Share Alike 4.0 International
682 stars 28 forks source link

Arduino wiring question and battery config. #6

Open pterodyne opened 3 months ago

pterodyne commented 3 months ago

Hey, great project. Im actually just using the battery monitoring part for my DIY Laptop. My system will use a Radxa Rockchip CM5 unit.

Anyway, Im not using the same BMS as you, but rather a 8A 2S unit with VIN rather than USB-C and a 100W USB C trigger board with a diode to drop the voltage from the hard wired 9V to 8.4. So I do have an LED that lights up when USB C is plugged in.

In reading your block diagram Im assuming that you are jumping off the LED to provide a trigger to the "Is charging" state. Do you see any reason why my difference would be a problem? How did you wire it? Which side of the LED? Or did you remove the LED?

Another question would be, Im using 2X5000Mah Lithium pouch cells, but otherwise they are the same chemistry as 18650, but with a larger capacity. Do I just adjust the discharge curves and capacity? I saw the part for calibration but I assuming I need to adjust all the parameters for the battery.

Oh, one other point of confusion. You mention a BEC at one point and show a picture of a stepdown converter in the BOM. Im using a 6A UBEC meant for a drone, but it can do wide input, and 6A@5V so suitable for my needs. It will cut off the batttery when below the voltage threshold unlike a buck converter. Saves the battery in the event the software doesn't shut it down or the system is crashed.

thanks for looking

Bryan

pterodyne commented 3 months ago

I found where you mention the the pads for the LED on the BMS you chose, so Maybe Ill try to use the LED as a trigger for my setup..

KenVanHoeylandt commented 3 months ago

I did indeed use a specific pad for that (the "D" one at https://www.aliexpress.com/item/1005004682732678.html).

Do I just adjust the discharge curves and capacity? I saw the part for calibration but I assuming I need to adjust all the parameters for the battery.

Yes, you need to adjust all the details for your cells. If the curve is not accurate, the reported battery percentage to the main computer will be inaccurate.

The most important part of the config is Battery.vCritical. You must check the data sheets to find the lowest voltage that is safe for your cells. Don't set this lowest voltage as vCritical: keep a safety margin. If the battery goes below the critical voltage it might damage the cell. Keep in mind that if the computer is off, the microcontroller for the battery management is still running. My electronics design doesn't allow for shutting off that system currently. I might redesign that in the future.

pterodyne commented 2 months ago

thanks for replying. Im working on porting the l294x.dtbo to rockchip, and waiting for the kernel maintainer to turn on the kernel driver for it (Ubuntu rockchip by Joshua Riek). Looks like mostly the overlay has compatibility strings for broadcom, which Ive removed, but cannot test until the kernel is updated. Don't want to deal with custom kernels. Anyway Ive been playing with it on a Pi5, and have a new question.

Ive been trying to understand just the "chargestate" pin. I don't have the same board as you for USB input power, but I figured it's just reading the pin led pin going high from your board. What Im seeing in reality, with no pin connected is it just displaying:

charging: yes charging: no charging: yes charging: no

in the serial console. Generally toggling back and forth unconnected. Sometimes if I apply 5v on that pin it changes to yes or no, but doesn't seem to be any rhyme or reason to it.

I did have to use a different pin because Im using an Ardunio Pro Micro. but it definitely does seem to trigger sometimes. I even tried a different pin from the original one since this arduino is a cheapo and pulled from a box. The battery sensing works great. If it matters I don't really have it installed I just have a bench supply attached to A0 set to a low voltage 2 or 3V and lowering and raising it changes the battery display on the Pi as expected. Also I don't have the power switch/FET hooked up yet if it matters. That pin is unused right now.

Thanks

Bryan

KenVanHoeylandt commented 2 months ago

and waiting for the kernel maintainer to turn on the kernel driver for it (Ubuntu rockchip by Joshua Riek). Looks like mostly the overlay has compatibility strings for broadcom, which Ive removed, but cannot test until the kernel is updated.

Assuming it's just a kernel module, you could compile that module and enable it locally. This was my plan in case Raspberry Pi didn't have any suitable drivers available by default.

Ive been trying to understand just the "chargestate" pin. I don't have the same board as you for USB input power, but I figured it's just reading the pin led pin going high from your board. What Im seeing in reality, with no pin connected is it just displaying:

Regarding the chargestate pin: it's just a high/low input. If you don't connect it then it will "float" and thus you get random alternating high/low values. You can connect it to either ground to get a continuously low signal or to constant voltage for a continuously high signal. What voltage is "high" depends on your board: for some that is 3.3 V and for others it is 5 V. Make sure you don't apply 5 V to an input that only tolerates 3.3 V.

edit: On AliExpress you can find cheap logic analyzers for about 5 USD. They connect with USB to a computer that runs the analysis software. These things are great tools for debugging signal issues.