예제 #1
0
def generate_wemos_d1_mini():
    """Generate Wemos D1 footprint"""
    subcircuit_label('wemos_d1_mini')
    global U1
    U1 = Part('MCU_Module',
              'WeMOs_D1_mini',
              footprint='Module:WEMOS_D1_mini_light')
    U1['5V'] += Net.fetch('+VBatt')
    U1['GND'] += Net.fetch('GND')
def connect_parts(a, b):
    """Connect pins with same name of two parts"""
    flatten = itertools.chain.from_iterable

    a_pins = list(flatten([pin.name.split("/") for pin in a.get_pins()]))
    b_pins = list(flatten([pin.name.split("/") for pin in b.get_pins()]))
    common_pins = [value for value in a_pins if value in b_pins]

    for pin_name in common_pins:
        a[pin_name] += Net.fetch(pin_name)
        b[pin_name] += Net.fetch(pin_name)
def generate_esp():
    """Generate ESP-module code to circuit"""
    subcircuit_label('esp')
    global U1
    U1 = Part('RF_Module', 'ESP-12E', footprint='RF_Module:ESP-12E')

    U1['VCC'] += Net.fetch('+3V3')
    U1['GND'] += Net.fetch('GND')
    U1['EN'] & R('10k') & Net.fetch('+3V3')
    U1['GPIO15'] & R('4k7') & Net.fetch('GND')

    @subcircuit
    def generate_power_led():
        """Generate led connected to ESP GPI0 that is on after boot"""
        subcircuit_label('power_led')
        led = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
        U1['GPIO0'] & (R('1k') & led & Net.fetch('+3V3'))

    generate_power_led()

    # Generate button for pulling ESP RST pin to low (e.g. reset)

    sw_reset = Part('Switch',
                    'SW_Push',
                    footprint="Button_Switch_SMD:SW_SPST_B3U-1000P")
    sw_reset[1] += Net.fetch('RST')
    sw_reset[2] += Net.fetch('GND')

    # Generate ESP serial networks

    U1['TX'] += Net.fetch('tx')
    U1['RX'] += Net.fetch('rx')
예제 #4
0
def generate_esp():
    """Generate ESP-module code to circuit"""
    global U1
    U1 = Part('RF_Module', 'ESP-12E', footprint='RF_Module:ESP-12E')

    U1['VCC'] += Net.fetch('+VBatt')
    U1['GND'] += Net.fetch('GND')
    U1['EN'] & R('10k') & Net.fetch('+VBatt')
    U1['GPIO15'] & R('4k7') & Net.fetch('GND')

    @subcircuit
    def generate_power_led():
        """Generate led connected to ESP GPI0 that is on after boot"""
        led = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
        U1['GPIO0'] & (R('1k') & led & Net.fetch('+VBatt'))

    generate_power_led()
def generate_esp_uart_reset():
    """Generate reset circuitry for ESP"""
    subcircuit_label('esp_uart_reset')
    Q1 = Part('Device',
              'Q_NPN_BEC',
              value='mmbt2222',
              footprint='Package_TO_SOT_SMD:SOT-23')
    Q2 = Part('Device',
              'Q_NPN_BEC',
              value='mmbt2222',
              footprint='Package_TO_SOT_SMD:SOT-23')
    Net.fetch('DTR') & R('10k') & Q1['B']
    Net.fetch('RTS') & R('10k') & Q2['B']
    Net.fetch('DTR') & Q2['E']
    Net.fetch('RTS') & Q1['E']
    Q1['C'] & Net.fetch('RST')
    Q2['C'] & Net.fetch('GPIO0')
def generate_mcp73831():
    """Generate MCP73831 battery management IC"""
    subcircuit_label('mcp73831')
    BATTERYMANAGER = Part('Battery_Management',
                          'MCP73831-2-OT',
                          footprint='Package_TO_SOT_SMD:SOT-23-5')

    BM_LED = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
    BATTERYMANAGER['STAT'] & R('1k') & BM_LED & Net.fetch('+VBus')

    BATTERYMANAGER['VSS'] += Net.fetch('GND')
    Net.fetch('GND') & R('2k') & BATTERYMANAGER['PROG']
    Net.fetch('+VLipo') & C('10uF') & Net.fetch('GND')
예제 #7
0
def generate_esp():
    """Generate ESP-module code to circuit"""
    global U1
    U1 = Part('RF_Module', 'ESP-12E', footprint='RF_Module:ESP-12E')

    U1['VCC'] += Net.fetch('+VBatt')
    U1['GND'] += Net.fetch('GND')
    U1['EN'] & R('10k') & Net.fetch('+VBatt')
    U1['GPIO15'] & R('4k7') & Net.fetch('GND')

    U1['RST'] += Net.fetch('RST')
    U1['GPIO16'] += Net.fetch('RST')

    @subcircuit
    def generate_power_led():
        """Generate led connected to ESP GPI0 that is on after boot"""
        led = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
        U1['GPIO0'] & (R('1k') & led & Net.fetch('+VBatt'))

    generate_power_led()

    # Generate button for pulling ESP RST pin to low (e.g. reset)

    sw_reset = Part('Switch',
                    'SW_Push',
                    footprint="Button_Switch_SMD:SW_SPST_B3U-1000P")
    sw_reset[1] += Net.fetch('RST')
    sw_reset[2] += Net.fetch('GND')

    # Generate button for pulling pulling ESP GPIO0 low (e.g. flash mode when booting)

    sw_flash = Part('Switch',
                    'SW_Push',
                    footprint="Button_Switch_SMD:SW_SPST_B3U-1000P")
    sw_flash[1] += U1['GPIO0']
    sw_flash[2] += Net.fetch('GND')
예제 #8
0
 def generate_power_led():
     """Generate led connected to ESP GPI0 that is on after boot"""
     led = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
     U1['GPIO0'] & (R('1k') & led & Net.fetch('+VBatt'))
예제 #9
0

def C(value):
    """Creates default capacitor footprint"""
    return Part('Device',
                'C',
                value=value,
                footprint='Capacitor_SMD:C_1206_3216Metric')


U1 = Part('MCU_Microchip_ATmega',
          'ATmega328P-AU',
          footprint='Package_QFP:TQFP-32_7x7mm_P0.8mm')

# Power networks
U1['VCC'] += Net.fetch('+5V')
U1['AVCC'] += Net.fetch('+5V')
U1['GND'] += Net.fetch('GND')
U1['~RESET~/PC6'] & R('10k') & Net.fetch('+5V')

# Crystal
ATMEGA_XTAL = Part('Device',
                   'Resonator',
                   footprint='Resonator_SMD_muRata_CSTxExxV-3Pin_3.0x1.1mm')
U1['XTAL1/PB6'] += ATMEGA_XTAL[1]
U1['XTAL2/PB7'] += ATMEGA_XTAL[3]
ATMEGA_XTAL[2] += Net.fetch('GND')

ATMEGA_XTAL_R = Part('Device',
                     'R',
                     value='1M',
예제 #10
0
    sw_reset[1] += Net.fetch('RST')
    sw_reset[2] += Net.fetch('GND')

    # Generate button for pulling pulling ESP GPIO0 low (e.g. flash mode when booting)

    sw_flash = Part('Switch',
                    'SW_Push',
                    footprint="Button_Switch_SMD:SW_SPST_B3U-1000P")
    sw_flash[1] += U1['GPIO0']
    sw_flash[2] += Net.fetch('GND')

    # Generate ESP serial networks

    U1['TX'] += Net.fetch('tx')
    U1['RX'] += Net.fetch('rx')


generate_esp()

FTDI_HEADER = Part('Connector',
                   'Conn_01x06_Female',
                   footprint='Skimibowi:FTDI_Header')
FTDI_HEADER[1] += Net.fetch('GND')
FTDI_HEADER[2] += Net.fetch('CTS')
FTDI_HEADER[3] += Net.fetch('+VBatt')
FTDI_HEADER[4] += Net.fetch('rx')
FTDI_HEADER[5] += Net.fetch('tx')
FTDI_HEADER[6] += Net.fetch('RTS')

generate_netlist()
def generate_cp2104():
    """Generate CP2104 usb uart circuitry"""
    subcircuit_label('cp2104')
    cp2104 = Part(
        'Interface_USB',
        'CP2104',
        footprint="Package_DFN_QFN:QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm")
    cp2104['VIO'] += Net.fetch('+3V3')
    cp2104['VDD'] += Net.fetch('+3V3')
    cp2104['REGIN'] += Net.fetch('+3V3')

    Net.fetch('GND') & C('10uF') & (cp2104['VIO'] | cp2104['VDD']
                                    | cp2104['REGIN'])

    cp2104['GND'] += Net.fetch('GND')
    cp2104['VBUS'] += Net.fetch('+VBus')
    cp2104['D+'] += Net.fetch('USBD+')
    cp2104['D-'] += Net.fetch('USBD-')
    cp2104['TXD'] & R('470') & Net.fetch('rx')
    cp2104['RXD'] & R('470') & Net.fetch('tx')
    cp2104['DTR'] += Net.fetch('DTR')
    cp2104['RTS'] += Net.fetch('RTS')

    # Support ROM programming
    cp2104['VPP'] & C('4.7uF') & Net.fetch('GND')

    # Optional, improves stability
    cp2104['RST'] & R('4k7') & Net.fetch('+3V3')
                    footprint="Button_Switch_SMD:SW_SPST_B3U-1000P")
    sw_reset[1] += Net.fetch('RST')
    sw_reset[2] += Net.fetch('GND')

    # Generate ESP serial networks

    U1['TX'] += Net.fetch('tx')
    U1['RX'] += Net.fetch('rx')


generate_esp()

BATTERY = Part('Connector',
               'Conn_01x02_Female',
               footprint='JST_PH_S2B-PH-K_1x02_P2.00mm_Horizontal')
BATTERY[1] += Net.fetch('+VBatt')
BATTERY[2] += Net.fetch('GND')


@subcircuit
def generate_mcp73831():
    """Generate MCP73831 battery management IC"""
    subcircuit_label('mcp73831')
    BATTERYMANAGER = Part('Battery_Management',
                          'MCP73831-2-OT',
                          footprint='Package_TO_SOT_SMD:SOT-23-5')

    BM_LED = Part('Device', 'LED', footprint='LED_SMD:LED_1206_3216Metric')
    BATTERYMANAGER['STAT'] & R('1k') & BM_LED & Net.fetch('+VBus')

    BATTERYMANAGER['VSS'] += Net.fetch('GND')
예제 #13
0
    """Generate Wemos D1 footprint"""
    subcircuit_label('wemos_d1_mini')
    global U1
    U1 = Part('MCU_Module',
              'WeMOs_D1_mini',
              footprint='Module:WEMOS_D1_mini_light')
    U1['5V'] += Net.fetch('+VBatt')
    U1['GND'] += Net.fetch('GND')


generate_wemos_d1_mini()

BATTERY = Part('Device',
               'Battery',
               footprint='Battery:BatteryHolder_Keystone_2462_2xAA')
BATTERY['+'] += Net.fetch('+VBatt')
BATTERY['-'] += Net.fetch('GND')

U1['D4'] += Net.fetch('DQ')
Net.fetch('+VBatt') & R('4k7') & Net.fetch('DQ')

U3 = Part('Sensor_Temperature',
          'DS18B20U',
          footprint="Package_SO:MSOP-8_3x3mm_P0.65mm")
U3['VDD'] += Net.fetch('+VBatt')
U3['GND'] += Net.fetch('GND')
U3['DQ'] += Net.fetch('DQ')

Net.fetch('+VBatt') & BATTERY

generate_netlist()