import Relay, ElectricPower, Diode, NFET, ElectricLogic

relay = new Relay
relay.coil_max_voltage = 12V
relay.coil_max_current = 50mA
relay.coil_resistance = 240ohm +/- 10%
relay.contact_max_switching_voltage = 250V
relay.contact_max_switching_current = 10A
relay.contact_max_current = 16A

# Connect coil power
power_12v = new ElectricPower
assert power_12v.voltage within 12V +/- 5%
relay.coil_power ~ power_12v

# Control relay with MOSFET and flyback diode
control_mosfet = new NFET
flyback_diode = new Diode
control_signal = new ElectricLogic

# Coil control circuit
power_12v.hv ~ relay.coil_power.hv
relay.coil_power.lv ~> control_mosfet ~> power_12v.lv
control_signal ~ control_mosfet.gate

# Flyback diode for coil protection
relay.coil_power.hv ~ flyback_diode.cathode
flyback_diode.anode ~ relay.coil_power.lv

# Switch high-power load using normally open contact
high_power_load ~ relay.switch_a_no
relay.switch_a_common ~ high_voltage_supply

Parameters

coil_max_current
ampere
coil_max_voltage
volt
coil_resistance
ohm
contact_max_current
ampere
contact_max_switching_current
ampere
contact_max_switching_voltage
volt

Interfaces

coil_power
ElectricPower
switch_a_common
Electrical
switch_a_nc
Electrical
switch_a_no
Electrical
switch_b_common
Electrical
switch_b_nc
Electrical
switch_b_no
Electrical

Global Attributes

These attributes are available to all modules and interfaces in a design.
lcsc_id
str
Assign the LCSC ID of the module.If set, this will tell the picker to select that part from LCSC for this block.
manufacturer
str
This module’s manufacturer name, as a string.Only exact matches on the manufacturer’s name will be found by the picker. It’s recommended to fill this information based on what ato create component provides.
mpn
str
This module’s manufacturer part number, as a string.For the picker to select the correct part from the manufacturer, this must be set.
package
str
The package of the module.This drives which components can be selected, and what footprint is used.Must exactly match a known package name.
exclude_from_bom
bool
override_net_name
str
When set on an interface, this will override the net name of the interface.This is useful for renaming nets which are automatically generated.
required
bool
Only for ModuleInterfaces. If set to True, require that interface is connected to something outside of the module it’s defined in.
import Relay, ElectricPower, Diode, NFET, ElectricLogic

relay = new Relay
relay.coil_max_voltage = 12V
relay.coil_max_current = 50mA
relay.coil_resistance = 240ohm +/- 10%
relay.contact_max_switching_voltage = 250V
relay.contact_max_switching_current = 10A
relay.contact_max_current = 16A

# Connect coil power
power_12v = new ElectricPower
assert power_12v.voltage within 12V +/- 5%
relay.coil_power ~ power_12v

# Control relay with MOSFET and flyback diode
control_mosfet = new NFET
flyback_diode = new Diode
control_signal = new ElectricLogic

# Coil control circuit
power_12v.hv ~ relay.coil_power.hv
relay.coil_power.lv ~> control_mosfet ~> power_12v.lv
control_signal ~ control_mosfet.gate

# Flyback diode for coil protection
relay.coil_power.hv ~ flyback_diode.cathode
flyback_diode.anode ~ relay.coil_power.lv

# Switch high-power load using normally open contact
high_power_load ~ relay.switch_a_no
relay.switch_a_common ~ high_voltage_supply