Skip to content
Core Engineering

Electronics Engineering interview questions and answers

80 questions, 18 with code. About 3 h 24 min to read them all.

By TestLab · Updated

Plan for an interview
80 questions

Track what you know and what to revise.

Sign in to track progress

You can open a few full answers without signing in. Sign in to read all

1

What is a semiconductor?

A semiconductor is a material whose electrical conductivity lies between that of a conductor (such as copper) and an insulator (such as glass), and can be controlled by temperature, light, electric fields and adding impurities (doping). Silicon and germanium are the classic examples, and almost all modern electronics is built on silicon.

Read full answer

Applies toElectronics engineering (semiconductor physics)

Working Principle: Energy Bands

  • Electrons in a solid occupy energy bands. The valence band holds bound electrons; the conduction band holds free electrons that carry current.

  • The gap between them is the band gap (Eg).

  • Conductors: bands overlap, so many free electrons exist.

  • Insulators: large band gap (above about 5 eV), so almost no electrons cross it.

  • Semiconductors: small band gap, so some electrons gain enough thermal energy to jump into the conduction band, leaving holes behind in the valence band. Both electrons and holes carry current.

Material Band gap at 300 K Typical use
Germanium (Ge) 0.66 eV Early transistors, IR detectors
Silicon (Si) 1.12 eV ICs, diodes, transistors, solar cells
Gallium arsenide (GaAs) 1.42 eV RF, LEDs, lasers
Silicon carbide (SiC) about 3.3 eV High-voltage power devices
Gallium nitride (GaN) 3.4 eV Fast chargers, RF power, blue LEDs

Key Formula

Intrinsic carrier concentration rises steeply with temperature:

n_i ∝ T^(3/2) · e^(−Eg / 2kT)

where k = 8.617 × 10⁻⁵ eV/K. For silicon at 300 K, n_i ≈ 1.0 × 10¹⁰ cm⁻³ (about 1.0 × 10¹⁶ m⁻³).

Conductivity: σ = q(n·μn + p·μp), in siemens per metre (S/m), where q = 1.602 × 10⁻¹⁹ C and μ is mobility.

Worked Example

Pure silicon at 300 K: n = p = 1.0 × 10¹⁶ m⁻³, μn = 0.135 m²/V·s, μp = 0.048 m²/V·s.

σ = 1.602 × 10⁻¹⁹ × 1.0 × 10¹⁶ × (0.135 + 0.048) ≈ 2.9 × 10⁻⁴ S/m, so resistivity ≈ 3,400 Ω·m. Copper’s resistivity is about 1.7 × 10⁻⁸ Ω·m, so pure silicon is a very poor conductor until it is doped.

Temperature Behaviour

Unlike metals, a semiconductor’s resistance falls as temperature rises (negative temperature coefficient), because more electron-hole pairs are generated. This is the basis of NTC thermistors.

Industry Applications

Diodes, transistors, integrated circuits, LEDs, solar cells, image sensors and power devices (MOSFETs, IGBTs, SiC and GaN switches) all depend on controlling conduction in semiconductors.

2

What is the difference between intrinsic and extrinsic semiconductors?

An intrinsic semiconductor is a pure semiconductor crystal, such as pure silicon, where the number of free electrons equals the number of holes. An extrinsic semiconductor is one that has been deliberately doped with impurity atoms to increase one type of carrier, making it N-type (extra electrons) or P-type (extra holes) and far more conductive.

Read full answer

Applies toElectronics engineering (semiconductor physics)

Intrinsic Semiconductor

  • Carriers are created only by thermal energy breaking covalent bonds.

  • n = p = n_i (intrinsic carrier concentration).

  • For silicon at 300 K, n_i ≈ 1.0 × 10¹⁶ m⁻³, so conductivity is very low.

  • Conductivity depends strongly on temperature.

Extrinsic Semiconductor

  • N-type: doped with pentavalent atoms (phosphorus, arsenic, antimony) called donors; electrons are majority carriers.

  • P-type: doped with trivalent atoms (boron, aluminium, gallium) called acceptors; holes are majority carriers.

  • Doping levels are tiny (often 1 impurity atom per 10⁶ to 10⁸ silicon atoms) yet raise conductivity by many orders of magnitude.

Key Formula: Mass-Action Law

n · p = n_i² (valid in thermal equilibrium, for both intrinsic and extrinsic material)

For N-type with donor concentration N_D ≫ n_i: n ≈ N_D and p ≈ n_i² / N_D.

Worked Example

Silicon doped with phosphorus at N_D = 1.0 × 10²² m⁻³ (10¹⁶ cm⁻³), n_i = 1.0 × 10¹⁶ m⁻³.

  • n ≈ 1.0 × 10²² m⁻³

  • p = (1.0 × 10¹⁶)² / 1.0 × 10²² = 1.0 × 10¹⁰ m⁻³

  • σ ≈ q · n · μn = 1.602 × 10⁻¹⁹ × 1.0 × 10²² × 0.135 ≈ 216 S/m

Compared with intrinsic silicon (about 2.9 × 10⁻⁴ S/m), conductivity rises by roughly 750,000 times.

Comparison

Aspect Intrinsic Extrinsic
Purity Pure crystal Doped with impurities
Carriers n = p n ≫ p (N-type) or p ≫ n (P-type)
Conductivity Very low Much higher, set by doping
Temperature dependence Strong Weak over the normal operating range
Fermi level Near the middle of the band gap Near the conduction band (N) or valence band (P)
Practical use Reference material, very rarely used directly All diodes, transistors and ICs

Industry Application

Controlled doping (by ion implantation or diffusion) defines every region of a transistor: source, drain, wells and channels. At very high temperatures, extrinsic silicon behaves intrinsically again, which is one reason silicon devices have a maximum junction temperature of around 150–175 °C.

3

What are N-type and P-type semiconductors?

An N-type semiconductor is made by doping a pure semiconductor with pentavalent (donor) atoms, giving it extra free electrons as majority carriers. A P-type semiconductor is made by doping with trivalent (acceptor) atoms, creating extra holes as majority carriers. Joining the two forms a PN junction, the basis of diodes and transistors.

Read full answer

Applies toElectronics engineering (semiconductor devices)

N-Type

  • Dopants: phosphorus (P), arsenic (As), antimony (Sb), each with 5 valence electrons.

  • Four electrons bond with neighbouring silicon atoms; the fifth is loosely bound and becomes free at room temperature.

  • The dopant atom becomes a fixed positive ion after donating its electron.

  • Majority carriers: electrons. Minority carriers: holes.

  • The Fermi level moves closer to the conduction band.

P-Type

  • Dopants: boron (B), aluminium (Al), gallium (Ga), indium (In), each with 3 valence electrons.

  • One bond is incomplete, creating a hole that can accept an electron from a neighbouring atom.

  • The dopant becomes a fixed negative ion after accepting an electron.

  • Majority carriers: holes. Minority carriers: electrons.

  • The Fermi level moves closer to the valence band.

Key Point: Both Are Electrically Neutral

Doping adds no net charge. In N-type material, the extra free electrons are balanced by positive donor ions; in P-type, holes are balanced by negative acceptor ions.

Formulas

  • N-type: n ≈ N_D, p = n_i² / N_D

  • P-type: p ≈ N_A, n = n_i² / N_A

  • Conductivity: σ = q(n·μn + p·μp)

Worked Example

P-type silicon with N_A = 1.0 × 10²³ m⁻³, μp = 0.048 m²/V·s:

σ ≈ q · N_A · μp = 1.602 × 10⁻¹⁹ × 1.0 × 10²³ × 0.048 ≈ 769 S/m, resistivity ≈ 1.3 × 10⁻³ Ω·m.

Note: for the same doping level, N-type silicon conducts about 2.8 times better, because electron mobility (0.135 m²/V·s) is higher than hole mobility (0.048 m²/V·s). This is why NMOS transistors are faster than PMOS transistors of the same size.

Comparison

Property N-type P-type
Dopant group Group V (donor) Group III (acceptor)
Majority carrier Electrons Holes
Fixed ions Positive Negative
Mobility of majority carrier Higher Lower

Industry Applications

PN junctions in diodes, NPN/PNP bipolar transistors, NMOS and PMOS transistors in CMOS logic, and solar cells (an N-type layer on a P-type wafer).

4

What is a PN junction diode, and how does it work?

A PN junction diode is a two-terminal semiconductor device formed by joining P-type and N-type material, which lets current flow easily in one direction (forward bias, anode to cathode) and blocks it in the other (reverse bias). This one-way behaviour makes it the basic device for rectification, protection and signal detection.

Read full answer

Applies toElectronics engineering (semiconductor devices)

How the Junction Forms

  1. When P and N regions are joined, electrons diffuse from N to P and holes from P to N.

  2. They recombine near the junction, leaving fixed ions: negative on the P side, positive on the N side.

  3. This depletion region has an electric field that opposes further diffusion.

  4. Equilibrium creates a built-in potential (barrier potential): about 0.7 V for silicon, 0.3 V for germanium.

Operation

  • Forward bias (anode positive): the external voltage reduces the barrier; once it exceeds about 0.6–0.7 V, current rises rapidly.

  • Reverse bias (anode negative): the barrier widens; only a tiny reverse saturation current (nanoamps for silicon) flows until breakdown.

Diode Equation (Shockley)

I = I_S · (e^(V / (n·V_T)) − 1)

  • I_S = reverse saturation current (A)

  • V_T = kT/q ≈ 25.85 mV at 300 K

  • n = ideality factor (1 to 2)

Worked Example

A silicon diode has I_S = 1.0 × 10⁻¹⁴ A and n = 1. Find the current at V = 0.65 V.

I = 10⁻¹⁴ × (e^(0.65 / 0.02585) − 1) = 10⁻¹⁴ × e^25.15 ≈ 10⁻¹⁴ × 8.3 × 10¹⁰ ≈ 0.83 mA.

At 0.71 V the current is about 8.3 mA: each extra 60 mV raises current tenfold, which is why the forward voltage looks almost constant near 0.7 V.

Key Specifications

Parameter Meaning Example (1N4007)
V_F Forward voltage About 1.0 V at 1 A
I_F(avg) Average forward current 1 A
V_RRM Peak repetitive reverse voltage 1000 V
t_rr Reverse recovery time Microseconds (standard recovery)

Practical Models

  • Ideal: short circuit forward, open reverse.

  • Constant-drop: 0.7 V drop when conducting (used in most hand calculations).

  • Piecewise linear: 0.7 V plus a small series resistance.

Industry Applications

Rectifiers in power supplies, freewheeling (flyback) diodes across relay coils and motors, reverse-polarity protection, clamping and clipping circuits, and signal demodulation. Schottky diodes (metal-semiconductor) offer a lower 0.2–0.4 V drop and fast switching for SMPS.

5

What are forward bias and reverse bias in a diode?

Forward bias connects the positive terminal of a supply to the P side (anode) and the negative to the N side (cathode), lowering the junction barrier so a large current flows. Reverse bias connects the supply the other way, raising the barrier so almost no current flows until the breakdown voltage is reached.

Read full answer

Applies toElectronics engineering (semiconductor devices)

Forward Bias

  • The applied voltage opposes the built-in potential, narrowing the depletion region.

  • Majority carriers cross the junction; current rises exponentially once V exceeds the cut-in (knee) voltage: about 0.6–0.7 V for silicon, 0.2–0.3 V for germanium, 0.2–0.4 V for Schottky diodes.

  • The diode behaves like a small resistance in series with an almost fixed voltage drop.

Reverse Bias

  • The applied voltage adds to the built-in potential, widening the depletion region.

  • Only minority carriers flow, giving a tiny reverse saturation current I_S (nanoamps for silicon), which roughly doubles for every 10 °C rise.

  • At the breakdown voltage, current increases sharply (Zener or avalanche breakdown). Ordinary diodes can be destroyed if power is not limited.

  • The widened depletion region acts as a capacitor whose value falls as reverse voltage rises; varactor diodes use this for tuning.

Comparison

Aspect Forward bias Reverse bias
Connection P to +, N to − P to −, N to +
Depletion region Narrows Widens
Barrier Lowered Raised
Current Large (mA to A), majority carriers Very small (nA to µA), minority carriers
Resistance Low Very high

Worked Example

A 5 V supply drives a red LED (V_F = 2.0 V) through a resistor for 10 mA in forward bias.

R = (V_S − V_F) / I = (5 − 2.0) / 0.010 = 300 Ω (use the standard 330 Ω, giving about 9.1 mA).

Power in the resistor: P = I²R = (0.0091)² × 330 ≈ 27 mW, so a 0.125 W resistor is fine.

If the LED is inserted backwards, it is reverse biased: no current flows and it stays off. Most LEDs tolerate only about 5 V in reverse, so a higher reverse voltage needs a protective diode.

Industry Applications

  • Forward bias: rectifiers, LEDs, signal diodes, clamps.

  • Reverse bias: Zener regulators, photodiodes (reverse-biased for fast response), varactors in VCOs, and ESD/TVS protection diodes that stay off until a surge arrives.

6

What is the depletion region in a PN junction?

The depletion region is the thin zone around a PN junction that has been emptied (depleted) of free electrons and holes, leaving only fixed charged ions: negative acceptor ions on the P side and positive donor ions on the N side. These ions create an electric field and a built-in potential that block further carrier diffusion.

Read full answer

Applies toElectronics engineering (semiconductor physics)

How It Forms

  1. Electrons diffuse from the N side into the P side; holes diffuse from P to N.

  2. They recombine near the junction, so the region loses its mobile carriers.

  3. The fixed ions left behind set up an electric field pointing from N to P.

  4. Equilibrium is reached when the drift caused by this field balances diffusion.

Built-In Potential

V_bi = V_T · ln(N_A · N_D / n_i²)

where V_T = kT/q ≈ 25.85 mV at 300 K.

Width of the Depletion Region

W = √[(2ε_s / q) · (V_bi − V) · (1/N_A + 1/N_D)]

  • ε_s = permittivity of silicon ≈ 11.7 × 8.854 × 10⁻¹² F/m ≈ 1.04 × 10⁻¹⁰ F/m

  • V = applied voltage (positive for forward bias, negative for reverse bias)

The region extends further into the more lightly doped side.

Worked Example

Silicon junction with N_A = 1.0 × 10²³ m⁻³, N_D = 1.0 × 10²² m⁻³, n_i = 1.0 × 10¹⁶ m⁻³, at zero bias.

  • V_bi = 0.02585 × ln(10⁴⁵ / 10³²) = 0.02585 × ln(10¹³) = 0.02585 × 29.93 ≈ 0.77 V

  • 1/N_A + 1/N_D = 1.1 × 10⁻²² m³

  • W = √[(2 × 1.04 × 10⁻¹⁰ / 1.602 × 10⁻¹⁹) × 0.77 × 1.1 × 10⁻²²] ≈ √(1.10 × 10⁻¹³) ≈ 0.33 µm

With 10 V reverse bias, (V_bi − V) becomes 10.77 V and W grows to about 1.24 µm.

Effect of Bias

Condition Depletion width Barrier
Forward bias Narrower Lower
Zero bias Equilibrium width V_bi
Reverse bias Wider V_bi + V_R

Junction Capacitance

The depletion region acts like a parallel-plate capacitor: C_j = ε_s · A / W. Higher reverse bias widens W and lowers capacitance. Varactor diodes use this to tune oscillators and filters electronically.

Industry Applications

  • Photodiodes and solar cells: light creates electron-hole pairs in the depletion region, and its field sweeps them out as current.

  • MOSFET channel and junction isolation in ICs.

  • High-voltage power diodes use lightly doped, wide drift regions to support large reverse voltages.

7

What is a Zener diode, and how is it used as a voltage regulator?

A Zener diode is a heavily doped silicon diode designed to operate safely in reverse breakdown, where its voltage stays almost constant (the Zener voltage, V_Z) over a wide range of current. Connected in reverse bias with a series resistor, it acts as a simple shunt voltage regulator that holds the load voltage at V_Z despite changes in input voltage or load current.

Read full answer

Applies toElectronics engineering (analog circuits, power supplies)

How It Works

  • In forward bias it behaves like a normal diode (about 0.7 V).

  • In reverse bias, once the voltage reaches V_Z, it conducts sharply and the voltage across it changes very little as current changes.

  • Available voltages: about 2.4 V to 200 V (for example 3.3 V, 5.1 V, 12 V).

  • Key ratings: V_Z, test current I_ZT, minimum current I_Z(min) (knee), maximum power P_Z, and dynamic resistance r_z.

Regulator Circuit

Input (V_in) → series resistor R_S → node with the Zener (cathode to the node, anode to ground) in parallel with the load R_L.

  • R_S drops the extra voltage: V_in − V_Z.

  • The Zener absorbs whatever current the load does not take, keeping V_out ≈ V_Z.

Design Formulas

  • Series resistor: R_S = (V_in(min) − V_Z) / (I_L(max) + I_Z(min))

  • Maximum Zener current (no load, highest input): I_Z(max) = (V_in(max) − V_Z) / R_S

  • Zener power: P_Z = V_Z · I_Z(max), which must be below the rating

Worked Example

Answer first: R_S ≈ 113 Ω (use 110 Ω), and a 1 W Zener is needed.

Requirements: 5.1 V output, load up to 40 mA, input 10 V to 12 V, I_Z(min) = 5 mA.

  1. R_S = (10 − 5.1) / (0.040 + 0.005) = 4.9 / 0.045 ≈ 109 Ω → choose 110 Ω standard.

  2. Worst-case Zener current (12 V input, load disconnected): I_Z = (12 − 5.1) / 110 ≈ 62.7 mA.

  3. Zener power: 5.1 × 0.0627 ≈ 0.32 W. Choose a 1 W Zener (for example the 1N4733A) for margin.

  4. Resistor power: (12 − 5.1)² / 110 ≈ 0.43 W → use a 1 W resistor.

Limitations

  • Low efficiency: power is wasted in R_S and the Zener.

  • Output varies slightly with current due to r_z (a few ohms) and with temperature.

  • Suitable only for low currents (tens of milliamps).

  • For better regulation, use a Zener as a reference for a transistor or op-amp regulator, or a linear regulator IC (7805, LM317) or a precision reference such as the TL431.

Industry Applications

Reference voltages, overvoltage clamps on inputs, gate protection for MOSFETs (for example a 15 V Zener between gate and source), and simple bias supplies.

8

What is the difference between Zener breakdown and avalanche breakdown?

Zener breakdown occurs in heavily doped junctions with a very thin depletion region, where a strong electric field pulls electrons directly out of covalent bonds by quantum tunnelling, typically below about 5 V. Avalanche breakdown occurs in lightly doped junctions with a wide depletion region, where carriers gain enough energy to knock out more carriers by impact ionisation, creating a chain reaction, typically above about 6 V.

Read full answer

Applies toElectronics engineering (semiconductor devices)

Zener Breakdown

  • Requires heavy doping on both sides, so the depletion region is very thin (around 10 nm or less).

  • Electric field reaches about 3 × 10⁷ V/m or more, strong enough for electrons to tunnel from the P-side valence band to the N-side conduction band.

  • Breakdown is gradual (soft knee).

  • Negative temperature coefficient: V_Z falls as temperature rises, because the band gap shrinks and tunnelling becomes easier.

Avalanche Breakdown

  • Occurs with lighter doping and a wide depletion region.

  • Minority carriers accelerate across the region, gaining enough kinetic energy to ionise silicon atoms in collisions.

  • Each collision frees an electron-hole pair, which also accelerates, producing multiplication (an “avalanche”).

  • Breakdown is sharp.

  • Positive temperature coefficient: breakdown voltage rises with temperature, because increased lattice vibration shortens the distance carriers travel between collisions, so they gain less energy.

Comparison

Aspect Zener breakdown Avalanche breakdown
Mechanism Quantum tunnelling (field emission) Impact ionisation and multiplication
Doping Heavy Light to moderate
Depletion width Very thin Wide
Typical voltage Below about 5 V Above about 6 V
Temperature coefficient Negative Positive
Knee Soft Sharp

The 5–6 V Region

Between roughly 5 V and 6 V both mechanisms act together, and their temperature coefficients partly cancel. That is why diodes rated around 5.6 V to 6.2 V have the lowest temperature drift and are popular as voltage references.

Worked Example

A 4.7 V Zener has a temperature coefficient of about −2 mV/°C. Over a 50 °C rise its voltage changes by −2 × 50 = −100 mV, to about 4.6 V. A 12 V diode (avalanche) with +8 mV/°C would rise by 400 mV to about 12.4 V over the same change.

Industry Applications

  • “Zener diodes” in catalogues include both types; the name is used for any breakdown diode.

  • Avalanche-rated rectifiers and TVS diodes absorb energy from voltage spikes.

  • Avalanche photodiodes (APDs) use controlled avalanche multiplication for sensitive light detection in fibre optics and lidar.

9

What is an LED, and how does it work?

An LED (light-emitting diode) is a PN junction diode that emits light when forward biased: electrons from the N side recombine with holes from the P side, releasing energy as photons. The colour depends on the semiconductor’s band gap, and LEDs are far more efficient and longer-lasting than incandescent lamps.

Read full answer

Applies toElectronics engineering (optoelectronics)

Working Principle

  • In forward bias, electrons and holes are injected into the junction region.

  • When an electron drops from the conduction band to the valence band, it releases energy equal to the band gap as a photon (radiative recombination).

  • This only works efficiently in direct band gap materials such as GaAs, GaN and InGaN. Silicon has an indirect band gap, so it emits very little light.

Colour and Band Gap

Photon wavelength: λ = h·c / E_g, or λ (nm) ≈ 1240 / E_g (eV)

Colour Material Wavelength Typical V_F
Infrared GaAs 850–940 nm 1.2–1.5 V
Red AlGaInP 620–630 nm 1.8–2.2 V
Green InGaN 520–530 nm 2.8–3.3 V
Blue InGaN 450–470 nm 2.8–3.3 V
White Blue InGaN + yellow phosphor Broad 2.8–3.3 V

Worked Example 1: Wavelength

A red LED material has E_g = 1.97 eV. λ ≈ 1240 / 1.97 ≈ 630 nm (red).

Worked Example 2: Series Resistor

Answer: about 100 Ω. A white LED (V_F = 3.0 V, 20 mA) runs from a 5 V supply.

R = (5 − 3.0) / 0.020 = 100 Ω. Resistor power = 0.02² × 100 = 40 mW.

Driving LEDs

  • LEDs must be current-limited, because current rises exponentially with voltage; a resistor works for indicators.

  • High-power LEDs use constant-current drivers (buck or boost converters) to keep brightness stable and avoid thermal runaway.

  • Brightness is controlled by PWM dimming (fast on/off switching), which keeps colour consistent.

Key Characteristics

  • Efficacy: modern white LEDs exceed 150 lm/W, versus about 15 lm/W for incandescent lamps.

  • Lifetime: tens of thousands of hours (often specified as L70, the time to fall to 70% of initial output).

  • Heat: light output and lifetime fall as junction temperature rises, so heat sinking is essential for power LEDs.

  • Low reverse voltage rating: typically only about 5 V.

Industry Applications

Indicators, displays and backlights, lighting, automotive lamps, IR remote controls and optocouplers, optical communication (Li-Fi and fibre links), and UV LEDs for curing and sterilisation.

10

What is a photodiode?

A photodiode is a PN (or PIN) junction diode that converts light into electrical current. Photons absorbed in or near the depletion region create electron-hole pairs, which the junction’s electric field sweeps apart to produce a photocurrent proportional to light intensity. It is usually operated in reverse bias for fast, linear response.

Read full answer

Applies toElectronics engineering (optoelectronics and sensors)

Working Principle

  1. A photon with energy greater than the band gap (E = h·f ≥ E_g) is absorbed.

  2. It creates an electron-hole pair.

  3. The depletion-region field pushes electrons to the N side and holes to the P side.

  4. This flow appears as a reverse current, the photocurrent I_ph, which adds to the small dark current.

Modes of Operation

Mode Bias Characteristics Use
Photovoltaic Zero bias Low noise, no dark current, slower Precision light meters, solar cells
Photoconductive Reverse bias Faster (lower capacitance), more linear, some dark current Optical communication, fast detection

Key Formula: Responsivity

I_ph = R · P_opt

  • R = responsivity (A/W), P_opt = optical power (W).

  • R = η · q · λ / (h · c) ≈ η · λ(nm) / 1240, where η is quantum efficiency.

Worked Example

Answer: about 0.44 µA and 0.44 V. A silicon photodiode at 850 nm with η = 0.80 receives 0.8 µW, and a transimpedance amplifier with R_f = 1 MΩ converts the current to a voltage.

  • R = 0.80 × 850 / 1240 ≈ 0.55 A/W

  • I_ph = 0.55 × 0.8 × 10⁻⁶ ≈ 0.44 µA

  • V_out = I_ph × R_f = 0.44 × 10⁻⁶ × 10⁶ ≈ 0.44 V

Types

  • PN photodiode: simple, general purpose.

  • PIN photodiode: an intrinsic layer widens the depletion region, giving lower capacitance and faster response; common in fibre optics.

  • Avalanche photodiode (APD): internal gain through avalanche multiplication for very weak signals.

  • Material: silicon (about 400–1100 nm), InGaAs (900–1700 nm, used for 1310/1550 nm fibre links), germanium.

Important Parameters

  • Dark current (noise floor), junction capacitance (sets speed), rise time, active area, and noise-equivalent power (NEP).

Industry Applications

Optical fibre receivers, barcode scanners, smoke detectors, pulse oximeters and heart-rate sensors, ambient light sensors in phones, lidar, optocouplers and IR remote receivers.

11

What is a rectifier, and what is a bridge rectifier?

A rectifier is a circuit that converts alternating current (AC) into direct current (DC) using diodes that conduct in only one direction. A bridge rectifier uses four diodes arranged in a bridge to perform full-wave rectification without needing a centre-tapped transformer, so both halves of the AC cycle reach the load in the same direction.

Read full answer

Applies toElectronics engineering (power supplies)

Types of Rectifiers

Type Diodes Output Ripple frequency (50 Hz mains) Efficiency (max)
Half-wave 1 One half-cycle only 50 Hz 40.6%
Full-wave centre-tap 2 Both half-cycles 100 Hz 81.2%
Bridge (full-wave) 4 Both half-cycles 100 Hz 81.2%

How a Bridge Rectifier Works

  • Positive half-cycle: diodes D1 and D2 conduct; current flows through the load from top to bottom.

  • Negative half-cycle: diodes D3 and D4 conduct; current still flows through the load from top to bottom.

  • Two diodes conduct at any time, so the output peak is reduced by two diode drops.

Key Formulas (Bridge, Resistive Load)

  • V_peak(out) = V_peak(in) − 2V_D (V_D ≈ 0.7 V for silicon)

  • V_DC = 2 · V_peak(out) / π ≈ 0.637 · V_peak(out)

  • V_rms(out) = V_peak(out) / √2

  • Peak inverse voltage (PIV) per diode ≈ V_peak(in)

  • Ripple factor (no filter) = 0.48 (half-wave: 1.21)

Worked Example

Answer: about 9.9 V DC. A 12 V rms transformer secondary feeds a bridge rectifier with a resistive load.

  1. V_peak(in) = 12 × √2 ≈ 16.97 V

  2. V_peak(out) = 16.97 − 2 × 0.7 = 15.57 V

  3. V_DC = 0.637 × 15.57 ≈ 9.9 V (closer to 9.5 V at high current, where each diode drops nearer 1 V).

  4. PIV per diode ≈ 17 V, so a 1N4007 (1000 V, 1 A) has ample margin.

With a large filter capacitor, the output rises close to the peak, about 15.5 V, minus ripple.

Bridge vs Centre-Tap

Aspect Bridge Centre-tap
Transformer Simple secondary Centre-tapped, twice the winding
Diodes 4 2
Diode drops in path 2 (about 1.4 V) 1 (about 0.7 V)
PIV per diode V_m 2V_m
Transformer utilisation Better Poorer

Industry Applications

Every mains-powered device has a rectifier: phone chargers and SMPS (bridge followed by a bulk capacitor), battery chargers, welding equipment and motor drives. Bridge rectifiers are sold as single four-pin packages (for example the KBP or GBU series). For low-voltage, high-current outputs, Schottky diodes or synchronous rectification with MOSFETs reduce losses.

12

What is ripple, and how does a filter capacitor reduce it?

Ripple is the AC variation left on the DC output of a rectifier or power supply. A filter capacitor placed across the load charges to the peak voltage when the diodes conduct and supplies current to the load between peaks, so the output drops only slightly before the next recharge, greatly reducing ripple.

Read full answer

Applies toElectronics engineering (power supplies)

How the Capacitor Filter Works

  1. As the rectified voltage rises, the capacitor charges almost to the peak value.

  2. When the input voltage falls below the capacitor voltage, the diodes turn off.

  3. The capacitor discharges through the load, so the voltage falls slowly (roughly linearly).

  4. The next rectified peak recharges it. The result is a sawtooth-like ripple on top of DC.

Key Formulas

  • Peak-to-peak ripple: V_r(pp) ≈ I_L / (f_r · C)

  • f_r = ripple frequency: f for half-wave (50 Hz), 2f for full-wave (100 Hz)

  • DC output: V_DC ≈ V_peak − V_r(pp) / 2

  • Ripple factor: r = V_r(rms) / V_DC, with V_r(rms) ≈ V_r(pp) / (2√3)

Larger C, higher ripple frequency or smaller load current all reduce ripple.

Worked Example

Answer: C ≈ 5,000 µF (use 4,700 µF or 6,800 µF). A full-wave rectifier on 50 Hz mains supplies 1 A, and ripple must be at most 2 V peak-to-peak.

C = I_L / (f_r · V_r) = 1 / (100 × 2) = 0.005 F = 5,000 µF.

Choosing 4,700 µF gives V_r ≈ 1 / (100 × 0.0047) ≈ 2.13 V. Choosing 6,800 µF gives about 1.47 V. With a 15.5 V peak, V_DC ≈ 15.5 − 0.74 ≈ 14.8 V using 6,800 µF.

Rating: the capacitor’s voltage rating should exceed the peak (use 25 V for a 15.5 V peak), and its ripple current rating must handle the charging pulses.

Side Effects of Large Capacitors

  • Peak charging current: diodes conduct for only a short part of each cycle, so current pulses are several times the load current. This stresses diodes and the transformer and causes poor power factor and harmonics.

  • Inrush current at switch-on, limited with NTC thermistors or soft-start circuits.

Other Filter Types

Filter Description
Capacitor © Simplest; good for light loads
Choke input (LC) Inductor smooths current; better for heavy loads
π filter (CLC) Very low ripple
Active (regulator) A linear regulator after the capacitor removes most remaining ripple

Industry Applications

Bulk capacitors after bridge rectifiers in SMPS and adapters, output capacitors in DC-DC converters (where ripple frequency is the switching frequency, so much smaller capacitors are enough), and decoupling capacitors near ICs.

13

What is a BJT, and what are NPN and PNP transistors?

A BJT (bipolar junction transistor) is a three-terminal semiconductor device (emitter, base, collector) in which a small base current controls a much larger collector current. It is called bipolar because both electrons and holes carry current. An NPN transistor has a P-type base between two N-type regions; a PNP transistor has an N-type base between two P-type regions.

Read full answer

Applies toElectronics engineering (analog electronics)

Structure

  • Emitter: heavily doped, injects carriers.

  • Base: very thin and lightly doped, controls the flow.

  • Collector: moderately doped and largest, collects carriers and dissipates heat.

  • Two junctions: base-emitter (BE) and base-collector (BC).

How an NPN Transistor Works (Active Mode)

  1. The BE junction is forward biased (V_BE ≈ 0.7 V), so electrons are injected from the emitter into the base.

  2. The base is thin, so only a small fraction recombine there (forming base current).

  3. The BC junction is reverse biased, and its field sweeps most electrons into the collector.

  4. Result: a small base current controls a large collector current.

Key Relationships

  • I_E = I_B + I_C

  • I_C = β · I_B (β or h_FE, typically 50–300)

  • α = I_C / I_E = β / (β + 1), typically 0.98–0.995

Worked Example

Answer: I_C = 4 mA, I_E ≈ 4.02 mA. An NPN transistor has β = 200 and I_B = 20 µA.

  • I_C = 200 × 20 µA = 4 mA

  • I_E = 4 + 0.02 = 4.02 mA

  • α = 200 / 201 ≈ 0.995

NPN vs PNP

Aspect NPN PNP
Majority carriers Electrons Holes
Turn-on condition Base about 0.7 V above emitter Base about 0.7 V below emitter
Current direction Into collector, out of emitter Into emitter, out of collector
Symbol arrow Pointing out of emitter Pointing into emitter
Typical switching position Low-side (between load and ground) High-side (between supply and load)
Speed Faster (electron mobility is higher) Slower
Common parts BC547, 2N2222, 2N3904 BC557, 2N2907, 2N3906

Industry Applications

Amplifiers (audio, RF), switches for relays and LEDs, current mirrors and differential pairs inside op-amps, voltage regulators, and push-pull output stages (complementary NPN and PNP pairs). In power switching, MOSFETs and IGBTs have largely replaced BJTs, but BJTs remain common in analog and low-cost circuits.

14

What are the three regions of operation of a BJT?

A BJT operates in three main regions, set by how its two junctions are biased: cut-off (both junctions reverse biased, transistor off), active (base-emitter forward, base-collector reverse, used for amplification) and saturation (both junctions forward biased, transistor fully on, used as a closed switch).

Read full answer

Applies toElectronics engineering (analog electronics)

The Regions (NPN)

Region BE junction BC junction Behaviour Use
Cut-off Reverse (V_BE < about 0.5 V) Reverse I_C ≈ 0, open switch Switch OFF
Active (forward-active) Forward (V_BE ≈ 0.7 V) Reverse I_C = β·I_B Amplifier
Saturation Forward Forward V_CE ≈ 0.1–0.3 V, I_C limited by circuit Switch ON
Reverse active Reverse Forward Very low gain Rarely used

Output Characteristics

On a plot of I_C against V_CE for several values of I_B:

  • Saturation is the steep region near V_CE ≈ 0.2 V on the left.

  • Active is the flat region where each curve is nearly horizontal (I_C set by I_B).

  • Cut-off is the region along the axis where I_B = 0.

Identifying the Region: Worked Example

Answer: the transistor is saturated. Circuit: V_CC = 12 V, R_C = 1 kΩ, base driven through R_B = 10 kΩ from 5 V, β = 100.

  1. I_B = (5 − 0.7) / 10 kΩ = 0.43 mA

  2. If active: I_C = β·I_B = 43 mA

  3. Maximum possible I_C (V_CE ≈ 0.2 V): I_C(sat) = (12 − 0.2) / 1 kΩ = 11.8 mA

  4. Since 43 mA > 11.8 mA, the transistor cannot be in the active region; it is saturated, with I_C ≈ 11.8 mA and V_CE ≈ 0.2 V.

If R_B were 470 kΩ: I_B ≈ 9.1 µA, I_C = 0.91 mA, V_CE = 12 − 0.91 = 11.1 V → active region.

Key Points for Design

  • Amplifiers bias the transistor in the middle of the active region (the Q-point), so the signal can swing both ways without clipping.

  • Switches drive the transistor hard into saturation (overdrive factor of 2–10, i.e. I_B ≥ I_C / (β/5) or so) and fully into cut-off.

  • Saturation delay: excess charge stored in the base slows turn-off; Schottky-clamped transistors (used in 74LS logic) or Baker clamps avoid deep saturation.

Industry Applications

LED and relay drivers (saturation/cut-off), audio and RF amplifiers (active region), and digital logic families such as TTL, which switch transistors between cut-off and saturation.

15

What are the CE, CB and CC transistor configurations?

A BJT can be connected in three configurations, named after the terminal common to both input and output: common emitter (CE), common base (CB) and common collector (CC, emitter follower). Each gives a different combination of voltage gain, current gain, input impedance and output impedance.

Read full answer

Applies toElectronics engineering (analog amplifiers)

Configurations

  • Common emitter (CE): input at the base, output at the collector, emitter common.

  • Common base (CB): input at the emitter, output at the collector, base common.

  • Common collector (CC): input at the base, output at the emitter, collector common (to AC ground).

Comparison

Parameter CE CB CC (emitter follower)
Voltage gain High (−g_m·R_C), e.g. 50–300 High, similar to CE About 1 (slightly less)
Current gain High (β) About 1 (α) High (β + 1)
Power gain Highest Moderate Moderate
Input impedance Medium (about 1–5 kΩ) Low (about 10–50 Ω) High (β·R_E, hundreds of kΩ)
Output impedance Medium to high (≈ R_C) High Low (tens of ohms)
Phase shift 180° 0° 0°
Typical use General voltage amplification High-frequency amplifiers, cascode Buffers, impedance matching

Worked Example (CE Gain)

Answer: voltage gain ≈ −154. A CE amplifier has I_C = 1 mA, R_C = 4 kΩ, no emitter resistance in the AC path.

  • Transconductance g_m = I_C / V_T = 1 mA / 25.85 mV ≈ 38.7 mS

  • A_v = −g_m · R_C = −38.7 × 10⁻³ × 4,000 ≈ −155 (the minus sign means 180° phase inversion)

If a 200 Ω unbypassed emitter resistor is added, A_v ≈ −R_C / (r_e + R_E) = −4,000 / (25.85 + 200) ≈ −17.7, lower but more stable.

Worked Example (CC Input Impedance)

β = 150, R_E = 2 kΩ: R_in ≈ (β + 1) · R_E = 151 × 2,000 ≈ 302 kΩ, which hardly loads the source.

Why Each Is Used

  • CE: the workhorse for voltage gain.

  • CB: low input capacitance effect (no Miller multiplication), so it works well at high frequencies; used in RF amplifiers and in the cascode stage.

  • CC: drives low-impedance loads (speakers, cables) and isolates stages; used in output stages and voltage regulators.

Industry Applications

Multi-stage amplifiers combine them: for example a CE gain stage followed by a CC buffer, or a cascode (CE + CB) for wide-bandwidth, high-gain RF stages.

16

Why is the common emitter configuration most widely used?

The common emitter (CE) configuration is most widely used because it is the only BJT configuration that provides both high voltage gain and high current gain, and therefore the highest power gain. Its moderate input and output impedances also make it easy to cascade CE stages without heavy loading.

Read full answer

Applies toElectronics engineering (analog amplifiers)

Reasons

  1. High voltage gain: A_v = −g_m · R_C (often 50–300).

  2. High current gain: A_i ≈ β (often 100–300).

  3. Highest power gain: A_p = A_v × A_i, which can be thousands to tens of thousands.

  4. Convenient impedances: input impedance of a few kilohms and output impedance near R_C suit most source and load conditions.

  5. Easy biasing: one supply with a voltage divider sets the Q-point.

  6. Works as a switch: the same configuration is used for driving loads in saturation.

Comparison of Gains

Configuration Voltage gain Current gain Power gain
CE High High Very high
CB High About 1 Moderate
CC About 1 High Moderate

Worked Example

Answer: power gain ≈ 23,000 (about 43.6 dB). A CE stage has I_C = 1 mA, R_C = 3.9 kΩ, β = 150.

  • g_m = 1 mA / 25.85 mV ≈ 38.7 mS

  • A_v = 38.7 × 10⁻³ × 3,900 ≈ 151 (magnitude)

  • A_i ≈ β = 150

  • A_p = 151 × 150 ≈ 22,650 → 10·log₁₀(22,650) ≈ 43.6 dB

A CC stage with A_v ≈ 0.98 and A_i ≈ 151 gives A_p ≈ 148 (21.7 dB), much lower.

Drawbacks to Know

  • Phase inversion (180°), which matters in some feedback designs.

  • Miller effect: the base-collector capacitance appears multiplied by (1 + |A_v|) at the input, limiting bandwidth. This is why high-frequency designs use a cascode (CE + CB).

  • Gain depends on temperature and β, so an emitter resistor (degeneration) and negative feedback are added for stability, trading some gain.

Industry Applications

Audio pre-amplifiers, sensor signal conditioning, the gain stages inside op-amps, RF low-noise amplifiers (often in cascode form), and transistor switches for relays, LEDs and motors.

17

What is the difference between a BJT and a MOSFET?

A BJT is a current-controlled device: a small base current controls a larger collector current, and both electrons and holes carry the current. A MOSFET is a voltage-controlled device: the gate voltage creates a conducting channel, the gate draws almost no DC current, and only one carrier type conducts. MOSFETs dominate digital ICs and power switching, while BJTs remain common in analog circuits.

Read full answer

Applies toElectronics engineering (semiconductor devices)

Comparison

Aspect BJT MOSFET
Control Current (I_B) Voltage (V_GS)
Terminals Emitter, base, collector Source, gate, drain (plus body)
Carriers Bipolar (electrons and holes) Unipolar (electrons in NMOS, holes in PMOS)
Input impedance Low to medium (kΩ) Very high (gate is insulated; >10¹² Ω at DC)
Drive power Continuous base current Only charge/discharge gate capacitance
On-state loss V_CE(sat) ≈ 0.2 V (fixed drop) I² · R_DS(on) (resistive)
Transconductance High (g_m = I_C / V_T) Lower at the same current
Switching speed Slower (stored charge) Faster
Thermal behaviour Risk of thermal runaway Positive temperature coefficient of R_DS(on) helps current sharing in parallel
Integration density Lower Very high (CMOS)
ESD sensitivity Lower Higher (thin gate oxide)

Worked Example: Conduction Loss

Answer: the MOSFET wastes 0.1 W and the BJT about 1.0 W. Both switch 5 A.

  • MOSFET with R_DS(on) = 4 mΩ: P = I² · R = 25 × 0.004 = 0.1 W

  • BJT with V_CE(sat) = 0.2 V: P = 5 × 0.2 = 1.0 W, plus base drive power: with forced β = 20, I_B = 0.25 A at about 5 V ≈ 1.25 W from the driver.

This is why MOSFETs replaced BJTs in power supplies and motor drives at low and medium voltages.

When a BJT Is Still Better

  • Precision analog: low noise, good matching and high g_m for amplifiers and references.

  • Simple low-cost switching with small currents.

  • High-voltage, high-current switching uses the IGBT, which combines a MOSFET gate with bipolar conduction.

When a MOSFET Is Better

  • Digital logic (CMOS consumes power only when switching).

  • Power conversion at high frequencies (SMPS, DC-DC converters).

  • Battery-powered circuits that need very low drive power.

  • Load switches and reverse-polarity protection.

Interview Tip

The most common follow-up is “why does a MOSFET still need a gate driver if the gate draws no current?” Answer: the gate capacitance (nanocoulombs of gate charge) must be charged quickly for fast switching, which needs amps of peak current.

18

What is a FET, and how do JFETs and MOSFETs differ?

A FET (field-effect transistor) is a voltage-controlled transistor in which an electric field from the gate controls the conductivity of a channel between the source and drain. A JFET controls the channel with a reverse-biased PN junction gate, while a MOSFET uses a gate electrode insulated from the channel by a thin oxide layer, giving even higher input impedance.

Read full answer

Applies toElectronics engineering (semiconductor devices)

JFET

  • The gate is a PN junction that must be kept reverse biased.

  • Increasing reverse gate voltage widens the depletion regions, squeezing (pinching off) the channel and reducing current.

  • Depletion-mode only: it conducts at V_GS = 0 and is turned off by a negative V_GS (N-channel).

  • Transfer equation (Shockley): I_D = I_DSS · (1 − V_GS / V_P)²

  • I_DSS = drain current at V_GS = 0; V_P = pinch-off voltage.

MOSFET

  • The gate sits on a thin insulating layer (SiO₂ or high-k dielectric), so no junction exists.

  • Enhancement-mode: no channel at V_GS = 0; a positive V_GS above threshold (N-channel) creates one.

  • Depletion-mode: a channel exists at V_GS = 0 and can be enhanced or depleted.

  • Saturation equation (enhancement): I_D = (k/2) · (V_GS − V_th)²

Comparison

Aspect JFET MOSFET
Gate Reverse-biased PN junction Insulated by oxide
Input impedance High (about 10⁹ Ω) Very high (10¹² Ω or more)
Gate current Small leakage (nA–pA) Negligible (fA–pA)
Modes Depletion only Enhancement and depletion
Gate voltage polarity One polarity only Either polarity (within limits)
Noise Very low Higher 1/f noise
ESD sensitivity Robust Sensitive (thin oxide)
Integration Rare in ICs Basis of CMOS ICs
Typical uses Low-noise preamps, analog switches, constant-current sources Digital ICs, power switching, almost everything else

Worked Example (JFET)

Answer: I_D ≈ 3.0 mA. An N-channel JFET has I_DSS = 12 mA and V_P = −4 V. Find I_D at V_GS = −2 V.

I_D = 12 × (1 − (−2)/(−4))² = 12 × (1 − 0.5)² = 12 × 0.25 = 3.0 mA.

Advantages of FETs Over BJTs

  • Voltage control with almost no input current.

  • Unipolar conduction, so no minority-carrier storage delay in switching.

  • Better thermal stability (no thermal runaway in most conditions).

Industry Applications

JFETs: microphone preamplifiers (electret microphones contain a JFET), instrumentation front ends and RF mixers. MOSFETs: microprocessors and memory, power supplies, motor drives and load switches.

19

What is the difference between enhancement and depletion MOSFETs?

An enhancement-mode MOSFET has no conducting channel when the gate-source voltage is zero, so it is normally OFF and a gate voltage beyond the threshold must be applied to create a channel. A depletion-mode MOSFET has a built-in channel at zero gate voltage, so it is normally ON and must be driven with a gate voltage of the opposite polarity to turn it off.

Read full answer

Applies toElectronics engineering (semiconductor devices)

Enhancement MOSFET (N-Channel)

  • Structure: N+ source and drain in a P-type body, no channel between them.

  • Applying V_GS > V_th (typically 1–4 V for power devices, 0.3–0.5 V in modern logic) attracts electrons under the gate, forming an inversion layer (channel).

  • I_D ≈ 0 for V_GS < V_th.

  • Saturation current: I_D = (k/2) · (V_GS − V_th)²

Depletion MOSFET (N-Channel)

  • Structure: a lightly doped N-type channel is implanted between source and drain during manufacture.

  • At V_GS = 0, current I_DSS flows.

  • Negative V_GS depletes the channel; it turns off at V_GS = V_GS(off) (negative).

  • Positive V_GS can enhance the channel further.

  • I_D = I_DSS · (1 − V_GS / V_GS(off))²

Comparison

Aspect Enhancement Depletion
Channel at V_GS = 0 None Present
Default state Normally OFF Normally ON
N-channel turn-on V_GS > V_th (positive) Already on; turns off with negative V_GS
Symbol Broken (dashed) channel line Solid channel line
Popularity Overwhelmingly common Niche
Typical uses CMOS logic, power switches Constant-current sources, start-up circuits in SMPS, normally-on switches

Worked Example

Answer: I_D = 4.5 mA. An N-channel enhancement MOSFET has V_th = 2 V and k = 1 mA/V². Find I_D at V_GS = 5 V (saturation).

I_D = (1/2) × 1 × (5 − 2)² = 0.5 × 9 = 4.5 mA.

Why Enhancement Mode Dominates

  • Normally OFF means a circuit draws no current and is safe when the gate driver fails or is unpowered.

  • CMOS logic depends on complementary normally-off NMOS and PMOS devices, so static power is near zero.

Where Depletion Mode Is Used

  • SMPS start-up: a high-voltage depletion MOSFET supplies the controller from the rectified mains until the auxiliary winding takes over.

  • Current limiters and constant-current sources (gate tied to source through a resistor).

  • GaN HEMTs are naturally depletion-mode; they are often paired in cascode with a low-voltage silicon MOSFET to make a normally-off switch.

20

How can a transistor be used as a switch?

A transistor as a switch is driven between two states: fully OFF (cut-off, no current, like an open switch) and fully ON (saturation for a BJT, or the linear/ohmic region for a MOSFET, with a very small voltage drop, like a closed switch). A small control signal from a microcontroller can therefore turn a much larger load such as an LED, relay or motor on and off.

Read full answer

Applies toElectronics engineering (analog and embedded circuits)

BJT Low-Side Switch (NPN)

  • Load between the supply and the collector; emitter to ground.

  • A base resistor limits current from the control pin.

  • Design rule: drive into saturation with I_B ≥ I_C / β_forced, where β_forced is about 10–20 (well below the datasheet β).

Worked Example (BJT)

Answer: R_B ≈ 1.2 kΩ. A 3.3 V microcontroller pin drives a 12 V relay coil of 400 Ω using a BC547 (β ≈ 200).

  1. I_C = (12 − 0.2) / 400 ≈ 29.5 mA

  2. Forced β ≈ 13 → I_B ≈ 2.2 mA

  3. R_B = (3.3 − 0.7) / 2.2 mA ≈ 1.18 kΩ → use 1.2 kΩ (I_B ≈ 2.2 mA, well within a typical pin’s limit).

  4. Add a flyback diode (1N4148 or 1N4007) across the relay coil, cathode to +12 V, to absorb the inductive kick at turn-off.

MOSFET Low-Side Switch (N-Channel)

  • Gate driven from the control pin through a small series resistor (about 10–100 Ω) to limit ringing.

  • A gate-to-source pull-down resistor (about 10–100 kΩ) keeps it OFF when the pin floats during reset.

  • Choose a logic-level MOSFET whose R_DS(on) is specified at the drive voltage (for example at V_GS = 2.5 V or 4.5 V), such as the AO3400 or IRLZ44N.

  • Conduction loss: P = I² · R_DS(on).

Worked Example (MOSFET)

A 2 A LED strip with a MOSFET of R_DS(on) = 30 mΩ at V_GS = 4.5 V: P = 2² × 0.03 = 0.12 W, so no heat sink is needed.

Embedded C Control

#include <avr/io.h>

#define RELAY_PIN PB0

int main(void) {
    DDRB |= (1 << RELAY_PIN);       /* set the pin as output */
    PORTB |= (1 << RELAY_PIN);      /* switch ON: transistor saturates */
    /* ... */
    PORTB &= ~(1 << RELAY_PIN);     /* switch OFF: transistor cut off */
    while (1) { }
}

Best Practices

  • Inductive loads (relays, motors, solenoids) always need a flyback diode or snubber.

  • Use low-side switching for simplicity; use a PNP/P-channel MOSFET or a gate driver for high-side switching.

  • For fast PWM switching of MOSFETs, use a gate driver to charge the gate capacitance quickly.

  • Check power dissipation and the safe operating area.

Industry Applications

Relay and solenoid drivers, LED drivers, motor control (H-bridges), load switches in phones, and the building block of all digital logic.

21

What is transistor biasing, and why is voltage divider bias preferred?

Biasing is setting a transistor’s DC operating point (the Q-point: I_C and V_CE) so that it works in the correct region, usually the middle of the active region for an amplifier. Voltage divider bias is preferred because it makes the Q-point almost independent of the transistor’s current gain β and much less sensitive to temperature.

Read full answer

Applies toElectronics engineering (analog amplifiers)

Why Biasing Matters

  • An amplifier needs room for the signal to swing both up and down without hitting saturation or cut-off.

  • β varies widely between parts of the same type (for example 100 to 400 for a BC547B) and with temperature.

  • I_C roughly doubles for every 10 °C rise in leakage current, and V_BE falls by about 2 mV/°C, which can shift the Q-point or cause thermal runaway.

Common Bias Methods

Method Stability Notes
Fixed (base resistor) bias Poor I_C = β·I_B, so I_C changes directly with β
Collector feedback bias Moderate Negative feedback from collector to base
Emitter bias (dual supply) Good Needs two supplies
Voltage divider bias Very good Single supply, widely used

Voltage Divider Bias Circuit

R1 (from V_CC to base) and R2 (base to ground) form a divider; R_E sits in the emitter; R_C in the collector. If the divider current is about 10 times the base current, the base voltage is fixed by R1 and R2, and R_E provides negative feedback: if I_C rises, V_E rises, V_BE falls, and I_C is pulled back.

Formulas (Approximate)

  • V_B = V_CC · R2 / (R1 + R2)

  • V_E = V_B − 0.7

  • I_C ≈ I_E = V_E / R_E (independent of β)

  • V_CE = V_CC − I_C(R_C + R_E)

Worked Example

Answer: I_C ≈ 1.3 mA and V_CE ≈ 4.6 V (β = 100). V_CC = 12 V, R1 = 47 kΩ, R2 = 10 kΩ, R_C = 4.7 kΩ, R_E = 1 kΩ.

  1. Thevenin voltage: V_TH = 12 × 10 / 57 ≈ 2.11 V

  2. Thevenin resistance: R_TH = 47 k ∥ 10 k ≈ 8.25 kΩ

  3. I_B = (V_TH − 0.7) / (R_TH + (β + 1)·R_E) = 1.41 / (8.25 k + 101 k) ≈ 12.9 µA

  4. I_C = β·I_B ≈ 1.29 mA

  5. V_CE = 12 − 1.29 mA × (4.7 k + 1 k) ≈ 4.6 V

Stability check: with β = 300, the same formula gives I_C ≈ 1.37 mA. Tripling β changes I_C by only about 6%. With fixed bias, I_C would triple.

Design Guidelines

  • Choose V_E ≈ 10% of V_CC for good stability.

  • Make the divider current at least 10 × I_B (R2 ≤ 0.1·β·R_E).

  • Bypass R_E with a capacitor if full AC gain is needed, or leave part unbypassed for stable gain.

Industry Applications

Discrete audio pre-amplifiers, RF amplifier stages and sensor interfaces. Inside ICs, current mirrors and bandgap references perform the same job.

22

What is an amplifier, and what are classes A, B, AB and C?

An amplifier is a circuit that increases the power of a signal, using energy from a DC supply, while keeping its shape (for linear amplifiers). Power amplifiers are grouped into classes by how much of each input cycle the output transistor conducts: Class A (360°), Class B (180°), Class AB (slightly more than 180°) and Class C (less than 180°).

Read full answer

Applies toElectronics engineering (analog and power amplifiers)

Amplifier Gain

  • Voltage gain A_v = V_out / V_in; current gain A_i = I_out / I_in; power gain A_p = P_out / P_in.

  • In decibels: A_v(dB) = 20·log₁₀(A_v); A_p(dB) = 10·log₁₀(A_p).

  • Example: A_v = 100 → 40 dB.

Amplifier Classes

Class Conduction angle Max theoretical efficiency Distortion Typical use
A 360° 25% (resistive load), 50% (transformer/inductor load) Lowest Small-signal stages, high-end audio
B 180° (push-pull pair, each half) 78.5% (π/4) Crossover distortion Rarely used alone
AB Slightly over 180° Between A and B (about 50–70% in practice) Low Most linear audio power amps
C Less than 180° Up to about 90% Very high (needs tuned load) RF transmitters (FM, oscillators)
D Switching (PWM) Above 90% in practice Low with good filtering Class-D audio, phones, speakers

Class B Crossover Distortion

In a push-pull pair (NPN for the positive half, PNP for the negative), neither transistor conducts while the input is between about −0.7 V and +0.7 V, so the output has a “dead zone” near zero crossing. Class AB fixes this by biasing both transistors slightly on with two diodes or a V_BE multiplier.

Worked Example (Class B Efficiency)

Answer: about 62.8%. A Class B push-pull amplifier on ±15 V rails drives an 8 Ω speaker with a 12 V peak sine.

  • P_out = V_p² / (2R_L) = 144 / 16 = 9 W

  • Supply power P_DC = 2·V_CC·V_p / (π·R_L) = 2 × 15 × 12 / (π × 8) ≈ 14.3 W

  • Efficiency η = 9 / 14.3 ≈ 62.8% (the theoretical maximum of 78.5% occurs only when V_p = V_CC)

  • Heat in transistors: 14.3 − 9 = 5.3 W total

Choosing a Class

  • Low-level signals: Class A (pre-amplifiers, op-amp stages).

  • Audio power with good fidelity: Class AB, or Class D for efficiency.

  • RF with constant-envelope signals (FM): Class C or switching classes (E, F).

Industry Applications

Audio systems, RF transmitters in phones and radios, ultrasound drivers and motor drivers. Class D dominates portable audio because its high efficiency extends battery life and avoids large heat sinks.

23

What is negative feedback, and why is it used in amplifiers?

Negative feedback feeds a portion of an amplifier’s output back to its input in opposite phase, so it subtracts from the input signal. It reduces the overall gain, but in return makes the gain stable and predictable, widens bandwidth, lowers distortion and noise, and lets designers set input and output impedances.

Read full answer

Applies toElectronics engineering (analog amplifiers and op-amps)

Basic Formula

Closed-loop gain: A_f = A / (1 + A·β)

  • A = open-loop gain of the amplifier

  • β = feedback factor (fraction of output fed back)

  • A·β = loop gain

If A·β ≫ 1, then A_f ≈ 1/β, which depends only on the feedback network (usually precision resistors), not on the amplifier’s variable gain.

Benefits

Property Effect of negative feedback
Gain stability Sensitivity to changes in A is reduced by (1 + Aβ)
Bandwidth Increased by about (1 + Aβ); gain-bandwidth product stays constant
Distortion Reduced by about (1 + Aβ)
Noise from inside the loop Reduced (noise at the input is not)
Input impedance Raised (series mixing) or lowered (shunt mixing)
Output impedance Lowered (voltage sampling) or raised (current sampling)

Worked Example

Answer: closed-loop gain ≈ 9.999, and a 50% drop in A changes it by only about 0.02%. An op-amp has A = 100,000, and resistors set β = 0.1.

  • A_f = 100,000 / (1 + 100,000 × 0.1) = 100,000 / 10,001 ≈ 9.999

  • If A falls to 50,000 (temperature or part variation): A_f = 50,000 / 5,001 ≈ 9.998

  • Gain changes by only about 0.01% despite a 50% change in A.

Bandwidth: if the open-loop bandwidth is 10 Hz, the closed-loop bandwidth ≈ 10 × (1 + 10,000) ≈ 100 kHz.

Four Feedback Topologies

  • Series-shunt (voltage-series): voltage amplifier; raises Z_in, lowers Z_out (non-inverting op-amp amplifier).

  • Shunt-shunt (voltage-shunt): transresistance amplifier; lowers Z_in and Z_out (inverting amplifier, TIA).

  • Series-series (current-series): transconductance amplifier.

  • Shunt-series (current-shunt): current amplifier.

Trade-Offs and Risks

  • Lower gain, so more stages may be needed.

  • Instability: phase shift around the loop can turn negative feedback into positive feedback at high frequencies, causing oscillation. Designers check phase margin (typically at least 45–60°) using Bode plots, and op-amps are internally compensated for this.

Industry Applications

Every op-amp circuit, audio power amplifiers, voltage regulators (the error amplifier), motor and temperature control loops, and PLLs all rely on negative feedback.

24

What is an operational amplifier?

An operational amplifier (op-amp) is a high-gain, direct-coupled differential amplifier IC with two inputs (inverting − and non-inverting +) and one output. It amplifies the voltage difference between its inputs, and with external negative feedback it performs precise operations such as amplification, addition, integration, filtering and comparison.

Read full answer

Applies toElectronics engineering (analog circuits)

Basic Equation (Open Loop)

V_out = A_OL · (V+ − V−)

A_OL (open-loop gain) is very large, typically 10⁵ to 10⁶ (100–120 dB), so without feedback the output saturates at the supply rails for even microvolts of input difference.

Internal Structure

  1. Differential input stage: high input impedance, rejects common-mode signals.

  2. Gain stage: provides most of the voltage gain, with a compensation capacitor for stability.

  3. Output stage: Class AB push-pull for low output impedance and current drive.

Golden Rules (With Negative Feedback)

  1. No current flows into the inputs (very high input impedance).

  2. The output does whatever is needed to make V+ ≈ V− (the “virtual short”).

These two rules solve most op-amp circuits by hand.

Common Circuits

Circuit Gain or function
Inverting amplifier −R_f / R_in
Non-inverting amplifier 1 + R_f / R_in
Voltage follower 1 (buffer)
Summing amplifier −R_f(V1/R1 + V2/R2 + …)
Difference amplifier (R_f / R_in)(V2 − V1) with matched resistors
Integrator / differentiator Output ∝ ∫V_in dt / dV_in/dt
Comparator (open loop) Output high or low
Active filters Low-pass, high-pass, band-pass

Worked Example

Answer: V_out = 2.2 V. A non-inverting amplifier has R_f = 10 kΩ and R_in = 1 kΩ, with V_in = 0.2 V.

Gain = 1 + 10/1 = 11, so V_out = 11 × 0.2 = 2.2 V.

Key Real-World Parameters

Parameter Typical (LM358 / precision type)
Open-loop gain 100 dB / 120+ dB
Gain-bandwidth product 1 MHz / 1–10 MHz
Input offset voltage 2–7 mV / under 50 µV
Slew rate 0.3–0.5 V/µs / 1–20 V/µs
CMRR 70–85 dB / 100+ dB
Output swing Not to the rails / rail-to-rail on many modern parts

Industry Applications

Sensor signal conditioning (thermocouples, strain gauges), active filters, ADC drivers, audio pre-amplifiers, current sensing, voltage regulators and control systems. Popular parts include the LM358, LM741 (legacy, for teaching), TL072, OPA2333 and MCP6002.

25

What are the characteristics of an ideal op-amp?

An ideal op-amp is a theoretical model with infinite open-loop gain, infinite input impedance, zero output impedance, infinite bandwidth, infinite slew rate and zero offset, noise and drift. Real op-amps fall short of each, but the ideal model gives accurate results for most hand calculations when negative feedback is used.

Read full answer

Applies toElectronics engineering (analog circuits)

Ideal vs Real Characteristics

Characteristic Ideal Typical real (LM358) Good modern part
Open-loop gain (A_OL) ∞ 100 dB (10⁵) 120–140 dB
Input impedance ∞ About 1 MΩ (input bias current tens of nA) 10¹² Ω (CMOS inputs, pA bias)
Output impedance 0 Tens of ohms (open loop) Much lower in closed loop
Bandwidth ∞ GBW ≈ 1 MHz 10 MHz to GHz
Slew rate ∞ 0.3 V/µs 10–1000 V/µs
Input offset voltage 0 2–7 mV Under 10 µV (zero-drift parts)
CMRR ∞ 80 dB 120 dB+
PSRR ∞ 100 dB 120 dB
Noise 0 Tens of nV/√Hz 1–5 nV/√Hz (low-noise parts)
Output swing To the rails About 1.5 V below V+ Rail-to-rail

Consequences Used in Analysis

  1. Infinite input impedance → no current flows into the inputs.

  2. Infinite gain with negative feedback → V+ = V− (virtual short); if V+ is grounded, V− is a virtual ground.

  3. Zero output impedance → output voltage does not change with load.

Worked Example: Effect of Finite Gain

Answer: about 99.90 instead of 100 (0.1% error). A non-inverting amplifier with R_f / R_in = 99 (ideal gain 100) uses an op-amp with A_OL = 10⁵.

With β = 1/100: A_f = A / (1 + Aβ) = 100,000 / (1 + 1,000) ≈ 99.90. The error is about 0.1%, small enough to ignore in most designs.

Where the Ideal Model Breaks Down

  • High frequency: closed-loop bandwidth ≈ GBW / noise gain. A gain-of-100 stage on a 1 MHz GBW op-amp has only about 10 kHz of bandwidth.

  • Large fast signals: slew rate limits the full-power bandwidth: f_max = SR / (2π·V_p).

  • Precision DC: offset voltage and bias currents add errors that are amplified by the noise gain.

  • Output limits: current limit and swing to the rails.

Interview Tip

After listing the ideal characteristics, state the two golden rules and mention one real limitation (GBW or slew rate) with a quick number. That shows practical understanding beyond the textbook list.

26

How do inverting and non-inverting op-amp amplifiers differ?

An inverting amplifier applies the input to the op-amp’s inverting (−) input through a resistor, giving gain −R_f/R_in with the output 180° out of phase. A non-inverting amplifier applies the input directly to the non-inverting (+) input, giving gain 1 + R_f/R_in with the output in phase and a very high input impedance.

Read full answer

Applies toElectronics engineering (analog circuits)

Inverting Amplifier

  • Circuit: V_in → R_in → (−) input; R_f from output to (−); (+) to ground.

  • (−) is a virtual ground, so input current = V_in / R_in, which all flows through R_f.

  • Gain: A_v = −R_f / R_in

  • Input impedance = R_in.

Non-Inverting Amplifier

  • Circuit: V_in → (+) input; R_f from output to (−); R_in from (−) to ground.

  • (−) follows (+), so V_in appears across R_in.

  • Gain: A_v = 1 + R_f / R_in (always at least 1)

  • Input impedance: very high (op-amp input impedance, megaohms to teraohms).

Comparison

Aspect Inverting Non-inverting
Gain formula −R_f / R_in 1 + R_f / R_in
Phase 180° inverted In phase
Minimum gain magnitude Can be below 1 (attenuate) 1
Input impedance R_in (low to moderate) Very high
Common-mode voltage at inputs 0 V (virtual ground) Equals V_in, so op-amp CMRR matters
Summing several inputs Easy (summing amplifier) Less convenient
Noise gain 1 + R_f / R_in 1 + R_f / R_in

Worked Example

Answer: inverting −4.7 V; non-inverting 5.7 V. With R_f = 47 kΩ, R_in = 10 kΩ and V_in = 1 V:

  • Inverting: A_v = −47/10 = −4.7 → V_out = −4.7 V

  • Non-inverting: A_v = 1 + 4.7 = 5.7 → V_out = 5.7 V

Both need supply rails beyond these values (for example ±12 V) to avoid clipping.

Choosing Between Them

  • Use non-inverting when the source has high impedance (sensors such as pH probes or piezo transducers), because it does not load the source.

  • Use inverting for summing, for gains below 1, and when the common-mode input range of the op-amp is limited (inputs stay near 0 V).

  • Both have the same bandwidth for the same noise gain: f_BW ≈ GBW / (1 + R_f/R_in).

Industry Applications

Inverting: audio mixers (summing), transimpedance amplifiers for photodiodes. Non-inverting: sensor buffers, ADC driver gain stages, and the error amplifier inside voltage regulators.

27

What is the inverting amplifier gain for Rf=100 kΩ and Rin=10 kΩ?

The voltage gain is −10 (20 dB), so the output is ten times the input and inverted. For an inverting op-amp amplifier, gain depends only on the ratio of the feedback resistor to the input resistor: A_v = −R_f / R_in.

Read full answer

Applies toElectronics engineering (analog circuits, op-amps)

Solution

A_v = −R_f / R_in = −100 kΩ / 10 kΩ = −10

In decibels: 20·log₁₀(10) = 20 dB (the sign indicates a 180° phase shift).

Derivation

  1. The non-inverting input is grounded, so the inverting input is a virtual ground (0 V).

  2. Input current: I = V_in / R_in.

  3. No current enters the op-amp input, so the same current flows through R_f.

  4. V_out = 0 − I·R_f = −V_in · R_f / R_in.

Worked Numbers

V_in V_out (ideal)
+0.5 V −5.0 V
−0.3 V +3.0 V
1 V peak sine 10 V peak sine, inverted
+1.5 V −15 V → clipped at the negative rail (e.g. about −13.5 V on ±15 V supplies)

Other Properties of This Circuit

  • Input impedance = R_in = 10 kΩ.

  • Noise gain = 1 + R_f / R_in = 11, which sets bandwidth and offset error.

  • Bandwidth: with an op-amp GBW of 1 MHz, f_−3dB ≈ 1 MHz / 11 ≈ 91 kHz.

  • Offset at output: a 2 mV input offset voltage appears as 2 mV × 11 = 22 mV at the output.

  • Bias current compensation: put a resistor of R_in ∥ R_f ≈ 9.1 kΩ from the non-inverting input to ground to cancel errors from bias currents (for bipolar-input op-amps).

Practical Notes

  • Use 1% (or better) resistors; gain accuracy depends directly on their ratio.

  • Keep R_f in the 1 kΩ to 1 MΩ range: very small values load the op-amp output, while very large values increase noise and sensitivity to stray capacitance.

  • A small capacitor across R_f (for example 10–100 pF) limits bandwidth and improves stability.

Industry Applications

Signal level scaling before an ADC, audio gain stages, and inverting stages in active filters.

28

What is a voltage follower, and why is it used?

A voltage follower (unity-gain buffer) is an op-amp circuit whose output is connected directly to its inverting input, with the input signal applied to the non-inverting input, giving a gain of exactly 1. It is used to isolate stages: it presents a very high input impedance to the source and a very low output impedance to the load, so the source voltage is passed on without being loaded down.

Read full answer

Applies toElectronics engineering (analog circuits)

Circuit and Gain

  • V_in → (+) input; output tied to (−).

  • From the non-inverting formula with R_f = 0 and R_in = ∞: A_v = 1 + 0 = 1.

  • So V_out = V_in, in phase.

Why Use a Gain of 1?

Because of impedance transformation:

  • Input impedance: very high (MΩ to TΩ), so almost no current is drawn from the source.

  • Output impedance: very low (milliohms to ohms in closed loop), so the output stays steady under load.

Worked Example

Answer: without a buffer the ADC sees 2.0 V; with a buffer it sees 2.5 V. A sensor modelled as 2.5 V behind 10 kΩ feeds a circuit with 40 kΩ input resistance.

  • Without a buffer: V = 2.5 × 40 / (10 + 40) = 2.0 V (20% error from loading).

  • With a voltage follower: the op-amp draws only picoamps, so its input is 2.5 V and its output drives the 40 kΩ load at 2.5 V.

Typical Uses

  • Buffering high-impedance sensors (pH electrodes, piezo sensors, potentiometers, voltage dividers).

  • Driving ADC inputs: sampling capacitors in SAR ADCs draw current spikes; a buffer (often with a small RC filter) keeps the input steady.

  • Buffering voltage references so loads don’t change the reference voltage.

  • Isolating filter stages (for example between passive RC sections).

  • Driving cables or capacitive loads (with care for stability).

Design Considerations

  • The op-amp must be unity-gain stable; some fast op-amps (decompensated) are not.

  • The input common-mode range must include the signal (choose rail-to-rail input/output op-amps for single-supply circuits).

  • Capacitive loads can cause oscillation; add a small series output resistor (10–100 Ω).

  • Slew rate limits large, fast signals.

Industry Applications

Sensor front ends, ADC drivers, reference buffers, sample-and-hold circuits and audio line drivers.

29

What is CMRR in an op-amp?

CMRR (common-mode rejection ratio) measures how well a differential amplifier, such as an op-amp, rejects signals that appear equally on both inputs (common-mode signals) while amplifying the difference between them. It is the ratio of differential gain to common-mode gain, usually given in decibels; a higher CMRR means better rejection of noise and interference.

Read full answer

Applies toElectronics engineering (analog circuits)

Definitions

  • Differential input: V_d = V+ − V−; differential gain A_d.

  • Common-mode input: V_cm = (V+ + V−) / 2; common-mode gain A_cm.

  • V_out = A_d · V_d + A_cm · V_cm

  • CMRR = A_d / A_cm, or in dB: CMRR(dB) = 20·log₁₀(A_d / A_cm)

An ideal op-amp has A_cm = 0, so CMRR = ∞.

Why It Matters

Many real signals are small differences riding on a large common voltage:

  • A strain-gauge bridge produces millivolts of difference on top of about 2.5 V common voltage.

  • 50/60 Hz mains hum couples equally onto both wires of a sensor cable.

  • ECG electrodes pick up common-mode mains noise much larger than the heart signal.

Worked Example

Answer: an error equal to about 31.6 µV of differential input. An op-amp with CMRR = 90 dB sees 1 V of common-mode noise.

  • CMRR ratio = 10^(90/20) ≈ 31,623

  • Input-referred error = V_cm / CMRR = 1 / 31,623 ≈ 31.6 µV

If the wanted differential signal is 10 mV, the common-mode error is about 0.3% of it. With CMRR = 60 dB the error would be 1 mV (10% of the signal).

Typical Values

Device CMRR
General-purpose op-amp (LM358) 70–85 dB
Precision op-amp 100–130 dB
Instrumentation amplifier (gain 100) 100–140 dB
Discrete difference amplifier with 1% resistors About 40 dB (limited by resistor mismatch)

What Degrades CMRR

  • Resistor mismatch in difference amplifiers: a 1% mismatch limits CMRR to about 40 dB.

  • Frequency: CMRR falls at higher frequencies.

  • Source impedance imbalance between the two input lines.

Improving It

Use an instrumentation amplifier (such as INA128, AD620, INA333) with laser-trimmed internal resistors, keep input wiring balanced (twisted pairs), and use a driven shield or right-leg drive in biomedical circuits.

30

What is the slew rate of an op-amp?

Slew rate is the maximum rate at which an op-amp’s output voltage can change, usually given in volts per microsecond (V/µs). If a signal asks the output to change faster than this, the output cannot keep up and the waveform is distorted, for example a sine wave turns into a triangle wave.

Read full answer

Applies toElectronics engineering (analog circuits)

Definition

SR = (dV_out / dt)_max, in V/µs.

It is limited mainly by the current available to charge the internal compensation capacitor: SR ≈ I_max / C_c.

Full-Power Bandwidth

For a sine wave V_out = V_p · sin(2πft), the maximum slope is 2πf·V_p. To avoid slew-rate distortion:

2π·f·V_p ≤ SR → f_max = SR / (2π·V_p)

Worked Example 1

Answer: about 8 kHz. An LM741 (SR = 0.5 V/µs) must output a 10 V peak sine.

f_max = 0.5 × 10⁶ / (2π × 10) ≈ 7.96 kHz

So it cannot reproduce a full 10 V peak signal across the 20 kHz audio band. A TL072 (SR ≈ 13 V/µs) gives f_max ≈ 207 kHz at 10 V peak.

Worked Example 2

Answer: SR must be at least 1.26 V/µs. A 20 kHz audio signal needs 10 V peak output.

SR ≥ 2π × 20,000 × 10 = 1.26 × 10⁶ V/s = 1.26 V/µs. Designers add a margin of 2–5×.

Slew Rate vs Bandwidth

Limit Applies to Symptom
Gain-bandwidth product (GBW) Small signals Gain falls at high frequency
Slew rate Large signals Distorted (triangular) waveform, extra delay

A circuit can pass the small-signal bandwidth test but fail for large amplitudes because of slew rate.

Typical Values

Op-amp Slew rate
LM358 0.3 V/µs
LM741 0.5 V/µs
TL072 13 V/µs
OPA1612 (audio) 27 V/µs
High-speed (e.g. THS4304) Over 800 V/µs

Where It Matters

Audio amplifiers, ADC drivers handling fast steps, video signals, comparators built from op-amps (too slow), and pulse circuits. Low-power op-amps trade slew rate for lower supply current, so check it whenever signals are large and fast.

31

What is a comparator in electronics?

A comparator is a circuit that compares two voltages and outputs a digital-like high or low level depending on which input is larger. If V+ > V−, the output goes high; if V+ < V−, it goes low. It turns an analog signal into a 1-bit digital decision.

Read full answer

Applies toElectronics engineering (analog and mixed-signal circuits)

How It Works

  • It is an open-loop, very high-gain differential amplifier with no negative feedback.

  • Even a tiny input difference drives the output to one of its limits.

  • Dedicated comparator ICs (LM393, LM339, TLV3501) are optimised for fast switching and logic-compatible outputs; many have open-collector or open-drain outputs that need a pull-up resistor.

Comparator vs Op-Amp

Aspect Comparator IC Op-amp used as comparator
Speed Fast (ns to µs) Slow recovery from saturation
Output Logic-compatible, often open-drain Swings to rails, not logic-specific
Stability without feedback Designed for it Fine, but slow and may misbehave
Use Recommended Acceptable only for slow signals

Hysteresis (Schmitt Trigger)

A noisy input near the threshold can make a plain comparator chatter (switch many times). Adding positive feedback creates two thresholds: an upper V_UT and a lower V_LT. The output changes only when the input crosses the far threshold.

For a non-inverting Schmitt trigger with R1 from input to V+ and R2 from output to V+, and threshold reference at V−:

Hysteresis width ≈ (R1 / R2) × (V_OH − V_OL)

Worked Example

Answer: thresholds about 2.62 V and 2.38 V (0.24 V hysteresis). An inverting Schmitt trigger on a 5 V supply (output swings 0 V to 5 V) takes the input on V−. V+ is fed from a 2.5 V reference through R1 = 10 kΩ, with R2 = 200 kΩ from the output back to V+.

  • V+ when output high (5 V): 2.5 + (5 − 2.5) × 10 / 210 ≈ 2.62 V

  • V+ when output low (0 V): 2.5 − 2.5 × 10 / 210 ≈ 2.38 V

  • Hysteresis ≈ 0.24 V, enough to ignore about 0.1 V of noise.

Common Circuits

  • Zero-crossing detector: compares a signal to 0 V.

  • Window comparator: two comparators detect whether a voltage lies between limits (over/under-voltage monitors).

  • Battery low detector: compares a divided battery voltage with a reference.

  • PWM generation: compares a triangle wave with a control voltage.

  • Flash ADC: many comparators in parallel.

Industry Applications

Over-current and over-voltage protection in power supplies, light/dark switches with LDRs, zero-crossing detection for TRIAC control, and the comparator inside every SAR ADC and microcontroller analog comparator peripheral.

32

What are op-amp integrator and differentiator circuits?

An integrator is an op-amp circuit whose output is proportional to the time integral of its input, built by placing a capacitor in the feedback path of an inverting amplifier. A differentiator produces an output proportional to the rate of change of its input, built by placing the capacitor at the input instead. They turn square waves into triangles (integrator) and triangles into squares (differentiator).

Read full answer

Applies toElectronics engineering (analog circuits)

Integrator

  • Circuit: V_in → R → (−) input; C from output to (−); (+) grounded.

  • Output: V_out(t) = −(1 / RC) ∫ V_in dt

  • Frequency response: gain = 1 / (2π·f·RC), falling at 20 dB/decade (a low-pass behaviour).

  • Practical fix: an ideal integrator also integrates DC offset and drifts into saturation. Add a large resistor R_f in parallel with C to limit DC gain (a “lossy” integrator). It then integrates properly only above f = 1 / (2π·R_f·C).

Differentiator

  • Circuit: V_in → C → (−) input; R from output to (−); (+) grounded.

  • Output: V_out(t) = −RC · dV_in/dt

  • Frequency response: gain = 2π·f·RC, rising at 20 dB/decade (a high-pass behaviour).

  • Practical fix: gain rising with frequency amplifies noise and can oscillate. Add a small resistor in series with C and a small capacitor across R to limit high-frequency gain.

Worked Example (Integrator)

Answer: a triangle wave of 2.5 V peak-to-peak. An integrator with R = 10 kΩ and C = 0.1 µF (RC = 1 ms) receives a ±1 V square wave at 200 Hz (each half-cycle 2.5 ms).

Slope = V_in / RC = 1 / 0.001 = 1,000 V/s. Over 2.5 ms the output changes by 1,000 × 0.0025 = 2.5 V, so the output is a triangle with 2.5 V peak-to-peak (inverted).

Worked Example (Differentiator)

Answer: a ±1 V square wave. A differentiator with R = 10 kΩ and C = 10 nF (RC = 100 µs) receives a triangle wave rising and falling at 10,000 V/s.

V_out = −RC × dV/dt = −100 × 10⁻⁶ × (±10,000) = ∓1 V.

Comparison

Aspect Integrator Differentiator
Feedback element Capacitor Resistor
Input element Resistor Capacitor
Frequency behaviour Low-pass (−20 dB/dec) High-pass (+20 dB/dec)
Square wave in Triangle out Spikes out
Triangle in Parabolic segments out Square wave out
Main problem DC drift, saturation Noise, instability

Industry Applications

Integrators: PI/PID controllers, ramp and triangle generators, dual-slope ADCs, the loop filter in PLLs, charge amplifiers. Differentiators: edge and rate-of-change detection, and the D term in PID control (usually filtered).

33

What is an oscillator, and what is the Barkhausen criterion?

An oscillator is a circuit that produces a continuous periodic waveform (sine, square or triangle) from a DC supply, without any input signal. Feedback oscillators work by amplifying and feeding back their own output; the Barkhausen criterion states the conditions for sustained oscillation: the loop gain must equal 1 in magnitude and the total phase shift around the loop must be 0° (or 360°).

Read full answer

Applies toElectronics engineering (analog circuits, RF)

Barkhausen Criterion

For an amplifier with gain A and feedback network β:

  • |A·β| = 1 (loop gain magnitude is unity)

  • ∠A·β = 0° or 360°·n (positive feedback, in phase)

In practice, the loop gain is set slightly above 1 at start-up so oscillation builds up from noise, and a non-linear mechanism (amplitude limiting, an AGC, a lamp or diodes) brings it back to exactly 1 at the steady amplitude.

How Oscillation Starts

  1. Electrical noise contains all frequencies.

  2. The feedback network passes only the frequency that satisfies the phase condition.

  3. At that frequency loop gain > 1, so the signal grows each pass.

  4. The amplifier’s limits reduce the effective gain until |Aβ| = 1, giving a stable amplitude.

Worked Example: RC Phase-Shift Oscillator

Answer: about 650 Hz with an inverting gain of at least 29. A three-section RC phase-shift oscillator uses R = 10 kΩ and C = 10 nF.

  • Each RC section gives 60° of phase shift at the oscillation frequency; three give 180°, and the inverting amplifier adds another 180°.

  • f = 1 / (2π·R·C·√6) = 1 / (2π × 10,000 × 10 × 10⁻⁹ × 2.449) ≈ 650 Hz

  • The network attenuates by 1/29 at this frequency, so the amplifier gain must be at least 29 to meet |Aβ| = 1.

Worked Example: Wien Bridge Oscillator

With R = 10 kΩ and C = 16 nF: f = 1 / (2πRC) ≈ 995 Hz (about 1 kHz). The Wien network passes 1/3 at zero phase, so the non-inverting amplifier needs a gain of 3 (for example R_f = 2 × R_g).

Types of Oscillators

Type Frequency range Feature
RC phase-shift, Wien bridge Hz to about 1 MHz Audio, simple
LC (Colpitts, Hartley, Clapp) 100 kHz to GHz RF
Crystal kHz to about 100 MHz (fundamental) Very stable
Relaxation (555, Schmitt RC) Hz to MHz Square/triangle waves
Ring oscillator MHz to GHz On-chip, in ICs

Industry Applications

Clock generation for microcontrollers, RF carriers in transmitters and receivers, local oscillators in mixers, function generators and audio tone generation.

34

What is the difference between RC and LC oscillators?

An RC oscillator uses resistor-capacitor networks to set its frequency and is best for low frequencies (audio, up to around 1 MHz). An LC oscillator uses an inductor-capacitor tank circuit that resonates, and is best for high frequencies (from about 100 kHz into the GHz range), with better spectral purity.

Read full answer

Applies toElectronics engineering (analog and RF circuits)

RC Oscillators

  • Examples: RC phase-shift oscillator, Wien bridge oscillator.

  • Frequency: phase-shift f = 1 / (2πRC√6); Wien bridge f = 1 / (2πRC).

  • At high frequencies the required R and C become very small and parasitics dominate, and the op-amp’s bandwidth limits performance.

  • Inductors would be very large at audio frequencies, which is why RC networks are used there.

LC Oscillators

  • Examples: Colpitts (capacitive divider), Hartley (tapped inductor), Clapp (Colpitts with extra series C for stability).

  • Frequency: f = 1 / (2π√(LC)).

  • The tank stores energy, exchanging it between L and C; the transistor only replaces losses.

  • High Q of the tank gives low phase noise and a cleaner sine wave.

Comparison

Aspect RC oscillator LC oscillator
Frequency-setting parts Resistors and capacitors Inductor and capacitor tank
Typical range 1 Hz to about 1 MHz About 100 kHz to several GHz
Frequency formula 1/(2πRC) or 1/(2πRC√6) 1/(2π√(LC))
Size at low frequency Small Large inductors needed
Frequency stability Moderate Good (better with high-Q parts)
Waveform purity Good with amplitude control Very good
Tuning Variable resistors or dual-gang capacitors Variable capacitor or varactor
Common uses Audio test oscillators, function generators RF transmitters, receivers, VCOs

Worked Example (Colpitts)

Answer: about 10.1 MHz. A Colpitts oscillator uses L = 1 µH and two capacitors C1 = C2 = 500 pF in series.

  • C_eq = (500 × 500) / (500 + 500) = 250 pF

  • f = 1 / (2π√(1 × 10⁻⁶ × 250 × 10⁻¹²)) = 1 / (2π × 1.581 × 10⁻⁸) ≈ 10.07 MHz

Worked Example (Wien Bridge)

R = 4.7 kΩ, C = 22 nF: f = 1 / (2π × 4,700 × 22 × 10⁻⁹) ≈ 1.54 kHz.

Choosing Between Them

  • Low frequency, simple and cheap: RC.

  • Radio frequencies and low phase noise: LC.

  • When high frequency stability is needed at any frequency: a crystal oscillator, which behaves like a very high-Q LC circuit.

Industry Applications

RC: audio test signals, tone generators. LC: VCOs in PLL synthesisers, FM transmitters, RF local oscillators and metal detectors.

35

What is a crystal oscillator, and why is it so stable?

A crystal oscillator uses a piece of quartz crystal as its frequency-determining element. Quartz is piezoelectric, so it vibrates mechanically at a very precise resonant frequency when driven electrically, and it behaves like an LC circuit with an extremely high quality factor (Q of 10⁴ to 10⁶). This high Q and quartz’s low temperature sensitivity make it far more stable than RC or LC oscillators.

Read full answer

Applies toElectronics engineering (oscillators and timing)

Piezoelectric Effect

  • Applying voltage to quartz makes it deform; deforming it generates voltage.

  • A cut crystal has a natural mechanical resonance set by its size, shape and cut (for example AT-cut for MHz crystals, tuning-fork crystals for 32.768 kHz).

Electrical Equivalent Circuit

A series R-L-C branch (motional arm: R_m, L_m, C_m) in parallel with a shunt capacitance C_0 (electrodes and holder).

  • Series resonance: f_s = 1 / (2π√(L_m·C_m)), where impedance is lowest.

  • Parallel resonance: f_p slightly above f_s, where impedance is highest.

  • The crystal is inductive only in the narrow band between f_s and f_p; oscillators operate there.

Why It Is So Stable

Reason Effect
Very high Q (10⁴–10⁶) Phase changes sharply with frequency, so circuit variations barely shift frequency
Stable material Quartz properties change little with time (low ageing, a few ppm per year)
Temperature-optimised cuts AT-cut drift is only about ±10–50 ppm over −40 to 85 °C
Large L_m, tiny C_m Frequency is set by the crystal, not by external parts

Worked Example

Answer: up to ±0.86 seconds per day. A 32.768 kHz watch crystal is specified at ±10 ppm.

Error per day = 86,400 s × 10 × 10⁻⁶ = 0.864 s, or about 26 seconds per month. An RC oscillator with ±1% accuracy would drift by 864 seconds (over 14 minutes) per day.

Also note: 32,768 = 2¹⁵, so a 15-stage binary divider produces exactly 1 Hz, which is why watches and RTCs use this frequency.

Load Capacitance

A parallel-resonant crystal is specified with a load capacitance C_L (for example 12 pF). The two capacitors in a Pierce oscillator are chosen so that: C_L ≈ (C1 × C2) / (C1 + C2) + C_stray. With C_stray = 3 pF and C_L = 12 pF, C1 = C2 = 18 pF.

Types

  • XO: basic crystal oscillator, ±20–100 ppm.

  • TCXO: temperature-compensated, ±0.5–2 ppm (GPS, phones).

  • OCXO: oven-controlled, ±0.01 ppm or better (base stations, test equipment).

  • MEMS oscillators: silicon resonators, competing in some markets.

Industry Applications

Microcontroller and CPU clocks, real-time clocks, USB/Ethernet reference clocks, radio carrier references and GPS receivers.

36

What is a 555 timer, and how do its astable and monostable modes work?

The 555 timer is a versatile IC that generates accurate time delays and oscillations using an external resistor-capacitor network. It contains two comparators (thresholds at 1/3 and 2/3 of V_CC), an SR flip-flop, a discharge transistor and an output stage. In monostable mode it produces a single pulse of fixed width when triggered; in astable mode it runs freely, producing a continuous square wave.

Read full answer

Applies toElectronics engineering (analog and timing circuits)

Internal Operation

  • Three equal 5 kΩ resistors form a divider giving references of 2/3 V_CC and 1/3 V_CC.

  • Trigger comparator (pin 2): when trigger falls below 1/3 V_CC, it sets the flip-flop → output high.

  • Threshold comparator (pin 6): when threshold rises above 2/3 V_CC, it resets the flip-flop → output low and the discharge transistor (pin 7) turns on.

  • Supply: 4.5–16 V (bipolar NE555); CMOS versions (TLC555, ICM7555) work from 2 V with much lower current.

Monostable Mode (One-Shot)

  • A trigger pulse makes the output go high and lets C charge through R.

  • When V_C reaches 2/3 V_CC, the output goes low and C discharges.

  • Pulse width: T = 1.1 · R · C

Astable Mode (Free-Running)

  • C charges through R_A + R_B and discharges through R_B, cycling between 1/3 and 2/3 V_CC.

  • t_high = 0.693 · (R_A + R_B) · C

  • t_low = 0.693 · R_B · C

  • f = 1.44 / ((R_A + 2R_B) · C)

  • Duty cycle D = (R_A + R_B) / (R_A + 2R_B), always above 50% unless a diode bypasses R_B during charging.

Worked Example (Astable)

Answer: about 686 Hz at 52% duty. R_A = 1 kΩ, R_B = 10 kΩ, C = 0.1 µF.

  • f = 1.44 / ((1 k + 20 k) × 0.1 × 10⁻⁶) = 1.44 / 0.0021 ≈ 686 Hz

  • t_high = 0.693 × 11,000 × 0.1 × 10⁻⁶ ≈ 0.762 ms; t_low = 0.693 × 10,000 × 0.1 × 10⁻⁶ ≈ 0.693 ms

  • Duty = 0.762 / 1.455 ≈ 52.4%

Worked Example (Monostable)

A 5-second delay with C = 100 µF: R = T / (1.1C) = 5 / (1.1 × 100 × 10⁻⁶) ≈ 45.5 kΩ → use 47 kΩ (T ≈ 5.17 s).

Pin Summary

Pin Name Function
1 GND Ground
2 Trigger Starts timing when below 1/3 V_CC
3 Output High or low
4 Reset Active low; tie to V_CC if unused
5 Control voltage Changes the 2/3 V_CC threshold; bypass with 10 nF
6 Threshold Ends timing at 2/3 V_CC
7 Discharge Discharges C
8 V_CC Supply

Industry Applications

LED flashers, tone generators, PWM for motor and LED control, debouncing switches, delay timers, missing-pulse detectors and simple frequency-to-voltage circuits. Also used in bistable mode as a simple flip-flop.

37

What is a voltage regulator, and how do linear and switching regulators differ?

A voltage regulator keeps its output voltage constant despite changes in input voltage, load current and temperature. A linear regulator does this by dropping the extra voltage across a transistor acting as a variable resistor, which is simple and quiet but wastes power as heat. A switching regulator rapidly switches a transistor on and off and uses an inductor and capacitors to store and transfer energy, which is highly efficient but more complex and noisier.

Read full answer

Applies toElectronics engineering (power electronics)

Linear Regulators

  • A pass transistor is controlled by an error amplifier that compares a fraction of the output with a reference.

  • Examples: 78xx series (7805: 5 V), LM317 (adjustable), LDOs such as the AMS1117 and TPS7A series.

  • Dropout voltage: minimum V_in − V_out needed (about 2 V for 7805, 0.1–0.4 V for LDOs).

  • Efficiency ≈ V_out / V_in.

Switching Regulators

  • A transistor switches at tens of kHz to several MHz; duty cycle is adjusted by feedback (PWM).

  • Buck (step-down): V_out = D · V_in

  • Boost (step-up): V_out = V_in / (1 − D)

  • Buck-boost and inverting topologies; isolated versions (flyback, forward) for mains.

  • Efficiency typically 85–95%.

Comparison

Aspect Linear Switching
Efficiency V_out / V_in (low if large difference) 80–95% typical
Heat High at large drop and current Low
Output noise/ripple Very low Switching ripple and EMI
Step-up possible No Yes (boost)
Complexity and parts Simple, few parts Inductor, diode/MOSFET, more capacitors, careful layout
Cost Low Higher
Best for Low current, noise-sensitive analog/RF Battery devices, high current, large voltage drop

Worked Example

Answer: the linear regulator wastes 3.5 W (42% efficient); a 90% buck wastes about 0.28 W. A 12 V supply must provide 5 V at 0.5 A.

  • Linear: P_loss = (12 − 5) × 0.5 = 3.5 W; efficiency = 5/12 ≈ 41.7%. A TO-220 7805 would need a heat sink.

  • Buck (η = 90%): P_out = 2.5 W, P_in = 2.78 W, P_loss ≈ 0.28 W. Duty cycle ≈ 5/12 ≈ 0.42.

Common Practice

Use a switching regulator to step down efficiently, then a low-noise LDO for sensitive analog or RF circuits (for example 12 V → buck → 3.6 V → LDO → 3.3 V).

Industry Applications

Phone chargers and laptops (switching), point-of-load regulators on motherboards (multi-phase bucks), battery-powered IoT devices (buck/boost), and LDOs for ADC references, sensors and RF modules.

38

What is an SMPS (switched-mode power supply)?

An SMPS (switched-mode power supply) converts electrical power efficiently by switching a transistor (MOSFET, or GaN/SiC switch) on and off at high frequency and using inductors, transformers and capacitors to store and transfer energy, with feedback adjusting the duty cycle to regulate the output. SMPS units are smaller, lighter and much more efficient (often 85–95%) than linear power supplies.

Read full answer

Applies toElectronics engineering (power electronics)

Block Diagram of an Off-Line (Mains) SMPS

  1. EMI filter: blocks switching noise from reaching the mains.

  2. Rectifier and bulk capacitor: AC mains → high-voltage DC (about 325 V from 230 V AC).

  3. PFC stage (in supplies above about 75 W): a boost converter shapes input current to follow the voltage, improving power factor.

  4. Switching stage: MOSFET driven by a PWM controller at tens to hundreds of kHz.

  5. High-frequency transformer: provides isolation and voltage step-down.

  6. Output rectifier and filter: diodes or synchronous MOSFETs, plus LC filter.

  7. Feedback: output sensed (often by a TL431) and sent across the isolation barrier through an optocoupler to the controller.

Why High Frequency Makes It Small

Transformer and inductor size falls as frequency rises. A 50 Hz transformer for 60 W may weigh around 1 kg; a 100 kHz transformer for the same power weighs tens of grams.

Common Topologies

Topology Isolation Typical power Use
Buck No Any DC-DC step-down
Boost No Any Step-up, PFC
Flyback Yes Up to about 150 W Phone chargers, adapters
Forward Yes 100–500 W Industrial supplies
Half/full bridge, LLC resonant Yes 200 W to kW PC and server supplies, TVs

Worked Example (Buck)

Answer: D ≈ 27.5%, L ≈ 8 µH (use a standard 8.2 µH). A buck converter steps 12 V to 3.3 V at 2 A, switching at 500 kHz, with inductor ripple 30% of the load current.

  • D = V_out / V_in = 3.3 / 12 = 0.275

  • ΔI_L = 0.3 × 2 = 0.6 A

  • L = (V_in − V_out) × D / (f × ΔI_L) = (8.7 × 0.275) / (500,000 × 0.6) ≈ 7.98 µH

  • The inductor’s saturation current should exceed the peak current: 2 + 0.3 = 2.3 A, with margin (for example a 3 A part).

Advantages and Disadvantages

Advantages Disadvantages
High efficiency EMI and switching noise
Small, light More complex design
Wide input range (85–265 V AC universal) Output ripple needs filtering
Can step up, down or invert Layout is critical

Industry Applications

Mobile chargers (now often GaN-based), laptop adapters, PC and server power supplies, LED drivers, TV power boards, telecom rectifiers and industrial DIN-rail supplies.

39

What are logic gates?

Logic gates are the basic building blocks of digital circuits: each one takes one or more binary inputs (0 or 1) and produces a single binary output according to a fixed Boolean function. Combining gates builds everything from adders to processors.

Read full answer

Applies toElectronics engineering (digital electronics)

Basic Gates and Truth Tables

A B AND OR NAND NOR XOR XNOR
0 0 0 0 1 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 1 0 0 0 1

NOT (inverter): output = A’ (0 → 1, 1 → 0).

Boolean Expressions

Gate Expression Description
AND Y = A·B 1 only if all inputs are 1
OR Y = A + B 1 if any input is 1
NOT Y = A’ Inverts
NAND Y = (A·B)‘ AND followed by NOT
NOR Y = (A + B)‘ OR followed by NOT
XOR Y = A ⊕ B = A’B + AB’ 1 if inputs differ (odd number of 1s)
XNOR Y = (A ⊕ B)‘ 1 if inputs are equal

Categories

  • Basic gates: AND, OR, NOT.

  • Universal gates: NAND and NOR, because any logic function can be built from either alone.

  • Special gates: XOR and XNOR, used in adders, parity and comparators.

How They Are Built

In CMOS technology: - An inverter uses one PMOS (pull-up) and one NMOS (pull-down) transistor. - A 2-input NAND uses 4 transistors: two PMOS in parallel, two NMOS in series. - An AND gate is a NAND followed by an inverter (6 transistors), which is why NAND and NOR are the natural CMOS gates.

Worked Example

Answer: Y = 1. Evaluate Y = (A·B) + C’ for A = 1, B = 0, C = 0.

A·B = 0; C’ = 1; Y = 0 + 1 = 1.

Common ICs (74 Series)

Function IC
Quad 2-input NAND 74HC00
Quad 2-input NOR 74HC02
Hex inverter 74HC04
Quad 2-input AND 74HC08
Quad 2-input OR 74HC32
Quad 2-input XOR 74HC86

Industry Applications

All digital systems: CPUs, memories, FPGAs (which implement gates in LUTs), control logic in appliances and safety interlocks (for example an AND gate requiring two buttons pressed at once).

40

Why are NAND and NOR called universal gates?

NAND and NOR are called universal gates because any Boolean function, and therefore any digital circuit, can be built using only NAND gates or only NOR gates. Each can be wired to make NOT, AND and OR, which together form a functionally complete set.

Read full answer

Applies toElectronics engineering (digital electronics)

Building Basic Gates From NAND

Gate NAND implementation Gates needed
NOT Tie both inputs together: (A·A)‘ = A’ 1
AND NAND followed by NAND-as-NOT: ((A·B)‘)’ = A·B 2
OR Invert each input, then NAND: (A’·B’)‘ = A + B (De Morgan) 3
NOR OR followed by NOT 4
XOR Standard 4-NAND circuit 4

Building Basic Gates From NOR

Gate NOR implementation Gates needed
NOT Tie inputs together: (A + A)‘ = A’ 1
OR NOR followed by NOR-as-NOT 2
AND Invert each input, then NOR: (A’ + B’)‘ = A·B 3
NAND AND followed by NOT 4
XOR 5 NOR gates 5

XOR From Four NAND Gates

  1. N1 = (A·B)‘

  2. N2 = (A·N1)‘

  3. N3 = (B·N1)‘

  4. Y = (N2·N3)‘ = A ⊕ B

Check A = 1, B = 0: N1 = 1, N2 = (1·1)‘ = 0, N3 = (0·1)’ = 1, Y = (0·1)‘ = 1. Correct.

Why This Matters in Practice

  • Manufacturing: a chip or PCB can be built from one gate type, simplifying inventory and design (historically, Apollo Guidance Computer logic used only NOR gates).

  • CMOS efficiency: NAND and NOR are the natural single-stage CMOS gates (4 transistors for 2 inputs), while AND and OR need an extra inverter (6 transistors).

  • NAND is usually preferred over NOR in CMOS: NAND puts NMOS transistors in series and PMOS in parallel, while NOR puts slower PMOS in series. Since electrons are about 2–3 times more mobile than holes, NAND gates are faster or smaller for the same speed.

  • NAND flash memory takes its name from the series-connected cell structure resembling a NAND gate.

Worked Example

Implement Y = A·B + C·D using only NAND gates.

Using De Morgan: Y = ((A·B)‘ · (C·D)’)‘. That is three NAND gates: two first-level NANDs for A·B and C·D, and one second-level NAND combining them. This “AND-OR to NAND-NAND” conversion works for any sum-of-products expression.

Interview Tip

Show the NOT, AND and OR constructions quickly on paper; interviewers often follow up with “build XOR using NAND gates only”.

41

What is Boolean algebra, and what are De Morgan's theorems?

Boolean algebra is the mathematics of binary variables (0 and 1) and logic operations (AND, OR, NOT), used to describe, simplify and design digital circuits. De Morgan’s theorems show how to turn the complement of a product into a sum of complements, and vice versa: (A·B)‘ = A’ + B’ and (A + B)‘ = A’·B’.

Read full answer

Applies toElectronics engineering (digital electronics)

Basic Laws

Law AND form OR form
Identity A·1 = A A + 0 = A
Null A·0 = 0 A + 1 = 1
Idempotent A·A = A A + A = A
Complement A·A’ = 0 A + A’ = 1
Involution (A’)‘ = A
Commutative A·B = B·A A + B = B + A
Associative (A·B)·C = A·(B·C) (A + B) + C = A + (B + C)
Distributive A·(B + C) = A·B + A·C A + B·C = (A + B)·(A + C)
Absorption A·(A + B) = A A + A·B = A
Consensus AB + A’C + BC = AB + A’C

De Morgan’s Theorems

  1. (A·B)‘ = A’ + B’: a NAND gate equals an OR gate with inverted inputs.

  2. (A + B)‘ = A’·B’: a NOR gate equals an AND gate with inverted inputs.

General rule: complement the whole expression by swapping AND ↔ OR and complementing each variable.

Truth Table Proof of Theorem 1

A B A·B (A·B)‘ A’ B’ A’ + B’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0

The (A·B)‘ and A’ + B’ columns match for every input.

Worked Example: Simplification

Answer: Y = A + B. Simplify Y = A·B + A·B’ + A’·B.

  1. A·B + A·B’ = A·(B + B’) = A

  2. Y = A + A’·B

  3. Using A + A’B = A + B: Y = A + B

The original needed three AND gates, one OR and inverters; the result is a single OR gate.

Worked Example: Apply De Morgan

((A + B’)·C)‘ = (A + B’)‘ + C’ = A’·B + C’.

Industry Applications

Logic minimisation reduces gate count, area, power and delay. Synthesis tools apply these rules automatically, but engineers use them for hand optimisation, writing compact HDL conditions, and converting circuits to NAND-only or NOR-only forms.

42

What is a Karnaugh map?

A Karnaugh map (K-map) is a grid representation of a truth table that lets you simplify Boolean expressions visually. Cells are arranged in Gray-code order so that neighbouring cells differ by one variable; grouping adjacent 1s in blocks of 1, 2, 4, 8 and so on eliminates variables and gives the minimal sum-of-products expression.

Read full answer

Applies toElectronics engineering (digital electronics)

Construction

  • A K-map for n variables has 2ⁿ cells: 4 (2 variables), 8 (3), 16 (4).

  • Rows and columns are labelled in Gray code: 00, 01, 11, 10.

  • Each cell holds the output (0, 1 or X for don’t care) for that input combination.

  • The map wraps around: the left edge is adjacent to the right edge, and the top to the bottom.

Grouping Rules

  1. Group only 1s (for SOP) or only 0s (for POS).

  2. Group sizes must be powers of 2: 1, 2, 4, 8, 16.

  3. Groups must be rectangles (including wrap-around).

  4. Make groups as large as possible, and use as few groups as possible.

  5. Groups may overlap; every 1 must be covered.

  6. Don’t-care cells (X) can be included if they help make larger groups.

Each group of 2^k cells eliminates k variables.

Worked Example

Answer: F = A’C + AB’. Simplify F(A, B, C) = Σm(1, 3, 4, 5).

A BC 00 01 11 10
0 0 (m0) 1 (m1) 1 (m3) 0 (m2)
1 1 (m4) 1 (m5) 0 (m7) 0 (m6)
  • Group 1: m1 and m3 (A = 0, C = 1, B varies) → A’C

  • Group 2: m4 and m5 (A = 1, B = 0, C varies) → AB’

  • m5 is covered by Group 2 (m1 and m5 could also pair as B’C, but it is not needed).

F = A’C + AB’: 2 two-input AND gates and one OR, instead of four 3-input minterms.

Worked Example With a 4-Variable Map

For F = Σm(0, 2, 8, 10) (the four corner cells), the corners are mutually adjacent through wrap-around, so they form one group of 4: F = B’D’.

Advantages and Limitations

Advantages Limitations
Fast and visual for up to 4 variables Hard for 5–6 variables, impractical beyond
Gives minimal SOP/POS Manual, error-prone for large functions
Handles don’t-cares easily Not used by synthesis tools (they use Quine-McCluskey/Espresso-style algorithms)

Industry Applications

Designing small combinational blocks such as seven-segment decoders, code converters and FSM next-state logic by hand, and in exams and interviews to show logic minimisation skills.

43

What is the difference between combinational and sequential circuits?

A combinational circuit produces outputs that depend only on its current inputs, with no memory. A sequential circuit produces outputs that depend on the current inputs and on its past history, stored in memory elements such as flip-flops or latches, and it usually needs a clock.

Read full answer

Applies toElectronics engineering (digital electronics)

Comparison

Aspect Combinational Sequential
Output depends on Present inputs only Present inputs and stored state
Memory None Flip-flops, latches, registers
Feedback None (no loops) Feedback from outputs/state to inputs
Clock Not needed Usually needed (synchronous)
Described by Truth table, Boolean expression State table, state diagram, timing diagram
Design complexity Simpler More complex (timing, setup/hold)
Examples Adders, multiplexers, decoders, encoders, comparators Flip-flops, counters, shift registers, FSMs, memory

Example: Combinational

A half adder: Sum = A ⊕ B, Carry = A·B. Changing A or B changes the outputs after a small propagation delay; nothing is remembered.

Example: Sequential

A 2-bit counter: on each clock edge it moves 00 → 01 → 10 → 11 → 00. The same clock input produces a different output each time, because the output depends on the stored count.

Types of Sequential Circuits

  • Synchronous: all state changes occur on clock edges; easy to analyse and the norm in digital design.

  • Asynchronous: state changes occur whenever inputs change; faster in some cases but prone to races and hazards.

  • Mealy and Moore machines: FSM models where outputs depend on state and inputs (Mealy) or state only (Moore).

Timing Considerations

  • Combinational logic has propagation delay and can produce brief glitches (hazards) when inputs change.

  • Sequential circuits must meet setup and hold times of flip-flops; the clock period must exceed the flip-flop delay plus the slowest combinational path plus setup time.

Worked example: with t_clk-to-Q = 2 ns, combinational delay = 12 ns and t_setup = 1 ns, the minimum clock period is 15 ns, so f_max ≈ 66.7 MHz.

Industry Applications

Every digital system combines both: a CPU’s ALU is combinational, while its registers, pipeline stages and control unit are sequential. Synchronous design (combinational logic between clocked registers) is the standard approach in FPGAs and ASICs.

44

What are a multiplexer and a demultiplexer?

A multiplexer (MUX) is a combinational circuit that selects one of several input lines and sends it to a single output, based on select lines: 2ⁿ inputs need n select lines. A demultiplexer (DEMUX) does the opposite: it takes one input and routes it to one of several outputs chosen by the select lines.

Read full answer

Applies toElectronics engineering (digital electronics)

4:1 Multiplexer

Truth table:

S1 S0 Y
0 0 I0
0 1 I1
1 0 I2
1 1 I3

Expression: Y = S1’S0’·I0 + S1’S0·I1 + S1S0’·I2 + S1S0·I3

1:4 Demultiplexer

S1 S0 Y0 Y1 Y2 Y3
0 0 D 0 0 0
0 1 0 D 0 0
1 0 0 0 D 0
1 1 0 0 0 D

Expressions: Y0 = S1’S0’·D, Y1 = S1’S0·D, Y2 = S1S0’·D, Y3 = S1S0·D.

A DEMUX with its data input held at 1 behaves like a decoder.

Comparison

Aspect MUX DEMUX
Inputs → outputs Many → one One → many
Select lines log₂(inputs) log₂(outputs)
Function Data selector Data distributor
Common ICs 74HC151 (8:1), 74HC153 (dual 4:1), 74HC157 (quad 2:1) 74HC138 (3-to-8 decoder/DEMUX), 74HC139

MUX as a Universal Logic Element

A 2ⁿ:1 MUX can implement any n-variable function by connecting its data inputs to the truth-table outputs. With variables also used on data inputs, an 8:1 MUX can implement any 4-variable function.

Worked example: implement F(A, B) = A ⊕ B with a 4:1 MUX: select lines S1 = A, S0 = B, and data inputs I0 = 0, I1 = 1, I2 = 1, I3 = 0.

Embedded Example: Selecting an Analog Channel

/* Select channel 0-7 on an external CD4051 analog multiplexer using pins PD2-PD4 */
#include <avr/io.h>

void mux_select(uint8_t ch) {
    PORTD = (PORTD & ~(0x07 << 2)) | ((ch & 0x07) << 2);   /* write S2 S1 S0 */
}

Industry Applications

Bus and data-path selection in CPUs, time-division multiplexing in communication, analog multiplexers feeding one ADC from many sensors, address decoding to select memory chips (DEMUX/decoder), and display scanning.

45

What are an encoder and a decoder in digital electronics?

An encoder is a combinational circuit that converts one active input out of 2ⁿ input lines into an n-bit binary code. A decoder does the reverse: it converts an n-bit binary input into the activation of exactly one of 2ⁿ output lines. Encoders compress information into codes; decoders expand codes into individual control signals.

Read full answer

Applies toElectronics engineering (digital electronics)

4-to-2 Encoder

I3 I2 I1 I0 Y1 Y0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1

Y1 = I2 + I3, Y0 = I1 + I3.

Problem: if two inputs are active together, or none are, the output is wrong or ambiguous.

Priority Encoder

  • Gives the code of the highest-priority active input and ignores the rest.

  • Adds a valid output (V) that is 0 when no input is active.

  • Example IC: 74HC148 (8-to-3 priority encoder).

  • Example: inputs I1 and I3 both active → output = 11 (I3 wins).

2-to-4 Decoder

A1 A0 D0 D1 D2 D3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1

D0 = A1’A0’, D1 = A1’A0, D2 = A1A0’, D3 = A1A0 (each output is one minterm). Many decoder ICs have an enable input and active-low outputs, such as the 74HC138 (3-to-8).

Comparison

Aspect Encoder Decoder
Inputs 2ⁿ lines n-bit code
Outputs n-bit code 2ⁿ lines
Typical use Keyboards, interrupt priority Address decoding, display drivers
Example IC 74HC148 74HC138, CD4511 (BCD to 7-segment)

Worked Example

Answer: 3 address lines and one 74HC138. A system has 8 memory chips, each needing a chip-select signal.

Use a 3-to-8 decoder: the upper three address bits feed the decoder, and each of its 8 outputs selects one chip. With 1 KB per chip on a 16-bit address bus, A10–A12 drive the decoder and A0–A9 address inside each chip.

Decoder as a Logic Function Generator

Since each output is a minterm, any function can be built by ORing the right outputs. For F = Σm(1, 2) on two variables: F = D1 + D2 = A1 ⊕ A0.

Industry Applications

Keyboard encoders, priority interrupt controllers, memory and I/O address decoding, seven-segment display drivers, and instruction decoding inside CPUs.

46

What are a half adder and a full adder?

A half adder adds two single bits and produces a sum and a carry, but cannot accept a carry from a previous stage. A full adder adds three bits (two inputs plus a carry-in) and produces a sum and a carry-out, so full adders can be chained to add multi-bit numbers.

Read full answer

Applies toElectronics engineering (digital electronics)

Half Adder

A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
  • Sum = A ⊕ B

  • Carry = A·B

  • Gates: one XOR and one AND.

Full Adder

A B Cin Sum Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
  • Sum = A ⊕ B ⊕ Cin

  • Cout = A·B + Cin·(A ⊕ B) (equivalently A·B + B·Cin + A·Cin)

  • Built from two half adders and an OR gate.

Ripple-Carry Adder

Chain n full adders: each stage’s Cout feeds the next stage’s Cin.

Worked example: add 0110 (6) and 0111 (7).

Bit A B Cin Sum Cout
0 0 1 0 1 0
1 1 1 0 0 1
2 1 1 1 1 1
3 0 0 1 1 0

Result: 1101 = 13, carry-out 0. Correct.

Speed Limitation

In a ripple-carry adder, the carry may have to pass through every stage. If one full adder’s carry delay is 2 gate delays, a 32-bit adder needs about 64 gate delays in the worst case. Faster designs include:

  • Carry-lookahead adder (CLA): computes carries in parallel using generate (G = A·B) and propagate (P = A ⊕ B) signals.

  • Carry-select and carry-skip adders.

  • Parallel-prefix adders (Kogge-Stone, Brent-Kung) in high-speed CPUs, with delay proportional to log₂(n).

Other Uses

  • Subtraction: A − B = A + B’ + 1 (two’s complement), using XOR gates to invert B and Cin = 1.

  • Building blocks of ALUs and multipliers.

Industry Applications

ALUs in every processor, address calculation, DSP multiply-accumulate units, checksums and counters. The 74HC283 is a 4-bit binary full adder IC with fast carry.

47

What is a flip-flop, and what are SR, JK, D and T flip-flops?

A flip-flop is a clocked, edge-triggered 1-bit memory element whose output changes only at a clock edge (rising or falling), according to its inputs. The four main types are SR (set-reset), JK (SR without the invalid state), D (data, copies input) and T (toggle), and they form the basis of registers, counters and state machines.

Read full answer

Applies toElectronics engineering (digital electronics)

The Four Types

SR flip-flop

S R Q(next) Action
0 0 Q Hold
0 1 0 Reset
1 0 1 Set
1 1 ? Invalid (forbidden)

Characteristic equation: Q(next) = S + R’·Q, with S·R = 0.

JK flip-flop

J K Q(next) Action
0 0 Q Hold
0 1 0 Reset
1 0 1 Set
1 1 Q’ Toggle

Characteristic equation: Q(next) = J·Q’ + K’·Q. It removes the SR invalid state by toggling.

D flip-flop

D Q(next)
0 0
1 1

Q(next) = D. The most widely used flip-flop: registers, pipelines and synchronisers in all modern digital design.

T flip-flop

T Q(next)
0 Q (hold)
1 Q’ (toggle)

Q(next) = T ⊕ Q. Made from a JK with J = K = T. Used in counters and frequency dividers (T = 1 divides the clock by 2).

Excitation Table (Used in Counter Design)

Q → Q(next) SR JK D T
0 → 0 0X 0X 0 0
0 → 1 10 1X 1 1
1 → 0 01 X1 0 1
1 → 1 X0 X0 1 0

Worked Example

Answer: 5 MHz. A T flip-flop with T = 1 is clocked at 10 MHz; its output toggles on each rising edge, so the output frequency is 10 / 2 = 5 MHz. Four cascaded stages divide by 16, giving 625 kHz.

Timing Parameters

  • Setup time: input must be stable before the edge.

  • Hold time: input must remain stable after the edge.

  • Clock-to-Q delay: time from edge to output change.

  • Asynchronous preset and clear inputs force Q regardless of the clock.

Common ICs

74HC74 (dual D, with preset/clear), 74HC73/74HC112 (dual JK), 74HC574 (octal D register).

Industry Applications

Registers in processors, counters, shift registers, FSMs, synchronisers for asynchronous signals, and frequency dividers.

48

What is the race-around condition in a JK flip-flop?

The race-around condition occurs in a level-triggered JK flip-flop when J = K = 1 and the clock pulse stays high longer than the flip-flop’s propagation delay. Because the output feeds back to the inputs, the output toggles repeatedly during that single clock pulse, so its final state is unpredictable.

Read full answer

Applies toElectronics engineering (digital electronics)

Why It Happens

  • In a JK flip-flop built from gated SR logic, Q and Q’ are fed back to the input gates.

  • With J = K = 1, the flip-flop is set to toggle.

  • If the clock is still high after the output changes (after propagation delay t_pd), the new output is fed back and causes another toggle.

  • This repeats every t_pd until the clock goes low.

Condition

Race-around occurs when: t_pulse (clock high time) > t_pd (propagation delay of the flip-flop)

Worked Example

Answer: it toggles about 5 times, leaving an unpredictable final state. A level-triggered JK flip-flop has t_pd = 20 ns, J = K = 1, and the clock is high for 100 ns.

Number of toggles ≈ 100 / 20 = 5. An odd number suggests Q ends inverted, but variations in delay make the actual count uncertain, so the final state cannot be relied on.

Solutions

  1. Edge-triggered flip-flops: the output changes only at the clock edge, and the inputs are sampled for an instant, so feedback has no time to cause another toggle. This is the standard modern solution.

  2. Master-slave JK flip-flop: two latches in series. The master is enabled when the clock is high, the slave when it is low. The output (from the slave) changes only after the master is disabled, so the feedback cannot reach the master during the same pulse. (The 74LS76 is a classic example.)

  3. Make the clock pulse narrower than t_pd: possible in theory but impractical, since t_pd is only nanoseconds.

Master-Slave Operation

Clock Master Slave Output
High Enabled, follows J and K Disabled, holds Unchanged
Low Disabled, holds Enabled, copies master Updates

Note: master-slave JK flip-flops have a “ones-catching” problem (a glitch on J or K while the clock is high can be captured), which is another reason edge-triggered designs are preferred.

Interview Tip

State the condition (t_pulse > t_pd, with J = K = 1, level-triggered) and the two standard fixes (edge triggering and master-slave). Mentioning that modern designs use edge-triggered D flip-flops almost exclusively shows practical awareness.

49

What is the difference between a latch and a flip-flop?

A latch is a level-sensitive memory element: while its enable (clock) is active, its output follows the input continuously (“transparent”). A flip-flop is edge-triggered: it samples its input only at a clock edge (rising or falling) and holds the value until the next edge. Flip-flops are preferred in synchronous design because their timing is easier to control.

Read full answer

Applies toElectronics engineering (digital electronics)

Behaviour

D latch

Enable D Q
1 0 0 (follows D)
1 1 1 (follows D)
0 X Holds last value

D flip-flop

Clock D Q
Rising edge 0 0
Rising edge 1 1
No edge (high, low or falling) X Holds

Comparison

Aspect Latch Flip-flop
Triggering Level (enable high or low) Edge (rising or falling)
Transparency Transparent while enabled Never transparent
Construction Cross-coupled gates (e.g. 2 NAND for SR) Two latches in master-slave form, or edge-triggered circuit
Transistor count (CMOS D type) About 10–12 About 20–24
Speed Faster Slightly slower
Glitch sensitivity Input glitches pass through while enabled Only the value at the edge matters
Timing analysis Harder (time borrowing) Simpler (setup/hold at edge)
Typical use Some high-speed designs, clock gating cells, SRAM Registers, counters, FSMs (standard choice)

Timing Example

Answer: the latch output changes three times; the flip-flop changes once. During one 10 ns clock-high period, the input D changes at 2 ns, 5 ns and 8 ns.

  • A positive-level latch passes each change to Q while the clock is high, so Q changes at about 2, 5 and 8 ns.

  • A rising-edge flip-flop samples D only at the rising edge (t = 0), so Q changes at most once per clock cycle.

Why Latches Can Be a Problem

  • Accidental latches in HDL (from incomplete if or case statements in combinational blocks) create unintended timing paths.

  • Transparency can let signals race through several stages in one clock phase.

Where Latches Are Useful

  • Clock-gating cells use a latch to hold the enable stable during the clock’s high phase.

  • Time borrowing in high-performance pipelines allows a slow stage to use time from the next.

  • Lower area and power in some custom designs.

Common ICs

  • Latch: 74HC373 (octal transparent latch), 74HC75.

  • Flip-flop: 74HC374/574 (octal D flip-flop), 74HC74.

Industry Applications

Flip-flops form the registers of every CPU and FPGA design. Latches appear in address latching on multiplexed buses (for example the 8085’s lower address byte is latched with a 74HC373 using the ALE signal), in clock gating and in SRAM cells.

50

What are a register and a shift register?

A register is a group of flip-flops that stores a multi-bit binary word, loaded together on a clock edge. A shift register is a register whose bits can move (shift) one position left or right on each clock pulse, which lets data be converted between serial and parallel form, delayed or rotated.

Read full answer

Applies toElectronics engineering (digital electronics)

Register

  • An n-bit register uses n D flip-flops sharing one clock.

  • With a load (enable) input, it keeps its value until new data is loaded.

  • Examples: CPU general-purpose registers, the program counter, status registers.

Types of Shift Registers

Type Input Output Typical use Example IC
SISO (serial in, serial out) Serial Serial Delay line 74HC91
SIPO (serial in, parallel out) Serial Parallel Expanding outputs (LEDs) 74HC595, 74HC164
PISO (parallel in, serial out) Parallel Serial Reading many buttons 74HC165
PIPO (parallel in, parallel out) Parallel Parallel Storage 74HC374
Universal / bidirectional Both Both Shift left/right, load 74HC194

How a 4-Bit SIPO Works

Each clock moves every bit one stage along and loads a new bit at the input.

Worked example: shift in 1011 (MSB first) into a register that starts at 0000.

Clock Serial in Q3 Q2 Q1 Q0
0 0000
1 1 1000
2 0 0100
3 1 1010
4 1 1101

After 4 clocks the whole word is available in parallel. The first bit shifted in has moved furthest, so reading Q0 to Q3 gives 1011.

Arithmetic Use

Shifting a binary number left by one position multiplies it by 2; shifting right divides by 2 (for unsigned numbers). Example: 0011 (3) shifted left → 0110 (6).

Ring and Johnson Counters

  • Ring counter: output of the last stage fed back to the first; a single 1 circulates. An n-bit ring counter has n states.

  • Johnson (twisted-ring) counter: inverted last output fed back; it has 2n states (4 bits → 8 states).

Embedded Example: Driving a 74HC595

/* Bit-bang one byte into a 74HC595 (SIPO) */
void shift_out(uint8_t data) {
    for (int8_t i = 7; i >= 0; i--) {
        if (data & (1 << i)) PORTB |= (1 << DATA_PIN);
        else                  PORTB &= ~(1 << DATA_PIN);
        PORTB |= (1 << CLK_PIN);     /* rising edge shifts the bit in */
        PORTB &= ~(1 << CLK_PIN);
    }
    PORTB |= (1 << LATCH_PIN);       /* copy shift register to outputs */
    PORTB &= ~(1 << LATCH_PIN);
}

Industry Applications

Expanding microcontroller I/O (LED matrices, relays), serial communication (UART and SPI hardware use shift registers internally), CRC and scrambler circuits (LFSRs), and delay lines in DSP.

51

What is a counter, and how do synchronous and asynchronous counters differ?

A counter is a sequential circuit built from flip-flops that moves through a defined sequence of states, usually binary numbers, on each clock pulse. In an asynchronous (ripple) counter, only the first flip-flop gets the external clock and each later stage is clocked by the previous stage’s output. In a synchronous counter, all flip-flops share the same clock and change together.

Read full answer

Applies toElectronics engineering (digital electronics)

Asynchronous (Ripple) Counter

  • Built from T (or JK with J = K = 1) flip-flops; each output clocks the next stage.

  • Simple, few gates.

  • Delays accumulate: the last stage changes only after all earlier stages have toggled.

  • During transitions, intermediate wrong states (glitches) appear briefly, e.g. going from 0111 to 1000 may pass through 0110, 0100 and 0000.

Synchronous Counter

  • All flip-flops are clocked together; logic gates decide which ones toggle.

  • For a binary up counter: stage n toggles when all lower bits are 1 (T_n = Q0·Q1·…·Q(n−1)).

  • No ripple delay; outputs change at nearly the same time.

  • Needs more gates, but is faster and glitch-free.

Comparison

Aspect Asynchronous (ripple) Synchronous
Clocking Each stage clocked by previous Common clock
Speed Limited by total delay n × t_pd Limited by one flip-flop + gate delay
Decoding glitches Yes No
Hardware Fewer gates More gates
Design Simple More involved
Example ICs 74HC93, 74HC4040 74HC161, 74HC163, 74HC190

Worked Example: Maximum Frequency

Answer: 12.5 MHz for the ripple counter; about 40 MHz for the synchronous counter. Each flip-flop has t_pd = 20 ns, and the AND gate delay is 5 ns, for a 4-bit counter.

  • Ripple: total delay = 4 × 20 = 80 ns → f_max = 1/80 ns = 12.5 MHz (if outputs must be read stable each cycle).

  • Synchronous: delay = t_pd + t_gate (+ setup) ≈ 20 + 5 = 25 ns → f_max ≈ 40 MHz.

Mod-N Counters

A mod-N counter counts N states then resets. Example: a decade (mod-10) counter counts 0–9; when it reaches 1010 (10), a NAND gate detects Q3 and Q1 both high and resets the counter (asynchronous reset), or synchronous logic loads 0 on the next clock. Number of flip-flops needed: n = ⌈log₂N⌉; mod-10 needs 4.

Other Counter Types

  • Up/down counters (74HC191/193).

  • Ring and Johnson counters from shift registers.

  • Gray-code counters: only one bit changes per count, useful across clock domains.

Industry Applications

Frequency dividers, digital clocks and timers, event counting (production lines, pulse counting from encoders), address generation for memories, PWM generation and baud-rate generators in microcontroller timers.

52

What is the difference between RAM and ROM?

RAM (random access memory) is read-write memory used for temporary working data; it is volatile, so its contents are lost when power is removed. ROM (read-only memory) stores permanent or rarely changed data such as firmware; it is non-volatile, so contents remain without power. Modern “ROM” is usually Flash or EEPROM, which can be rewritten but much more slowly than RAM.

Read full answer

Applies toElectronics engineering (digital electronics and memory)

Comparison

Aspect RAM ROM (and Flash/EEPROM)
Volatility Volatile Non-volatile
Read/write Fast read and write Read; writing is slow, restricted or impossible
Purpose Variables, stack, buffers, running programs Firmware, boot code, constants, configuration
Speed Faster Slower (especially writes)
Write endurance Practically unlimited Limited (Flash about 10⁴–10⁵ cycles, EEPROM about 10⁵–10⁶)
Cost per bit Higher Lower (Flash)
Examples SRAM, DRAM, DDR4/DDR5 Mask ROM, PROM, EPROM, EEPROM, NOR/NAND Flash

Types of RAM

  • SRAM: flip-flop cells (6 transistors), fast, no refresh, used for caches and microcontroller RAM.

  • DRAM: capacitor cells (1 transistor + 1 capacitor), dense and cheap, needs refresh; used for main memory.

Types of ROM

Type How it is programmed Erasable?
Mask ROM At manufacture No
PROM Once by the user (fuses) No
EPROM Electrically; erased with UV light Yes (UV window)
EEPROM Electrically, byte by byte Yes
Flash Electrically, in blocks/sectors Yes

Worked Example: Memory Size

Answer: 64 KB. A memory chip has 16 address lines and an 8-bit data bus.

Locations = 2¹⁶ = 65,536; each stores 8 bits (1 byte), so capacity = 65,536 bytes = 64 KB. To get 1 MB with 8-bit data, you would need 20 address lines (2²⁰).

In a Microcontroller

An ATmega328P (Arduino Uno) has: - 32 KB Flash (program memory, non-volatile) - 2 KB SRAM (variables and stack, volatile) - 1 KB EEPROM (non-volatile settings)

#include <avr/eeprom.h>

uint8_t EEMEM saved_mode;                  /* variable placed in EEPROM */

void save_mode(uint8_t m) { eeprom_update_byte(&saved_mode, m); }  /* survives power-off */
uint8_t load_mode(void)   { return eeprom_read_byte(&saved_mode); }

Industry Applications

RAM: computer main memory, caches, buffers in network and video devices. ROM/Flash: BIOS/UEFI firmware, microcontroller programs, SSDs and USB drives (NAND Flash), configuration storage.

53

What is the difference between SRAM and DRAM?

SRAM (static RAM) stores each bit in a bistable latch made of about six transistors, so it holds data as long as power is on without refreshing, and it is very fast. DRAM (dynamic RAM) stores each bit as charge on a tiny capacitor with one access transistor, which is much denser and cheaper but leaks, so it must be refreshed every few milliseconds. SRAM is used for caches; DRAM for main memory.

Read full answer

Applies toElectronics engineering (memory technology)

Cell Structure

  • SRAM (6T cell): two cross-coupled inverters (4 transistors) store the bit; two access transistors connect it to the bit lines when the word line is active.

  • DRAM (1T1C cell): one transistor and one capacitor (tens of femtofarads). Reading is destructive and the sensed value must be written back.

Comparison

Aspect SRAM DRAM
Cell 6 transistors 1 transistor + 1 capacitor
Density Low High (about 4–6× or more denser)
Cost per bit High Low
Speed (access time) About 1–10 ns (on-chip caches under 1 ns) Tens of ns (about 50–100 ns latency for DDR)
Refresh Not needed Needed (typically every 64 ms)
Standby power Leakage only Refresh power
Read Non-destructive Destructive (rewrite needed)
Use CPU caches, registers, MCU RAM, FPGA BRAM Main memory (DDR4/DDR5, LPDDR), graphics memory

Refresh: Worked Example

Answer: about 7.8 µs between refresh commands. A DRAM device must refresh all 8,192 rows every 64 ms.

Interval = 64 ms / 8,192 ≈ 7.8 µs. The memory controller issues a refresh command roughly every 7.8 µs (the standard tREFI for DDR3/DDR4 at normal temperature). Above 85 °C, the refresh rate doubles (3.9 µs) because capacitors leak faster.

Why the Memory Hierarchy Uses Both

Level Technology Typical size Typical latency
Registers Flip-flops Bytes Under 1 ns
L1/L2/L3 cache SRAM KB to tens of MB About 1–15 ns
Main memory DRAM GB About 50–100 ns
Storage NAND Flash TB Microseconds

Fast but expensive SRAM sits close to the CPU; dense, cheaper DRAM provides capacity.

Industry Applications

SRAM: CPU and GPU caches, microcontroller on-chip RAM, FPGA block RAM, network switch buffers. DRAM: PCs and servers (DDR5), phones (LPDDR5), graphics cards (GDDR6, HBM for AI accelerators).

54

What are an ADC and a DAC?

An ADC (analog-to-digital converter) converts a continuous analog voltage into a digital number that a processor can use. A DAC (digital-to-analog converter) converts a digital number back into an analog voltage or current. Together they connect the real analog world (sensors, audio, motors) to digital systems.

Read full answer

Applies toElectronics engineering (mixed-signal electronics)

Key Parameters

  • Resolution (n bits): number of output codes = 2ⁿ.

  • LSB size (step): V_LSB = V_ref / 2ⁿ.

  • Sampling rate: samples per second (must exceed twice the highest signal frequency, per Nyquist).

  • Accuracy: offset, gain error, INL, DNL.

  • Quantisation error: up to ±½ LSB.

  • SNR (ideal): SNR ≈ 6.02n + 1.76 dB.

ADC Conversion Formula

Digital code = (V_in / V_ref) × (2ⁿ − 1), rounded (formulas with 2ⁿ are also common; the difference is one LSB at full scale).

Worked Examples

ADC

Answer: code ≈ 2,048 (0x800), and each step is about 0.81 mV. A 12-bit ADC with V_ref = 3.3 V reads 1.65 V.

  • LSB = 3.3 / 4,096 ≈ 0.806 mV

  • Code = 1.65 / 3.3 × 4,096 = 2,048

  • Ideal SNR = 6.02 × 12 + 1.76 ≈ 74 dB

DAC

An 8-bit DAC with V_ref = 5 V receives code 200: V_out = 200 / 256 × 5 ≈ 3.91 V.

ADC Types

Type Speed Resolution Use
Flash Fastest (GS/s) Low (6–8 bits) Oscilloscopes, radar
SAR (successive approximation) Medium (kS/s to a few MS/s) 8–18 bits Microcontrollers, data acquisition
Sigma-delta (ΣΔ) Slow to medium 16–24 bits Audio, precision sensors, weighing scales
Dual-slope (integrating) Slow High Digital multimeters
Pipelined Fast (tens to hundreds of MS/s) 10–16 bits Communications, video

DAC Types

  • R-2R ladder: uses only two resistor values; simple and accurate.

  • Binary-weighted resistor: needs a wide range of resistor values.

  • PWM + low-pass filter: a cheap DAC from a microcontroller timer.

  • Sigma-delta DAC: audio.

Embedded C Example (AVR ADC)

#include <avr/io.h>

uint16_t adc_read(uint8_t ch) {
    ADMUX  = (1 << REFS0) | (ch & 0x07);          /* AVcc reference, select channel */
    ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); /* enable, clk/128 */
    ADCSRA |= (1 << ADSC);                         /* start conversion */
    while (ADCSRA & (1 << ADSC)) { }               /* wait until done */
    return ADC;                                    /* 10-bit result, 0-1023 */
}

Industry Applications

ADCs: sensor reading (temperature, pressure, current), audio recording, oscilloscopes, software-defined radio. DACs: audio playback, waveform generation, motor control setpoints and display drivers.

55

What is the difference between a microprocessor and a microcontroller?

A microprocessor is a CPU on a single chip that needs external memory (RAM, ROM) and peripheral chips to form a working computer; it is designed for high performance and general-purpose computing. A microcontroller puts a CPU, RAM, Flash memory and peripherals (timers, ADC, UART, GPIO) on one chip, making it a complete small computer designed for dedicated control tasks at low cost and power.

Read full answer

Applies toElectronics engineering (embedded systems)

Comparison

Aspect Microprocessor Microcontroller
Contents CPU (plus caches, sometimes GPU) CPU + RAM + Flash + peripherals
External parts Needs RAM, storage, I/O chips Often works with just power and a crystal
Purpose General-purpose computing Dedicated control
Performance High (GHz, multi-core) Moderate (MHz to a few hundred MHz)
Memory GBs of external DRAM KBs to a few MB on-chip
Power Watts to hundreds of watts Microwatts to milliwatts
Cost Higher Low (cents to a few dollars)
Operating system Full OS (Linux, Windows) Bare metal or RTOS
Real-time behaviour Less predictable Deterministic
Examples Intel Core, AMD Ryzen, 8085 (classic), ARM Cortex-A in phones 8051, AVR ATmega328P, PIC, STM32 (ARM Cortex-M), ESP32

Example System: Microcontroller

A digital thermometer using an STM32 or ATmega328P: the on-chip ADC reads the sensor, the CPU calculates temperature, a timer schedules readings, and GPIO or I2C drive a display, all on one chip.

Example System: Microprocessor

A laptop: an Intel or AMD processor with external DDR memory, an SSD, a chipset and graphics running a full operating system.

Worked Example: Power

Answer: about 2.6 years on a 2,000 mAh battery (before allowing for self-discharge). A microcontroller sensor node draws 5 mA for 1 second every minute while measuring, and 5 µA while asleep.

  • Average current = (5 mA × 1 s + 0.005 mA × 59 s) / 60 s ≈ 0.088 mA

  • Battery life = 2,000 mAh / 0.088 mA ≈ 22,700 hours ≈ 2.6 years

A microprocessor system drawing several watts would drain the same battery in hours.

Where the Line Blurs

  • SoCs (systems on chip), such as Raspberry Pi’s Broadcom chips, include processors, GPUs and peripherals but still need external RAM and run Linux.

  • Microprocessor units (MPUs) like ARM Cortex-A7 parts sit between the two.

Industry Applications

Microcontrollers: appliances, automotive ECUs, IoT devices, motor control, wearables. Microprocessors: PCs, servers, smartphones (application processors), networking equipment.

56

What is the architecture of the 8085 microprocessor?

The Intel 8085 is an 8-bit microprocessor introduced in 1976, with an 8-bit data bus, a 16-bit address bus (64 KB of addressable memory), and a single +5 V supply. Its architecture consists of an ALU, a register array, a timing and control unit, an interrupt control unit, serial I/O control and a multiplexed address/data bus.

Read full answer

Applies toElectronics engineering (microprocessors, Intel 8085)

Main Blocks

  • ALU: 8-bit arithmetic and logic operations, working with the accumulator and a temporary register.

  • Accumulator (A): 8-bit register holding one operand and the result of most operations.

  • Flag register: five flags set by ALU results.

  • General-purpose registers: B, C, D, E, H, L (8-bit), usable as pairs BC, DE, HL (16-bit). HL often acts as a memory pointer.

  • Program counter (PC): 16-bit, holds the address of the next instruction.

  • Stack pointer (SP): 16-bit, points to the top of the stack in memory.

  • Instruction register and decoder: hold and decode the current opcode.

  • Timing and control unit: generates control signals (RD, WR, ALE, IO/M, S0, S1).

  • Interrupt control: five hardware interrupts.

  • Serial I/O control: SID and SOD pins for simple serial data.

Flags

Flag Meaning
S (sign) Set if bit 7 of the result is 1
Z (zero) Set if the result is 0
AC (auxiliary carry) Carry from bit 3 to bit 4 (used for BCD)
P (parity) Set if the result has an even number of 1s
CY (carry) Set on carry out of bit 7 (or borrow)

Multiplexed Bus

  • AD0–AD7 carry the lower address byte at the start of a machine cycle, then data.

  • ALE (address latch enable) goes high during the first T-state, and an external latch (74LS373) captures the lower address.

  • A8–A15 carry the upper address byte.

Interrupts (Priority Order)

Interrupt Type Vector address
TRAP Non-maskable, edge and level 0024H
RST 7.5 Maskable, edge-triggered 003CH
RST 6.5 Maskable, level 0034H
RST 5.5 Maskable, level 002CH
INTR Maskable, non-vectored Supplied by external device

Worked Example: Program

Add two numbers stored at 2050H and 2051H, and store the result at 2052H:

LDA 2050H     ; A <- [2050H]
MOV B, A      ; B <- A
LDA 2051H     ; A <- [2051H]
ADD B         ; A <- A + B, flags updated
STA 2052H     ; [2052H] <- A
HLT           ; stop

If [2050H] = 3AH and [2051H] = 25H, the result is 5FH (58 + 37 = 95).

Clock and Timing

The 8085 uses a crystal at twice the operating frequency (e.g. 6 MHz crystal → 3 MHz clock). An instruction takes 1 to 5 machine cycles, each of 3 to 6 T-states. At 3 MHz one T-state is about 333 ns.

Relevance Today

The 8085 is mainly taught for its clear structure: buses, registers, instruction cycles and interrupts carry over directly to modern microcontrollers and processors.

57

What is the 8051 microcontroller, and what are its main features?

The 8051 is an 8-bit microcontroller architecture introduced by Intel in 1980 that integrates a CPU, RAM, ROM, timers, a serial port and I/O ports on one chip. It uses a Harvard architecture with separate program and data memory, and modern derivatives from Microchip (AT89 series), Silicon Labs and Nuvoton are still widely used.

Read full answer

Applies toElectronics engineering (microcontrollers, 8051)

Main Features (Original 8051)

Feature Specification
CPU 8-bit, with boolean (bit) processor
Program memory 4 KB on-chip ROM (expandable to 64 KB external)
Data memory 128 bytes on-chip RAM (8052: 256 bytes); 64 KB external
I/O 32 lines in four 8-bit ports (P0–P3)
Timers Two 16-bit timer/counters (T0, T1)
Serial port One full-duplex UART
Interrupts 5 sources (2 external, 2 timer, 1 serial), 2 priority levels
Clock Typically 11.0592 MHz or 12 MHz crystal
Machine cycle 12 clock periods (1 µs at 12 MHz) in the classic core

Memory Organisation

  • Register banks: 4 banks of R0–R7 at addresses 00H–1FH.

  • Bit-addressable area: 20H–2FH (128 individually addressable bits).

  • General-purpose RAM: 30H–7FH.

  • Special function registers (SFRs): 80H–FFH, e.g. accumulator (A), B, PSW, SP, DPTR, P0–P3, TMOD, TCON, SCON, SBUF, IE, IP.

Port Notes

  • P0: open-drain, needs external pull-ups; also multiplexed address/data bus for external memory.

  • P2: upper address byte for external memory.

  • P3: alternate functions (RXD, TXD, INT0, INT1, T0, T1, WR, RD).

Worked Example: Baud Rate

Answer: TH1 = 0xFD gives 9,600 baud with an 11.0592 MHz crystal (Timer 1, mode 2, SMOD = 0).

Baud = f_osc / (12 × 32 × (256 − TH1)) = 11,059,200 / (384 × 3) = 9,600.

The 11.0592 MHz crystal is chosen because it divides exactly into standard baud rates.

Embedded C Example (Keil C51)

#include <reg51.h>

void delay_ms(unsigned int ms) {
    unsigned int i, j;
    for (i = 0; i < ms; i++)
        for (j = 0; j < 120; j++);     /* about 1 ms at 12 MHz (approximate) */
}

void main(void) {
    while (1) {
        P1 = 0x00;      /* LEDs on port 1 on (active low) */
        delay_ms(500);
        P1 = 0xFF;      /* LEDs off */
        delay_ms(500);
    }
}

Industry Applications

Still found in low-cost appliances, smart meters, keyboards, remote controls, USB controllers and as cores inside other chips. For new designs, ARM Cortex-M and AVR/PIC devices are more common, but the 8051 remains a standard teaching and interview topic.

58

What is the difference between Harvard and von Neumann architecture?

In a von Neumann architecture, program instructions and data share the same memory and the same bus, so the CPU fetches them one at a time. In a Harvard architecture, instructions and data use separate memories and separate buses, so the CPU can fetch an instruction and access data at the same time, which is faster and suits real-time and DSP work.

Read full answer

Applies toElectronics engineering (computer architecture, microcontrollers)

Von Neumann Architecture

  • One memory space for both code and data.

  • One set of address and data buses.

  • Von Neumann bottleneck: instruction fetches and data accesses compete for the same bus.

  • Simpler and flexible: programs can be loaded into memory as data (and code can treat itself as data).

  • Examples: classic PCs, Intel 8085/8086, most general-purpose processors at the main-memory level.

Harvard Architecture

  • Separate program memory and data memory.

  • Separate buses allow simultaneous instruction fetch and data access.

  • Instruction and data word widths can differ (e.g. PIC16 has 14-bit instructions and 8-bit data).

  • Examples: 8051, AVR (ATmega), PIC, many DSPs.

Comparison

Aspect Von Neumann Harvard
Memory Shared for code and data Separate
Buses One Two (or more)
Simultaneous fetch and data access No Yes
Speed Limited by bus contention Higher throughput
Hardware complexity Simpler More complex
Flexibility High (self-loading programs) Code memory often read-only at runtime
Typical use General-purpose computers Microcontrollers, DSPs

Worked Example

Answer: the Harvard design finishes in about 50% of the time. A loop executes 1,000 instructions, each requiring one instruction fetch and one data access, with each memory access taking 1 cycle.

  • Von Neumann: 2 accesses per instruction over one bus → 2,000 cycles.

  • Harvard: fetch and data access in parallel → about 1,000 cycles.

Modified Harvard Architecture

Most modern processors combine both ideas:

  • ARM Cortex-M3/M4/M7: separate instruction and data buses (Harvard) but a single unified address map (von Neumann view for the programmer).

  • x86 and ARM Cortex-A: unified main memory, but separate L1 instruction and data caches, giving Harvard-like parallelism inside the CPU.

  • AVR: Harvard, but special instructions (LPM) read constants stored in Flash.

#include <avr/pgmspace.h>

const char msg[] PROGMEM = "Hello";       /* stored in Flash (program memory) */
char c = pgm_read_byte(&msg[0]);          /* special access needed on Harvard AVR */

Interview Tip

Mention the bottleneck, give one example of each (8085 vs 8051/AVR), and add that modern CPUs are “modified Harvard”, which shows awareness beyond the textbook.

59

What is the difference between RISC and CISC?

RISC (Reduced Instruction Set Computer) processors use a small set of simple, fixed-length instructions that each execute in about one clock cycle, relying on many registers and a load/store design. CISC (Complex Instruction Set Computer) processors provide many complex, variable-length instructions, some of which perform multi-step operations (including memory access) in a single instruction.

Read full answer

Applies toElectronics engineering (computer architecture)

Comparison

Aspect RISC CISC
Instruction count Small, simple set Large, complex set
Instruction length Fixed (e.g. 32-bit; 16-bit Thumb) Variable (x86: 1–15 bytes)
Cycles per instruction About 1 (pipelined) Many for complex instructions
Memory access Only load and store instructions Many instructions can access memory directly
Registers Many general-purpose (e.g. 31 in ARM64) Fewer (historically)
Control unit Hardwired Often microcoded
Code size Larger Smaller
Pipelining Easy Harder (handled by decoding into micro-ops)
Power efficiency Generally better Generally higher power
Examples ARM, RISC-V, MIPS, AVR, PIC Intel x86, AMD x86-64, Motorola 68000, 8085/8086

Example: Multiply Two Memory Values

CISC (conceptual single instruction):

MUL [mem_a], [mem_b]      ; load both, multiply, store, in one instruction

RISC (load/store, ARM-style):

LDR R0, [R4]              ; load a
LDR R1, [R5]              ; load b
MUL R2, R0, R1            ; multiply registers
STR R2, [R4]              ; store result

The RISC version uses more instructions, but each is simple and pipelines efficiently.

Performance Equation

Execution time = Instruction count × CPI × Clock period

  • CISC reduces instruction count.

  • RISC reduces CPI and allows higher clock rates.

Worked example: a CISC program runs 1 million instructions at CPI 4 and 2 GHz → 2 ms. A RISC program needs 1.6 million instructions at CPI 1.2 and 2 GHz → 0.96 ms, about 2.1× faster.

Modern Reality

  • Modern x86 processors decode complex instructions into RISC-like micro-operations internally.

  • ARM processors added more complex instructions (SIMD/NEON, crypto).

  • The line has blurred; the key differences today are in the instruction encoding, ecosystem and power efficiency.

Industry Applications

ARM (RISC) dominates phones, tablets, embedded systems and increasingly laptops and servers (Apple M-series, AWS Graviton). x86 (CISC) dominates desktop PCs and many servers. RISC-V, an open ISA, is growing in microcontrollers, storage controllers and custom accelerators.

60

What is an interrupt, and what is an ISR?

An interrupt is a signal that makes a processor pause its current program to handle an urgent event, such as a timer overflow, received data or a button press. The code that runs in response is the ISR (interrupt service routine); after it finishes, the processor resumes the interrupted program exactly where it left off.

Read full answer

Applies toElectronics engineering (microcontrollers, embedded C)

What Happens During an Interrupt

  1. A peripheral sets its interrupt flag.

  2. If the interrupt is enabled (and global interrupts are enabled), the CPU finishes the current instruction.

  3. It saves the program counter (and on many cores, some registers) on the stack.

  4. It looks up the ISR address in the interrupt vector table and jumps there.

  5. The ISR runs, clears the flag if needed, and returns with a return-from-interrupt instruction.

  6. The saved context is restored and the main program continues.

Interrupts vs Polling

Aspect Polling Interrupts
How events are detected CPU repeatedly checks a flag Hardware signals the CPU
CPU usage Wastes cycles checking CPU free until the event
Response time Depends on the loop period Fast and predictable
Power CPU must stay awake CPU can sleep until woken
Complexity Simple Needs care with shared data

Types

  • Hardware (external pins, timers, UART, ADC) and software (trap or system-call instructions).

  • Maskable (can be disabled) and non-maskable (NMI, for critical faults).

  • Vectored (fixed ISR address) and non-vectored.

  • Edge-triggered and level-triggered.

  • Priority and nesting: ARM Cortex-M’s NVIC supports programmable priorities and nested interrupts.

Embedded C Example (AVR)

#include <avr/io.h>
#include <avr/interrupt.h>

volatile uint8_t button_pressed = 0;     /* shared with ISR: must be volatile */

ISR(INT0_vect) {                          /* runs on falling edge of INT0 */
    button_pressed = 1;                   /* keep the ISR short: just set a flag */
}

int main(void) {
    EICRA = (1 << ISC01);                 /* INT0 on falling edge */
    EIMSK = (1 << INT0);                  /* enable INT0 */
    sei();                                /* enable global interrupts */
    while (1) {
        if (button_pressed) {
            button_pressed = 0;
            /* handle the event in the main loop */
        }
    }
}

Interrupt Latency: Worked Example

Answer: 0.75 µs. An ARM Cortex-M4 at 16 MHz has a 12-cycle interrupt entry latency.

Latency = 12 / 16 MHz = 0.75 µs (before the first ISR instruction runs). At 168 MHz it falls to about 71 ns.

ISR Best Practices

  • Keep ISRs short; defer heavy work to the main loop or an RTOS task.

  • Declare shared variables volatile and protect multi-byte shared data (disable interrupts briefly or use atomic access).

  • Do not call blocking functions (delays, printf) inside ISRs.

  • Clear interrupt flags correctly to avoid repeated triggering.

61

What are UART, SPI and I2C communication protocols?

UART, SPI and I2C are the three most common serial protocols for communication between microcontrollers, sensors and other chips. UART is asynchronous, point-to-point and needs no clock line; SPI is a fast synchronous bus with a master clock and a separate chip-select per device; I2C is a two-wire synchronous bus where many devices share the same lines and are selected by address.

Read full answer

Applies toElectronics engineering (embedded systems and interfacing)

UART (Universal Asynchronous Receiver-Transmitter)

  • Lines: TX, RX (plus ground); optional RTS/CTS flow control.

  • No shared clock: both sides agree on a baud rate (e.g. 9,600 or 115,200).

  • Frame: 1 start bit (low), 5–9 data bits (LSB first), optional parity, 1–2 stop bits (high).

  • Point-to-point (two devices).

  • Used with RS-232, RS-485 or USB-to-serial converters.

SPI (Serial Peripheral Interface)

  • Lines: SCLK (clock), MOSI (master out, slave in), MISO (master in, slave out), CS/SS (chip select, one per slave). Newer naming uses controller/peripheral (COPI, CIPO).

  • Full-duplex: data moves in both directions at once.

  • Speeds of tens of MHz.

  • Four modes set by clock polarity and phase (CPOL, CPHA).

  • No addressing or acknowledgement.

I2C (Inter-Integrated Circuit)

  • Lines: SDA (data) and SCL (clock), both open-drain with pull-up resistors.

  • Multi-master, multi-slave; each device has a 7-bit (or 10-bit) address.

  • Speeds: 100 kHz (standard), 400 kHz (fast), 1 MHz (fast-mode plus), 3.4 MHz (high-speed).

  • Half-duplex; each byte is acknowledged (ACK/NACK).

  • Frame: START, address + R/W bit, ACK, data bytes with ACKs, STOP.

Comparison

Aspect UART SPI I2C
Wires (excluding ground) 2 4 (+1 CS per extra slave) 2
Clock None (asynchronous) Shared (master) Shared (master)
Duplex Full Full Half
Devices 2 1 master, many slaves Many masters and slaves
Addressing None Chip select lines 7- or 10-bit address
Speed Up to a few Mbps Tens of MHz 100 kHz to 3.4 MHz
Acknowledgement No No Yes
Typical devices GPS, Bluetooth/Wi-Fi modules, debug consoles SD cards, displays, Flash, fast ADCs Sensors, EEPROMs, RTCs, PMICs

Worked Example: UART Throughput

Answer: 11,520 bytes per second. At 115,200 baud with 8N1 framing (1 start + 8 data + 1 stop = 10 bits per byte): 115,200 / 10 = 11,520 bytes/s.

Industry Applications

UART for debug consoles and modules, SPI for displays, SD cards, external Flash and high-speed ADCs, and I2C for sensors, EEPROMs, real-time clocks and power-management ICs on phones and boards.

62

What is the difference between I2C and SPI?

I2C uses just two shared wires (SDA and SCL) and selects devices by address, making it ideal for connecting many low-speed devices with minimal wiring. SPI uses four or more wires (SCLK, MOSI, MISO and a chip-select per device), runs much faster, and is full-duplex, making it better for high-speed data such as displays, SD cards and Flash memory.

Read full answer

Applies toElectronics engineering (embedded systems and interfacing)

Comparison

Aspect I2C SPI
Wires 2 (SDA, SCL) 4 + 1 CS per additional device
Device selection 7-bit/10-bit address in each message Dedicated chip-select line
Speed 100 kHz, 400 kHz, 1 MHz, 3.4 MHz Typically 1–50 MHz or more
Duplex Half-duplex Full-duplex
Acknowledgement ACK/NACK per byte None (no built-in error checking)
Multi-master Supported (with arbitration) Not standard
Electrical Open-drain, needs pull-ups Push-pull, no pull-ups
Clock stretching Slaves can hold SCL low No
Overhead Start, address, ACK, stop bits Minimal
Bus length Short (limited by capacitance, max 400 pF) Short (board level)
Power Pull-up resistors consume current when low Lower at high speeds

Worked Example: Effective Data Rate

Answer: I2C delivers about 44 KB/s at 400 kHz, while SPI at 10 MHz delivers about 1.25 MB/s.

  • I2C at 400 kHz: each byte takes 9 clock cycles (8 data + ACK) → about 44,400 bytes/s, minus address and start/stop overhead.

  • SPI at 10 MHz: 8 clocks per byte → 1.25 MB/s with almost no overhead.

So SPI is roughly 28 times faster in this comparison.

Pull-Up Resistor Sizing (I2C)

Rise time t_r ≈ 0.847 × R_p × C_bus. For fast mode (t_r ≤ 300 ns) with C_bus = 100 pF: R_p ≤ 300 ns / (0.847 × 100 pF) ≈ 3.5 kΩ. Typical values are 2.2 kΩ to 4.7 kΩ at 3.3 V.

When to Choose Which

Choose I2C when: - Many sensors or peripherals must share few pins. - Data rates are low (temperature, humidity, IMU at moderate rates, EEPROM, RTC). - Board space and wiring are limited.

Choose SPI when: - High throughput is needed (TFT displays, SD cards, external Flash, high-speed ADCs/DACs). - Full-duplex transfer is useful. - Deterministic timing matters.

Embedded C Example (STM32 HAL, I2C Read)

uint8_t reg = 0x75;                 /* WHO_AM_I register of an IMU */
uint8_t id;
HAL_I2C_Mem_Read(&hi2c1, 0x68 << 1, reg, I2C_MEMADD_SIZE_8BIT, &id, 1, 100);
/* id should be the device identity value if the sensor responds */

Common Problems

  • I2C: missing or wrong pull-ups, address conflicts, bus hang (a slave holding SDA low; fix by clocking SCL nine times).

  • SPI: wrong mode (CPOL/CPHA), chip-select timing, long wires causing signal-integrity issues at high clock rates.

63

What is PWM, and where is it used?

PWM (pulse-width modulation) is a technique that controls the average power delivered to a load by switching a signal fully on and off at a fixed frequency and varying the fraction of each period it stays on, called the duty cycle. Because the switch is either fully on or fully off, very little power is wasted, making PWM the standard way to control motors, LEDs and power converters.

Read full answer

Applies toElectronics engineering (embedded systems and power electronics)

Key Formulas

  • Duty cycle D = t_on / T × 100%

  • Average voltage V_avg = D × V_high

  • Frequency f = 1 / T

Worked Example 1

Answer: 3 V average. A 5 V PWM signal at 60% duty cycle: V_avg = 0.6 × 5 = 3 V.

Worked Example 2: Timer Configuration

Answer: TOP = 799 for 20 kHz. A microcontroller timer runs at 16 MHz with no prescaler; find the TOP value for 20 kHz PWM and the compare value for 25% duty.

  • TOP = f_clk / f_PWM − 1 = 16,000,000 / 20,000 − 1 = 799

  • Compare = 0.25 × 800 = 200

  • Resolution = log₂(800) ≈ 9.6 bits

Embedded C Example (AVR Fast PWM on Timer1)

#include <avr/io.h>

void pwm_init(void) {
    DDRB  |= (1 << PB1);                                  /* OC1A pin as output */
    TCCR1A = (1 << COM1A1) | (1 << WGM11);                /* non-inverting, fast PWM */
    TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);   /* mode 14, no prescaler */
    ICR1   = 799;                                         /* TOP: 20 kHz at 16 MHz */
    OCR1A  = 200;                                         /* 25% duty cycle */
}

Choosing the PWM Frequency

Application Typical frequency Reason
LED dimming 200 Hz to a few kHz (higher for cameras) Above visible flicker
DC motor control 15–25 kHz Above audible range, inductance smooths current
Hobby servo 50 Hz (1–2 ms pulses) Servo standard
Switching regulators 100 kHz to several MHz Smaller inductors and capacitors
Class-D audio 300 kHz to over 1 MHz Well above audio band

Applications

  • Motor speed control with H-bridges.

  • LED brightness control.

  • DC-DC converters and inverters (buck, boost, motor drives).

  • Servo position control.

  • Simple DAC: PWM plus an RC low-pass filter gives an analog voltage. Filter cut-off should be well below the PWM frequency; for 20 kHz PWM, R = 10 kΩ and C = 1 µF give f_c ≈ 16 Hz with very low ripple.

  • Audio generation and heating control.

Why Efficient

When the switch is ON the voltage across it is near zero, and when OFF the current is zero, so P = V·I in the switch stays small. Losses occur mainly during transitions, which is why switching frequency is a trade-off between component size and switching loss.

64

What is a watchdog timer?

A watchdog timer (WDT) is a hardware timer that automatically resets a microcontroller if the software stops working correctly. The program must periodically restart (“kick”, “feed” or “pet”) the watchdog before it times out; if the code hangs in an infinite loop, crashes or deadlocks, the watchdog expires and resets the system, recovering it without human help.

Read full answer

Applies toElectronics engineering (embedded systems)

How It Works

  1. The watchdog counts down (or up) from a set timeout, using an independent clock in good designs.

  2. Normal firmware resets the counter at safe points in its main loop.

  3. If the counter reaches zero, the watchdog triggers a system reset (or first an interrupt, then a reset).

  4. After reset, the firmware can check a reset-cause register to know the watchdog fired, and log the event.

Types

Type Description
Internal watchdog Built into the MCU (e.g. AVR WDT, STM32 IWDG)
Independent watchdog Runs from a separate low-speed oscillator, so it works even if the main clock fails
Window watchdog Must be refreshed within a time window, not too early or too late (STM32 WWDG); catches code running too fast or looping wrongly
External watchdog IC Separate chip (e.g. TPS3823, MAX6369) for higher safety

Embedded C Example (AVR)

#include <avr/io.h>
#include <avr/wdt.h>

int main(void) {
    MCUSR &= ~(1 << WDRF);       /* clear watchdog reset flag */
    wdt_enable(WDTO_1S);         /* reset if not fed within about 1 second */

    while (1) {
        read_sensors();
        update_outputs();
        wdt_reset();             /* feed the watchdog once per healthy loop */
    }
}

Choosing the Timeout: Worked Example

Answer: about 500 ms. A main loop normally takes 50 ms, and occasionally up to 200 ms when writing to Flash.

Choose a timeout comfortably above the worst-case healthy loop time (with margin, e.g. 2–2.5×), so 500 ms. Too short causes false resets; too long delays recovery. A device that hangs will then be back in service within about half a second plus boot time.

Best Practices

  • Feed the watchdog in one place in the main loop, not inside ISRs or timer callbacks (which may keep running while the main code is stuck).

  • In an RTOS, feed it only when all critical tasks have reported progress (a supervisory task checks each task’s heartbeat).

  • Enable the watchdog early in start-up.

  • Don’t disable it in production code; use a debug configuration if needed.

  • Record the reset cause so field failures can be diagnosed.

Industry Applications

Automotive ECUs, medical devices, industrial controllers, remote IoT sensors, routers, satellites and any system that must recover on its own. Safety standards such as IEC 61508 and ISO 26262 expect watchdog supervision.

65

What is button debouncing, and how is it done in hardware and software?

Debouncing removes the rapid, unwanted on-off transitions (“bounce”) that occur when a mechanical push button or switch is pressed or released. The metal contacts physically bounce for a few milliseconds, so a microcontroller can read one press as many. Debouncing makes the system register exactly one clean transition per press, using either hardware filtering or software timing.

Read full answer

Applies toElectronics engineering (embedded systems and interfacing)

Why Bounce Happens

When contacts close, they hit and rebound several times before settling. Bounce typically lasts 1–10 ms (sometimes up to 20 ms for worn switches). A microcontroller sampling at microsecond speed sees a burst of pulses.

Hardware Debouncing

1. RC filter with a Schmitt trigger - A resistor and capacitor slow the edges; a Schmitt-trigger input (e.g. 74HC14) converts the slow edge into one clean transition using hysteresis. - Time constant: τ = R·C, chosen longer than the bounce time.

Worked example: answer τ = 10 ms. With R = 10 kΩ and C = 1 µF: τ = 10,000 × 1 × 10⁻⁶ = 10 ms, enough to cover typical bounce.

2. SR latch debouncer: an SPDT switch drives the set and reset inputs of an SR latch (e.g. two cross-coupled NAND gates); the first contact sets the latch, and bounces do not change it.

3. Dedicated ICs such as the MAX6816/MAX6817.

Software Debouncing

  • Delay method: on detecting a change, wait about 20 ms and read again; accept the change only if it is still present.

  • Sampling/counter method: read the pin at fixed intervals (e.g. every 5 ms from a timer interrupt) and accept a new state only after N consistent readings.

  • Shift-register method: shift each sample into a byte; the state is stable when the byte is 0x00 or 0xFF.

Embedded C Example (Timer-Based)

#include <stdint.h>
#include <stdbool.h>

#define STABLE_COUNT 4                 /* 4 samples x 5 ms = 20 ms */

static uint8_t count = 0;
static bool stable_state = false;      /* debounced state: true = pressed */

/* Call every 5 ms from a timer ISR or scheduler; raw = current pin reading */
bool debounce_update(bool raw) {
    if (raw != stable_state) {
        if (++count >= STABLE_COUNT) { /* new state held long enough */
            stable_state = raw;
            count = 0;
            return true;               /* report a clean edge */
        }
    } else {
        count = 0;                     /* bounce: reset the counter */
    }
    return false;
}

Hardware vs Software

Aspect Hardware Software
Extra parts Resistor, capacitor, Schmitt trigger or latch None
CPU load None Small (periodic sampling)
Flexibility Fixed timing Easy to tune
Cost Slightly higher Free
Typical use Interrupt inputs, noisy environments Most microcontroller projects

Many designs combine a small RC filter (for noise and ESD) with software debouncing.

66

What is embedded C, and how is it different from regular C?

Embedded C is the C language as used to program microcontrollers and other embedded hardware: standard C plus compiler extensions, hardware-specific headers and coding practices for direct register access, interrupts, fixed-point arithmetic and limited memory. Regular C targets general-purpose computers with an operating system, while embedded C usually runs on bare metal or an RTOS and controls hardware directly.

Read full answer

Applies toElectronics engineering (embedded systems, C99/C11 on microcontrollers)

Key Differences

Aspect Regular C (desktop) Embedded C
Target PC/server with an OS Microcontroller, often no OS
Program end main returns to the OS main never returns (infinite loop)
Hardware access Through OS drivers Direct register access via pointers/macros
Memory GBs, virtual memory KBs of RAM and Flash
I/O Files, printf, console GPIO, timers, ADC, UART registers
Libraries Full standard library Reduced library; avoid malloc, heavy printf
Timing Not critical Often real-time
Compiler Native (gcc, clang, MSVC) Cross-compiler (arm-none-eabi-gcc, avr-gcc, Keil, IAR)
Extensions Rare interrupt keywords, memory qualifiers (PROGMEM, code, xdata), intrinsics
Debugging Debugger, prints JTAG/SWD, logic analyser, LEDs

Typical Embedded C Features

  • Bit manipulation on registers:

  • Set: REG |= (1 << n);

  • Clear: REG &= ~(1 << n);

  • Toggle: REG ^= (1 << n);

  • Test: if (REG & (1 << n))

  • volatile for hardware registers and variables shared with ISRs.

  • Fixed-width types from <stdint.h> (uint8_t, int16_t, uint32_t) so sizes are exact.

  • ISRs declared with compiler-specific syntax.

  • const data placed in Flash to save RAM.

Example: Blink an LED (Bare Metal)

#include <stdint.h>

#define GPIOA_ODR (*(volatile uint32_t *)0x40020014u)  /* example output register address */

static void delay(volatile uint32_t n) { while (n--) { } }

int main(void) {
    /* clock and pin-mode setup omitted for brevity */
    while (1) {                       /* embedded main never returns */
        GPIOA_ODR ^= (1u << 5);       /* toggle PA5 */
        delay(500000);
    }
}

Good Practices

  • Avoid dynamic memory allocation (fragmentation, unpredictable timing).

  • Keep ISRs short; use flags or queues.

  • Follow coding standards such as MISRA C for safety-critical code (automotive, medical).

  • Use integer or fixed-point maths on MCUs without an FPU.

  • Check stack usage; small RAM makes stack overflow a common bug.

Industry Applications

Firmware for appliances, automotive ECUs, IoT sensors, wearables, motor controllers, medical devices and industrial equipment. C remains the dominant embedded language, with C++ and Rust growing.

67

What does the volatile keyword mean in embedded C?

The volatile keyword tells the C compiler that a variable’s value can change at any time outside the normal program flow, for example by hardware, an interrupt service routine or another thread. The compiler must therefore read it from memory every time it is used and write it every time it is assigned, rather than keeping a cached copy in a register or optimising the access away.

Read full answer

Applies toElectronics engineering (embedded C)

Why It Is Needed

Optimising compilers assume that only the code they can see changes a variable. Without volatile:

  • A loop waiting on a flag set by an ISR may read it once and loop forever.

  • Repeated writes to a hardware register may be merged or removed.

  • Reads of a status register may be moved or skipped.

When to Use volatile

  1. Memory-mapped hardware registers (GPIO, timer, UART status).

  2. Global variables shared between an ISR and the main code.

  3. Variables shared between RTOS tasks or threads (together with proper synchronisation).

  4. Delay loop counters you do not want optimised away.

Example: Bug Without volatile

uint8_t data_ready = 0;            /* BUG: missing volatile */

ISR(USART_RX_vect) {
    data_ready = 1;                /* set by interrupt */
}

int main(void) {
    while (!data_ready) { }        /* compiler may read once and loop forever */
    process();
}

With optimisation enabled, the compiler sees nothing in the loop changing data_ready, so it can turn this into an infinite loop. Declaring volatile uint8_t data_ready = 0; fixes it.

Example: Hardware Register

#define UART_STATUS (*(volatile uint32_t *)0x40011000u)
#define TX_READY    (1u << 7)

while (!(UART_STATUS & TX_READY)) { }   /* re-reads the register every iteration */

What volatile Does Not Do

  • It does not make operations atomic. On an 8-bit MCU, reading a 16-bit or 32-bit volatile variable takes several instructions, and an ISR can change it halfway. Protect it by disabling interrupts briefly or using atomic blocks:

#include <util/atomic.h>
volatile uint32_t ticks;

uint32_t get_ticks(void) {
    uint32_t t;
    ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { t = ticks; }   /* safe multi-byte read */
    return t;
}
  • It does not provide memory ordering between CPU cores; use proper synchronisation primitives (mutexes, atomics, memory barriers) for multi-core and RTOS code.

Related: const volatile

const volatile is valid: for example, a read-only status register that the program must not write but whose value can change at any time.

Interview Tip

Give the three standard cases (hardware registers, ISR-shared variables, multi-threaded shared variables) and add that volatile does not guarantee atomicity. That distinction is what interviewers look for.

68

What is an RTOS (real-time operating system)?

An RTOS (real-time operating system) is a lightweight operating system for embedded devices that guarantees tasks respond within predictable time limits (deadlines). It schedules multiple tasks by priority, and provides services such as timing, inter-task communication and synchronisation, so complex firmware can be split into independent tasks without a big super-loop.

Read full answer

Applies toElectronics engineering (embedded systems; FreeRTOS, Zephyr, ThreadX)

Key Concepts

  • Task (thread): an independent function with its own stack and priority.

  • Scheduler: decides which ready task runs. Most RTOSs use preemptive priority scheduling: the highest-priority ready task always runs, and equal-priority tasks can share time (round-robin).

  • Tick: a periodic timer interrupt (e.g. 1 ms) that drives time delays and timeouts.

  • Task states: running, ready, blocked (waiting for time or an event), suspended.

  • Context switch: saving one task’s registers and restoring another’s.

Communication and Synchronisation

Mechanism Purpose
Queue Pass data between tasks or from ISRs to tasks
Semaphore (binary/counting) Signal events, count resources
Mutex Protect shared resources; supports priority inheritance
Event groups / flags Wait for combinations of events
Software timers Run callbacks after delays

Hard vs Soft Real-Time

  • Hard real-time: missing a deadline is a failure (airbag deployment, engine control, pacemakers).

  • Soft real-time: occasional misses are tolerable (video streaming, user interfaces).

Example (FreeRTOS)

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

static QueueHandle_t temp_queue;

static void sensor_task(void *arg) {
    for (;;) {
        int16_t t = read_temperature();          /* application function */
        xQueueSend(temp_queue, &t, 0);
        vTaskDelay(pdMS_TO_TICKS(100));          /* run every 100 ms */
    }
}

static void display_task(void *arg) {
    int16_t t;
    for (;;) {
        if (xQueueReceive(temp_queue, &t, portMAX_DELAY) == pdTRUE)
            show_temperature(t);                  /* blocks until data arrives */
    }
}

int main(void) {
    temp_queue = xQueueCreate(8, sizeof(int16_t));
    xTaskCreate(sensor_task,  "sensor",  256, NULL, 2, NULL);
    xTaskCreate(display_task, "display", 256, NULL, 1, NULL);
    vTaskStartScheduler();                        /* never returns */
    for (;;) { }
}

RTOS vs Super-Loop vs General-Purpose OS

Aspect Super-loop (bare metal) RTOS General-purpose OS (Linux)
Determinism Depends on loop length High Lower (unless real-time patches)
Complexity Simple Moderate High
Memory Smallest KBs MBs to GBs
Multitasking Manual Built-in, preemptive Built-in

Common Pitfalls

  • Priority inversion: a low-priority task holds a mutex needed by a high-priority task; fixed with priority inheritance (famously affected NASA’s Mars Pathfinder in 1997).

  • Stack overflow in tasks; deadlocks; calling non-ISR-safe APIs from interrupts.

Industry Applications

FreeRTOS (and Amazon FreeRTOS), Zephyr, Azure RTOS ThreadX, VxWorks, QNX and RTEMS run in IoT devices, automotive systems, medical equipment, drones, industrial controllers and aerospace.

69

What is modulation, and why is it needed?

Modulation is the process of varying a property of a high-frequency carrier wave (its amplitude, frequency or phase) according to the information signal (the message). It is needed because baseband signals such as voice cannot be transmitted efficiently over long distances by radio, and because modulation lets many signals share the spectrum on different carrier frequencies.

Read full answer

Applies toElectronics engineering (communication systems)

Why Modulation Is Needed

  1. Practical antenna size: an efficient antenna is about λ/4 long. For a 3 kHz voice signal, λ = c / f = 3 × 10⁸ / 3,000 = 100 km, so λ/4 = 25 km, which is impossible. At a 100 MHz carrier, λ/4 = 0.75 m.

  2. Multiplexing: different stations use different carrier frequencies (frequency-division multiplexing), so signals don’t interfere.

  3. Range and propagation: high-frequency signals propagate better through the atmosphere and can be directed.

  4. Noise and interference reduction: FM and digital schemes trade bandwidth for better noise immunity.

  5. Matching the channel: shifts the signal into the frequency band the channel (cable, fibre, radio) supports.

Worked Example

Answer: 0.75 m antenna at 100 MHz versus 25 km at 3 kHz.

  • At 3 kHz: λ = 3 × 10⁸ / 3 × 10³ = 10⁵ m → λ/4 = 25 km

  • At 100 MHz: λ = 3 × 10⁸ / 10⁸ = 3 m → λ/4 = 0.75 m

Types of Modulation

Category Analog message Digital message
Amplitude AM, DSB-SC, SSB, VSB ASK, OOK
Frequency FM FSK, GFSK (Bluetooth)
Phase PM PSK, BPSK, QPSK
Amplitude + phase — QAM (16, 64, 256, 1024-QAM)
Pulse PAM, PWM, PPM, PCM —

Basic AM Example

Carrier: c(t) = A_c cos(2πf_c t). Message: m(t) = A_m cos(2πf_m t).

AM signal: s(t) = A_c[1 + μ cos(2πf_m t)] cos(2πf_c t), with modulation index μ = A_m / A_c.

It contains the carrier f_c and sidebands at f_c ± f_m, so the bandwidth is 2f_m.

Demodulation

The receiver recovers the message by reversing the process: envelope detection (AM), discriminators or PLLs (FM), and coherent detection with carrier recovery (PSK, QAM).

Industry Applications

AM and FM broadcasting, TV, Wi-Fi (OFDM with up to 4096-QAM in Wi-Fi 7), 4G/5G cellular (QPSK to 256-QAM and beyond), satellite links, Bluetooth (GFSK and PSK), RFID and cable modems.

70

What is the difference between AM, FM and PM?

AM (amplitude modulation) varies the carrier’s amplitude with the message, FM (frequency modulation) varies the carrier’s frequency, and PM (phase modulation) varies the carrier’s phase. FM and PM are both forms of angle modulation and have a constant amplitude, which makes them more resistant to noise than AM, at the cost of more bandwidth.

Read full answer

Applies toElectronics engineering (communication systems)

Equations

For carrier A_c cos(2πf_c t) and message m(t):

  • AM: s(t) = A_c[1 + k_a·m(t)] cos(2πf_c t)

  • FM: s(t) = A_c cos(2πf_c t + 2πk_f ∫m(t) dt) (instantaneous frequency = f_c + k_f·m(t))

  • PM: s(t) = A_c cos(2πf_c t + k_p·m(t))

FM and PM are closely related: FM of m(t) is PM of the integral of m(t).

Bandwidth

  • AM: B = 2f_m.

  • FM (Carson’s rule): B ≈ 2(Δf + f_m), where Δf is peak frequency deviation; modulation index β = Δf / f_m.

Worked Example

Answer: AM needs 10 kHz; FM needs 180 kHz. Message bandwidth f_m = 5 kHz (AM) and 15 kHz (FM audio), FM deviation 75 kHz.

  • AM: B = 2 × 5 kHz = 10 kHz (AM broadcast channel spacing is 9 or 10 kHz).

  • FM: B ≈ 2 × (75 + 15) = 180 kHz (FM broadcast uses 200 kHz channels). β = 75/15 = 5.

Comparison

Aspect AM FM PM
Parameter varied Amplitude Frequency Phase
Amplitude of signal Varies Constant Constant
Bandwidth Narrow (2f_m) Wide Wide
Noise immunity Poor (noise adds to amplitude) Good (limiter removes amplitude noise) Good
Power efficiency Low (most power in carrier) High (constant envelope) High
Transmitter amplifier Must be linear Can be non-linear (efficient Class C) Can be non-linear
Receiver Simple (envelope detector) More complex (discriminator, PLL) Coherent detection
Range Long (ionospheric skywave at MF/HF) Line of sight at VHF Mostly used in digital form
Applications MW/SW radio, aviation voice FM radio, two-way radio, analog TV sound Basis of PSK in digital communications

AM Power

With modulation index μ: P_total = P_c(1 + μ²/2). At μ = 1, only one-third of the power is in the sidebands carrying information, which is why AM is inefficient. Variants such as DSB-SC and SSB save power and bandwidth.

Industry Applications

AM: medium-wave broadcasting and aircraft VHF voice (AM avoids capture effect, so overlapping transmissions are both heard). FM: broadcast radio, walkie-talkies. PM: in digital form (BPSK, QPSK and QAM), the basis of Wi-Fi, cellular and satellite communication.

71

What are ASK, FSK and PSK modulation?

ASK (amplitude-shift keying), FSK (frequency-shift keying) and PSK (phase-shift keying) are digital modulation schemes that represent binary data by switching the carrier’s amplitude, frequency or phase respectively between discrete values. They are the digital equivalents of AM, FM and PM.

Read full answer

Applies toElectronics engineering (digital communication)

ASK

  • Bit 1 → carrier present (or high amplitude); bit 0 → carrier absent (or low amplitude).

  • Simplest form: on-off keying (OOK).

  • Simple and cheap, but very sensitive to noise and fading.

  • Bandwidth ≈ 2 × bit rate (for rectangular pulses, first-null bandwidth).

  • Uses: optical fibre (light on/off), 433 MHz remote controls, RFID.

FSK

  • Bit 1 → frequency f1; bit 0 → frequency f2.

  • Constant amplitude, so robust to amplitude noise and non-linear amplifiers.

  • Bandwidth ≈ |f1 − f2| + 2 × bit rate.

  • Variants: MSK, GFSK (Gaussian-filtered, used in Bluetooth Classic and BLE).

  • Uses: Bluetooth, LoRa-like low-power links (LoRa itself uses chirp spread spectrum), old modems, caller ID, pagers.

PSK

  • BPSK: bit 1 → 0° phase, bit 0 → 180° phase.

  • QPSK: 4 phases (45°, 135°, 225°, 315°), 2 bits per symbol, doubling data rate in the same bandwidth.

  • Best noise performance of the three for a given power.

  • Needs coherent detection (carrier phase recovery) or differential schemes (DPSK).

  • Uses: Wi-Fi, satellite, GPS (BPSK), cellular, RFID.

Comparison

Aspect ASK FSK PSK
Parameter switched Amplitude Frequency Phase
Noise immunity Poor Good Best
Bandwidth efficiency Moderate Lowest (wider) High (better still with QPSK)
Complexity Simplest Moderate Highest (phase recovery)
Bit error rate (same Eb/N0) Worst Medium Best

Worked Example

Answer: about 2 kHz of bandwidth for BPSK and 1 kHz for QPSK at 1,000 bps (null-to-null).

  • BPSK: 1 bit per symbol → symbol rate 1,000 baud → bandwidth ≈ 2 × 1,000 = 2 kHz.

  • QPSK: 2 bits per symbol → 500 baud → bandwidth ≈ 2 × 500 = 1 kHz.

Bit Error Rate

For coherent BPSK in additive white Gaussian noise: BER = Q(√(2Eb/N0)). At Eb/N0 = 9.6 dB, BER ≈ 10⁻⁵. Coherent FSK needs about 3 dB more power for the same BER, and non-coherent ASK even more.

Beyond the Basics

Modern systems combine amplitude and phase in QAM (16-QAM carries 4 bits per symbol, 256-QAM carries 8), and use OFDM to spread data over many sub-carriers (Wi-Fi, 4G, 5G).

72

What is the Nyquist sampling theorem?

The Nyquist sampling theorem (Nyquist-Shannon theorem) states that a band-limited continuous signal can be perfectly reconstructed from its samples if the sampling frequency is greater than twice its highest frequency component: f_s > 2·f_max. The minimum rate 2·f_max is called the Nyquist rate, and half the sampling rate, f_s/2, is the Nyquist frequency.

Read full answer

Applies toElectronics engineering (signals and systems, DSP)

Key Terms

  • f_max: highest frequency present in the signal.

  • Nyquist rate: 2·f_max, the minimum sampling rate needed.

  • Nyquist frequency: f_s / 2, the highest frequency that can be represented at a given sample rate.

  • Aliasing: if f_s ≤ 2·f_max, higher frequencies fold back and appear as false lower frequencies.

Why It Works

Sampling creates copies (images) of the signal’s spectrum at multiples of f_s. If f_s > 2·f_max, the copies do not overlap, and an ideal low-pass filter can recover the original spectrum exactly. If they overlap, information is lost (aliasing).

Worked Example 1

Answer: at least 40 kHz (CD audio uses 44.1 kHz). Human hearing extends to about 20 kHz.

Nyquist rate = 2 × 20 kHz = 40 kHz. CDs use 44.1 kHz, leaving a margin (2.05 kHz on each side of the Nyquist frequency) for a practical anti-aliasing filter to roll off.

Worked Example 2

Answer: 8 kHz. Telephone speech is band-limited to about 3.4 kHz.

Nyquist rate = 6.8 kHz; telephone systems sample at 8 kHz, giving 8,000 × 8 bits = 64 kbps for standard PCM voice.

Practical Considerations

  • Anti-aliasing filter: a low-pass filter before the ADC removes frequencies above f_s/2. Real filters are not ideal, so sampling is done at 2.5–10× f_max, or oversampled.

  • Oversampling: sigma-delta ADCs sample much faster than needed, which relaxes the analog filter and improves resolution.

  • Reconstruction filter: after a DAC, a low-pass filter removes the spectral images.

  • Bandpass (undersampling): a narrowband signal at a high centre frequency can be sampled below 2× its highest frequency, as long as the sampling rate is more than twice its bandwidth and chosen to avoid overlap; used in software-defined radio.

Common Sampling Rates

Application Bandwidth Sampling rate
Telephone voice 3.4 kHz 8 kHz
Wideband voice 7 kHz 16 kHz
CD audio 20 kHz 44.1 kHz
Professional audio/video 20+ kHz 48, 96, 192 kHz
ECG About 150 Hz 250–1,000 Hz

Industry Applications

Every ADC-based system: audio, sensors, software-defined radios, oscilloscopes, medical instruments and communication receivers depend on choosing the sample rate and anti-aliasing filter correctly.

73

What is aliasing in signal sampling?

Aliasing is the distortion that occurs when a signal is sampled at less than twice its highest frequency, so high-frequency components appear in the sampled data as false, lower frequencies (aliases). Once aliasing has happened, the original signal cannot be recovered, so it must be prevented before sampling with an anti-aliasing low-pass filter.

Read full answer

Applies toElectronics engineering (signals and systems, DSP)

How Aliasing Happens

  • Sampling at f_s creates spectral copies at multiples of f_s.

  • A component at frequency f above f_s/2 folds back to an alias frequency:

f_alias = |f − k·f_s|, where k is the integer that brings the result into 0 to f_s/2.

Worked Example 1

Answer: the 7 kHz tone appears as 3 kHz. A 7 kHz tone is sampled at 10 kHz (Nyquist frequency 5 kHz).

f_alias = |7 − 1 × 10| = 3 kHz. The digital system cannot distinguish it from a real 3 kHz tone.

Worked Example 2

Answer: 50 Hz appears as 0 Hz (DC). A 50 Hz mains interference is sampled at exactly 50 Hz: f_alias = |50 − 50| = 0 Hz, so the interference shows up as a constant offset. If sampled at 49 Hz, it appears as a slow 1 Hz wobble.

Visual Examples

  • Wagon-wheel effect: in films (24 frames/s), spinning wheels appear to rotate slowly or backwards.

  • Moiré patterns: fine stripes photographed by a digital camera create false patterns because the sensor samples too coarsely.

  • Strobe effect: a fan under fluorescent or LED lighting appears to stand still.

Preventing Aliasing

  1. Anti-aliasing filter: an analog low-pass filter before the ADC removes components above f_s/2. In practice the cut-off is set below f_s/2 because real filters roll off gradually.

  2. Higher sampling rate (oversampling): gives more room between the signal band and f_s/2, so a simpler filter suffices. Sigma-delta ADCs use high oversampling plus digital filtering.

  3. Band-limiting the signal at its source.

  4. Digital decimation: when lowering the sample rate in software, apply a digital low-pass filter before discarding samples.

Filter Design Example

Sampling at 48 kHz with a 20 kHz signal band leaves a 4 kHz transition band to f_s/2 = 24 kHz. To attenuate everything above 24 kHz by 90 dB in that narrow band would need a very steep analog filter. Oversampling at 192 kHz moves the folding frequency to 96 kHz, allowing a gentle filter, followed by a sharp digital filter and decimation to 48 kHz.

Industry Applications

Audio interfaces, data acquisition systems, digital oscilloscopes (which show aliased waveforms when the sample rate is too low for the signal), vibration analysis, image sensors (optical low-pass filters) and radio receivers. In software-defined radio, controlled aliasing (undersampling) is used intentionally to down-convert signals.

74

What is the signal-to-noise ratio (SNR)?

The signal-to-noise ratio (SNR) compares the power of a wanted signal with the power of the background noise, usually expressed in decibels. A higher SNR means a cleaner signal: better audio quality, more accurate measurements and fewer bit errors in digital communication.

Read full answer

Applies toElectronics engineering (communication systems and measurement)

Formulas

  • Power ratio: SNR = P_signal / P_noise

  • In decibels: SNR(dB) = 10·log₁₀(P_signal / P_noise)

  • Using RMS voltages across the same impedance: SNR(dB) = 20·log₁₀(V_signal / V_noise)

Worked Example

Answer: 40 dB. A sensor outputs 1 V rms with 10 mV rms of noise.

SNR = 20 × log₁₀(1 / 0.01) = 20 × 2 = 40 dB (power ratio of 10,000).

If the noise rises to 100 mV rms, SNR = 20 dB (power ratio 100).

Thermal Noise

Every resistor generates thermal (Johnson-Nyquist) noise:

  • P_n = k·T·B (watts)

  • V_n(rms) = √(4·k·T·R·B)

with k = 1.38 × 10⁻²³ J/K, T in kelvin, B in Hz.

Example: a 1 kΩ resistor at 300 K over a 20 kHz bandwidth: V_n = √(4 × 1.38 × 10⁻²³ × 300 × 1,000 × 20,000) ≈ 0.58 µV rms. At room temperature, noise power density is about −174 dBm/Hz.

SNR of an Ideal ADC

SNR ≈ 6.02·N + 1.76 dB for a full-scale sine wave.

Bits Ideal SNR
8 49.9 dB
12 74.0 dB
16 98.1 dB
24 146.2 dB (real converters achieve far less)

Shannon Capacity

The maximum error-free data rate over a channel: C = B·log₂(1 + SNR) (SNR as a ratio).

Example: B = 1 MHz, SNR = 30 dB (1,000): C = 10⁶ × log₂(1,001) ≈ 9.97 Mbps.

Ways to Improve SNR

  • Increase signal level (gain early in the chain, before noisy stages).

  • Use low-noise amplifiers (LNA) at the front end; the first stage dominates overall noise figure (Friis formula).

  • Reduce bandwidth to what is necessary (filtering).

  • Shielding, twisted pairs, differential signalling and good grounding against interference.

  • Averaging repeated measurements: SNR improves by √N (10·log₁₀N dB in power), e.g. 100 averages give +20 dB.

  • Cooling sensitive detectors (thermal noise falls with temperature).

Related terms

  • SINAD: signal to noise and distortion.

  • Noise figure (NF): how much an amplifier degrades SNR.

  • Eb/N0: energy per bit to noise density, used in digital communication.

Industry Applications

Audio specifications, ADC selection, wireless link budgets (Wi-Fi and 5G choose modulation based on SNR), medical imaging and sensor design.

75

What is bandwidth in electronics and communication?

Bandwidth is the range of frequencies a signal occupies or a system can pass, measured in hertz (Hz). For an amplifier or filter, it is usually the range between the lower and upper −3 dB (half-power) frequencies. In digital communication, the word is also used informally for data rate (bits per second), which is related to, but not the same as, frequency bandwidth.

Read full answer

Applies toElectronics engineering (signals, circuits and communication)

Definitions

  • Signal bandwidth: f_high − f_low of the frequencies in a signal. Voice: about 300–3,400 Hz → 3.1 kHz.

  • System (−3 dB) bandwidth: BW = f_H − f_L, where the gain falls to 1/√2 (70.7%) of mid-band gain.

  • Channel bandwidth: the frequency range allocated to a transmission (e.g. a 20 MHz Wi-Fi channel).

  • Data rate: bits per second; depends on bandwidth and SNR (Shannon: C = B·log₂(1 + SNR)).

Key Formulas

  • First-order RC low-pass: f_c = 1 / (2πRC)

  • Resonant circuit: BW = f_0 / Q

  • Op-amp: closed-loop BW ≈ GBW / noise gain

  • Rise time and bandwidth: t_r ≈ 0.35 / BW (for a single-pole system)

  • AM bandwidth: 2·f_m; FM (Carson’s rule): 2(Δf + f_m)

Worked Examples

RC filter: answer about 1.59 kHz. R = 10 kΩ, C = 10 nF: f_c = 1 / (2π × 10⁴ × 10⁻⁸) ≈ 1.59 kHz.

Op-amp amplifier: answer 100 kHz. An op-amp with GBW = 1 MHz in a non-inverting gain-of-10 stage: BW ≈ 1 MHz / 10 = 100 kHz.

Oscilloscope: a 100 MHz scope has t_r ≈ 0.35 / 100 MHz = 3.5 ns, so it cannot accurately show edges faster than a few nanoseconds. A rule of thumb is to use a scope with 3–5 times the signal’s bandwidth.

Tuned circuit: f_0 = 10.7 MHz, Q = 50: BW = 10.7 MHz / 50 = 214 kHz.

Bandwidth vs Data Rate

Concept Unit Example
Analog bandwidth Hz 20 MHz Wi-Fi channel
Data rate bit/s Up to hundreds of Mbps in that channel with 1024-QAM and MIMO
Spectral efficiency bit/s/Hz Data rate ÷ bandwidth

Why Bandwidth Matters

  • Too little bandwidth distorts signals (rounded edges, lost detail, inter-symbol interference).

  • Too much bandwidth lets in more noise (noise power is proportional to bandwidth: P_n = kTB).

  • Spectrum is limited and licensed, so efficient use of bandwidth is a central goal in communication design.

Industry Applications

Amplifier and filter design, oscilloscope and probe selection, choosing ADC sample rates, RF channel planning (4G/5G, Wi-Fi), and network capacity planning.

76

What is the difference between analog and digital signals?

An analog signal is continuous in both time and amplitude: it can take any value within a range, like the voltage from a microphone. A digital signal is discrete: it takes only a limited set of values (usually two levels, 0 and 1) at defined time intervals. Digital signals are more robust to noise and easier to store and process, while the physical world is analog, so electronics constantly converts between the two.

Read full answer

Applies toElectronics engineering (signals and systems)

Comparison

Aspect Analog Digital
Values Continuous, infinite possible values Discrete, finite levels (e.g. 0 and 1)
Time Continuous Sampled at intervals (for digitised signals)
Representation Sine waves, voltages, currents Bits, pulses, codes
Noise Noise adds directly and accumulates Small noise is rejected by thresholds; signal can be regenerated
Storage and copying Degrades with each copy Perfect copies
Processing Analog circuits (op-amps, filters) Processors, DSP, FPGAs
Bandwidth needed Lower for the same information Higher (but compression helps)
Accuracy limit Component tolerances, noise Number of bits (quantisation)
Examples Microphone output, thermocouple voltage, AM/FM radio Computer data, USB, Wi-Fi, digital audio files

Conversion

  • ADC (analog to digital): sample, quantise, encode.

  • DAC (digital to analog): convert codes back into voltages, then smooth with a filter.

Worked Example: Quantisation

Answer: 1,024 levels, step about 4.9 mV, maximum error about ±2.4 mV. A 10-bit ADC with a 5 V reference digitises a sensor voltage.

  • Levels = 2¹⁰ = 1,024

  • Step = 5 / 1,024 ≈ 4.88 mV

  • Maximum quantisation error = ±½ step ≈ ±2.44 mV

A 2.500 V input gives code 512 (0x200).

Noise Immunity Example

For 3.3 V CMOS logic, a high input is guaranteed above about 2.0 V and a low below about 0.8 V (LVTTL-compatible thresholds). Noise of 0.3 V on a 3.3 V “1” leaves it well above 2.0 V, so the bit is read correctly. The same 0.3 V on an analog 1 V signal is a 30% error.

Mixed-Signal Systems

Most products combine both: a smartphone has analog microphones, antennas, power circuits and sensors, with ADCs and DACs feeding digital processors. Key design concerns at the boundary are anti-aliasing filters, reference voltages and separating analog and digital grounds and supplies to keep digital switching noise out of analog signals.

Industry Applications

Analog: sensor front ends, audio amplifiers, RF circuits, power electronics. Digital: computing, storage, communication protocols and control logic.

77

What is the Fourier transform used for in electronics?

The Fourier transform converts a signal from the time domain (how it changes over time) into the frequency domain (which frequencies it contains and how strong each is). Electronics engineers use it to analyse spectra, design filters, understand modulation, measure distortion and noise, and process signals digitally with the FFT.

Read full answer

Applies toElectronics engineering (signals and systems, DSP)

Definitions

  • Fourier series: a periodic signal is a sum of sine and cosine waves at the fundamental frequency and its harmonics.

  • Fourier transform (continuous): X(f) = ∫ x(t)·e^(−j2πft) dt, for non-periodic signals.

  • DFT: X[k] = Σ x[n]·e^(−j2πkn/N), for N sampled points.

  • FFT: a fast algorithm for the DFT, reducing work from N² to about N·log₂N operations.

Worked Example: Square Wave Harmonics

Answer: a square wave contains only odd harmonics with amplitudes falling as 1/n. A 1 kHz square wave of amplitude ±1 V:

x(t) = (4/π)[sin(ωt) + (1/3)sin(3ωt) + (1/5)sin(5ωt) + …]

Harmonic Frequency Amplitude
1st 1 kHz 1.27 V
3rd 3 kHz 0.42 V
5th 5 kHz 0.25 V
7th 7 kHz 0.18 V

This explains why fast digital edges cause EMI at many frequencies, and why filtering a square wave leaves a sine.

Worked Example: FFT Resolution

Answer: 10 Hz per bin. Sampling at 10.24 kHz with N = 1,024 points: frequency resolution Δf = f_s / N = 10,240 / 1,024 = 10 Hz, covering 0 to 5.12 kHz.

Uses in Electronics

  • Spectrum analysis: measuring harmonics, noise and interference with spectrum analysers or oscilloscope FFT functions.

  • Filter design: specifying and checking frequency responses.

  • Communication systems: understanding sidebands in AM/FM; OFDM (Wi-Fi, 4G, 5G, DSL) uses the IFFT/FFT to create and separate hundreds of sub-carriers.

  • Distortion measurement: THD = √(V₂² + V₃² + …) / V₁.

  • Power quality: measuring mains harmonics from non-linear loads.

  • Audio and image processing: equalisers, compression (MP3 and JPEG use related transforms: MDCT and DCT).

  • Vibration analysis and predictive maintenance.

  • Fast convolution: convolution in time equals multiplication in frequency.

Practical Points

  • Windowing (Hann, Hamming, Blackman) reduces spectral leakage when the signal is not periodic in the capture window.

  • The sampling rate must satisfy Nyquist, or aliases appear in the spectrum.

  • Related transforms: Laplace (circuit analysis and stability) and Z-transform (digital filters).

Industry Applications

Wireless modems, audio codecs, radar, medical imaging (MRI reconstruction), test and measurement instruments, and EMI compliance testing.

78

What is a sensor, and which sensors are common in embedded projects?

A sensor is a device that detects a physical quantity (such as temperature, light, motion, pressure or distance) and converts it into an electrical signal that a circuit or microcontroller can measure. Sensors give embedded systems their inputs from the real world, either as analog voltages read by an ADC or as digital data over interfaces such as I2C, SPI or UART.

Read full answer

Applies toElectronics engineering (embedded systems and instrumentation)

Sensor Characteristics

  • Range: minimum to maximum measurable value.

  • Sensitivity: output change per unit input (e.g. 10 mV/°C).

  • Resolution and accuracy.

  • Linearity, response time, drift and hysteresis.

  • Output type: analog, digital (I2C/SPI/UART/1-Wire), PWM or frequency.

Common Sensors

Quantity Sensor Output / interface Notes
Temperature LM35 Analog, 10 mV/°C Simple
Temperature DS18B20 1-Wire digital ±0.5 °C, multiple on one wire
Temperature NTC thermistor Resistance (with divider) Cheap, non-linear
Temperature + humidity DHT22, SHT31, BME280 Single-wire / I2C BME280 also measures pressure
Light LDR, BH1750, photodiode Analog / I2C Ambient light
Distance HC-SR04 ultrasonic Pulse width 2 cm to about 4 m
Distance VL53L0X time-of-flight I2C Laser, up to about 2 m
Motion PIR (HC-SR501) Digital high/low Human presence
Acceleration/rotation MPU6050, LSM6DS3 I2C/SPI 6-axis IMU
Gas MQ-2, MQ-135 Analog Needs heater and calibration
Current ACS712, INA219 Analog / I2C Hall effect / shunt
Pressure/weight Load cell + HX711 24-bit ADC Weighing scales
Position Rotary encoder Quadrature pulses Motor speed and position

Worked Example 1 (LM35)

Answer: 27 °C. An LM35 is read by a 10-bit ADC with a 5 V reference, giving code 55.

  • Voltage = 55 × 5 / 1,024 ≈ 0.2686 V

  • Temperature = 0.2686 / 0.010 ≈ 26.9 °C, about 27 °C

Worked Example 2 (HC-SR04)

The echo pulse lasts 1,166 µs. Distance = (time × speed of sound) / 2 = (1,166 × 10⁻⁶ × 343) / 2 ≈ 0.20 m.

Embedded C Example

/* LM35 on ADC channel 0 of an AVR; adc_read() returns a 10-bit result */
float read_temperature_c(void) {
    uint16_t raw = adc_read(0);
    float volts = raw * (5.0f / 1024.0f);
    return volts * 100.0f;          /* 10 mV per degree C */
}

Practical Tips

  • Use the right interface and pull-ups (I2C) and check voltage levels (3.3 V vs 5 V).

  • Filter noisy readings (moving average or median) and calibrate against a reference.

  • Place sensors away from heat sources and noise (e.g. keep temperature sensors away from regulators).

Industry Applications

Smart homes, wearables, agriculture monitoring, industrial automation, automotive (tyre pressure, airbags, ADAS) and medical devices.

79

What is a PCB, and what are the steps in PCB design?

A PCB (printed circuit board) is a board made of insulating material (usually FR-4 fibreglass) with copper tracks that mechanically support and electrically connect electronic components. PCB design turns a circuit schematic into a manufacturable board layout, through steps such as schematic capture, footprint assignment, placement, routing, design rule checks and generating fabrication files.

Read full answer

Applies toElectronics engineering (PCB design; KiCad, Altium, OrCAD/Allegro, Eagle/Fusion)

PCB Basics

  • Layers: single-sided, double-sided, and multilayer (4, 6, 8 or more layers, with internal power and ground planes).

  • Copper weight: often 1 oz/ft² (about 35 µm thick).

  • Vias: plated holes connecting layers (through-hole, blind, buried, micro-vias).

  • Solder mask: protective coating (usually green); silkscreen: labels.

  • Surface finish: HASL, ENIG (gold), OSP, immersion silver.

Design Steps

  1. Requirements: size, layer count, interfaces, power, environment, cost.

  2. Schematic capture: draw the circuit with correct symbols and nets; run electrical rule checks (ERC).

  3. Footprints: assign the physical land patterns for each component (SMD or through-hole).

  4. Board outline and stack-up: define shape, mounting holes and layer structure.

  5. Component placement: connectors at the edges, decoupling capacitors close to IC power pins, separate analog/digital/power sections, keep high-speed paths short.

  6. Routing: power and ground first (planes or wide tracks), then critical signals (clocks, high-speed, sensitive analog), then the rest. Use impedance-controlled traces where needed (e.g. 90 Ω differential for USB).

  7. Copper pours and ground planes.

  8. Design rule check (DRC): minimum track width, spacing, drill sizes, annular rings, per the manufacturer’s capabilities.

  9. Review: 3D view, silkscreen check, design review with peers.

  10. Output files: Gerbers (or ODB++/IPC-2581), drill files, bill of materials (BOM), pick-and-place (centroid) file, assembly drawings.

  11. Fabrication, assembly and testing: bring-up, debugging and revisions.

Worked Example: Track Width

Answer: about 0.5 mm (20 mil) for 1.5 A. Using IPC-2221 for an external layer, 1 oz copper, 10 °C temperature rise:

I = k·ΔT^0.44·A^0.725, with k = 0.048 for external layers and A in mil². For I = 1.5 A: A = (1.5 / (0.048 × 10^0.44))^(1/0.725) ≈ (1.5 / 0.132)^1.379 ≈ 11.36^1.379 ≈ 28.5 mil². With 1.37 mil copper thickness, width ≈ 28.5 / 1.37 ≈ 21 mil (about 0.53 mm).

Good Design Practices

  • Solid ground plane under signals; avoid splitting it under high-speed traces.

  • Place a 100 nF decoupling capacitor at each IC supply pin, plus bulk capacitors.

  • Keep switching regulator loops small to reduce EMI.

  • Avoid 90° corners on high-speed traces (use 45° or curves) mainly for manufacturability and consistency.

  • Provide test points and clear labelling.

  • Follow manufacturer limits (e.g. 0.15 mm track/space for low-cost fabrication).

Industry Applications

Every electronic product, from IoT boards and phones (HDI boards with micro-vias) to automotive and aerospace electronics, depends on good PCB design for function, reliability and EMC compliance.

80

How do you explain an electronics project you built in an interview?

To explain an electronics project in an interview, tell a short, structured story: the problem, your design (block diagram and key components), how you built and tested it, the problems you hit and how you solved them, and the measurable results. Interviewers use this question to check real hands-on understanding, so be specific about numbers, part choices and debugging.

Read full answer

Applies toElectronics engineering (interview preparation)

Structure (About 2–3 Minutes)

  1. Problem and goal: what the project does and why.

  2. Block diagram: sensors, controller, power supply, outputs, communication.

  3. Key design decisions: why you chose each main component or method.

  4. Your role: what you personally designed, coded or soldered.

  5. Testing: how you verified it (multimeter, oscilloscope, logic analyser, test cases).

  6. Problems and fixes: one or two real issues with root causes.

  7. Results: numbers (accuracy, battery life, range, response time).

  8. Improvements: what you would do next.

Example Answer

“I built a battery-powered soil-moisture monitor for a college garden. It uses an ESP32, a capacitive moisture sensor and a BME280 for temperature and humidity, and sends readings every 15 minutes over Wi-Fi to a dashboard.

Power was the main challenge. The first version drained an 18650 cell in two days because the ESP32 stayed awake and the AMS1117 regulator had high quiescent current. I switched to deep sleep between readings, replaced the regulator with a low-quiescent-current LDO (MCP1700, about 1.6 µA), and powered the sensor from a GPIO pin only during measurement. Measured sleep current fell from about 8 mA to about 25 µA, and the estimated battery life rose to around four months.

The second problem was noisy ADC readings. I added a 100 nF capacitor at the sensor output, averaged 16 samples, and calibrated the sensor in dry and wet soil, which brought the variation down to about ±2%.

I designed a two-layer PCB in KiCad and checked the supply rail and wake-up timing on an oscilloscope. Next, I would add LoRa for longer range.“

What Makes an Answer Strong

  • Numbers: currents, voltages, accuracy, data rates, battery life.

  • Reasons for choices: “I chose a MOSFET over a relay because the PWM needed 20 kHz switching.”

  • Real debugging: ground loops, brown-outs, I2C pull-ups, EMI, thermal problems, ADC noise.

  • Tools: oscilloscope, logic analyser, multimeter, KiCad/Altium, simulators (LTspice).

Questions to Prepare For

  • Why did you choose this microcontroller or sensor?

  • How did you power it, and what was the current consumption?

  • Draw the schematic of one part (e.g. the regulator or driver stage).

  • What would you change for mass production?

  • What happens if the sensor fails or the Wi-Fi drops?

Common Mistakes

  • Describing what the project does without explaining how it works.

  • Claiming team work as your own.

  • No measurements or test results.

  • Not knowing details of your own circuit (datasheet values, resistor choices).

Interview Tip

Bring the schematic, photos or a short demo video, and practise drawing the block diagram from memory.

Sign in to keep reading

You've opened 2 full answers. Sign in to read all 80 Electronics Engineering answers, mark what you know and pick up where you left off.

Report a mistake

What's wrong?

All Core Engineering subjects