* _line name (T is required)
* / _left_two_nodes (input)
* / / _right_two_nodes (output)
* / / / _characteristic_impedance
* / / / / _time_delay
* / |-| |-| / /
T1 1 0 2 0 Z0=50 TD=10u
Characteristic impedance is always given as pure real resistivity in Ohms. A coaxial cable, for example, has a characteristic impedance of 50 Ohms. This impedance is not to be confused with line resistance! Characteristic impedance is the ratio of the amplitude of a single voltage wave to its current wave.
Vsrc 10 0 DC 0 AC 1 PULSE 0 1 10u 1u 1u 10u
Rsrc 10 1 50
T1 1 0 2 0 Z0=50 TD=10u
Rload 2 0 50
Voltage source generates a pulse: 0 V start voltage, 1.0 V stop voltage, 10 us time delay, 1 us rise-time, 1 us falling time, 10 us pulse width.
Let us run the AC analysis first, and plot both characteristics.
ac lin 100 1 100k
plot abs(v(2)) yl -1 1 title 'Amplitude characteristics'
plot ph(v(2)) title 'Phase characteristics'
Why do we get uniform amplitude characteristics with amplitude of 0.5 V? Another question to think about - what happens with phase? What does the slope mean?
Let us now observe signal in time domain. Let us plot input v(1) and output v(2) signal on the same plot, one above the other. We can do that with a simple nasty trick: if we want v(1) above v(2) on the plot, simply add a positive value (e.g. 2) to the vector v(1):
* Transient analysis
tran 0.1u 60u
plot v(1)+2 v(2) title 'No reflection on the load - source and load matched'
We can see that time delay is exactly 10 us, as stated in transmission line configuration. You might also notice that amplitude on both nodes is half of the voltage, generated at the input. Try to answer why.
You will change parameters of this simple circuit like this:
Try to explain what happens in each of these cases. By the way, you can change a value in some circuit before running new analysis in control block like this:
* _at device rload change parameter:
* / _parameter
* / / _value
* / / /
let @rload[resistance]=1m
Attenuator is an electronic device that reduces the power of a signal without distorting its waveform. They are often used in signal transmission systems to reduce signal bouncing. They are usually passive devices constructed from simple voltage divider networks. On the top right of the cover image of this session you will find a so-called T-attenuator circuit, which translates characteristic impedance Z0 on the input to impedance Z0 on the output. Try to encode this circuit in SPICE. Choose resistor values to match Z0 = 50 Ohms and attenuation factor k = 2.
We will encode a hypothetical transmission line circuit, where three transmission lines and two T-attenuator circuits are used. Imagine now writing a net-list, where the same attenuator circuit has to be defined within the circuit multiple times. It would be something like:
Vin 10 0 dc=0 ac=1 pulse 0 1 10u 1u 1u 10u
Rsrc 10 1 50
T1 1 0 2 0 Z0=50 TD=10u
r1 2 22 16.67
r2 22 3 16.67
r3 22 0 66.67
T2 3 0 4 0 Z0=50 TD=10u
r4 4 44 16.67
r5 44 5 16.67
r6 44 0 66.67
T3 5 0 6 0 Z0=50 TD=10u
Rload 6 0 50
.end
We can see that circuits between the transmission line definitions are repeating. When circuits grow, some complex net-list becomes non-readable and often - useless for a designer. This is why we use so called sub-circuits, where we can join a certain circuit block into a compact object and reuse it wherever we want. We can define a sub-circuit in the following manner:
* _sub-circuit_name
* / _sequence_of_nodes_available_to_outer_world
* / |---|
.subckt attn 1 2 3
r1 1 4 16.67
r2 4 2 16.67
r3 4 3 66.67
.ends
* \_end_of_the_sub-circuit
We can now use a sub-circuit to encode the transmission lines series:
*Source-line-atten-line-atten-line-load
Vin 10 0 dc=0 ac=1 pulse 0 1 10u 1u 1u 10u
Rsrc 10 1 50
T1 1 0 2 0 Z0=50 TD=10u
x1 2 3 0 attn
T2 3 0 4 0 Z0=50 TD=10u
x2 4 5 0 attn
T3 5 0 6 0 Z0=50 TD=10u
Rload 6 0 50
.end
It might feel to you that this is no improvement (the overall net-list is even longer), but you fill find sub-circuits convenient to use, as you use functions and classes instead of similar programming blocks when programming.
You can also use same sub-circuits with different parameters in SPICE. The existing T-attenuator circuit is calculated to translate Z0 = 50 Ohms and k = 2. It is possible to configure a sub-circuit, where values are not pre-defined, but calculated for every sub-circuit instance. We will call such sub-circuits parameterized sub-circuit.
* Parametrized attenuator: factor k, characteristic impedance R
* _sub-circuit_name
* / _sequence_of_nodes_available_to_outer_world
* / / _parameter_name and default_value
* / / / __parameter_name and default_value
* / |---| / /
.subckt attn 1 2 3 param: k=2 R=50
r1 1 4 {R*(k-1)/(k+1)}
r2 4 2 {R*(k-1)/(k+1)}
r3 4 3 {R*2*k/(k^2-1)}
.ends
You can use parametrized sub-circuit in the following way. Note that you can set every sub-circuit instance with different parameters.
*Source-line-atten-line-atten-line-load
Vin 10 0 dc=0 ac=1 pulse 0 1 10u 1u 1u 10u
Rsrc 10 1 50
T1 1 0 2 0 Z0=50 TD=10u
x1 2 3 0 attn k=1.1
T2 3 0 4 0 Z0=50 TD=10u
x2 4 5 0 attn k=1.1
T3 5 0 6 0 Z0=50 TD=10u
Rload 6 0 50
.endn