How much of the edge reflects?
Compute the reflection coefficient of a line and decide whether it needs termination. An easy embedded C problem (Signal integrity and EMC), run and graded…
easy · Signal integrity and EMC · signal-integrity · termination · calculation
A fast edge travelling down a trace or cable with characteristic impedance Z0 partly reflects where it meets a different impedance ZL (the receiver, or the end of the line). The reflection coefficient is:
Γ = (ZL − Z0) / (ZL + Z0)
Γ is 0 for a matched line, +1 for an open end and −1 for a short. Reflections cause ringing and false edges.
Write reflection_permille(zl, z0): Γ in thousandths, rounded toward zero; an open end is zl = 0xFFFFFFFF (Γ = +1000). And needs_termination(zl, z0): true if |Γ| is more than 100 (10 %).
Starter code
int reflection_permille(uint32_t zl, uint32_t z0) {
return (int)((zl - z0) * 1000u / (zl + z0));
}
bool needs_termination(uint32_t zl, uint32_t z0) {
return reflection_permille(zl, z0) > 100;
}Example tests
Matched and nearly matched
show(50, 50);
show(55, 50);Expected output:
ZL 50, Z0 50: gamma 0/1000, ok
ZL 55, Z0 50: gamma 47/1000, okLearn it first
- Signal integrity and EMC · Rise times, reflections, grounding and passing EMC.