فنون
الجمال والعناية
حِرَف
الثقافة والتاريخ
ترفيه
البيئة
الطعام والمشروبات
الهندسة العكسية
العلوم
رياضة
التقنية
الأجهزة القابلة للارتداء
The String Galvanometer and the ECG
Ed

أنشأه

Ed

27. أغسطس 2026FI
4
0
0
0
0

The String Galvanometer and the ECG

The heart is an electrical organ that happens to move blood. Every beat begins as a wave of depolarisation, and because the body is a volume conductor, that wave is measurable as a millivolt-scale potential difference on the skin. The measurement was the hard part. In 1903 Willem Einthoven built an instrument that could resolve it: a silvered quartz filament, a few microns across, stretched across the gap of a powerful electromagnet. Current through the filament pushed it sideways, a microscope threw its shadow onto a moving photographic plate, and the trace that came out is the one still printed today. The machine weighed around 270 kilograms and took several people to operate. Patients were sometimes recorded in a different building, connected by cable, with their limbs in buckets of saline for electrical contact. Einthoven also gave us the geometry. Treating the two arms and the left leg as vertices of a triangle around the heart gives three leads, and those leads are not independent — lead II is the sum of leads I and III, a straight consequence of Kirchhoff's voltage law applied to the body. That relation is still the first thing checked when an ECG looks wrong. You will build a working single-lead ECG on a modern instrumentation front end, and use it to discover why the filter settings on a cardiograph are a clinical decision rather than an engineering preference.
متقدم
7 hours

التعليمات

1

The signal, and everything competing with it

Get the scale right before designing anything, because the design is entirely determined by it. The QRS complex on a limb lead is roughly one millivolt peak. The P wave is a tenth of that. Against those, here is what else arrives at your electrodes. Mains interference at 50 or 60 hertz couples capacitively into the leads and into you, and arrives common-mode at both electrodes at amplitudes that can exceed the signal by an order of magnitude. Half-cell potentials at the electrode-skin interface are direct-current offsets of up to several hundred millivolts — hundreds of times the signal — and they drift as the gel wets and the skin sweats. Muscle activity from any voluntary contraction is broadband and can bury the trace entirely. Motion of the cable moves charge and looks exactly like a slow deflection. So the front end has three jobs, in order. Reject the common-mode mains, which is what a high common-mode rejection ratio instrumentation amplifier is for. Block the direct-current half-cell offset without eating the low-frequency content of the signal, which is a high-pass filter with a very low corner. Limit the bandwidth at the top to keep muscle noise out, which is a low-pass. The second of those is where the clinical argument lives, and step 3 is about nothing else.

الأدوات المطلوبة:

Notebook and PencilNotebook and Pencil
Digital Oscilloscope (100MHz, 2-Channel)Digital Oscilloscope (100MHz, 2-Channel)
2

Build the front end

Wire the AD8232 module, which is a purpose-built single-lead biopotential front end: an instrumentation amplifier with a very high common-mode rejection ratio, a right-leg drive to actively cancel the common-mode voltage on the body, and switchable filtering. The electrode placement for a lead-I-like recording is right arm, left arm, and the right leg as the drive reference. In practice, place the two signal electrodes below the collarbones on either side and the reference on the lower right ribs — this gives a clean trace with far less muscle noise than limb placement, because there is less muscle in the path. Skin preparation matters more than anything else in this build. Wipe the sites with alcohol, let them dry completely, and abrade very lightly. Electrode-skin impedance dominated by dry stratum corneum is the single largest source of a poor trace, and no amount of gain fixes it. Connect the analog output to an Arduino analog input, and bring the two leads-off detection outputs to digital pins. Those outputs are not a luxury: a detached electrode produces a signal that looks superficially like a heart rhythm and has fooled people. Power the whole thing from a battery. This is the safety rule for the build and it is not negotiable: never run this while the Arduino is connected by USB to a mains-powered computer with electrodes on a person. Log to an SD card or use an isolated link, and treat the battery requirement as part of the circuit rather than an inconvenience.

المواد لهذه الخطوة:

AD8232 Single-Lead ECG Front End ModuleAD8232 Single-Lead ECG Front End Module1 قطعة
Ag/AgCl Disposable Electrodes (50-Pack)Ag/AgCl Disposable Electrodes (50-Pack)1 عبوة
Arduino BoardArduino Board1 قطعة
9V Battery with Barrel Jack Lead9V Battery with Barrel Jack Lead1 قطعة
Jumper Wire Set (Male-Female)Jumper Wire Set (Male-Female)1 طقم

الأدوات المطلوبة:

Soldering Station (Temperature-Controlled)Soldering Station (Temperature-Controlled)
Digital Multimeter (Lab Grade)Digital Multimeter (Lab Grade)
Digital Oscilloscope (100MHz, 2-Channel)Digital Oscilloscope (100MHz, 2-Channel)
3

Acquisition firmware with leads-off handling

This sketch samples the front end at a fixed 500 hertz using a hardware timer rather than a delay loop, because a jittery sample interval puts noise into the frequency axis and makes every later filter analysis wrong. It streams samples as plain numbers so any serial plotter can show them live, and it explicitly emits a sentinel when either leads-off detector fires. That sentinel is the important part of the program: a disconnected electrode must produce an obviously invalid reading, never a plausible-looking one. A simple running estimate of the R-R interval is included so you get a heart rate, with a refractory period after each detection to stop the T wave being counted as a second beat. That refractory blanking is the oldest trick in cardiac signal processing and it is still in every monitor.
ecg_acquire.inoarduino
/*
 * Single-lead ECG acquisition — AD8232 front end
 *
 * Wiring:
 *   AD8232 OUTPUT -> A0
 *   AD8232 LO+    -> D11        (leads-off detect, positive electrode)
 *   AD8232 LO-    -> D10        (leads-off detect, negative electrode)
 *   AD8232 3.3V   -> 3.3V       AD8232 GND -> GND
 *
 * BATTERY POWER ONLY while electrodes are on skin.
 * This is a physiology demonstrator. It is not a diagnostic device and
 * nothing it prints may be used to make a decision about anyone's health.
 */

const uint8_t PIN_ECG = A0;
const uint8_t PIN_LO_P = 11;
const uint8_t PIN_LO_N = 10;

const uint16_t FS_HZ = 500;                     // sample rate
const uint32_t SAMPLE_US = 1000000UL / FS_HZ;   // 2000 us

// R-wave detection
const uint16_t REFRACTORY_MS = 200;   // no second R can occur inside this
const float    THRESH_DECAY  = 0.999f;

uint32_t nextSampleUs = 0;
uint32_t lastRMs      = 0;
uint32_t lastRRMs     = 0;
float    peakEstimate = 0.0f;
bool     armed        = true;

void setup() {
  Serial.begin(115200);
  pinMode(PIN_LO_P, INPUT);
  pinMode(PIN_LO_N, INPUT);
  analogReference(DEFAULT);
  nextSampleUs = micros();
  Serial.println(F("# ecg_raw  bpm  (-1 = leads off)"));
}

void loop() {
  // Fixed-interval sampling. Busy-wait on the timer rather than delay(),
  // so the interval does not drift with the work done in the loop.
  uint32_t now = micros();
  if ((int32_t)(now - nextSampleUs) < 0) return;
  nextSampleUs += SAMPLE_US;

  // Leads-off takes absolute priority over any signal processing.
  if (digitalRead(PIN_LO_P) == HIGH || digitalRead(PIN_LO_N) == HIGH) {
    peakEstimate = 0.0f;
    armed = true;
    Serial.println(F("-1 -1"));
    return;
  }

  int raw = analogRead(PIN_ECG);          // 0..1023
  float centred = (float)(raw - 512);
  float mag = fabs(centred);

  // Adaptive threshold: track the running peak, decay it slowly so the
  // detector follows changing signal amplitude without manual tuning.
  if (mag > peakEstimate) peakEstimate = mag;
  else                    peakEstimate *= THRESH_DECAY;

  float threshold = peakEstimate * 0.6f;
  uint32_t ms = millis();

  if (armed && mag > threshold && threshold > 20.0f) {
    if (ms - lastRMs > REFRACTORY_MS) {
      if (lastRMs != 0) lastRRMs = ms - lastRMs;
      lastRMs = ms;
      armed = false;                       // blank until signal falls back
    }
  }
  if (!armed && mag < threshold * 0.5f) armed = true;

  uint16_t bpm = (lastRRMs > 0) ? (uint16_t)(60000UL / lastRRMs) : 0;

  Serial.print(raw);
  Serial.print(' ');
  Serial.println(bpm);
}

الأدوات المطلوبة:

Computer with Arduino IDEComputer with Arduino IDE
Arduino BoardArduino Board
4

What the high-pass filter does to the ST segment

Loading Jupyter Notebook...

الأدوات المطلوبة:

Desktop ComputerDesktop Computer
5

Check Einthoven's triangle, then stop

Record three traces in turn by moving your electrodes: right arm to left arm for lead I, right arm to left leg for lead II, left arm to left leg for lead III. Record each for thirty seconds with the subject still. Now test the relation. Line the three traces up on a common beat and check that lead II equals lead I plus lead III, sample by sample. It should hold closely, and where it does not, the discrepancy tells you something specific: a large residual means one electrode had poor contact, because the relation is a consequence of Kirchhoff's voltage law and cannot fail if the measurements are good. This is the most useful thing in the blueprint. You have a self-checking measurement — three numbers with one constraint between them, so the data can tell you it is wrong. Build that property into any instrument you can. Where this stops, and it stops firmly. You have built a single-lead biopotential recorder and used it to demonstrate real signal-processing physics. A clinical electrocardiograph is a twelve-lead device with defined electrode positions, calibrated amplitude so that one millivolt is exactly ten millimetres, a defined paper speed of twenty-five millimetres per second, medical electrical isolation tested to a standard, and — the part no bench build can supply — interpretation by someone trained to do it. An ECG trace is not self-explanatory, normal-looking traces occur in serious disease, and abnormal-looking ones occur in perfectly well people. Use this to see the electrical heart, learn what a filter does to evidence, and enjoy the fact that a 270-kilogram instrument from 1903 now fits in your palm. Do not use it to answer a question about anybody's health.

المواد لهذه الخطوة:

Ag/AgCl Disposable Electrodes (50-Pack)Ag/AgCl Disposable Electrodes (50-Pack)1 عبوة

الأدوات المطلوبة:

Digital Oscilloscope (100MHz, 2-Channel)Digital Oscilloscope (100MHz, 2-Channel)
Desktop ComputerDesktop Computer
Analog GalvanometerAnalog Galvanometer

المواد

5

الأدوات المطلوبة

8

المخططات ذات الصلة

هذه المخططات تشارك المعرفة مع هذا — التقنيات والمواد والمبادئ

CC0 ملكية عامة

هذا المخطط مُصدر بموجب CC0. يحق لك نسخه وتعديله وتوزيعه واستخدامه لأي غرض، دون طلب إذن.

ادعم الصانع بشراء منتجات عبر مخططه حيث يكسب عمولة الصانع يحددها البائعون، أو أنشئ نسخة جديدة من هذا المخطط وضمّنه كرابط في مخططك لمشاركة الإيرادات.

النقاش

(0)

تسجيل الدخول للمشاركة في النقاش

جارٍ تحميل التعليقات...