Measuring three-phase mains with a microcontroller needs isolation, scaling and some care in firmware. This guide uses small potential transformers (PTs) to measure phase and line-to-line voltages, detect a failed phase and check phase sequence, based on a charger monitor we built.

In this article
  • Why use PTs for mains voltage sensing
  • Scaling a 220:12 V PT into a 3.3 V ADC
  • Phase-to-neutral and line-to-line RMS
  • Detecting phase failure and phase sequence
  • Calibration and safety

Why potential transformers?

A resistor divider straight from the mains can measure voltage, but it ties your whole circuit to line potential. A small PT per phase gives isolation, so the microcontroller, display and communication ports stay safe to touch and easy to connect to other equipment.

The front-end circuit

RYB PT 220:12 V150 kΩ10 kΩ to bias1 kΩ + 10 nF MCU ADCCH1: RCH2: YCH3: B Bias: Vref/2Sample all threechannels per scan Neutral returns of the PT primaries are not shown. Fuse each PT primary.
Each phase is stepped down and isolated by a small PT, scaled by a divider around the Vref/2 bias, filtered and sampled by the ADC.

Scaling a 220:12 V PT for a 3.3 V ADC

Design for the highest voltage you must measure without clipping, not the nominal one. With a 220:12 V PT:

ConditionPhase voltagePT secondary (rms)Secondary peakPeak at ADC with 150k/10k (÷16)
Nominal230 V12.5 V17.7 V1.11 V
High mains250 V13.6 V19.3 V1.21 V
Surge margin300 V16.4 V23.1 V1.45 V

With the signal biased at 1.65 V, a 1.45 V peak still fits inside 0–3.3 V, so the reading stays valid up to about 300 V phase-to-neutral. Use our voltage divider calculator to check other ratios. Remember that a lightly loaded PT outputs more than its nameplate voltage, so measure it and set the final scale by calibration.

Phase-to-neutral and line-to-line voltages

Compute each phase RMS the same way as for current: remove the bias, square, average over whole cycles and take the square root. For line-to-line voltages, do not just multiply by √3; that is only true when the phases are balanced. Instead, subtract the two phase samples taken in the same ADC scan and compute the RMS of the difference:

#include <math.h>
#include <stdint.h>

/* a, b: bias-removed samples of two phases taken in the same ADC scan
   k: volts per count referred to the PT primary (divider x PT ratio x cal) */
float line_to_line_rms(const int16_t *a, const int16_t *b, uint32_t n, float k)
{
    float acc = 0.0f;
    for (uint32_t i = 0; i < n; i++) {
        float d = (float)(a[i] - b[i]);     /* v_RY = v_R - v_Y */
        acc += d * d;
    }
    return sqrtf(acc / (float)n) * k;
}

If the ADC converts channels one after another, there is a small time skew between R, Y and B samples. At 50 Hz and a few microseconds per channel the error is tiny, but for best accuracy use simultaneous-sampling ADCs or interpolate.

Detecting a failed phase

  • Treat a phase as good inside a window, for example 180–250 V phase-to-neutral, and as failed outside it.
  • Add hysteresis and a short delay so a single dip does not trip the alarm.
  • Only report line-to-line values that involve two good phases; show the failed phase clearly instead.
  • Switch the main contactor or breaker indication on only when all three phases are good.

Frequency and phase sequence

Detect rising zero crossings on each phase (with a little hysteresis). The time between crossings on one phase gives the frequency; the order in which R, Y and B cross gives the sequence. R → Y → B with about 6.67 ms between them at 50 Hz is the correct rotation; anything else should raise a phase-sequence fault before motors or rectifiers start.

Calibration and safety

  • Calibrate each channel against a true-RMS meter and store the gain in non-volatile memory.
  • Fuse each PT primary and keep mains creepage distances on the PCB.
  • Choose PTs with a suitable insulation rating and test voltage for your installation category.

Where we used this

This approach measures the three-phase input of our industrial battery charger monitor, which shows RY, YB and BR line voltages, flags a failed phase and only shows the AC breaker as ON when all three phases are good.

Building a charger, inverter or monitoring product? We design measurement front ends, firmware and complete controllers. Message us on WhatsApp or use the contact form.


MKDas

Mithun K. Das. B.Sc. in Electrical and Electronic Engineering (EEE) from KUET. Senior Embedded Systems Designer at a leading international company. Welcome to my personal blog! I share articles on various electronics topics, breaking them down into simple and easy-to-understand explanations, especially for beginners. My goal is to make learning electronics accessible and enjoyable for everyone. If you have any questions or need further assistance, feel free to reach out through the Contact Us page. Thank you for visiting, and happy learning!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *