Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/atopile/generics
Browse files Browse the repository at this point in the history
  • Loading branch information
napowderly committed Feb 29, 2024
2 parents 853c029 + 92c1373 commit 2dd7f58
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 51 deletions.
28 changes: 24 additions & 4 deletions buttons.ato
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Power from "generics/interfaces.ato"
import Resistor from "generics/resistors.ato"
import Pair from "generics/interfaces.ato"

from "interfaces.ato" import Pair, Power
from "resistors.ato" import Resistor

module NoButton:
"""
Expand Down Expand Up @@ -49,12 +47,16 @@ component _ButtonSKTDLDE010:
mpn = "C115365"

module ButtonSKTDLDE010 from NoButton:
"""
Small SMD right angle button
"""
btn = new _ButtonSKTDLDE010
in ~ btn.in
out ~ btn.out

module ButtonPullup:
btn = new NoButton
signal out
output = new Pair
power = new Power
pullup = new Resistor
Expand All @@ -69,5 +71,23 @@ module ButtonPullup:
power.vcc ~ pullup.p1; pullup.p2 ~ btn.in; btn.out ~ power.gnd
out ~ btn.in

output.io ~ out
output.gnd ~ power.gnd

module ButtonPulldown:
btn = new NoButton
signal out
output = new Pair
power = new Power
pulldown = new Resistor
pulldown.value = 10kohms +/- 20%
pulldown.package = "0402"

power.gnd ~ pulldown.p1; pulldown.p2 ~ btn.in; btn.out ~ power.vcc
out ~ btn.in

output.io ~ out
output.gnd ~ power.gnd

module ButtonPullup90Degree from ButtonPullup:
btn -> _1TS003B_1400_3500A
74 changes: 64 additions & 10 deletions connectors.ato
Original file line number Diff line number Diff line change
@@ -1,17 +1,71 @@
import WJ15EDGRC_3_81_2P from "elec/src/WJ15EDGRC_3_81_2P.ato"
component Connector2Pin:
signal p1
signal p2

component Connector3Pin:
signal p1
signal p2
signal p3

component Header2Pin:
component Connector4Pin:
signal p1
signal p2
signal p3
signal p4

component PluggableHeader2Pin from _WJ15EDGRC_3_81_2P:
component Connector5Pin:
signal p1
signal p2
signal p3
signal p4
signal p5

component _WJ15EDGRC_3_81_2P:
# component WJ15EDGRC-3.81-2P
footprint = "CONN-TH_2P-P3.81_WJ15EDGRC-3.81-2P"
lcsc_id = "C8387"
# pins
signal p1 ~ pin 1
signal p2 ~ pin 2
component Connector6Pin:
signal p1
signal p2
signal p3
signal p4
signal p5
signal p6

component Connector7Pin:
signal p1
signal p2
signal p3
signal p4
signal p5
signal p6
signal p7

component Connector8Pin:
signal p1
signal p2
signal p3
signal p4
signal p5
signal p6
signal p7
signal p8

component Connector9Pin:
signal p1
signal p2
signal p3
signal p4
signal p5
signal p6
signal p7
signal p8
signal p9

component Connector10Pin:
signal p1
signal p2
signal p3
signal p4
signal p5
signal p6
signal p7
signal p8
signal p9
signal p10
7 changes: 6 additions & 1 deletion diodes.ato
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ component RectifierDiode from Diode:

import Power from "interfaces.ato"
module PowerDiodeOr:
"""
A diode or gate that combines two power rails, only dropping the
"""
diode = new ShottkyDiode
power_in = new Power
power_in1 = new Power
power_in2 = new Power
power_out = new Power

power_in2 ~ power_out
power_in.vcc ~ diode.anode; diode.cathode ~ power_out.vcc
power_in.gnd ~ power_out.gnd

Expand Down
29 changes: 26 additions & 3 deletions filters.ato
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import Power from "interfaces.ato"
import Capacitor from "capacitors.ato"
import CapacitorElectrolytic from "capacitors.ato"
import Inductor from "inductors.ato"
from "interfaces.ato" import Power, Pair
from "capacitors.ato" import Capacitor, CapacitorElectrolytic
from "inductors.ato" import Inductor
from "resistors.ato" import Resistor


module LowPassFilter:
# Interfaces
input = new Pair
output = new Pair

# Components
capacitor = new Capacitor
resistor = new Resistor

# Default values
capacitor.package = "0402"
resistor.package = "0402"

# Connections
input.io ~ resistor.1
output.io ~ resistor.2
output.io ~ capacitor.1
output.gnd ~ capacitor.2
input.gnd ~ output.gnd


module LowPassPiFilter:
C1 = new CapacitorElectrolytic
Expand Down
12 changes: 11 additions & 1 deletion interfaces.ato
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ interface STEPPER_MOTOR:
signal b1
signal b2

interface DcMotor:
signal a
signal b

interface GPIO:
signal io
signal gnd
Expand Down Expand Up @@ -133,4 +137,10 @@ interface Pair:

interface Analog:
signal io
signal gnd
signal gnd

interface I2S:
signal ws
signal sck
signal sd
signal gnd
38 changes: 34 additions & 4 deletions mosfets.ato
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Power from "generics/interfaces.ato"
import Load from "generics/interfaces.ato"
import Resistor from "generics/interfaces.ato"
import Diode from "generics/diodes.ato"
import Power from "interfaces.ato"
import Pair from "interfaces.ato"
import DiffPair from "interfaces.ato"
import Load from "interfaces.ato"
import Resistor from "interfaces.ato"
import Diode from "diodes.ato"

component NFET:
signal gate
Expand All @@ -21,6 +23,34 @@ component PFET:
type = "mosfet"
polarity = "P Channel"

module HalfBridge:
power = new Power
gate_high = new Pair
gate_low = new Pair
shunt_output = new DiffPair
output = new Pair

# this doesnt work until we have replace with instance.
# # Components
# nfet_high = new NFET
# nfet_low = new NFET
# shunt = new Resistor

# # Connect power
# power.vcc ~ nfet_high.drain
# output ~ nfe_high.source
# output ~ nfet_low.drain
# power.gnd ~ shunt.2; shunt.1 ~ nfet_high.source

# # Connect the gates
# gate_high.io ~ nfet_high.gate
# gate_low.io ~ nfet_low.gate

# # Connect the gnds
# output.gnd ~ power.gnd
# gate_high.gnd ~ power.gnd
# gate_low.gnd ~ power.gnd

module LowSideSwitch:
fet = new Mosfet_nchannel
gate_resistor = new Resistor
Expand Down
51 changes: 26 additions & 25 deletions opamps.ato
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component Opamp:
power = new Power
signal inverting_input
signal noninverting_input
signal inverting
signal non_inverting
signal output
designator_prefix = "U"

Expand All @@ -15,11 +15,12 @@ module VoltageFollower:
signal input
signal output

input ~ opamp.noninverting_input
opamp.inverting_input ~ opamp.output
input ~ opamp.non_inverting
opamp.inverting ~ opamp.output
output ~ opamp.output

import vdiv from "StandardCircuits.ato"
# import vdiv from "StandardCircuits.ato"

module Amplifier:
power = new Power
opamp = new Opamp
Expand All @@ -28,19 +29,19 @@ module Amplifier:
power ~ opamp.power

# TODO: add equation for gain
gain = unknown\
gain = unknown
vdiv.r_top.value = unknown
vdiv.r_bottom.value = unknown

signal input
signal output

input ~ vdiv.input
vdiv.output ~ opamp.inverting_input
vdiv.output ~ opamp.inverting
output ~ opamp.output
output ~ vdiv.gnd

inverting_input ~ power.gnd
inverting ~ power.gnd

# Inverting Amplifier: Amplifies and inverts the input signal.
# The gain is determined by the resistor values.
Expand All @@ -53,9 +54,9 @@ module InvertingAmplifier:
signal input
signal output

input ~ opamp.inverting_input
input ~ opamp.inverting
output ~ opamp.output
opamp.noninverting_input ~ power.gnd
opamp.non_inverting ~ power.gnd


module SummingAmplifier:
Expand All @@ -68,10 +69,10 @@ module SummingAmplifier:
signal input2
signal output

input1 ~ opamp.inverting_input
input2 ~ opamp.inverting_input
input1 ~ opamp.inverting
input2 ~ opamp.inverting
output ~ opamp.output
opamp.noninverting_input ~ power.gnd
opamp.non_inverting ~ power.gnd

module DifferentialAmplifier:
power = new Power
Expand All @@ -83,8 +84,8 @@ module DifferentialAmplifier:
signal input_negative
signal output

input_positive ~ opamp.noninverting_input
input_negative ~ opamp.inverting_input
input_positive ~ opamp.non_inverting
input_negative ~ opamp.inverting
output ~ opamp.output

module Integrator:
Expand All @@ -96,9 +97,9 @@ module Integrator:
signal input
signal output

input ~ opamp.inverting_input
input ~ opamp.inverting
output ~ opamp.output
# Note: Needs a capacitor between inverting_input and output for integration
# Note: Needs a capacitor between inverting and output for integration

module Differentiator:
power = new Power
Expand All @@ -109,7 +110,7 @@ module Differentiator:
signal input
signal output

input ~ opamp.inverting_input
input ~ opamp.inverting
output ~ opamp.output
# Note: Needs a capacitor at the input for differentiation

Expand All @@ -123,8 +124,8 @@ module Comparator:
signal input_negative
signal output

input_positive ~ opamp.noninverting_input
input_negative ~ opamp.inverting_input
input_positive ~ opamp.non_inverting
input_negative ~ opamp.inverting
output ~ opamp.output

module InstrumentationAmplifier:
Expand All @@ -141,10 +142,10 @@ module InstrumentationAmplifier:
signal input_negative
signal output

input_positive ~ opamp1.noninverting_input
input_negative ~ opamp2.inverting_input
opamp1.output ~ opamp3.inverting_input
opamp2.output ~ opamp3.noninverting_input
input_positive ~ opamp1.non_inverting
input_negative ~ opamp2.inverting
opamp1.output ~ opamp3.inverting
opamp2.output ~ opamp3.non_inverting
output ~ opamp3.output

module ActiveFilter:
Expand All @@ -156,6 +157,6 @@ module ActiveFilter:
signal input
signal output

input ~ opamp.inverting_input
input ~ opamp.inverting
output ~ opamp.output
# Note: Specific filter components (capacitors, resistors) needed around opamp
Loading

0 comments on commit 2dd7f58

Please sign in to comment.