Skip to content

Commit 6fe8909

Browse files
authored
Add fuel gauge max17048 (#459)
This pull request introduces a new part definition for the MAX17048 1-cell Li-Ion fuel gauge, along with its integration into the package exports. The main changes are the addition of a new device class with proper electrical modeling, footprint assignment, and typical usage block, as well as updating the package's `__init__.py` to make the part available for import. New part implementation: * Added the `Max17048_Device` class in `FuelGauge_Max17048.py`, modeling the MAX17048 fuel gauge with ports for power, ground, I2C, alert, and QSTRT, including electrical characteristics and footprint assignment. * Created the `Max17048` block in `FuelGauge_Max17048.py`, which wraps the device with a decoupling capacitor, QSTRT grounding, alert pull-up resistor, and default I2C address assignment for typical usage. Package integration: * Updated `__init__.py` to export the new `Max17048` part, making it available for use elsewhere in the codebase.
1 parent 2a556ad commit 6fe8909

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

edg/parts/FuelGauge_Max17048.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from typing_extensions import override
2+
from ..abstract_parts import *
3+
from .JlcPart import JlcPart
4+
5+
6+
class Max17048_Device(InternalSubcircuit, FootprintBlock, JlcPart):
7+
def __init__(self) -> None:
8+
super().__init__()
9+
self.pwr = self.Port(
10+
VoltageSink(
11+
voltage_limits=Range(2.5, 4.5),
12+
current_draw=(0.5, 40) * uAmp, # ~23 uA typ
13+
)
14+
)
15+
self.gnd = self.Port(Ground())
16+
17+
# I2C target interface
18+
# I/O tolerant to 5.5 V independent of pwr (per datasheet)
19+
dio_model = DigitalBidir.from_supply(
20+
self.gnd, self.pwr, voltage_limit_abs=(-0.3, 5.5) * Volt, input_threshold_abs=(0.5, 1.4) * Volt
21+
)
22+
self.i2c = self.Port(I2cTarget(dio_model, addresses=[0x36]))
23+
24+
self.alrt = self.Port(
25+
DigitalSource.low_from_supply(self.gnd),
26+
optional=True,
27+
)
28+
29+
self.qstrt = self.Port(Passive())
30+
31+
@override
32+
def contents(self) -> None:
33+
super().contents()
34+
self.footprint(
35+
"U",
36+
"Package_DFN_QFN:DFN-8-1EP_2x2mm_P0.5mm_EP0.8x1.6mm",
37+
{
38+
"1": self.gnd,
39+
"3": self.pwr,
40+
"4": self.gnd,
41+
"5": self.alrt,
42+
"6": self.qstrt,
43+
"7": self.i2c.scl,
44+
"8": self.i2c.sda,
45+
"9": self.gnd,
46+
},
47+
mfr="Analog Devices (Maxim)",
48+
part="MAX17048",
49+
datasheet="https://www.analog.com/media/en/technical-documentation/data-sheets/MAX17048-MAX17049.pdf",
50+
)
51+
self.assign(self.lcsc_part, "C2682616")
52+
self.assign(self.actual_basic_part, False)
53+
54+
55+
class Max17048(DefaultExportBlock):
56+
"""1-Cell Li-Ion voltage based fuel gauge. Senses its pwr as the battery voltage."""
57+
58+
def __init__(self) -> None:
59+
super().__init__()
60+
self.ic = self.Block(Max17048_Device())
61+
62+
self.pwr = self.Export(self.ic.pwr, [Power])
63+
self.gnd = self.Export(self.ic.gnd, [Common])
64+
self.i2c = self.Export(self.ic.i2c)
65+
self.alrt = self.Export(self.ic.alrt, optional=True)
66+
67+
@override
68+
def contents(self) -> None:
69+
super().contents()
70+
71+
# Required local decoupling 0.1 uF from pwr to GND
72+
self.pwr_cap = self.Block(DecouplingCapacitor(0.1 * uFarad(tol=0.2))).connected(self.gnd, self.ic.pwr)
73+
74+
# Tie QSTRT to ground unless otherwise needed
75+
self.connect(self.ic.qstrt.adapt_to(Ground()), self.gnd)

edg/parts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
from .CanTransceiver_Sn65hvd230 import Sn65hvd230
182182
from .CurrentSense_Ad8418 import Ad8418a
183183
from .Ina219 import Ina219
184+
from .FuelGauge_Max17048 import Max17048
184185
from .BatteryProtector_S8261A import S8261A
185186
from .BatteryCharger_Mcp73831 import Mcp73831
186187
from .Distance_Vl53l0x import Vl53l0x, Vl53l0xConnector, Vl53l0xArray

0 commit comments

Comments
 (0)