element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Or choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Test & Tools
  • Technologies
  • More
Test & Tools
Blog Mains Voltage Supply Monitoring
  • Blog
  • Forum
  • Documents
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Test & Tools requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 24 May 2022 1:05 AM Date Created
  • Views 4688 views
  • Likes 12 likes
  • Comments 5 comments
  • wave miner
  • waveminer
  • mcc172
  • mains test tool
  • mcc daq
  • mains breakout box
Related
Recommended

Mains Voltage Supply Monitoring

shabaz
shabaz
24 May 2022

Table of Contents

  • Introduction
  • Circuit Diagram
  • Construction
  • Using it with a Multimeter or Oscilloscope
  • Capturing using an ADC
  • Processing using Wave Miner
  • Summary

Introduction


Sometimes there's a need or even curiosity to explore what the mains supply voltage looks like on a 'scope. I wanted to be able to do this in a safe way.

This blog post could be useful if there's ever a need to examine the voltage with (say) a multimeter or an oscilloscope, or even to chart or log the measurement over time, or examine any harmonics. It could also be useful for obtaining the 50/60 Hz timing (depending on region), or to connect to an alert if the supply fails.

The photo below shows the output for a nominal 240 V RMS mains input.

image


This project at a high level is simple, but I can't be held responsible if something goes wrong. I believe the project is safe, but no expert has assessed it, so you shouldn't assume it is faultless. If you have any corrections/improvements/tips, then please place them in the comments so that everyone, including myself, can benefit.


Circuit Diagram


The mains supply goes through a fast-blow fuse, and then it is used to supply a small current through four resistors and the primary of a current transformer, all in series. The output of the transformer is used to generate a voltage across a resistor, which is made available on a BNC connector (you could also use banana sockets if desired).


The output voltage will be approximately 1880 times lower than the input voltage, i.e. 240 V RMS will appear as 128 mV RMS and 120V RMS will be 64 mV RMS. If you prefer rounder numbers, then replace the 100-ohm resistor with two 47 ohm resistors in series, and then the output voltage will be 2000 times lower. 1% resistors would be a good option.

image

The ZMPT107-1 transformer (PDF datasheet) is available from AliExpress and from my measurements has a flat frequency response from at least 50 Hz to beyond 1 kHz (I didn't check beyond this range), so it is handy for observing mains harmonics levels too. The phase shift between input and output is about 2 degrees at 100 Hz, and about 20 degrees at 1 kHz.


Construction


I didn't create a custom PCB for this project, although it would benefit from that. Instead, the prototype uses single-sided copper-clad board; the copper was removed (I used a manual milling machine, it's a 15-minute job with that) leaving lots of clearance between the connections.


Extra holes were drilled for all off-board connections so that wires could be passed through them for some strain relief, or cable ties could be used to secure the wires further.


I placed everything to the left of the transformer onto one board, and the transformer and output resistor onto a separate board. This was so that it could fit more easily into the enclosure, and also it allows me to more easily swap out the transformer if I ever needed to.

image

The undersides of the boards are shown below.

image


The board undersides were covered with MG Chemicals 422C coating (a couple of coats) and dried off with a hot air tool.


The IEC connector hole was cut in the enclosure using a Dremel tool with cutting disc attachment. I used a Hammond 1591C enclosure.

image

I secured the IEC connector, and the BNC connector from rotating, with a small bit of superglue (the IEC connector has plastic tabs that prevent it from popping out, but it's better safe than sorry).

Thick wire (18 AWG) with a flame rating should be used for the connections to the IEC connector, so that the fuse blows in a fault condition, rather than the wire melting. Use a plastic enclosure with a flame rating. Stick a mains warning label inside the enclosure, or at least on the outside (or both). Don't omit the IEC connector, it makes the project safer than directly attaching mains cable to the box. The fuse is important too. Try to reduce the amount of naked connections just in case a user touches something.

image


Using it with a Multimeter or Oscilloscope


I connected a BNC-to-Banana-Plug cable to the device and attached a multimeter as shown in the earlier photo. The measured voltage was 0.128V where I am based (the mains voltage is 240V nominal).


By measuring the mains voltage directly and comparing the result, it was determined that the measurement needs to be multiplied by approximately 1900 in order to obtain the actual voltage of the mains supply, which is close to the calculated value.


Next, I swapped out the multimeter with an oscilloscope. The result is shown below. The flattened top and bottom is expected; the mains supply where I am based always has this shape. The 'scope measurements also show 0.128V, and the frequency was close to 50 Hz as expected too.

image

Capturing using an ADC

By connecting the tool to an ADC board, it is possible to log the data to a PC, for additional processing. A sound card would be one option. I used the MCC 172 card, it is possible for the Raspberry Pi to capture the data with great detail.
The chart below shows some captured data (see the MCC 172 RoadTest review to see how to capture the data; in brief, I installed and used the mcc-daq-tools on GitHub that were developed during the RoadTest, by typing the following on the Pi:


cd ~/development/daqproj/daqstream
./daqstream


The above daqstream commands expose the data to other programs. I used Matlab. If you wish to use LabView, see Jan's RoadTest review for the MCC 172. Within Matlab, I typed the following to capture five seconds of data from the two channels that are on the MCC 172 board:


[c1 c2] = daqgrab(5);


The daqstream and daqgrab programs are on the GitHub site.
The above command captured five seconds of data to an array called c1 (The MCC 172 card has two inputs, but the second channel was unused and c2 is just an unused array containing 0V measurements).

image


It is possible to compute the RMS and THD values by typing in Matlab:


rms(c1)
thd(c1)


Here is the frequency domain view; I used Matlab's Signal Analyzer to auto-generate the commands for this, and then tweaked them to display the data in a friendly way:

image



Processing using Wave Miner


It's possible to connect the device to the Wave Miner which is a cheap Digital Signal Processor (DSP) board connected to a Raspberry Pi, to approximately measure the mains signal and to compute the distortion. The result won't be as accurate as using the MCC 172, but it's still useful if no more accurate tool is available.


I'll post the code to the Wave Miner GitHub page in the next few days. It computed the distortion in my case to be 2.5%, whereas the MCC 172 and Matlab measurement was 3.1%. The diagram below shows how the Wave Miner code works. It implements a ton of filters, all aligned to the harmonics, and basically measures the amplitude of the output for each filter. The Pi collects the results and computes the THD value.

image


Summary


This short project allows the user to be able to examine mains voltages in a hopefully safe way. Thanks for reading.

  • Sign in to reply
Parents
  • shabaz
    shabaz over 1 year ago

    There was a mains outage today, it covered a large portion of the town (49 postal codes!).

    Anyway, even after an hour or so, the mains voltage is still not fully recovered, it is slightly lower than usual.

    I took a few captures using this project, with an ADC connected to the Pi (using an ADC board reviewed here), about an hour after some electricity returned, I didn't capture the precise time unfortunately.

    By chance I caught a very noticeable fluctuation in the mains voltage. Y-axis is volts:

    image

    The only reason I decided to capture the mains was because the electric fan sounded strange, it had a louder-than-normal whine from its motor (presumably an induction motor) that was very noticeable at its slowest setting. 

    I've placed CSV files of a few mains captures that I took about an hour after the outage, in a file called mains_data.zip in case anyone ever wants to explore such a thing (I have not looked in any more detail than this). The captures are for 5 and 30 seconds, there are several files in the zip folder, and they were captured in the order that they are named, i.e. the file c1 was captured before d1. The sample values in the files need multiplying by 1880 to see the actual values in volts.

    The chart above is drawn from the file c1.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • shabaz
    shabaz over 1 year ago

    There was a mains outage today, it covered a large portion of the town (49 postal codes!).

    Anyway, even after an hour or so, the mains voltage is still not fully recovered, it is slightly lower than usual.

    I took a few captures using this project, with an ADC connected to the Pi (using an ADC board reviewed here), about an hour after some electricity returned, I didn't capture the precise time unfortunately.

    By chance I caught a very noticeable fluctuation in the mains voltage. Y-axis is volts:

    image

    The only reason I decided to capture the mains was because the electric fan sounded strange, it had a louder-than-normal whine from its motor (presumably an induction motor) that was very noticeable at its slowest setting. 

    I've placed CSV files of a few mains captures that I took about an hour after the outage, in a file called mains_data.zip in case anyone ever wants to explore such a thing (I have not looked in any more detail than this). The captures are for 5 and 30 seconds, there are several files in the zip folder, and they were captured in the order that they are named, i.e. the file c1 was captured before d1. The sample values in the files need multiplying by 1880 to see the actual values in volts.

    The chart above is drawn from the file c1.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube