Skip to content

Commit

Permalink
add equations support to leds, regulators and vdivs
Browse files Browse the repository at this point in the history
  • Loading branch information
napowderly committed Feb 29, 2024
1 parent a620e21 commit 853c029
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
20 changes: 17 additions & 3 deletions leds.ato
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ module LEDIndicator:
resistor = new Resistor
led = new LED
resistor.package = "0402"
current: current
v_in: voltage

# Default value
current = 1mA to 5mA

assert (v_in - led.v_f) / resistor.value within current
assert current < led.i_max

# Connect power
power.vcc ~ input
Expand All @@ -26,24 +34,26 @@ module LEDIndicatorRed from LEDIndicator:
led -> _KT_0603R

#Assuming 3.3v input, 2V forward voltage, 5mA current
resistor.value = 270ohms +/- 20%
# resistor.value = 270ohms +/- 20%

module LEDIndicatorGreen from LEDIndicator:
led -> _KT_0603G

#Assuming 3.3v input, 2.75V forward voltage, 5mA current
resistor.value = 110ohms +/- 20%
# resistor.value = 110ohms +/- 20%

module LEDIndicatorBlue from LEDIndicator:
led -> _KT_0603B

#Assuming 3.3v input, 2.9V forward voltage, 5mA current
resistor.value = 82ohms +/- 20%
# resistor.value = 82ohms +/- 20%

component _KT_0603B from LED:
# component Blue light 0603
footprint = "LED0603-RD"
mpn = "C2288"
v_f = 2.9V
i_max = 20mA
# pins
signal cathode ~ pin 1
signal anode ~ pin 2
Expand All @@ -53,6 +63,8 @@ component _KT_0603G:
footprint = "LED0603-RD"
mpn = "C12624"
designator_prefix = "LED"
v_f = 2.75V
i_max = 20mA
# pins
signal anode ~ pin 2
signal cathode ~ pin 1
Expand All @@ -61,6 +73,8 @@ component _KT_0603R:
# component KT-0603R
footprint = "LED0603-RD"
mpn = "C2286"
v_f = 2V
i_max = 20mA
# pins
signal cathode ~ pin 1
signal anode ~ pin 2
Expand Down
14 changes: 12 additions & 2 deletions regulators.ato
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Power from "interfaces.ato"
import VDiv from "vdivs.ato"
import _VDiv from "vdivs.ato"

module Regulator:
power_in = new Power
Expand All @@ -8,7 +8,17 @@ module Regulator:
power_in.gnd ~ power_out.gnd

module AdjustableRegulator from Regulator:
feedback_div = new VDiv
# using vanilla voltage divider without equations
feedback_div = new _VDiv
v_ref: voltage
i_q: current
r_total: resistance
v_in: voltage
v_out: voltage


assert v_ref * (1 + feedback_div.r_top.value / feedback_div.r_bottom.value) within v_out
assert v_out / (feedback_div.r_top.value + feedback_div.r_bottom.value) within i_q

module Buck from AdjustableRegulator:
# regulator parameters
Expand Down
1 change: 1 addition & 0 deletions resistors.ato
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ component Resistor:
designator_prefix = "R"
mpn = "generic_resistor"
type = "resistor"
value: resistance

# Equations
# R = V/I
Expand Down
16 changes: 15 additions & 1 deletion vdivs.ato
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ import Resistor from "resistors.ato"
import Power from "interfaces.ato"
import Pair from "interfaces.ato"

module VDiv:
module VDiv from _VDiv:
r_total: resistance
# ratio: None
v_in: voltage
v_out: voltage
i_q: current

# assert r_top.value / r_bottom.value within ratio
assert r_top.value + r_bottom.value within r_total
assert v_in * r_bottom.value / (r_top.value + r_bottom.value) within v_out
# assert v_in * r_total within i_q



module _VDiv:
signal top
signal out
signal bottom
Expand Down

0 comments on commit 853c029

Please sign in to comment.