EModel¶
The emodel statement associates an electrical model with a component type. To use this statement in your design, use import jitx/emodels.
This statement is only valid from within a pcb-component definition.
Signature¶
emodel = <EModel>
The emodel statement is optional. If the user does not provide an emodel statement, then no model is associated with this component.
The EModel is a type defined in the jitx package. There are currently 3 JITX-defined EModel types
defined in the jitx/emodels package:
ResistorCapacitorInductor
Currently, these are the only assignable models to pcb-component definitions. We plan to add generic SPICE model statements in the future.
Usage¶
Here is a typical application of the emodel statement:
pcb-component my-resistor:
pin-properties:
[pin:Ref | pads:Int ... ]
[p[1], | 1 ]
[p[2], | 2 ]
emodel = Resistor(
100.0, ; Value - 100 ohm
0.05, ; Precision value between 0 and 1 - (eg 5%)
0.25 ; Power rating in Watts - 0.25 W
)
Each EModel type has different parameters for the different types of components. See below for more details.
EModel Types¶
Below is a listing of currently available models and their parameters.
Resistor¶
defstruct Resistor <: EModel :
resistance: Double
tolerance: Double
max-power: Double
resistance- Resistance value of this resistor in ohmstolerance- Precision of this resistor as a value from 0.0 - 1.0.- Example:
0.05=> 5%0.01=> 1%0.001=> 0.1%
max-power- Max Power Rating of the component in watts.
Signatures:¶
There are multiple forms of the constructor for the Resistor Emodel:
defn Resistor (resistance:Double) -> EModel:
...
defn Resistor (resistance:Double, tolerance:Double) -> EModel:
...
defn Resistor (resistance:Double, tolerance:Double, max-power:Double) -> EModel:
...
Optional values tolerance and max-power are just not set if not provided.
Capacitor¶
defstruct Capacitor <: EModel :
capacitance: Double
tolerance: Double
max-voltage: Double
polarized?: True|False
low-esr?: True|False
temperature-coefficient: String
dielectric: String
capacitance- Capacitance value in Faradstolerance- Precision of this capacitor as a value from 0.0 - 1.0.- Example:
0.2=> 20% max-voltage- Max working voltage in Voltspolarized?- Boolean indicating whether this is a polarized capacitor or not.low-esr?- Boolean flag indicating if the ESR of the capacitor is below a threshold. This is currently not well defined and not recommended for usage.temperature-coefficient- Typically a string value likeX7RorC0Gdielectric- Typically a string value likeCeramic,Tantalum, etc
Signatures for the constructor are similar to the Resistor EModel type.
Inductor¶
defstruct Inductor <: EModel :
inductance: Double
tolerance: Double
max-current: Double
inductance- Resistance value of this resistor in ohmstolerance- Precision of this inductor as a value from 0.0 - 1.0.- Example:
0.15=> 15% max-current- Max current rating of the component in Amps. This is typically not the saturation current.
Signatures for the constructor are similar to the Resistor EModel type.
Introspection¶
The emodel? query command returns the electrical model of an instance or a component definition.
defn emodel? (obj:Instance) -> EModel|False:
...
The function returns false if:
- There is no electrical model
- The argument is not a single component instance.
Example:¶
val r1 = res-strap(power-5v, signal, 10.0e3)
val m = emodel?(r1)
println("Model: %_" % [m])
; Prints:
; Model: Resistor(10000.0, 0.05, 0.063)
You may see a different printout depending on what resistor gets selected in the database query.
Mapping to the >VALUE template¶
The EModel value of a resistor, capacitor, or inductor is used to populate the >VALUE string template in pcb-symbol and pcb-landpattern definitions.
Example:
pcb-symbol symb:
...
draw("foreground") = Text(">VALUE", 1.0, C, loc(10.0, 12.0))
pcb-landpattern lp:
...
layer(Silkscreen("values", Top)) = Text(">VALUE", 1.0, C, loc(1.0, 2.0))
pcb-component my-R:
assign-symbol(symb)
assign-landpattern(lp)
emodel = Resistor(100.0)
In this example, the resistance value is 100.0. In the schematic and the landpattern, the >VALUE string will render as 100R.