generated from atopile/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
365c818
commit 1f1aa3f
Showing
97 changed files
with
5,997 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,130 @@ | ||
module CellSim: | ||
signal gnd | ||
power_in = new Power | ||
power_batt = new Power | ||
power_5v = new Power | ||
power_3v3 = new Power | ||
dmm_out = new Power | ||
|
||
micro = new ESP32S3 | ||
usbc = new USBCConn | ||
|
||
# Power input | ||
input_filter = new PiFilter | ||
power_connector = new XT30_Male_Right_Angle | ||
current_sensor = new CurrentSensor | ||
current_sensor.current = 10A | ||
power_connector.power ~ input_filter.power_in | ||
input_filter.power_out ~ current_sensor.power_in | ||
current_sensor.power_out ~ power_in | ||
|
||
# Configure current sensor | ||
power_3v3 ~ current_sensor.power | ||
|
||
# Input voltage sense | ||
voltage_sense = new VDiv | ||
power_in ~ voltage_sense.power | ||
voltage_sense.v_out = 0V to 3V | ||
voltage_sense.out ~ micro.io16 | ||
|
||
# DMM output | ||
dmm_connector = new BananaPower | ||
dmm_connector.power ~ dmm_out | ||
|
||
# Micro connections | ||
power_3v3 ~ micro.power | ||
usbc.usb2 ~ micro.usb2 | ||
|
||
# LCD | ||
lcd = new LCDConnector | ||
power_3v3 ~ lcd.power | ||
micro.i2c ~ lcd.i2c | ||
lcd.address = "0x3C" | ||
|
||
# I2C mux | ||
mux = new TCA9548APWR | ||
power_3v3 ~ mux.power | ||
micro.i2c ~ mux.i2c | ||
mux.address = "0x70" | ||
|
||
i2c_pullup = new I2CPullup | ||
power_3v3 ~ i2c_pullup.power | ||
micro.i2c ~ i2c_pullup.i2c | ||
i2c_pullup.r_scl.value = 2kohm +/- 20% | ||
i2c_pullup.r_sda.value = 2kohm +/- 20% | ||
i2c_pullup.r_scl.package = "0402" | ||
i2c_pullup.r_sda.package = "0402" | ||
|
||
# regulator to 5V | ||
buck = new LV2842Kit | ||
buck.v_in = 12V +/- 10% | ||
buck.v_out = 5V +/- 5% | ||
power_in ~ buck.power_in | ||
|
||
# Diode or USB supply to 5V rail | ||
diode_or = new PowerDiodeOr | ||
usbc.power ~ diode_or.power_in1 | ||
buck.power_out ~ diode_or.power_in2 | ||
diode_or.power_out ~ power_5v | ||
|
||
# regulator to 3.3V | ||
ldo3v3 = new LDK220M_R | ||
ldo3v3.v_in = buck.v_out | ||
ldo3v3.v_out = 3.3V +/- 10% | ||
power_5v ~ ldo3v3.power_in | ||
ldo3v3.power_out ~ power_3v3 | ||
|
||
# LEDs | ||
level_shifter = new LevelShifter | ||
power_3v3 ~ level_shifter.power_lv | ||
power_5v ~ level_shifter.power_hv | ||
micro.io15 ~ level_shifter.lv_signal | ||
|
||
# Connect cells in a stack | ||
cell1 = new Cell | ||
mux.i2c1 ~ cell1.i2c | ||
power_in ~ cell1.power_in | ||
power_5v ~ cell1.power_5v | ||
power_3v3 ~ cell1.power_isolator | ||
dmm_out ~ cell1.dmm_out | ||
level_shifter.hv_signal ~ cell1.cell_down.led_data | ||
power_in.gnd ~ cell1.cell_down.cell | ||
|
||
cell2 = new Cell | ||
mux.i2c2 ~ cell2.i2c | ||
power_in ~ cell2.power_in | ||
power_5v ~ cell2.power_5v | ||
power_3v3 ~ cell2.power_isolator | ||
dmm_out ~ cell2.dmm_out | ||
cell1.cell_up ~ cell2.cell_down | ||
|
||
cell3 = new Cell | ||
mux.i2c3 ~ cell3.i2c | ||
power_in ~ cell3.power_in | ||
power_5v ~ cell3.power_5v | ||
power_3v3 ~ cell3.power_isolator | ||
dmm_out ~ cell3.dmm_out | ||
cell2.cell_up ~ cell3.cell_down | ||
|
||
# Connect power_batt across the stack | ||
power_batt.vcc ~ cell3.power_out.vcc | ||
power_batt.gnd ~ cell1.power_out.gnd | ||
|
||
# Debugging | ||
i2c_debug = new SaleaeHeader | ||
micro.i2c ~ i2c_debug.i2c | ||
power_5v.vcc ~ i2c_debug.ch2.io | ||
power_3v3.vcc ~ i2c_debug.ch3.io | ||
i2c_debug.gnd ~ power_in.gnd | ||
|
||
cell3_debug_1 = new SaleaeHeader | ||
cell3._iso_i2c ~ cell3_debug_1.i2c | ||
cell3.buck.power_out.vcc ~ cell3_debug_1.ch2.io | ||
cell3.ldo.power_out.vcc ~ cell3_debug_1.ch3.io | ||
cell3_debug_1.gnd ~ cell3._power_5v.gnd | ||
|
||
cell3_debug_2 = new SaleaeHeader | ||
cell3.current_sense.output ~ cell3_debug_2.ch0.io | ||
cell3.output_relay.input ~ cell3_debug_2.ch1.io | ||
cell3.dmm_relay.input ~ cell3_debug_2.ch2.io | ||
cell3._power_3v3.vcc ~ cell3_debug_2.ch3.io | ||
cell3_debug_2.gnd ~ cell3._power_5v.gnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
# Generics | ||
from "generics/interfaces.ato" import Power, I2C | ||
from "generics/resistors.ato" import SeriesPowerResistors, Resistor | ||
|
||
# Components | ||
from "i2c-devices/iso1640.ato" import ISO1640BDR | ||
from "i2c-devices/mcp4725.ato" import MCP4725A0T | ||
from "i2c-devices/ads1115.ato" import ADS1115IDGSR | ||
from "regulators/digitalBuck.ato" import DigitalBuck | ||
from "regulators/digitalLDO.ato" import DigitalLDO | ||
from "regulators/b1205s.ato" import B1205S_2WR2 | ||
from "current-sensor.ato" import CurrentSensor | ||
from "relay.ato" import Relay | ||
|
||
|
||
module Cell: | ||
""" | ||
Power: | ||
Isolated DCDC converter -> Buck regulator -> LDO -> filter -> Output switch -> current sensor -> Cell output | ||
|
||
Control: | ||
Digital isolator (i2c) -> | ||
- ADC current sense | ||
- ADC voltage sense (buck) | ||
- ADC voltage sense (LDO) | ||
- gpio output (switch) | ||
- DAC (buck) | ||
- DAC (LDO) | ||
|
||
Parts list: | ||
gpio expander: TCA6408ARGTR (0x20/0x21) | ||
DAC: MCP4725A0T-E/CH | ||
ADC: ADS1115IDGSR | ||
Digital isolator: ISO1640BDR | ||
Output relay: HFD4/5-SR | ||
Buck regulator: TPS563201DDCR | ||
LDO: TLV75901PDRVR | ||
Addressable leds: SK6805 | ||
""" | ||
# External interfaces | ||
power_in = new Power | ||
power_out = new Power | ||
power_5v = new Power # micro gnd referenced rail | ||
power_isolator = new Power # power for digital isolators | ||
dmm_out = new Power | ||
i2c = new I2C | ||
cell_up = new CellJumper | ||
cell_down = new CellJumper | ||
signal dmm_relay_enable | ||
|
||
#Output specs | ||
power_out.voltage &= 0V to 5V | ||
power_out.current -= 300mA | ||
|
||
# Internal interfaces | ||
_power_5v = new Power | ||
_power_3v3 = new Power | ||
_iso_i2c = new I2C | ||
|
||
isolated_converter = new B1205S_2WR2 | ||
adc = new ADS1115IDGSR | ||
buck = new DigitalBuck | ||
ldo = new DigitalLDO | ||
current_sense = new CurrentSensor | ||
output_relay = new Relay | ||
dmm_relay = new Relay | ||
gpio = new TCA6408ARGTR | ||
filter = new PiFilter | ||
digital_isolator = new ISO1640BDR | ||
voltage_led = new SK6805EC20 | ||
current_led = new SK6805EC20 | ||
load_switch = new LowSideSwitch | ||
load_resistor = new Resistor | ||
|
||
# addresses: | ||
adc.address = "0x48" | ||
buck.address = "0x61" | ||
ldo.address = "0x60" | ||
gpio.address = "0x20" | ||
current_sense.address = "0x21" | ||
|
||
# Power LEDs | ||
power_5v ~ voltage_led.power | ||
power_5v ~ current_led.power | ||
|
||
# Connect LEDs | ||
cell_down.led_data ~ current_led.din.io | ||
current_led.dout.io ~ voltage_led.din.io | ||
voltage_led.dout.io ~ cell_up.led_data | ||
|
||
# Jumper connections | ||
cell_up.cell ~ filter.power_out.vcc | ||
cell_down.cell ~ filter.power_out.gnd | ||
|
||
# Digital i2c isolator | ||
i2c ~ digital_isolator.i2c_non_isolated | ||
digital_isolator.i2c_isolated ~ _iso_i2c | ||
|
||
# Connect I2C to devices | ||
_iso_i2c ~ adc.i2c | ||
_iso_i2c ~ buck.i2c | ||
_iso_i2c ~ ldo.i2c | ||
_iso_i2c ~ gpio.i2c | ||
|
||
# Internal rails | ||
internal_ldo = new LDK220M_R | ||
_power_5v ~ internal_ldo.power_in | ||
internal_ldo.power_out ~ _power_3v3 | ||
|
||
# Pi Filter | ||
filter.C1.value = 10uF +/- 10% | ||
filter.C1.package = "0805" | ||
filter.L1 -> YNR4030_101M | ||
filter.C2.value = 10uF +/- 10% | ||
filter.C2.package = "0805" | ||
|
||
# Current sense config | ||
current_sense.current = 0.5A | ||
current_sense.shunt.value = 100mohm +/- 10% | ||
|
||
# Power devices | ||
power_isolator ~ digital_isolator.power_non_isolated | ||
_power_3v3 ~ adc.power | ||
_power_3v3 ~ digital_isolator.power_isolated | ||
_power_3v3 ~ buck.power_3v3 | ||
_power_3v3 ~ ldo.power_3v3 | ||
_power_3v3 ~ gpio.power | ||
_power_3v3 ~ current_sense.power | ||
_power_5v ~ output_relay.power_5v | ||
power_5v ~ dmm_relay.power_5v # powered from Micro 5V rail | ||
|
||
#TODO: do the math in ato | ||
# Buck config: vout = 5v when vctrl = 0V, vout = 0V when vctrl = 3.3V | ||
buck.power_out.voltage &= 0V to 5V | ||
buck.feedback_div.r_top.value = 37kohm +/- 2% | ||
buck.feedback_div.r_bottom.value = 10kohm +/- 2% | ||
buck.ctrl_resistor.value = 24kohm +/- 2% | ||
|
||
#TODO: do the math in ato | ||
# LDO config: vout = 5v when vctrl = 0V, vout = 0V when vctrl = 3.3V | ||
ldo.feedback_div.r_top.value = 60kohm +/- 2% | ||
ldo.feedback_div.r_bottom.value = 10kohm +/- 2% | ||
ldo.ctrl_resistor.value = 43kohm +/- 2% | ||
|
||
|
||
# Connect Cell components | ||
power_in ~ isolated_converter.power_in | ||
isolated_converter.power_out ~ _power_5v | ||
_power_5v ~ buck.power_in | ||
buck.power_out ~ ldo.power_in | ||
ldo.power_out ~ filter.power_in | ||
filter.power_out ~ current_sense.power_in | ||
current_sense.power_out ~ output_relay.power_in | ||
output_relay.power_out ~ power_out | ||
|
||
ldo.power_out ~ load_switch.power_in | ||
|
||
# dmm relay | ||
dmm_i_lim_resistors = new SeriesPowerResistors | ||
current_sense.power_out ~ dmm_relay.power_in | ||
dmm_relay.power_out ~ dmm_i_lim_resistors.power_in | ||
dmm_i_lim_resistors.power_out ~ dmm_out | ||
dmm_relay_enable ~ dmm_relay.input | ||
|
||
# ADC connections | ||
adc.AIN0 ~ buck.power_out.vcc | ||
adc.AIN1 ~ ldo.power_out.vcc | ||
adc.AIN2 ~ power_out.vcc | ||
adc.AIN3 ~ current_sense.output | ||
|
||
# GPIO expander | ||
gpio.P2 ~ buck.enable | ||
gpio.P3 ~ ldo.enable | ||
gpio.P4 ~ load_switch.control | ||
|
||
# Custom interface for connecting the cells together | ||
interface CellJumper: | ||
signal cell | ||
signal led_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from "generics/interfaces.ato" import Power | ||
from "generics/resistors.ato" import Resistor | ||
|
||
module CurrentSensor: | ||
sensor = new INA185A2IDRLR | ||
shunt = new Resistor | ||
power = new Power | ||
power_in = new Power | ||
power_out = new Power | ||
signal output ~ sensor.out | ||
current: current | ||
|
||
power_in.current += power_out.current | ||
power_in.voltage &= power_out.voltage - power_in.current * shunt.value | ||
|
||
# Shunt config | ||
assert shunt.value * current * sensor.gain within 1.2V to 3V | ||
shunt.package = "0805" | ||
|
||
# Shunt connections | ||
power_in.vcc ~ shunt.p1; shunt.p2 ~ power_out.vcc | ||
power_in.gnd ~ power_out.gnd | ||
|
||
# Sensor connections | ||
sensor.input.p ~ shunt.p1 | ||
sensor.input.n ~ shunt.p2 | ||
|
||
sensor.ref ~ power_in.gnd | ||
|
||
# Power connections | ||
power ~ sensor.power | ||
|
||
component INA185A2IDRLR: | ||
# component NTZD3154NT1G | ||
footprint = "SOT-563_L1.6-W1.2-P0.50-LS1.6-TL" | ||
lcsc_id = "C2059320" | ||
mpn = "C2059320" | ||
gain = 50 | ||
|
||
power = new Power | ||
power.vcc ~ pin 6 | ||
power.gnd ~ pin 2 | ||
|
||
signal out ~ pin 1 | ||
signal ref ~ pin 5 | ||
|
||
input = new DiffPair | ||
input.p ~ pin 3 | ||
input.n ~ pin 4 |
Oops, something went wrong.