Building a 3 Phase Power Analyzer: THD, FFT, and waveform recording

Hi Everybody,

I’m splitting the post in 3 post, since as a new user I can´t post more than one photo per post :disappointed:
[That should be fixed now - RW]

I’m new here, but I have been using OEM project parts for my experiments for two years more or less.
I have built and used for more than a year some systems for measuring water pumps. After building some prototypes around the EmonTX system, I switched to a commercial power analyzer for measuring the electrical parameters.

Here some photos of the system I built more than a year ago, which has worked flawlessly:

My current project is to build a 3 phase power analyzer, with the following requirements:

  1. 3 Phase V, I, P, VA, VAr
  2. THD measuring of V and I
  3. FFT of V and I for harmonics analysis
  4. Relative angles between phases, V and I, and vector graph.
  5. V and I waveform recording.

The project will fall between the OpenEnergy project and the OpenPowerQuality.org project.

The hardware I will be using is the following:

  1. 220 to 9 Volt AC transformers, 3 units. With divisor resistors
  2. 220 to 5 DC Power supply
  3. Teensy 3.2
  4. 1.8 Inch TFT display
  5. TTL to RS-485 converter
  6. Moteino LoRa 868 MHz
  7. Rapsberry Pi 3
  8. Maybe a 232-USB converter and a 485-USB converter

I will be comparing the measurements with a Eastron SDM630M CT Power Analyzer:

I will keep you in touch with the project progress.

Have a nice day,

Edit - fixed link. Moderator, BT

2 Likes

Hi all!!

I have wired the Teensy 3.2 and started wirking with this:

Here is the wiring I have made:

And here a photo of the oscilloscope and the FFT. With a Sample rate of 1600Hz and a FFT of 64, I get up to the 16th Harmonic and enough channel separation, for 1600Hz with a FFT of 32 would be enugh, but I’ll continue testing:

Good afternoon :smiley:

1 Like

Not bad!
It is a very interesting project. I will follow your progress.

What is your goal with the project?
What will be your next step?

Hi!

The next steps will be:

  1. Define the hardware I will be using.
  2. Implement the sampling of the 6 channels, FFT, integrate the EmonLib.
  3. Design a software for the Raspberry that will be the frontend.
  4. Decide the communication protocol that I’ll be using.

Now I’m investigating what to use for the frontend. Probably I will start with the Spectrograph program of the Adafruit example, which is written in Python.

Have a nice day,

Hi everyone!

It seems that the Teensy 3.2 a good choice. I’m sampling 3 V-I pairs (total 6 channels) at 3200Hz each and sending the raw data to my computer via USB, and it works. Currently I have the all channels connected to the same AC signal, so I can compare the timings. I’m setting up a repository i Github, so I’ll post the code soon.

Now I have to decide, if I make all the math (FFT, Vrms, Irms, P, VA…) in the Teensy, or I do it on the PC / RPi.What would you do?

Here is the output of the Python script I have made:

-------------------------
Bytes received: 3077
Packet conformed
Samples Packet
V1 data:  [1251, 1382, 1511, 1640, 1769, 1903, 2024, 2164, 2269, 2379, 2478, 2580, 2671, 2770, 2863, 2958, 3058, 3143, 3213, 3262, 3297, 3309, 3310, 3314, 3313, 3309, 3301, 3291, 3273, 3176, 3089, 2998, 2877, 2756, 2625, 2499, 2373, 2239, 2117, 2000, 1873, 1763, 1660, 1554, 1465, 1364, 1269, 1170, 1077, 984, 910, 863, 827, 813, 809, 808, 811, 814, 822, 829, 848, 941, 1033, 1125, 1243, 1371, 1500, 1629, 1754, 1889, 2013, 2154, 2261, 2374, 2470, 2574, 2663, 2759, 2857, 2952, 3053, 3134, 3209, 3261, 3291, 3309, 3313, 3315, 3313, 3308, 3301, 3291, 3277, 3181, 3097, 3009, 2891, 2768, 2637, 2509, 2377, 2249, 2128, 2006, 1883, 1783, 1677, 1565, 1471, 1373, 1278, 1176, 1077, 991, 915, 867, 827, 814, 810, 810, 809, 815, 819, 833, 843, 931, 1022, 1117, 1236, 1358, 1489, 1620, 1745, 1881, 2002, 2143, 2250, 2363, 2462, 2567, 2654, 2756, 2848, 2945, 3042, 3127, 3205, 3255, 3291, 3309, 3311, 3315, 3314, 3308, 3304, 3295, 3278, 3195, 3106, 3013, 2900, 2778, 2651, 2521, 2394, 2262, 2138, 2027, 1892, 1782, 1676, 1573, 1480, 1382, 1286, 1189, 1091, 996, 921, 871, 834, 812, 814, 809, 809, 814, 821, 829, 842, 920, 1015, 1112, 1221, 1347, 1475, 1608, 1737, 1870, 1994, 2135, 2242, 2351, 2454, 2558, 2651, 2746, 2840, 2937, 3036, 3124, 3200, 3253, 3289, 3302, 3310, 3310, 3317, 3309, 3305, 3294, 3282, 3206, 3108, 3022, 2905, 2785, 2660, 2532, 2401, 2274, 2148, 2021, 1900, 1789, 1685, 1579, 1485, 1391, 1292, 1196, 1097, 1004, 924, 875, 836, 810, 809, 809, 807, 811, 820, 829, 840, 914, 1009, 1104]
V2 data:  [1268, 1391, 1521, 1652, 1784, 1914, 2036, 2167, 2282, 2394, 2490, 2595, 2674, 2787, 2878, 2971, 3072, 3156, 3223, 3274, 3304, 3320, 3322, 3322, 3325, 3313, 3310, 3297, 3276, 3177, 3090, 2997, 2876, 2752, 2628, 2497, 2367, 2234, 2117, 1989, 1867, 1760, 1656, 1555, 1460, 1361, 1265, 1167, 1069, 981, 908, 860, 829, 814, 811, 812, 812, 818, 824, 834, 854, 950, 1039, 1136, 1257, 1382, 1511, 1640, 1776, 1904, 2027, 2162, 2274, 2381, 2479, 2585, 2676, 2775, 2868, 2966, 3065, 3144, 3221, 3272, 3303, 3318, 3321, 3323, 3320, 3315, 3309, 3299, 3281, 3187, 3097, 3008, 2885, 2764, 2640, 2508, 2377, 2245, 2127, 1998, 1877, 1770, 1666, 1560, 1469, 1372, 1275, 1177, 1075, 988, 913, 865, 832, 816, 812, 810, 815, 817, 819, 830, 852, 938, 1030, 1127, 1244, 1369, 1501, 1630, 1760, 1894, 2016, 2156, 2264, 2369, 2472, 2581, 2667, 2766, 2863, 2956, 3057, 3146, 3216, 3265, 3300, 3315, 3320, 3322, 3321, 3312, 3311, 3298, 3285, 3198, 3105, 3015, 2898, 2775, 2649, 2520, 2384, 2261, 2132, 2019, 1885, 1777, 1672, 1567, 1472, 1378, 1281, 1185, 1084, 994, 919, 870, 833, 817, 814, 811, 815, 818, 823, 834, 846, 931, 1022, 1118, 1231, 1359, 1486, 1622, 1750, 1882, 2007, 2145, 2252, 2364, 2464, 2571, 2663, 2758, 2852, 2950, 3051, 3135, 3212, 3261, 3300, 3312, 3322, 3323, 3322, 3317, 3311, 3301, 3287, 3202, 3112, 3024, 2907, 2785, 2662, 2530, 2400, 2267, 2141, 2018, 1894, 1786, 1684, 1578, 1480, 1386, 1289, 1193, 1091, 1001, 923, 873, 837, 817, 811, 811, 810, 815, 819, 830, 841, 920, 1016, 1111]
V3 data:  [1276, 1399, 1530, 1663, 1798, 1923, 2046, 2184, 2292, 2403, 2502, 2603, 2692, 2797, 2887, 2982, 3085, 3164, 3233, 3272, 3309, 3322, 3325, 3324, 3325, 3321, 3310, 3301, 3277, 3173, 3083, 2991, 2872, 2743, 2619, 2490, 2362, 2230, 2111, 1982, 1865, 1756, 1650, 1547, 1455, 1356, 1260, 1162, 1064, 975, 906, 856, 827, 813, 811, 810, 812, 817, 825, 834, 858, 954, 1047, 1144, 1265, 1392, 1524, 1652, 1783, 1919, 2037, 2176, 2280, 2390, 2491, 2595, 2686, 2785, 2879, 2974, 3076, 3156, 3226, 3276, 3310, 3325, 3325, 3326, 3325, 3321, 3314, 3302, 3278, 3179, 3098, 3000, 2882, 2762, 2632, 2500, 2370, 2238, 2119, 1991, 1873, 1761, 1658, 1556, 1464, 1364, 1265, 1169, 1071, 982, 909, 866, 830, 814, 813, 812, 813, 817, 823, 840, 854, 947, 1036, 1133, 1253, 1378, 1510, 1641, 1769, 1901, 2028, 2165, 2275, 2381, 2482, 2590, 2675, 2776, 2872, 2970, 3066, 3153, 3227, 3273, 3306, 3325, 3326, 3322, 3323, 3319, 3314, 3306, 3286, 3197, 3103, 3010, 2893, 2772, 2642, 2513, 2384, 2255, 2132, 2003, 1881, 1764, 1659, 1563, 1470, 1372, 1276, 1179, 1078, 988, 914, 869, 832, 816, 815, 811, 808, 813, 819, 837, 850, 938, 1029, 1127, 1243, 1368, 1498, 1630, 1759, 1892, 2020, 2157, 2264, 2374, 2476, 2581, 2672, 2769, 2862, 2960, 3061, 3146, 3220, 3277, 3300, 3319, 3326, 3325, 3325, 3325, 3320, 3305, 3287, 3202, 3110, 3021, 2901, 2778, 2655, 2534, 2391, 2263, 2125, 2013, 1889, 1781, 1677, 1568, 1472, 1382, 1277, 1188, 1084, 993, 920, 870, 834, 816, 812, 812, 814, 818, 823, 831, 847, 929, 1026, 1119]
I1 data:  [1253, 1369, 1510, 1641, 1766, 1907, 2020, 2162, 2267, 2378, 2478, 2581, 2673, 2784, 2868, 2959, 3055, 3144, 3213, 3262, 3300, 3309, 3318, 3313, 3313, 3308, 3303, 3291, 3270, 3181, 3089, 2999, 2878, 2762, 2625, 2500, 2372, 2239, 2119, 2001, 1874, 1762, 1659, 1554, 1464, 1364, 1268, 1172, 1071, 983, 911, 865, 827, 812, 807, 809, 807, 815, 821, 831, 849, 941, 1030, 1124, 1243, 1368, 1501, 1630, 1760, 1892, 2015, 2153, 2260, 2369, 2470, 2575, 2666, 2762, 2858, 2954, 3053, 3134, 3209, 3258, 3293, 3309, 3314, 3312, 3311, 3306, 3303, 3293, 3275, 3186, 3096, 3006, 2887, 2766, 2640, 2510, 2378, 2251, 2128, 2009, 1881, 1768, 1671, 1563, 1469, 1373, 1279, 1181, 1087, 991, 915, 864, 835, 815, 811, 809, 811, 817, 818, 831, 843, 932, 1023, 1118, 1232, 1355, 1486, 1620, 1745, 1881, 2004, 2143, 2251, 2361, 2466, 2568, 2654, 2754, 2849, 2945, 3042, 3128, 3206, 3256, 3290, 3307, 3314, 3314, 3311, 3309, 3301, 3295, 3276, 3197, 3104, 3011, 2899, 2776, 2652, 2521, 2390, 2262, 2135, 2027, 1894, 1781, 1681, 1573, 1479, 1381, 1283, 1191, 1090, 995, 920, 876, 835, 816, 809, 809, 810, 811, 818, 825, 843, 917, 1016, 1110, 1222, 1347, 1472, 1607, 1738, 1870, 1994, 2134, 2245, 2349, 2451, 2557, 2655, 2745, 2844, 2934, 3036, 3127, 3202, 3254, 3288, 3306, 3314, 3315, 3312, 3311, 3303, 3294, 3282, 3202, 3118, 3015, 2906, 2786, 2663, 2528, 2402, 2269, 2145, 2025, 1899, 1789, 1686, 1578, 1483, 1385, 1289, 1195, 1095, 1005, 925, 874, 835, 815, 808, 809, 810, 812, 819, 827, 840, 913, 1010, 1102]
I2 data:  [1262, 1397, 1521, 1652, 1782, 1916, 2035, 2167, 2282, 2390, 2491, 2594, 2673, 2782, 2877, 2972, 3072, 3155, 3222, 3274, 3306, 3321, 3319, 3320, 3320, 3317, 3306, 3298, 3277, 3173, 3089, 2997, 2875, 2757, 2627, 2495, 2367, 2234, 2115, 2006, 1869, 1757, 1656, 1557, 1462, 1358, 1258, 1165, 1069, 981, 909, 862, 828, 815, 811, 810, 814, 815, 823, 837, 857, 951, 1040, 1136, 1255, 1381, 1512, 1641, 1772, 1903, 2026, 2163, 2273, 2381, 2483, 2585, 2678, 2777, 2871, 2966, 3068, 3146, 3221, 3266, 3301, 3318, 3319, 3327, 3319, 3321, 3307, 3301, 3282, 3187, 3096, 3003, 2889, 2765, 2636, 2508, 2375, 2246, 2123, 2004, 1887, 1766, 1664, 1563, 1466, 1368, 1271, 1175, 1077, 987, 913, 864, 841, 819, 819, 811, 812, 816, 824, 834, 849, 943, 1030, 1128, 1242, 1368, 1500, 1625, 1759, 1896, 2020, 2155, 2262, 2373, 2479, 2579, 2666, 2767, 2864, 2957, 3055, 3141, 3215, 3266, 3298, 3317, 3319, 3322, 3320, 3317, 3309, 3302, 3286, 3196, 3108, 3013, 2898, 2776, 2646, 2518, 2384, 2259, 2131, 2021, 1886, 1775, 1674, 1566, 1475, 1373, 1281, 1184, 1086, 994, 924, 874, 832, 818, 812, 813, 811, 816, 824, 832, 845, 933, 1024, 1118, 1230, 1353, 1486, 1618, 1748, 1884, 2007, 2147, 2256, 2368, 2466, 2571, 2661, 2760, 2852, 2949, 3046, 3135, 3213, 3263, 3297, 3318, 3322, 3323, 3323, 3317, 3311, 3298, 3277, 3202, 3107, 3017, 2908, 2781, 2654, 2527, 2401, 2262, 2143, 2023, 1893, 1785, 1679, 1580, 1475, 1385, 1287, 1193, 1088, 1002, 920, 871, 835, 817, 813, 811, 809, 814, 824, 831, 845, 921, 1019, 1114]
I3 data:  [1276, 1399, 1532, 1663, 1793, 1924, 2045, 2185, 2292, 2400, 2501, 2603, 2694, 2793, 2887, 2981, 3081, 3164, 3229, 3278, 3311, 3323, 3324, 3326, 3325, 3318, 3312, 3302, 3276, 3173, 3086, 2994, 2871, 2747, 2623, 2490, 2360, 2229, 2110, 1988, 1863, 1754, 1651, 1547, 1458, 1359, 1259, 1160, 1060, 976, 905, 858, 832, 814, 812, 811, 815, 821, 825, 829, 852, 958, 1047, 1144, 1265, 1392, 1523, 1651, 1784, 1914, 2038, 2179, 2281, 2390, 2492, 2598, 2688, 2785, 2881, 2973, 3075, 3155, 3232, 3277, 3309, 3321, 3316, 3325, 3320, 3316, 3309, 3303, 3286, 3185, 3091, 3000, 2879, 2758, 2630, 2501, 2367, 2241, 2123, 1995, 1871, 1762, 1659, 1553, 1470, 1359, 1267, 1169, 1070, 983, 910, 863, 831, 815, 812, 811, 814, 824, 828, 836, 853, 949, 1038, 1133, 1252, 1378, 1509, 1639, 1771, 1904, 2027, 2164, 2272, 2382, 2486, 2589, 2678, 2775, 2872, 2967, 3066, 3149, 3224, 3273, 3301, 3321, 3324, 3326, 3324, 3321, 3312, 3304, 3285, 3193, 3105, 3011, 2893, 2769, 2642, 2508, 2384, 2256, 2135, 2007, 1879, 1769, 1669, 1564, 1471, 1371, 1276, 1178, 1077, 988, 916, 868, 831, 818, 813, 812, 815, 817, 825, 834, 847, 940, 1032, 1126, 1242, 1369, 1498, 1629, 1760, 1892, 2016, 2156, 2262, 2374, 2472, 2580, 2673, 2768, 2863, 2964, 3061, 3145, 3219, 3267, 3304, 3319, 3328, 3327, 3326, 3322, 3314, 3305, 3292, 3199, 3110, 3019, 2901, 2775, 2653, 2527, 2391, 2262, 2127, 2018, 1889, 1778, 1675, 1570, 1476, 1380, 1280, 1187, 1084, 996, 922, 873, 833, 818, 816, 814, 807, 812, 823, 832, 846, 927, 1024, 1119]

And one second of data more ore less:

out4.txt (620.9 KB)

Here I attach the code I’m using:
Files.zip (2.9 KB)

Have a nice day!!!

Hi all!!

I have decided to do all the math in the Raspberry Pi.

Here I attach a video of the setup doing FFT in 6 channels, and some photos of the setup. It is doing FFT up to 1600 Hz, but I truncated it to be able to show it on the RPi display. I have the same V connected to all V inputs and the same I clamp to all I inputs.

The next step is to do all the conventional math that EmonLib does, but in Python.

The hardware, RPi3 + Official Display, 5 Volt power supply, the Teensy 3.2 in the protoboard and the Voltage transformers under it.:

Photo of the display:

Have a nice day.

Hi again, I’m making progresses with the project.

I have mounted it in a permanent enclosure, and now I’ll improving the math, the event detector (when voltage is inconsistent, too much harmonics…) and the waveform recording if there is a event. After that I’ll do the GUI.

Photos, and video:

The box I’ll be using:

Cut for the RPi and the Display:

Display and RPi mounted:

Top of the Teensy Part:

Bottom of the Teensy part:

Top of the power part:

Bottom of the power part:

Closing the case:

Completed:

The system running:

The data of one phase:

Video of the system running:

.ino and Python files:
Packet_reader.zip (5.4 KB)

Have a nice day :smiley:

1 Like

Hi!!

I’m triying to build the GUI, here a photo and a video :slight_smile:

Video:

Have a nice sunday afternoon :smiley:

3 Likes

Great Job!!

Thank you for sharing your code. It seems to work good!:raised_hands:

Is the Voltage FFT correct? Your Voltage signal looks pretty pure in the time domain, but in the frequency domain it looks almost as distorted as your Current signal. In my monitor I don’t bother with a voltage FFT because it’s so predictable as you can see below. That pic is actually an FFT of the Current in the lights circuit with about 820W of incandescent bulbs on, which should be a pretty good approximation of the Voltage FFT. Even with a bit of flat-topping not much shows up in the FFT.


Hi dBC,

I’m calculating the spectrum in a logarithmic scale, I’m applying a log_10(x) formula. The units doesn’t have any sense, but the sacale is logarithmic in base 10. You can note that although the harmonics are greater after 3rd harmonic (4th point in the graph, the first is DC, sencond 50Hz, third 100Hz…), the 50 Hz component is much greater. Maybe I should change units and remove the log scale…

Thanks for the ideas :smiley:

A logarithmic scale explains it. Don’t remove it on my account, it’s a good way to bring out the detail.

hi
thank you for your time and sharing

Hi! Can u help me?

I need to measure the instantaneous power. The ‘watt’ or ‘VA’ values on the video is the instantaneous power?