The Microvolt Signal Chain

A brain signal is about 20 millionths of a volt, and the mains wiring around you can push in far more. Switch the bias drive on and watch the hum fall.

Follow one EEG signal from the electrode on the skin to a 24-bit number in firmware, and learn why every stage in between exists.

Press Bias drive to turn the fix on and off. Then drag the electrode mismatch and switch between 50 and 60 Hz mains. Then we build, piece by piece, the skin, the amplifier, the rejection and the converter that make this trace possible.

You need a feel for a sine wave (a smooth wave with a size and a frequency) and the habit of reading a datasheet. We build the rest from zero.

Part of the series Firmware from Zero to Expertise. Built from the Texas Instruments ADS1299 datasheet (SBAS499C), which has its own table of sources in the Field Guide. Every device is an honest model that runs in your browser, not real silicon. Each chapter ends with what to repeat on a real board.

Record a virtual EEG

20 kΩ

A model, not silicon. The brain signal is a made-up 10 Hz rhythm of 20 µV peak with a smaller 22 Hz part. The 1 V of mains on the body is illustrative. The amplifier numbers are the ADS1299’s: CMRR of 110 dB, 20 pF input capacitance, and a bias loop with 1 MΩ, 1.5 nF and 8 channels (datasheet Eq. 11 and Fig. 38, typical example values).

Chapter 0

Why a Brain Signal Is Hard to Catch

See how small 20 microvolts is next to everything else on the wire, and why the chain needs five separate tricks

You tape two small metal discs to a scalp. A thin wire runs from each disc to a board on your desk. You want to record the rhythm of a brain, and you expect a clean, gentle wave on your screen.

You get a thick, fast, wild line instead. It is almost a perfect sine wave, and it is not the brain. It is the building. The wires in the walls, the lamps and the chargers all push a small electric hum into your body, and your body carries it to the board.

This lesson follows the signal from the disc to a number in your code. Along the way you meet five ideas that each remove one problem. Together they let a chip hear a rhythm that is about 20 µV.

Three units, before we start

A volt (V) measures electrical push, the way pressure measures push in a water pipe. A phone charger pushes with 5 V. A millivolt (mV) is a thousandth of a volt. A microvolt (µV) is a thousandth of a millivolt, so one millionth of a volt.

An electrode is the disc: a small piece of metal (often silver coated with silver chloride) that touches the skin and turns the body’s tiny ion currents into a voltage on a wire. EEG (electroencephalography) is recording the brain’s voltage this way from the scalp. The ADS1299 datasheet, our worked part, gives its own design target: a signal of at least 10 µV peak, between 1 Hz and 50 Hz (Table 29).

An ADC (analog-to-digital converter) is the chip block that turns a voltage into a number. The number is a code. A 24-bit ADC has 16,777,216 possible codes. If you want to revisit how a smooth signal becomes samples, discrete signals covers it. If you want practice reading the part’s numbers, read the datasheet covers that. We use both ideas, and teach the small pieces we need.

Where the firmware sits

Firmware, the code on the microcontroller, sits at the end of the chain. It configures the converter, reads its codes, and trusts them. That trust is only fair if the analog stages ahead of the chip did their job. When a recording looks wrong, a firmware engineer must tell the difference between a bug in the code and hum that entered at the skin. So the engineer must know the whole chain.

The chain has five stages. The skin and electrode make a messy sensor. A differential amplifier takes the difference between two wires, so what both wires share disappears. CMRR says how well it does that. The bias drive pushes the shared hum down at its source, in the body. And a delta-sigma ADC turns what is left into 24 bits.

The ladder of sizes

Numbers on a page do not show how wide the gap is. Here is a ladder. Each rung is a size in microvolts on a log scale, where each step to the right is ten times bigger. Pick a gain and watch the rungs and the full-scale line move.

Climb the ladder of sizes

Each bar is one thing the chip must handle, in microvolts, on a log scale. The dashed line is the largest signal the converter can read at the gain you pick. Choose a gain.

From the datasheet: converter step = 2 × 4.5 V ÷ gain ÷ 224; full scale = ±4.5 V ÷ gain; noise is the peak-to-peak input-referred noise at 250 SPS (Tables 1 to 4). Illustrative: the 20 µV brain rhythm, the 127 µV of unfixed hum (Chapter 4 derives it) and a 100 mV electrode offset.

Look at the spread. At gain 24 the smallest rung is about 22 nV, and the biggest is the 100 mV offset. That is a ratio of more than four million. The brain signal sits in the middle, only 20 times above the noise. Hum, if you leave it alone, is several times bigger than the brain.

Now try gain 1. The full-scale line jumps to 4.5 V and the offset fits easily. But the amplifier noise rises to 7.59 µV peak to peak, and the brain signal looks small beside it. Gain 24 gives the opposite trade: low noise, but only ±187.5 mV of room. Choosing the gain is a real design decision, and Chapter 6 makes it.

The road

The five tricks each get a chapter, in the order the signal meets them. The last two chapters turn the ideas into registers and numbers you can use.

  1. The skin and the electrode: a sensor that is part battery, part resistor, part capacitor.
  2. Two wires, one difference: why the hum cancels when you subtract.
  3. The instrumentation amplifier and CMRR: how well it subtracts, in dB.
  4. Electrode imbalance: why a perfect amplifier still passes hum.
  5. The bias drive: pushing the hum down in the body itself.
  6. Offset, gain and headroom: the DC problem and the range of the converter.
  7. The delta-sigma ADC: trading speed for resolution.
  8. Noise, codes and microvolts: turning 24 bits back into a voltage.
  9. Bringing the chain up: the registers that set it all.
  10. The field guide: numbers, checklist and code on one page.
At gain 24, the 20 µV brain signal and a 100 mV electrode offset sit on the same input. Which statement is right?

Chapter 1

The Skin Is Part of the Circuit

Model the electrode and skin as a battery, a resistor and a capacitor, and see why they set the noise before any chip sees the signal

Two people wear the same headset. One has short hair and a drop of gel under each electrode. The other has thick, dry hair and no gel. The first recording is clean. The second one wanders up and down, and it is full of hum.

The chip, the code and the board are the same. The only difference is the thin layer between the metal and the brain’s voltage: the skin. Before we blame the amplifier, we must treat that layer as a part of the circuit, with a value we can measure.

A battery you did not order

Metal in a wet salty film forms a tiny battery. Ions in the film exchange charge with the metal, and a steady voltage builds up between them. That voltage is the half-cell potential. It does not carry any brain signal. It is a fixed DC offset that sits on the wire.

Two electrodes are never exactly equal. Their two half-cell voltages differ by some amount, and that difference rides on top of the 20 µV signal. In the Chapter 0 ladder we used 100 mV for it. That number is illustrative: real offsets depend on the metal, the gel and the skin, and they drift as the gel dries. Chapter 6 shows what the offset does to the converter.

A resistor and a capacitor

The skin layer also resists the current. Dead surface cells are poor conductors, and a thin film of gel only helps so much. The skin also stores a small charge across itself, like a capacitor. So the electrode contact acts like a resistor (R, which opposes current) with a capacitor (C, which passes fast changes more easily than slow ones) next to it.

The ADS1299 datasheet draws its electrode model this way in the lead-off figure (Fig. 35): 51 kΩ and 47 nF per electrode, plus a protection resistor. We treat the two as parallel, which is our assumption about the drawing. The total opposition to an alternating signal is the impedance (Z), measured in ohms like resistance, but it depends on frequency.

|Z|
The size of the impedance at frequency f, in ohms. It tells you how much voltage drops for each unit of current.
R
The skin resistance. We use 51 kΩ, the datasheet’s model value.
f
The frequency of the signal, in hertz. Slow signals see mostly R. Fast ones see less.
C
The skin capacitance. We use 47 nF.

At 10 Hz: 2π × 10 × 51,000 × 0.000000047 = 0.151, so |Z| = 51,000 / √(1 + 0.0227) = 50.4 kΩ. At 50 Hz: 0.753, so |Z| = 51,000 / √(1 + 0.567) = 40.7 kΩ.

So the skin is about 50 kΩ for a brain rhythm and 41 kΩ for the mains. Drag the skin resistance in the device below, from a wet gel contact to a dry one, and watch the curve and the noise.

Dry out the skin

The warm curve is the impedance size against frequency (log scale on both axes). The teal tick is a 10 Hz brain rhythm. The purple tick is the mains. Drag the skin resistance.

51 kΩ

The 51 kΩ and 47 nF are the datasheet’s electrode model (Fig. 35); we treat them as parallel. The presets other than 51 kΩ are illustrative round numbers. Noise is the thermal noise of the resistor, √(4 k T R B), at 310 K and the 65 Hz bandwidth of the ADS1299 at 250 SPS (Table 4).

Notice the read-out. A resistor makes noise just by being warm. For 51 kΩ over 65 Hz it is about 0.24 µV rms, which is more than the amplifier’s own 0.14 µV rms at gain 24 and 250 SPS. At 500 kΩ it grows to about 0.75 µV rms. The skin, not the chip, sets the noise floor of a good recording.

How the amplifier sees this

The electrode drives the chip input through that impedance. The input of the ADS1299 is a very high resistance (1000 MΩ at DC) in parallel with 20 pF. At 50 Hz that is about 157 MΩ. The skin’s 41 kΩ against 157 MΩ loses 41,000 / 157,000,000 = 0.026% of the signal. That loss is negligible.

This is why the datasheet design table asks for an input impedance above 10 MΩ. A weak amplifier input would form a divider with the skin and eat the signal. A strong one can ignore it. But there is a catch, and Chapter 4 is about it: when the two electrodes have different impedances, the tiny divider loss differs between them. That difference is what turns hum into a false signal.

When the electrode lifts: symptom, measurement, fix

The symptom is a trace that suddenly swings, or one that fills with hum. The measurement is to ask the chip. The ADS1299 has lead-off detection: it pushes a very small test current through the electrode and checks the voltage it makes. Its DC mode uses 6 nA (the datasheet lists 6 nA and 24 nA; the AC mode uses microamps). A good 51 kΩ contact gives 6 nA × 51 kΩ = 0.31 mV. A lifted electrode has a huge resistance, so the same current drives the pin toward the supply, and a status bit flips.

The fix is physical: press the electrode down, add gel, part the hair. In firmware, you read the status and show the user which electrode is off. Chapter 9 shows where those bits live. The datasheet itself says the feature is really “electrode-off” detection.

On real hardware: on an nRF52840 DK or STM32 Nucleo, put 51 kΩ in parallel with 47 nF between two analog pins and compare the voltage drop of a known small current. Repeat with 510 kΩ and compare how the noise grows.

Why does a dry electrode with high skin resistance make a recording worse, even with a good amplifier?

Chapter 2

Two Wires, One Difference

Subtract one electrode from another and watch the hum that both share disappear

Two boats float side by side on a choppy sea. Each one rises and falls by a metre as the waves pass. You want to know whether one boat sits a few centimetres higher than the other. Measuring each boat against the sea floor is hopeless: the waves swamp the answer. Measure the gap between the boats instead. The waves lift both together, so they drop out. Only the small difference remains.

That is the whole idea of this chapter. The sea is the mains hum. The boats are two electrodes. The gap is the brain.

Why the body acts like an antenna

Mains wiring carries 50 or 60 Hz alternating current. It makes a weak electric field around every cable and every lamp. Your body is a conductor, so it picks up that field like an antenna, and the whole body sits at a small wobbling voltage compared with the board’s ground. The datasheet says so directly: noise easily couples onto the body, “similar to an antenna” (section 10.1.3).

Every electrode on the body shares that wobble. How big is it? It depends on the room, the cables and where you stand, so any single number is illustrative. Later chapters use 1 V on the body. The toy below uses 1 mV, so the picture stays readable. The cancelling works the same at any size.

Common mode and differential mode

Take two electrode voltages, A and B, both measured against the board ground. Their average is the common-mode voltage: what both wires agree on. Their difference is the differential-mode voltage: what only one of them sees. The hum is common-mode. The brain signal is differential-mode.

Vdiff
What the amplifier should report: the gap between the two electrodes. This is the brain.
Vcm
What both electrodes share, measured against ground. This is the hum, plus the electrodes’ steady offsets. The amplifier should ignore it.

Illustrative: VA = hum + brain = 1,000 µV + 20 µV, VB = hum = 1,000 µV. Then Vdiff = 20 µV and Vcm = 1,010 µV. The hum is fifty times bigger, and it cancels exactly.

Try it. The device shows two electrode wires against ground and the difference. First choose One wire, which reads electrode A alone against ground. Then choose Subtract. Then raise the mismatch, which makes the two wires pick up slightly different hum.

Subtract the shared hum

The top two lanes are the two electrodes against ground, both with the same hum. The bottom lane is what the chip reports. Switch between reading one wire and subtracting, then drag the mismatch.

0%

Illustrative: 1,000 µV of 50 Hz hum on the body, a 20 µV peak 10 Hz brain rhythm on electrode A only. Mismatch means electrode B picks up that percentage more hum than A. The lane scales differ: the top two lanes show ±1.5 mV, the bottom lane rescales to its own contents.

With one wire, the brain is invisible. The 20 µV rhythm is a 2% ripple on a 1,000 µV wave. With subtraction and no mismatch, the output is the brain alone. With 1% mismatch, a 10 µV hum leaks through, which is half the size of the brain. At 5% the hum is bigger than the brain again.

So subtraction helps only as much as the two wires match. The next chapter measures how well an amplifier subtracts. Chapter 4 shows where the mismatch comes from.

Why not just filter it out later?

It is a fair question. The hum has one frequency, so a notch filter (a filter that removes one narrow band) in software could remove it. Three reasons say you cannot rely on that.

First, the hum is hundreds of times bigger than the brain at the input. It would use up the amplifier’s range, so the converter would clip before any digital filter ran. Second, brain activity also lives near 50 Hz (fast “gamma” rhythms), so a notch cuts real signal. Third, a notch filter has a delay and a ringing tail. Series lesson interference and filters measures that cost. The right order is: reject hum in hardware first, then clean up the rest in software.

Montages: which pairs do you subtract?

With many electrodes you choose which pairs to subtract. In a sequential montage each channel is the gap between two neighbours, for example Fp1 and F7. In a referential montage every electrode is measured against one shared reference electrode. The ADS1299 supports the second with its SRB1 pin, which can route the reference to every channel’s negative input (datasheet section 10.2.2). Subtracting afterwards recovers the sequential pairs.

For more on the electrode side, see the BCI analog front end.

Electrode A reads hum + brain and electrode B reads hum. What does a perfect subtraction A minus B give?

Chapter 3

How Well Can an Amplifier Subtract?

Measure subtraction quality in decibels, then work out how much hum leaks through a 110 dB amplifier

You weigh two nearly equal bags on a balance. The bags are heavy and the difference is a few grams. If the balance arms differ by one part in a thousand, the heavy load alone tips it by more than the grams you wanted to find. The balance must be level, and the better it is levelled, the smaller the difference it can read.

An amplifier that subtracts has the same problem. It must treat both inputs identically. Any tiny difference in how it treats them lets some of the shared hum tip the result.

Two gains, not one

An instrumentation amplifier is an amplifier built to take the difference of two inputs and multiply it by a set gain. In the ADS1299 this stage is the PGA, the programmable gain amplifier, with gains of 1, 2, 4, 6, 8, 12 or 24. Inside, it has two gains. The differential gain (Ad) applies to the difference between the inputs. The common-mode gain (Acm) applies to what both inputs share. An ideal amplifier has Acm = 0. A real one has a very small, nonzero value.

Vout
The amplifier output, before the converter.
Ad
The differential gain: the gain you set (up to 24).
Acm
The common-mode gain: the small, unwanted gain on the shared voltage.

The ratio of the two gains is the common-mode rejection ratio, CMRR = Ad / Acm. A bigger number means a better amplifier. Because the number is huge, we write it in decibels.

Decibels from zero

A decibel (dB) writes a ratio on a log scale. For a voltage ratio, dB = 20 × log10(ratio). Every 20 dB is a factor of 10. So 20 dB is 10 times, 40 dB is 100 times, 60 dB is 1,000 times, and 120 dB is 1,000,000 times. In between, 110 dB is 105.5 = 316,228 times.

Move the error to the input

Divide the output equation by Ad. The output looks like an ideal amplifier with an error voltage added to the input. That is the neatest way to compare the error with the brain signal, because both are then in the same input units.

Verr
The false differential signal at the input, caused only by common-mode voltage.
Vcm
The shared voltage on both electrodes: here the hum on the body.
CMRRdB
The rejection, in decibels. The ADS1299 lists −110 dB at 50 and 60 Hz, shown as 110 dB of rejection.

1 V of body hum, 110 dB: Verr = 1 V / 316,228 = 3.16 µV. The brain is 20 µV, so it is 6.3 times bigger than the leak. At 80 dB the ratio is 10,000, so Verr = 100 µV, and the leak is 5 times bigger than the brain.

Those two lines are the heart of the chapter. Thirty dB is a factor of about 31 in the leak, and it decides whether you see a brain or a wall socket. Play with it.

Dial the rejection

The purple line is the hum that leaks through, in microvolts at the input, for each CMRR. The teal line is the 20 µV brain rhythm. The dashed blue mark is the ADS1299’s 110 dB. Drag the CMRR and choose how much hum is on the body.

110 dB

The formula is Verr = Vcm ÷ 10dB/20. The 110 dB mark is the ADS1299’s CMRR at 50 and 60 Hz (datasheet Electrical Characteristics, measured with a common-mode signal across the whole input range, minimum of eight channels). The body hum values are illustrative.

Slide the CMRR down to 60 dB with 1 V on the body. The leak is 1,000 µV, fifty times the brain. Slide it to 110 dB and it falls to 3.16 µV. Now drop the body hum to 10 mV and you can get away with a far weaker amplifier. This is why people in shielded rooms need less from their hardware, and people in homes need more.

Where the dB come from, and where they go

A discrete difference amplifier made of four ordinary resistors reaches high CMRR only when those resistors match extremely well, to about one part per million for 110 dB (for a simple unity-gain stage). Nobody buys parts that good one by one. Integrated amplifiers trim the matching on the chip. That is one reason to use a dedicated front end such as the ADS1299 rather than build the amplifier from op-amps.

And the number holds only under the conditions the datasheet states. The ADS1299 figure is for a common-mode signal at 50 or 60 Hz, with the two inputs driven from low source impedance. Once you connect real, unequal electrodes, the system CMRR can be far worse than the chip CMRR. The next chapter shows how.

On real hardware: on an STM32 Nucleo with a 12-bit ADC, feed the same 1 V sine to both inputs of any differential amplifier board and read the output amplitude. Divide the input by the output to find its CMRR, then repeat at 60 Hz and 1 kHz.

A front end has 100 dB of CMRR and sees 1 V of hum on the body. How large is the false differential signal at the input?

Chapter 4

Why a Perfect Amplifier Still Passes Hum

Work out how two unequal electrodes turn shared hum into a false signal, and compare it with the amplifier’s own leak

Two garden hoses feed the same tank from the same tap. One hose has a small kink, and the other is clear. The tap pressure wobbles a little. Each hose passes the wobble to the tank, but the kinked one passes slightly less. The tank now sees a difference between the hoses, and the cause is the kink, not the tap.

Your electrodes are the hoses, and the amplifier input is the tank. Chapter 3 gave the amplifier a CMRR of 110 dB. That figure says nothing about the kinks in front of it.

Each electrode is a small voltage divider

A voltage divider is two impedances in a row. The voltage across the second one is the input times Z2 / (Z1 + Z2). Here the first is the electrode contact (Ze, about 50 kΩ from Chapter 1). The second is the amplifier input (Zin), which at 50 Hz is about 157 MΩ.

Body hum Vcm enters through the electrode. The input pin sees Vcm × Zin / (Zin + Ze). Because Ze is tiny next to Zin, this is almost exactly Vcm × (1 − Ze / Zin). Each pin loses a small fraction of the hum, in proportion to its own electrode impedance.

Now subtract the two pins. If both electrodes have the same Ze, they lose the same fraction and the difference is zero. If they differ by ΔZ, the difference is not zero.

Vleak
The false differential signal made by the imbalance, at the input.
Vcm
The hum on the body.
ΔZ
The difference between the two electrode impedances, at the hum frequency.
Zin
The amplifier input impedance at that frequency: 1000 MΩ in parallel with 20 pF, from the datasheet.

The worked number

Step 1: the 20 pF of input capacitance has an impedance of 1 / (2π × 50 × 20 pF) = 159 MΩ at 50 Hz.

Step 2: in parallel with the 1000 MΩ DC resistance, the size is 1000 × 159 / √(10002 + 1592) = 157 MΩ.

Step 3: take a modest mismatch, ΔZ = 20 kΩ, and 1 V of hum.

Vleak = 1 V × 20,000 / 157,000,000 = 127 µV.

That is six times the 20 µV brain rhythm, and 40 times the 3.16 µV that the amplifier’s own 110 dB CMRR leaks. The most expensive chip on the board was not the problem. A 20 kΩ difference between two scalp contacts is common, and often smaller than what a dry electrode shows.

The device below combines both leaks. We add them as a root of the sum of squares, because their phases are not tied together. Drag the mismatch and the frequency.

Unbalance the electrodes

Three bars on a log scale: the leak from the amplifier’s own CMRR, the leak from electrode mismatch, and their total. The teal line is the 20 µV brain rhythm. Drag the mismatch.

20.0 kΩ

Model: Vleak = Vcm × ΔZ ÷ Zin with Zin = 1000 MΩ ∥ 20 pF (datasheet Electrical Characteristics), taking that 20 pF as the capacitance from each input to ground (our assumption). The amplifier leak uses 110 dB. Body hum is an illustrative 1 V. Real front ends also see cable and filter mismatch, which this model ignores.

Set the mismatch to zero. Only the amplifier’s own 3.16 µV remains. Raise it to 500 Ω and the two bars meet: below that, the amplifier dominates, and above it, the electrodes do. Almost every real recording sits far to the right of that crossing. So the quality of the electrode contacts, not the chip’s CMRR, sets the hum in the data.

Fixes at the front

You can attack each factor in the formula. Lower ΔZ: prepare the skin, use gel, and use identical electrodes. Raise Zin: use an amplifier with a very high input impedance, as the datasheet table asks (above 10 MΩ). Lower Vcm: shield the cables, move away from sources, and use the bias drive of the next chapter.

Even the filter on the input matters. The ADS1299 datasheet advises forming the anti-alias filter with a single differential capacitor across the two inputs, not two separate capacitors to ground. The reason it gives is that the shared capacitor “removes dependence on component mismatch”. Two capacitors to ground, even at 5% tolerance, would be another source of ΔZ at 50 Hz. If you add small common-mode capacitors against RF interference, the datasheet says they should be 10 to 20 times smaller than the differential one, so they do not hurt CMRR.

The firmware lesson here is about diagnosis. When the 50 Hz line is large on only some channels, ask which electrode is dry, loose or different. The cure is a bench action, not a code change. A lead-off status bit, or a measured impedance, tells you where to look.

On real hardware: on a nRF52840 DK, drive both inputs of a differential ADC channel from a 1 V 50 Hz source through 1 kΩ and then through 1 kΩ and 21 kΩ. Compare the 50 Hz amplitude in the two captures.

Two electrodes differ by 10 kΩ at 50 Hz. The amplifier input is 157 MΩ and the body hum is 1 V. How large is the false signal from the imbalance?

Chapter 5

Cancel the Hum at Its Source

Sense the hum on the body, flip it upside down, and push it back in, so the body itself goes quiet

Noise-cancelling headphones listen to the room. They hear a low rumble, make the same rumble upside down, and play it into your ear. The two rumbles add up to nothing. The headphones did not shield your ear. They fought the noise with its own mirror image.

The bias drive does the same job for the body. It is also called the right-leg drive, because early ECG machines connected the extra electrode to the right leg. The ADS1299 datasheet calls it the patient bias or BIAS drive.

The loop, step by step

The chip takes the voltages of some of the electrodes and averages them. That average is mostly hum, because the brain signal is tiny and the two sides of a pair cancel. The chip feeds the average into an inverting amplifier, an amplifier whose output is the input multiplied by a negative gain, so it is the mirror image. The output goes to an extra electrode on the body, the drive electrode.

When the body voltage rises, the loop pushes it down. When it falls, the loop pushes it up. This is negative feedback: the correction opposes the error. The more gain in the loop, the smaller the leftover error.

The datasheet gives the gain for common-mode signals (Eq. 11): the output over the input is −Rf × N / 330 kΩ. Here Rf is the feedback resistor you choose, N is the number of channel inputs you enable for sensing, and 330 kΩ is the resistor at each PGA output. The capacitor Cf across Rf sets the bandwidth.

Vbody
The hum left on the body once the loop is closed.
Vcm
The hum the body picks up with no loop.
A(f)
The loop gain at frequency f. At low frequency it is Rf N / 330 kΩ. Above the pole fc it falls away.

We keep the toy simple: the loop divides the body hum by one plus the loop gain. That is the classic result for negative feedback. The datasheet’s example circuit (Fig. 38) uses Rf = 1 MΩ and Cf = 1.5 nF, labelled as typical example values. We use those.

Step 1: the pole sits at fc = 1 / (2π × 1,000,000 × 1.5 nF) = 106 Hz.

Step 2: with all 8 channels sensing, the low-frequency gain is 1,000,000 × 8 / 330,000 = 24.2.

Step 3: at 50 Hz, A = 24.2 / √(1 + (50/106)2) = 21.9.

Step 4: Vbody = 1 V / (1 + 21.9) = 43.7 mV. With a 20 kΩ mismatch the leak falls from 127 µV to 43.7 mV × 20,000 / 157 MΩ = 5.5 µV.

That is the trace in the hero. Hum drops by a factor of 23, from six times the brain signal to a bit over a quarter of it. Now play with the three knobs: whether the loop is closed, the feedback resistor, and how many electrodes feed the average.

Close the bias loop

The top row is the loop: the body hum goes through the electrodes, is averaged, flipped and driven back in. The bars below show the hum on the body and the leak at the output. Switch the loop on, then change Rf and the number of electrodes.

1.0 MΩ

Gain Rf N ÷ 330 kΩ is datasheet Eq. 11; Cf = 1.5 nF and Rf = 1 MΩ are the typical example values of Fig. 38. The toy divides the body hum by 1 + A, at 50 Hz, with 1 V of illustrative hum, 20 kΩ of mismatch and 110 dB of CMRR. A real loop also depends on the body path and its delay, and can oscillate if the gain is too high.

Try one channel with a small Rf. The gain is under 1, so the loop barely helps. Then try 8 channels with Rf near 5 MΩ. The hum falls much further. Do not conclude that a bigger gain is always better. Every real feedback loop has delay. Push the gain too high and the loop can ring or oscillate. The pole from Cf is there to keep that under control, and the datasheet tells you to check the amplifier has enough bandwidth for the signals you want to cancel.

The second job: keep the inputs inside the rails

The bias drive does more than cancel 50 Hz. The datasheet says it also biases the patient so that the electrode common-mode voltage stays inside the chip’s supply rails. That allows DC coupling: connecting the electrode straight to the amplifier with no blocking capacitor. Without it, the body’s slow drifts would push the inputs off the supply and the amplifier would saturate. The reference the loop drives toward is, by default, the mid-supply voltage (AVDD + AVSS) / 2, from the BIASREF_INT bit.

Failure, measurement, fix

The symptom is a 50 Hz wave on every channel at once. The measurement is the BIAS_STAT bit, which reads 1 when the bias is not connected. The fix is to check that the drive electrode touches the skin. Also remember the safety side: the datasheet lists a 1.1 mA short-circuit current for the bias amplifier. A medical design must limit current to a patient further with series parts and isolation. The lesson on-device decode and safety covers that.

On real hardware: on an ADS1299 evaluation board or any open EEG board, record 10 seconds with the bias electrode attached and 10 seconds with it lifted. Compare the 50 or 60 Hz amplitude in a spectrum. It should drop by roughly the factor you computed.

The bias loop has a gain of 21.9 at 50 Hz. By what factor does it divide the hum on the body?

Chapter 6

Offset, Gain and Headroom

Pick a gain that is big enough to see 20 microvolts and small enough that a 300 millivolt offset still fits

You want to measure how far a pencil mark sits from the edge of a table. You hold a ruler up. But the ruler is only 20 cm long, and the table is 3 m across. If you start at the wrong end, the mark is off the ruler and you read nothing.

The converter is that ruler. It has a limited range. The electrode offset decides where on the table your signal starts. If the offset moves the signal off the ruler, the output clips and the data is lost, no matter how good the chip is.

Two choices for handling DC

Traditional EEG machines block the DC offset with a high-pass filter (a filter that blocks slow changes) right at the input. The remaining signal is amplified by a large gain, and a 12 to 16 bit converter digitizes it. The ADS1299 datasheet describes this older design and then takes the other route (section 10.2.2): DC coupling. The electrode connects straight to the amplifier. The offset enters the chip, and the converter has so many bits (24) that it can hold both the offset and the 20 µV signal at once. A digital filter later removes the offset.

The price of DC coupling is that you must make sure the offset and the shared voltage stay inside the allowed ranges. There are two ranges, and they are independent.

Range 1: the differential full scale

The converter can read a difference of up to ±VREF / gain (datasheet Eq. 5). The ADS1299 uses VREF = 4.5 V. At gain 24 that is ±187.5 mV. At gain 12 it is ±375 mV. At gain 1 it is ±4.5 V. The code is clipped at 7FFFFFh for a positive overload and 800000h for a negative one.

Range 2: the common-mode window

Inside the PGA, each input swings around the shared voltage. The amplifier outputs cannot come closer than 200 mV to either supply rail. Otherwise they saturate and become nonlinear. So the common-mode voltage must sit in a window (Eq. 4):

CM
The common-mode voltage at the inputs: the average of the two electrode voltages, measured from the chip ground.
lower edge
The lowest CM that keeps the amplifier output 200 mV above the negative rail, even at the largest differential signal.
upper edge
The highest CM that keeps the output 200 mV below the positive rail. G is the gain and Vmax is the largest differential signal at the input, including the offset.

The datasheet works one example. With AVDD = 5 V, gain 12 and Vmax = 350 mV, the term G·Vmax / 2 is 12 × 0.35 / 2 = 2.1 V. The window is 0.2 + 2.1 = 2.3 V up to 5 − 0.2 − 2.1 = 2.7 V. That is a window only 0.4 V wide, centred on mid-supply (2.5 V). This is exactly where the bias drive of Chapter 5 holds the body. Without it, a few hundred millivolts of drift would leave the window.

Use the device. It has your offset, your gain and the shared voltage, and it shows both ranges at once.

Fit the signal in both ranges

Top bar: the converter’s differential range, with your electrode offset as a marker. Bottom bar: the 0 to 5 V supply, with the allowed common-mode window shaded. Pick a gain, then drag the offset and the common-mode voltage.

300 mV
2.50 V

Equations 4 and 5 of the datasheet, with AVDD = 5 V, AVSS = 0 V and VREF = 4.5 V. The offset is the largest differential signal at the input (the 20 µV signal is negligible beside it). Offsets of 100 to 300 mV are illustrative; real values depend on the electrode metal, the gel and the skin.

Start at gain 12 with 300 mV and 2.5 V. Everything fits: full scale is ±375 mV, and the window runs from 2.0 V to 3.0 V. Now switch to gain 24. The 300 mV offset is beyond ±187.5 mV, so it clips, and the window edges cross: the lower edge is 3.8 V and the upper edge is 1.2 V, so the window is empty. Switch back, then drag the common-mode voltage to 3.2 V and watch the window reject it.

The trade: what does a lower gain cost?

It costs little noise, and that is the surprise. The datasheet noise tables at 250 SPS give 0.98 µV peak to peak at gain 24 and 1.13 µV at gain 12. That is 15% more noise for twice the headroom. At gain 1 it is 7.59 µV, which is much worse. So for DC-coupled EEG, gain 12 is often a better pick than 24, and the datasheet’s own worked example uses it.

Failure, measurement, fix

The symptom is a trace stuck at one extreme, or a trace that is clean until a movement makes a flat top. The measurement is to read raw codes. A clipped channel returns 7FFFFFh or 800000h, and no real signal sits at those values. The fix is a lower gain, better matched electrodes, or the bias drive to centre the common mode. A high-pass filter in firmware cannot repair a clipped converter, because the information is already gone.

On real hardware: on an ADS1299 board, set the same input to gain 24 and gain 12, short the inputs, then apply a 200 mV DC offset from a divider. Look at the raw codes. The gain 24 channel pins at 7FFFFFh.

At gain 24 and VREF = 4.5 V, an electrode pair has a 250 mV DC offset. What happens?

Chapter 7

The Delta-Sigma ADC: 24 Bits From a 1-Bit Guess

Watch a converter that can only say up or down turn a slow signal into a precise number by guessing very fast

You must measure how much water sits in a barrel, but your only tool is a tiny cup. You cannot read half a cup. So you do a trick. You scoop water in and out very fast, and each time you note only one thing: is the barrel above or below the target level? If the level is high you pour out a cup. If it is low you pour one in. After a thousand quick scoops, the fraction of scoops that went in tells you the level to great precision.

That is a delta-sigma converter. Its quantizer has just two answers, up or down. Its precision comes from asking a very large number of times, and from the feedback that keeps the guess honest.

Quick background: what a quantizer does

An ADC chops a smooth voltage into steps. A quantizer picks the nearest step. The leftover distance is the quantization error. A 1-bit quantizer has only two steps, so its error is huge. See quantization noise for the standard treatment.

The trick of delta-sigma is that the huge error is made to sit at high frequencies, far above the brain’s band, where a filter can remove it. Two ideas do this: oversampling and noise shaping.

Oversampling: sample far faster than you need

The brain signal lives below about 50 Hz. The ADS1299 modulator samples at fMOD = fCLK / 2, which is 1.024 MHz for the 2.048 MHz clock (datasheet section 9.3.1.3.3). Output samples come out at only 250 to 16,000 per second. The ratio is the oversampling ratio (OSR): 1,024,000 / 250 = 4,096 at the slowest rate, and 1,024,000 / 16,000 = 64 at the fastest.

The quantization error spreads out evenly over the whole 0 to fMOD/2 band. The signal band is a thin slice of it. Averaging many samples keeps only that slice and throws away the rest of the error.

Noise shaping: push the error up

The feedback loop gives more. It adds an integrator (a block that adds up its input over time) before the quantizer. The loop then acts on the error like a seesaw: the error is small at low frequency and large at high frequency. A second-order modulator, which the ADS1299 uses, has two integrators and pushes the error up much more strongly than a first-order one. The datasheet says the noise is shaped up to fMOD/2 (Fig. 24).

Decimation: average, then drop samples

After the modulator, a digital filter keeps the low band and discards the shaped noise. Then it decimates: it keeps one output out of every OSR samples. The ADS1299 filter is a third-order sinc filter (section 9.3.2.1), which is a cascade of three moving averages. A moving average adds the last L samples and divides by L. The datasheet notes two things that matter for you:

Now see it work. The device runs a real first- or second-order modulator in your browser on a 0.5 amplitude sine, then a sinc3 decimator, and measures what is left.

Run the modulator

Top: the input sine (teal line) and the decimated output samples (blue dots). Bottom: a short stretch of the 1-bit stream that the modulator really produced. Choose an order and drag the oversampling ratio.

32

A model of the idea, not the ADS1299’s circuit. The first-order loop is s += u − v. The second-order loop is the Candy form: s1 += u − v, s2 += s1 − 2v, with v = sign(s2). The decimator is three cascaded moving averages of length OSR, as in a sinc3. The error is what remains after fitting the best sine, so the filter’s fixed delay and droop do not count as noise. Effective bits = log2(2 ÷ (√12 × error)), full scale ±1.

Set second order at OSR 64. The error is about 0.007% of full scale, near 13 effective bits. Switch to first order at the same OSR: it drops to about 9 bits. Same clock, same filter. The only change is how hard the loop pushes the noise upward. Now double the OSR with the slider. In this model a second-order loop gains about 2.3 bits per doubling (13.0, 15.4, 17.7 bits at OSR 64, 128, 256), and a first-order loop only about 1.2 to 1.6 bits. The datasheet’s OSR of 4,096 at 250 SPS is 64 times higher than the 64 here, so the converter has a huge margin.

The real chip then hits a different limit: thermal noise in the circuits. That is why the datasheet table stops at 19.85 effective bits for gain 24 at 250 SPS (Table 4), not 24. The extra bits in the 24-bit word are there so that the quantization never hides the analog noise.

The trade you control: rate against noise

You choose the output data rate with the DR bits of CONFIG1 (Chapter 9). A lower rate means more averaging and a narrower bandwidth. At gain 24, 250 SPS gives 0.14 µV rms of noise with a 65 Hz bandwidth. 16 kSPS gives 1.66 µV rms with 4,193 Hz. So you pay about 12 times more noise for 64 times more bandwidth. For a brain rhythm below 50 Hz, 250 SPS is enough. Higher rates are for lead-off detection and fast signals, as the datasheet states.

Failure, measurement, fix

The symptom is a recording that looks fine at rest but lags and smears after a sudden jump, such as a loose electrode snapping back. The cause is the filter’s settling: the first three outputs after a change are not valid. The measurement is to apply a step and count outputs until it settles. The fix is to discard those samples after a gain or mux change. The datasheet gives the settling time after a restart in clock cycles (Table 7): 8,201 tCLK for 1,000 SPS, which is 4.0 ms at 2.048 MHz, and 32,777 tCLK for 250 SPS, which is 16.0 ms.

On real hardware: on an ADS1299 board at 250 SPS, switch a channel’s mux between the input-short and the test signal, then print the first eight samples. The first few show the settling.

Why can a converter whose quantizer has only two levels reach 24-bit resolution?

Chapter 8

Noise, Codes and Microvolts

Turn 27 bytes from the chip back into eight voltages, and learn the three ways the conversion goes wrong

You print one frame from the chip to your serial console. It is 27 bytes of hex, like C0 00 00 00 03 A2 FF FC 84 …. Nothing on the screen says microvolts. Somewhere in your code, a small function must turn those bytes into numbers a person can trust.

That function is short. Most bugs in it come from three things: a missing sign, a wrong gain, and a clipped value that looks like data.

What the frame holds

After each conversion the ADS1299 drives its DRDY pin low and sends one frame. For the 8-channel part the frame has 24 status bits plus 24 bits × 8 channels = 216 bits, which is 27 bytes (datasheet section 9.5.2). The next lesson, acquisition firmware, covers how to read it over SPI. Here we only decode it.

The first 24 bits are the status word. Its layout is 1100, then the 8 bits LOFF_STATP (positive-side lead-off flags), then the 8 bits LOFF_STATN (negative side), then 4 GPIO bits. The leading 1100 is a fixed marker. If you ever read a frame that does not start with a 1100 nibble, the byte alignment is wrong.

The other 24 bits of each channel are a two’s complement number. This is the usual way computers store signed integers: the top bit says negative, and 800000h is the most negative value. A positive full-scale input gives 7FFFFFh. Negative full scale gives 800000h. The output clips at these codes (section 9.5.1).

From code to volts

One LSB (least significant bit, the smallest step) is the full-scale range divided by the number of codes, from datasheet Eq. 8:

LSB
The voltage step for one code. Smaller gain means bigger steps.
VREF
The reference voltage: 4.5 V on the ADS1299 with its internal reference.
G
The PGA gain you programmed into the channel.
code
The signed 24-bit integer from the frame.
V
The differential input voltage, before the gain. This is what you want.

Gain 24: LSB = (2 × 4.5 / 24) / 16,777,216 = 0.375 V / 16,777,216 = 22.35 nV. The code 0x0003A2 is 930. So V = 930 × 22.35 nV = 20.8 µV. The code 0xFFFC84 is −892 in two’s complement, so V = −19.9 µV.

The C function is short. The sign extension is the part people forget.

c// One ADS1299 channel: 3 bytes, big-endian, two's complement, to microvolts.
static inline int32_t ads_i24(const uint8_t *p) {
    int32_t v = ((int32_t)p[0] << 16) | ((int32_t)p[1] << 8) | p[2];
    return (v ^ 0x800000) - 0x800000;          // sign-extend bit 23 into bits 31..24
}
static inline float code_to_uv(int32_t code, int gain) {
    return (float)code * (2.0f * 4500000.0f / gain) / 16777216.0f;   // Eq. 8, VREF = 4.5 V in microvolts
}
static inline bool is_clipped(int32_t c) { return c == 0x7FFFFF || c == -0x800000; }

A float holds 24 bits of integer exactly, so the cast loses nothing. Now decode a frame yourself. The device holds three recorded frames. Choose one, then choose the gain your host code assumes. The frames were recorded at gain 24.

Decode a frame

Pick a recorded frame, then pick the gain your code assumes. The text box shows the status word and each channel’s code and voltage.

The frames are constructed for this lesson, not captured from a board. The layout follows the datasheet: status word = 1100, LOFF_STATP, LOFF_STATN, GPIO[4:7]; then eight 24-bit two’s complement codes. The 10 to 20 µV values are made-up brain-sized numbers. Recorded gain is 24.

In the clean frame, set the assumed gain to 12. Every voltage doubles, because the LSB at gain 12 is twice as large. Nothing in the data warns you. The bug is silent, and the only protection is to read the gain back from the chip’s registers and to log it with the data.

Now pick the electrode-off frame. The status word shows bit IN3P_OFF set and channel 3 holds 7FFFFFh, a pinned value. A real brain never produces that. A decoder must test for it, as is_clipped does, and mark the channel invalid instead of plotting it.

Noise, counted in codes

The datasheet gives input-referred noise at 250 SPS of 0.14 µV rms at gain 24, and 1.08 µV rms at gain 1 (Tables 1 and 4). Divide by the LSB. At gain 24 that is 0.14 / 0.02235 = 6.3 codes of rms noise. At gain 1 the LSB is 536 nV, so the noise is only 2.0 codes. In both cases the converter’s step is smaller than the noise, which is the design goal: the analog circuits set the floor, not the rounding.

So the bottom bits of each sample are noise, and that is fine. A 20 µV rhythm spans 895 codes at gain 24, and the noise wiggles it by about six.

Failure, measurement, fix

Three symptoms, three measurements. Values that are all too big or too small by a power of two point to the wrong gain: compare the gain register with the constant in your code. Values that jump by exactly 16.7 million between neighbours point to a missing sign extension. Flat tops at plus or minus 7FFFFFh point to clipping: lower the gain, or fix the offset (Chapter 6).

On real hardware: on an ADS1299 board, short the inputs (MUX bits 001) at gain 24 and capture 1000 samples. Compute the standard deviation of the codes. It should be about 6 codes at 250 SPS.

At gain 24 with VREF = 4.5 V, one channel returns the code 0x000FA0 (4000). What voltage does it represent?

Chapter 9

Bringing the Chain Up From Firmware

Write the registers that set gain, rate and bias, and prove each stage works before you trust an electrode

The board arrives. You solder the electrodes, plug in the USB cable and run your code. The trace shows nothing, or noise, or a flat line. You have no idea which of the six stages in this lesson is at fault.

The way out is to test the chain in the order the signal flows, one stage at a time, with the inputs under your control. The datasheet builds this order into its power-up flow (Fig. 67), and we follow it.

The datasheet’s power-up order

  1. Wait for the power-on reset, then issue a RESET pulse and wait 18 tCLK. At 2.048 MHz that is 8.8 µs.
  2. Send SDATAC (11h). The chip wakes in continuous-read mode, and you cannot write registers in that mode.
  3. Write CONFIG3 = E0h to switch the internal reference on, then CONFIG1 = 96h for 250 SPS and CONFIG2 = C0h.
  4. Write every CHnSET = 01h, which shorts the inputs together, and check the noise.
  5. Set START, then RDATAC (10h), then read frames when DRDY goes low.
  6. Switch to the internal test signal (CONFIG2 = D0h, CHnSET = 05h) to check the gain path.
  7. Only then write the electrode setup: CHnSET with the mux at 000, the bias registers, and CONFIG3 with the bias amplifier on.

A WREG command is two opcode bytes and then the data. The first byte is 40h plus the register address. The second is the number of registers minus one. So writing CONFIG1 (address 01h) is 41 00 96, and writing the eight channel registers from 05h is 45 07 followed by eight bytes (Table 10).

The bytes behind each stage

Each chapter of this lesson became a few bits.

Use the composer to see the exact bytes and what to expect. Choose a gain, a rate, an input and the bias channels.

Compose the register writes

Pick the settings. The box lists the SPI bytes in the order the datasheet uses, and the line below says what you should measure.

Register addresses, bit fields, command opcodes and the init flow are from the ADS1299 datasheet (Tables 10, 11, 13 to 17, Fig. 67). Noise is the input-referred rms noise in Tables 1 to 4 at 5 V analog supply and 4.5 V reference, from the 1000-reading measurements. The sequence composes all channels the same way.

Try inputs shorted at gain 24 and 250 SPS. The expected noise is 0.14 µV rms, which is 6.3 codes. If you see 600 codes, the supply, the reference or the clock is wrong, and you have not yet reached an electrode. Then try the test signal: a 0.98 Hz square wave. The register formula, VREF ÷ 2400, gives 1.875 mV, so at gain 24 it is about 83,900 codes tall. (The datasheet electrical table lists the test signal as 1 mV steps with 2% accuracy, so measure the real height on your board and expect a few percent of error.) If it has the right height, the gain path works. Only then connect a person.

The same flow in C

This is the datasheet flow with the SPI layer left abstract. spi_xfer and delay_us stand for your board’s own functions. The next lesson builds the real DRDY and DMA path.

cenum { CMD_RESET=0x06, CMD_START=0x08, CMD_RDATAC=0x10, CMD_SDATAC=0x11 };
enum { R_ID=0x00, R_CONFIG1=0x01, R_CONFIG2=0x02, R_CONFIG3=0x03, R_CH1SET=0x05, R_BIAS_SENSP=0x0D, R_BIAS_SENSN=0x0E };

static void wreg(uint8_t addr, const uint8_t *v, uint8_t n) {
    uint8_t hdr[2] = { (uint8_t)(0x40 | addr), (uint8_t)(n - 1) };   // 010r rrrr, then n-1
    spi_xfer(hdr, 2); spi_xfer(v, n);
}
bool ads_bringup(uint8_t gain_code, uint8_t dr) {            // gain_code: 5 = x12, 6 = x24; dr: 6 = 250 SPS
    cmd(CMD_RESET); delay_us(10);                          // 18 tCLK = 8.8 us at 2.048 MHz
    cmd(CMD_SDATAC);                                       // wakes in RDATAC; stop it to write registers
    uint8_t id; rreg(R_ID, &id, 1);
    if ((id & 0x1F) != 0x1E) return false;                     // bit4=1, DEV_ID=11, NU_CH=10: an 8-channel ADS1299
    uint8_t c3 = 0xE0, c1 = 0x90 | dr, c2 = 0xC0;
    wreg(R_CONFIG3, &c3, 1); wreg(R_CONFIG1, &c1, 1); wreg(R_CONFIG2, &c2, 1);
    uint8_t ch[8]; for (int i=0; i<8; i++) ch[i] = (gain_code << 4) | 0x01;   // mux 001: inputs shorted
    wreg(R_CH1SET, ch, 8);
    cmd(CMD_START); cmd(CMD_RDATAC);                         // DRDY now falls at 250 Hz; run the noise check
    return true;
}
void ads_go_live(uint8_t gain_code) {                          // after the noise and test-signal checks pass
    cmd(CMD_SDATAC);
    uint8_t ch[8]; for (int i=0; i<8; i++) ch[i] = (gain_code << 4);   // mux 000: electrodes
    wreg(R_CH1SET, ch, 8);
    uint8_t s = 0xFF, c3 = 0xEC;                                // all 8 sense the bias; PD_BIAS + BIASREF_INT on
    wreg(R_BIAS_SENSP, &s, 1); wreg(R_BIAS_SENSN, &s, 1); wreg(R_CONFIG3, &c3, 1);
    cmd(CMD_RDATAC);
}

Two details are easy to miss. The ID check (id & 0x1F) == 0x1E uses the fixed bits of the ID register: bit 4 reads 1, DEV_ID reads 11 and NU_CH reads 10 for the 8-channel part (Table 12). The top three bits are the revision, which can change without notice, so the mask ignores them. And the reset values are not the values you want: after reset, CHnSET is 61h, which means gain 24 with the inputs shorted.

Failure, measurement, fix

The symptom is a channel that reads a flat, tiny noise no matter what you touch. The measurement is to read CHnSET back. If the mux still says 001, the chip is still shorting its inputs from the reset value. The fix is to write mux 000. The second classic symptom is a CONFIG register that seems to ignore a write: you wrote while the chip was in RDATAC mode, where register commands are not accepted. Send SDATAC first.

On real hardware: on an STM32 Nucleo or an RP2040 board wired to an ADS1299 module over SPI, run the flow with a logic analyser on SCLK, MOSI and DRDY. Check the bytes against the composer, and confirm DRDY falls 250 times per second.

You write CHnSET = 60h for all channels at gain 24, and the traces show a person’s EEG. What does the low nibble 0 select?

Chapter 10

The Field Guide

Keep the numbers, the checklist and the core code for the whole chain on one page

You can now follow a 20 µV rhythm from the scalp to a number in your code, and say what each stage does to it. This page gathers everything so that you can check a design in a few minutes.

The one-paragraph summary

A brain signal is tiny and rides on an electrode offset of up to hundreds of millivolts and on hum that the body picks up from the mains. The electrode and skin add resistance, capacitance and noise. A differential amplifier removes what both electrodes share, and its CMRR says how well. Impedance imbalance between the electrodes turns some of the shared hum back into a false signal, and it is usually the bigger leak. The bias drive pushes the hum down on the body itself and keeps the inputs in range. The gain and the offset must fit inside the converter’s range. A delta-sigma ADC then turns what is left into a 24-bit code, and firmware turns the code back into microvolts with the right gain.

The numbers that matter

WhatNumberWhy it matters
EEG design target (TI Table 29)at least 10 µV peak; 1 to 50 Hz; DC coupled; input impedance above 10 MΩThe signal is tiny and slow
Electrode model (Fig. 35)51 kΩ with 47 nF; |Z| = 50.4 kΩ at 10 Hz, 40.7 kΩ at 50 HzThe sensor is part of the circuit
Skin thermal noise (310 K, 65 Hz)0.24 µV rms at 51 kΩ; 0.75 µV rms at 500 kΩSkin can out-noise the chip
CMRR at 50 and 60 Hz110 dB = 316,228 times; 1 V of hum leaks 3.16 µVThe amplifier’s own leak
Input impedance1000 MΩ with 20 pF; 157 MΩ at 50 HzThe denominator of the imbalance leak
Imbalance leak1 V × 20 kΩ ÷ 157 MΩ = 127 µV; equal to the CMRR leak at only 497 ΩElectrodes dominate the hum
Bias loop (Rf 1 MΩ, Cf 1.5 nF, 8 channels)gain 24.2; pole 106 Hz; 21.9 at 50 Hz; hum ÷ 22.9127 µV falls to 5.5 µV
Differential full scale±4.5 V ÷ gain: ±187.5 mV at 24, ±375 mV at 12Offset must fit
Common-mode window (Eq. 4 example)AVDD 5 V, gain 12, 350 mV: 2.3 V to 2.7 VThe bias drive holds mid-supply
Modulator and filterfMOD = 1.024 MHz; OSR 4,096 at 250 SPS, 64 at 16 kSPS; sinc3; settles in 3 × tDRResolution against rate
One code (LSB)22.35 nV at gain 24; 536 nV at gain 1Codes to microvolts
Noise, gain 24, 250 SPS0.14 µV rms, 0.98 µV pk-pk, 65 Hz bandwidth, 19.85 effective bitsThe floor of a good recording
One frame (8 channels)24 status bits + 8 × 24 = 216 bits = 27 bytesParser size
Reset valuesCONFIG1 96h; CONFIG3 60h; CHnSET 61h (gain 24, inputs shorted)A fresh chip is safe, not ready

Terms in one line each

TermMeaning
Common-modeThe voltage both inputs share. Here: hum and offsets.
DifferentialThe voltage between the inputs. Here: the brain.
CMRRDifferential gain divided by common-mode gain, in dB.
Bias driveAn inverting loop that pushes the body voltage back toward a reference.
DC couplingElectrode wired straight to the amplifier, no blocking capacitor.
OSRModulator samples per output sample.
LSBOne step of the ADC code, 2 VREF ÷ gain ÷ 224.
Lead-offA test that finds an electrode that has lost contact.

Checklist before you trust a recording

  1. Read the ID register and mask it with 1Fh. An 8-channel ADS1299 gives 1Eh.
  2. Short the inputs. The noise in codes should match the datasheet table for your gain and rate.
  3. Run the internal test signal. Its height in codes should match 1.875 mV divided by the LSB.
  4. Pick a gain so that the largest expected offset is below full scale, and the common-mode window is not empty.
  5. Switch the bias drive on and check the drive electrode touches the skin.
  6. Check the lead-off flags and the impedance of every electrode before recording.
  7. Decode with the gain you read back from the chip, and store that gain with the data.
  8. Flag any code equal to 7FFFFFh or 800000h as invalid.
  9. Look at a spectrum. A line at 50 or 60 Hz on all channels means the bias or the shielding; on one channel it means one electrode.
  10. After any gain, mux or rate change, drop the outputs that arrive before the filter has settled.

The hum budget as code

This is the model behind the hero, as a function you can use in a design review. It is a back-of-envelope tool, with the same assumptions as Chapters 3 to 5.

pythonimport math

def zin(f, r=1e9, c=20e-12):                       # ADS1299 input: 1000 MOhm || 20 pF
    x = 1 / (2 * math.pi * f * c)
    return r * x / math.hypot(r, x)

def bias_gain(f, rf=1e6, n=8, cf=1.5e-9):          # Eq. 11 with the Cf pole
    a0 = rf * n / 330e3
    fc = 1 / (2 * math.pi * rf * cf)
    return a0 / math.hypot(1, f / fc)

def hum_uV(vcm=1.0, dz=20e3, f=50, cmrr_db=110, bias=True):
    if bias:
        vcm /= (1 + bias_gain(f))                  # Chapter 5: loop divides the body hum
    leak_imbalance = dz / zin(f)                  # Chapter 4
    leak_cmrr = 10 ** (-cmrr_db / 20)              # Chapter 3
    return vcm * math.hypot(leak_imbalance, leak_cmrr) * 1e6

print(hum_uV(bias=False), hum_uV(bias=True))        # about 127 and 5.5 microvolts

Sources used

Where this sits

This lesson is the analog half of a biopotential front end. Next, acquisition firmware reads these frames over SPI with DRDY and DMA and catches lost samples. Interference and filters handles what hardware could not remove. Streaming it reliably and on-device decode and safety finish the track. Other places to go next:

The takeaway. Hum does not enter at the amplifier. It enters at the skin. The chain works because each stage removes a different problem: the differential pair removes what is shared, the bias drive shrinks the shared part, the gain and range keep the signal on the converter, and the delta-sigma loop trades speed for bits. When a recording looks wrong, walk the chain in order.
A recording shows a strong 50 Hz line on all eight channels, equal on each. Which first step fits best?

Now press Teach and explain the chain out loud, from memory: why a difference removes hum, what CMRR measures, why the electrodes matter more than the chip, how the bias loop divides the hum, why gain and offset compete, and how a 1-bit loop gives 24 bits. Then go back to the virtual EEG and switch the bias drive on and off once more.

Electrodes to Bits: The Microvolt Signal Chain
TI ADS1299 datasheet · Back to Read the Datasheet · Back to Gleams