[{"data":1,"prerenderedAt":247},["ShallowReactive",2],{"project-phasor-measurement-unit":3},{"id":4,"title":5,"body":6,"date":229,"description":230,"extension":231,"icon":232,"image":233,"live":234,"meta":235,"navigation":236,"path":237,"repo":234,"seo":238,"stem":239,"tags":240,"__hash__":246},"projects\u002Fprojects\u002Fphasor-measurement-unit.md","Low-Cost Phasor Measurement Unit",{"type":7,"value":8,"toc":217},"minimark",[9,14,18,30,34,37,59,63,66,71,74,78,81,93,96,100,103,137,160,164,171,186,193,197,204,208,211,214],[10,11,13],"h2",{"id":12},"overview","Overview",[15,16,17],"p",{},"A Phasor Measurement Unit (PMU) is a device that takes precise, time-stamped electrical measurements of a power grid — capturing voltage, frequency, and phase angle — synchronised to a common time reference. That synchronisation is what makes PMUs powerful: it lets grid operators compare measurements taken at different locations at the exact same instant, giving a real-time picture of what's happening across the whole network.",[15,19,20,21,25,26,29],{},"Commercial PMUs are expensive and bulky, limiting how widely they can be deployed. This final year project repurposed existing power measurement hardware and built a fully functional, low-cost PMU firmware in ",[22,23,24],"strong",{},"Rust"," on a Raspberry Pi — targeting real grid monitoring accuracy and full compliance with the ",[22,27,28],{},"IEEE C37.118 synchrophasor standard",".",[10,31,33],{"id":32},"hardware-platform","Hardware Platform",[15,35,36],{},"The firmware runs on a custom board providing:",[38,39,40,47,53],"ul",{},[41,42,43,46],"li",{},[22,44,45],{},"RC voltage divider networks"," — step the three-phase grid voltage (±325V) safely down to ±0.5V for the ADC",[41,48,49,52],{},[22,50,51],{},"MCP3914 ADC"," — an 8-channel, 24-bit delta-sigma converter, synchronously sampling all channels over a 20MHz SPI interface at ~9,875 Hz",[41,54,55,58],{},[22,56,57],{},"u-blox MAX-M10S GNSS module"," — provides UTC time accurate to 60 nanoseconds from the satellite network, connected over I2C",[10,60,62],{"id":61},"pipeline-architecture","Pipeline Architecture",[15,64,65],{},"The firmware is structured as a four-stage pipeline, each running in its own thread and passing data forward via channels:",[15,67,68],{},[22,69,70],{},"Data Acquisition → Data Processing → Data Storage → Data Transmission",[15,72,73],{},"This separation keeps each concern isolated and makes the system easy to test — both the ADC and time provider are defined as Rust traits, meaning fake hardware implementations can be swapped in for unit and integration tests without needing physical devices.",[10,75,77],{"id":76},"time-synchronisation","Time Synchronisation",[15,79,80],{},"Measurements are only meaningful with precise timestamps. The GNSS module delivers an accurate UTC second, but measurements happen thousands of times per second — sub-second resolution is essential.",[15,82,83,84,87,88,92],{},"The solution was the Raspberry Pi's ",[22,85,86],{},"GPU timer"," — a free-running 64-bit counter driven by a 1MHz clock, independent of the CPU and OS scheduler. Accessing it requires memory-mapping the hardware System Timer register directly from ",[89,90,91],"code",{},"\u002Fdev\u002Fmem",", giving 1 microsecond resolution with zero OS overhead. Anchoring this counter to the GNSS second pulse produces a precise full UTC timestamp for every single ADC sample.",[15,94,95],{},"The GNSS parser runs on a dedicated background thread, continuously reading NMEA messages over I2C and updating a shared, mutex-protected timestamp — keeping the acquisition loop free to focus entirely on sampling speed.",[10,97,99],{"id":98},"signal-processing","Signal Processing",[15,101,102],{},"Once samples arrive from acquisition, the processing stage computes:",[38,104,105,119,125,131],{},[41,106,107,110,111,114,115,118],{},[22,108,109],{},"Synchrophasor"," — the magnitude and phase angle of each voltage waveform, calculated via ",[22,112,113],{},"FFT"," using the ",[89,116,117],{},"rustfft"," crate",[41,120,121,124],{},[22,122,123],{},"Frequency"," — derived from the FFT output",[41,126,127,130],{},[22,128,129],{},"ROCOF"," — Rate of Change of Frequency, used for detecting grid instability events",[41,132,133,136],{},[22,134,135],{},"RMS voltage"," — effective magnitude per phase",[15,138,139,140,143,144,147,148,151,152,155,156,159],{},"Before the FFT, each signal passes through a ",[22,141,142],{},"2531-coefficient FIR filter"," to remove noise and out-of-band interference. Spline ",[22,145,146],{},"interpolation"," enforces a consistent effective sampling rate and corrects for any timing gaps. A ",[22,149,150],{},"ring buffer"," (",[89,153,154],{},"BoundedVecDeque",") keeps the most recent samples in memory for continuous windowed analysis. Parallel processing via ",[89,157,158],{},"rayon"," keeps throughput high across all channels.",[10,161,163],{"id":162},"ieee-c37118-compliance","IEEE C37.118 Compliance",[15,165,166,167,170],{},"PMU output is transmitted using the ",[22,168,169],{},"IEEE C37.118.2 protocol"," — the international standard for synchrophasor data transfer — over TCP\u002FIP. The implementation covers:",[38,172,173,176,183],{},[41,174,175],{},"Data frames, configuration frames (CFG-2), header frames, and command frames",[41,177,178,179,182],{},"Binary encoding with ",[22,180,181],{},"CRC-CCITT"," validation on every frame",[41,184,185],{},"Multi-client support with connection and command frame handling",[15,187,188,189,192],{},"A separate ",[22,190,191],{},"WebSocket server"," streams live measurements to a web dashboard for real-time waveform and phasor visualisation.",[10,194,196],{"id":195},"storage","Storage",[15,198,199,200,203],{},"All measurements are persisted to a local ",[22,201,202],{},"SQLite database"," in JSON format, supporting over two days of continuous storage. Historical data can be queried, exported as CSV or JSON, or replayed with timing accuracy for post-hoc analysis.",[10,205,207],{"id":206},"results","Results",[15,209,210],{},"The system met the majority of its requirements: processing latency under 100 microseconds, microsecond-level timestamps, and a complete pipeline from raw ADC samples to IEEE C37.118-formatted output. The trait-based design proved its value during development — the fake ADC and fake time provider let the processing and transmission stages be tested fully on a laptop before any hardware was involved.",[15,212,213],{},"Formal phasor accuracy verification against a reference-grade PMU was not possible within the project scope, leaving that validation as future work.",[215,216],"ui-git-hub-card",{},{"title":218,"searchDepth":219,"depth":219,"links":220},"",2,[221,222,223,224,225,226,227,228],{"id":12,"depth":219,"text":13},{"id":32,"depth":219,"text":33},{"id":61,"depth":219,"text":62},{"id":76,"depth":219,"text":77},{"id":98,"depth":219,"text":99},{"id":162,"depth":219,"text":163},{"id":195,"depth":219,"text":196},{"id":206,"depth":219,"text":207},"Oct 2024","A real-time Phasor Measurement Unit built in Rust on a Raspberry Pi, sampling three-phase grid voltages with GPS-synchronised timestamps and computing phasors, frequency, and ROCOF — fully compliant with the IEEE C37.118 standard.","md","bolt","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1754734387891-36fcbb96f830?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",null,{},true,"\u002Fprojects\u002Fphasor-measurement-unit",{"title":5,"description":230},"projects\u002Fphasor-measurement-unit",[24,241,242,243,244,99,245],"Embedded","Raspberry Pi","Power Systems","GNSS","Linux","1ArS91TECRpCZtlwmaoofAV8Ki9ZDhAnINwhJwaQ2BA",1780176250363]