element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • 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
  • Events
  • 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 2050 views
  • Likes 11 likes
  • Comments 4 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.


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.



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.



The undersides of the boards are shown below.


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.



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.


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.

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).


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:



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.



Summary


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

Anonymous
  • shabaz
    shabaz 1 month ago in reply to neuromodulator

    That's a good idea! I have a counter, so I could set it counting each cycle, and leave it running for say 24 hours and see what the result is compared to the actual time.

    I don't think the 'scope persistence setting will be long enough to catch any strange artifacts that may close the eye-shape, however the MCC 172 card + Pi could capture it for an extremely long time and then plot with unlimited persistence : ) There was a power dip last night that activated the burglar alarm, it's very rare to see such dips,I wish I had been constantly logging!

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • shabaz
    shabaz 1 month ago in reply to michaelkellett

    Hi Michael,

    I was unsure about that too! I can only easily test to 1 kV, at which I see >200 Gohm.

    I took a transformer apart with a Dremel tool. The core is very brittle/flaky thin sheet material in a toroid, with the light-coloured plastic surround visible in the photo. The two windings are on either side of the toroid. The only thing holding the windings apart on each side seems to be the potting material, I couldn't see any other barrier. There is about 4 mm gap between the left and right windings (rough estimate). 

    I've got this ancient Brandenburg 743 power supply which I would have liked to try along with a microammeter meter mechanism, I've had this supply for ages but never tried it because I don't know what connector it needs:

    I cannot tell if it requires a coaxial connector, i.e two conductors, or if it's just a single conductor inside the hole, i.e. if the chassis forms the other terminal. 

    The hole is just over 7mm diameter, and it's 60 mm deep down to the white plastic rim that's visible inside the hole. The hole in that rim is another 10 mm deep. 

    I wanted to replace it with coax but internally it is potted, so it's impossible to modify that connector.

     

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • neuromodulator
    neuromodulator 1 month ago

    Very interesting. Have you tried to time the waveform? In the old times synchronous clocks synched to utility frequency, which was controlled so that in the long run stayed constant. If we take the AC signal as a clock signal it would be interesting to see how it drifts from the ideal frequency. It also would be interesting to see how the waveform looks if you plot it overlapped like in an eye diagram.

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • michaelkellett
    michaelkellett 1 month ago

    Good idea if you need to measure mains often. Design looks good but is 100% dependent on the £0.41 transformer for safeness Slight smile

    Have you a way of testing it - I have a 1000V DC tester but that's about the minimum  - for a test box you should probably test right up to transformer spec (on the basis that if it doesn't meet its spec then it may have a fault which might get worse.).

    MK

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube