Storing Cookies (See : http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm ) help us to bring you our services at overunity.com . If you use this website and our services you declare yourself okay with using cookies .More Infos here:
https://overunity.com/5553/privacy-policy/
If you do not agree with storing cookies, please LEAVE this website now. From the 25th of May 2018, every existing user has to accept the GDPR agreement at first login. If a user is unwilling to accept the GDPR, he should email us and request to erase his account. Many thanks for your understanding

User Menu

Custom Search

Author Topic: Measuring power with analog oscilloscope  (Read 10176 times)

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Measuring power with analog oscilloscope
« on: October 10, 2016, 12:48:46 AM »
My analog oscilloscope cannot multiply channels, as cannot most other analog oscilloscopes. If it could, then painting the areas under the curves and then counting pixels, were an option. Which is good in that it needs no special software, as ImageMagick can do that. When the channels cannot be multiplied, it is possible to do the same and count pixels in every column for both channels, but this needs writing a special software, and it is not very easy and reliable.

So i use gschem and a script, to calculate power. gschem is what i used to use for drawing circuit diagrams, also for ngspice simulations, but it is a very simple vector graphics editor, with very simple file format. This is the sch file to draw the oscilloscope traces.

Quote
v 20130925 2
L 16503 20501 21503 20501 3 0 0 2 100 100
L 19000 22500 19000 18500 3 0 0 2 100 100
L 16503 16001 21503 16001 3 0 0 2 100 100
L 19000 18000 19000 14000 3 0 0 2 100 100

What follows is a simple example. The last two images are the traces of the first and second channels drawn with gschem. I drew them simply by hand based on the traces on the oscilloscope screen. It has to snap to grid, because the lines have to be joined, but for more precision the grid can be scaled down. The traces have to begin exactly at the beginning of the x axis, and end at the same x exactly at the end of the cycle, the calculation ends when the lines end for both channels. The images are simply screenshots taken from the gschem window with gimp, by selecying a region to grab.

Power is still V * I, even if the current is alternating. It is V * I at any moment, what we need is the average power. This is the python script to calculate the power.

Quote
import sys

XLEFT = 16503
XRIGHT = 21503
Y1TOP = 22500
Y1BOTTOM = 18500
Y2BOTTOM = 14000

if (len(sys.argv) < 2):
   print ("\nUsage: power.py sch_file\n")
   sys.exit()
f = open(sys.argv[1], "r")
lines = []
for s in f:
   l = []
   i1 = -1
   if (s[0] != "L"): continue
   for j in range(0, 5):
      if (i1 == len(s)): break
      i0 = i1 + 1
      i1 = i0 + s[i0:].find(" ")
      if (s[i0:].find(" ") == -1): i1 = len(s)
      if (j and s[i0:i1].isdigit()): l.append(int(s[i0:i1]))
   lines.append([l[0], l[1], l[2], l[3]])
f.close()
del lines[lines.index([16503, 20501, 21503, 20501])]
del lines[lines.index([19000, 22500, 19000, 18500])]
del lines[lines.index([16503, 16001, 21503, 16001])]
del lines[lines.index([19000, 18000, 19000, 14000])]
print ("\nChannel 1 scale (mV)?")
scale1 = int(sys.stdin.readline()) / 1000. / 500.
print ("Channel 2 scale (mV)?")
scale2 = int(sys.stdin.readline()) / 1000. / 500.
print ("Resistance (ohms)?")
r = float(sys.stdin.readline())
if (not r): r = 1e-3
power = 0.
half = (Y1TOP - Y1BOTTOM) / 2
for i in range(XLEFT, XRIGHT + 1, 10):
   current = voltage = y = 0.
   for j in range(0, len(lines)):
      if (i < lines[j][0] or i >= lines[j][2]): continue
      y = float(i - lines[j][0]) / (lines[j][2] - lines[j][0]) * \
         (lines[j][3] - lines[j][1]) + lines[j][1]
      if (lines[j][1] >= Y1BOTTOM):
         voltage = (y - Y1BOTTOM - half) * scale1
      else:
         current = (y - Y2BOTTOM - half) * scale2 / r
   if (y < Y2BOTTOM): break
   power += current * voltage
power = abs(power / (XRIGHT - XLEFT) * 10)
if (power < 1e-3):
   print ("Power was %.4f uW\n" % (power * 1e6))
elif (power < 1):
   print ("Power was %.4f mW\n" % (power * 1e3))
else:
   print ("Power was %.4f W\n" % power)

And this was the result.

Quote
Channel 1 scale (mV)?
10000
Channel 2 scale (mV)?
2000
Resistance (ohms)?
977
Power was 12.4585 mW

To somehow estimate the result, try to calculate the power assuming that both traces were sines, using the conventional way to calculate AC power.

Voltage amplitude was 2.2 * 10 = 22 V and current amplitude was 2.6 * 2 / 977 = 0.00532 A . Voltage root mean square was 22 / sqrt(2) = 15.556 V and current root mean square was .00532 / sqrt(2) = 0.00376 A .

If the current trace were sine, i estimate that the current did then cross 0 risingly approximately at 2.1 scales before the voltage, which is 0.84 times 2.5, which means that phi should be approximately 0.84 * 90 = 76 degrees.

Thus by the conventional calculation, the power was

15.556 * 0.00376 * cos(76) = 0.01415 W = 14.15 mW

This somewhat differs from the result calculated by the scipt, 12.46 mW, but this approximation is very rough and cannot give very precise results. But the result was a similar number, which shows that calculating power in that way works. This may not be the best way to measure power, but when there is no other way, at least it is possible to calculate power. It is some work of course, but it's not very difficult and doesn't take a very long time.

Hope it was useful for someone for some purpose.

verpies

  • Hero Member
  • *****
  • Posts: 3473
Re: Measuring power with analog oscilloscope
« Reply #1 on: October 10, 2016, 11:51:34 PM »
Use this analog multiplier to multiply the i&v channels if your scope cannot.

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #2 on: October 11, 2016, 12:16:31 AM »
Use this analog multiplier to multiply the i&v channels if your scope cannot.

Right, one has to buy it then. Or i'm pretty sure that one can make ones own analog multiplier, but it takes some time and effort. And what one gets is not that good, this painting job may not be easy. One may well end up drawing it all over by hand, not much better than drawing it in gschem. Too much is necessary, compared to the method that i described, that one can use right away. gschem is free and open source, if some didn't know, and i think some other vector graphics editors for circuit simulation are pretty similar, no matter what one uses. Or some other vector graphics editors may also write very simple files. Found no reason to try them though, as i use gschem anyway.

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #3 on: October 11, 2016, 03:56:41 PM »
I use Linux with KDE desktop. I can configure KDE to change transparency (opacity) of a window, with alt + mouse wheel. I open the drawing of the traces in gschem, then the oscilloscope screen image in gimp. I put the gimp and gschem windows one on another, and change the transparency of either the gimp window or the gschem window. Then i can zoom in the graph in gschem, scale the image in gimp to its size, and move the gschem window, so that the graph exactly matches the screen image in gimp. Then i can draw the trace in gschem with short lines, on the oscilloscope screen image in gimp, this can be done pretty fast.

This is when you don't want to draw the lines just visually, either from the oscilloscope screen image or directly from the oscilloscope screen. This is what i did in the example above. And it may be the fastest way of doing it, after you get some experience, if you only want a rough estimation of power.

forest

  • Hero Member
  • *****
  • Posts: 4076
Re: Measuring power with analog oscilloscope
« Reply #4 on: October 11, 2016, 06:01:59 PM »
Any chance you post (in spare time) video explaining this process in details ? How do you snapshot analog scope screen ? Is the resolution important ? Video explanation would be useful especially for people with basic English.

ALVARO_CS

  • Full Member
  • ***
  • Posts: 178
Re: Measuring power with analog oscilloscope
« Reply #5 on: October 11, 2016, 07:21:45 PM »
An of the topic question
I recently bought a Mini DS202 oscilloscope (portable)

Where do I connect the ground clip in the case of an alternating current source ? (eg. the 2 output leads of a coil and a rotor with magnets )

(slowly learning)
thanks
Alvaro

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #6 on: October 12, 2016, 12:27:47 AM »
> Any chance you post (in spare time) video explaining this process in details?

I may do that, but unfortunately i think i would not have enough time for that in any foreseeable future. So don't wait for a video, please try to understand it by what was written.

> How do you snapshot analog scope screen?

I used to do it with my webcam, and guvcview. Just hold it in hand, but it has to be held at the center of the screen, and straight, which is somewhat difficult to do.

> Is the resolution important?

No. Because with an image manipulation program such as gimp, it can be easily scaled, rotated and otherwise transformed.

> Where do I connect the ground clip in the case of an alternating current source?

It depends on your AC source. Like for the example above, i used a wall adapter, that outputs AC voltage. The '-' on the AC source, is the terminal that may be actually connected to the ground. The ground clips of the oscilloscope probes (both are connected to the oscilloscope ground) should be connected to that terminal. Because both the AC source and the oscilloscope may be connected to the ground, and in that case connecting the scope ground to the other terminal causes a short circuit, which may do a lot of damage, to the AC source and to the oscilloscope.

Whether the AC source and the oscilloscope are grounded, and what terminal of the AC source is grounded, can be found by measuring the resistance between the oscilloscope ground and a terminal of the AC source, with a multimeter. If both are grounded, then the resistance is zero. If they are not grounded, like it actually was in my case, though by how i connected the oscilloscope they could as well be grounded, then the oscilloscope ground can be connected anywhere in the circuit. This is called a "hanging scope", but the resistance between the oscilloscope ground and the AC source terminal has to be carefully measured then, and one must be sure that there is never a connection, otherwise it may cause a great damage.

> (slowly learning)

I'm a beginner too, i have not done any electronics as work or anything, though in the university i somewhat learned electronics. It is about finding out what is necessary, all that is about knowledge, more so than experimenting.

To get gschem, install gEDA, this is the general download page for Windows, Linux and macOS  http://wiki.geda-project.org/geda:download . These are the Linux debian packages  https://packages.debian.org/search?keywords=geda , the package should be geda-gschem , you would likely find it with your package manager. There are downloads for Windows  http://www.delorie.com/pcb/geda-windows , you should download the zip file and geda-runtime.exe . There is a bit to download for Windows, but you may not regret, you will also get a great circuit simulator ngspice for Windows.

ALVARO_CS

  • Full Member
  • ***
  • Posts: 178
Re: Measuring power with analog oscilloscope
« Reply #7 on: October 12, 2016, 08:52:40 AM »
thank you ayeaye
My question refers to isolated systems, that is: neither the source nor the scope are grounded, or at last, the scope ground is its own chassis without an (earth) ground reference, and the setup of the coil-rotor is also "floating" so when the coil is producing AC (via induction) there is no -lead and no "hot" line as both alternate.

Or did I got it all wrong ??
thanks
Alvaro

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #8 on: October 12, 2016, 09:12:10 AM »
No, you got it right, if your scope is not grounded, then you can connect the scope ground to anywhere in the circuit (floating scope). Make sure though that your scope is not grounded, like when you give it power by a power adapter, then the power adapter may be grounded and then also the scope is grounded.

ALVARO_CS

  • Full Member
  • ***
  • Posts: 178
Re: Measuring power with analog oscilloscope
« Reply #9 on: October 12, 2016, 11:19:44 AM »
Thank you

forest

  • Hero Member
  • *****
  • Posts: 4076
Re: Measuring power with analog oscilloscope
« Reply #10 on: October 12, 2016, 03:16:03 PM »
For AC I use 1:1 transformer with safely fuse. I made that from two identical step down transformers ,by disassembly and assembly both primaries on one core.


ALVARO_CS

  • Full Member
  • ***
  • Posts: 178
Re: Measuring power with analog oscilloscope
« Reply #11 on: October 12, 2016, 05:27:06 PM »
@forest
I use to measure AC voltage with a DMM previous to connecting the scope, to check if the voltage is in the safe range of probes or scope.
In the setup I want to check out now, which is a small proof of concept, it is OK. My doubt was if I may connect my probe and g clip equally (interchangeably) at both leads of a generator coil.
regards
Alvaro

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #12 on: October 12, 2016, 05:52:28 PM »
For these who don't know what gschem is, gschem is a schematic editor. You likely already know such editor, when you use any software to draw circuit diagrams, to simulate them with any version of spice, or create printed circuit boards. The schematic editor you use there is likely very similar to gschem. This is a very simple editor.

The matter is that i wrote this python script only for gschem, as i cannot write it for all numerous circuit simulation programs there are, or then for all vector graphics editors there are (such as inkscape, heh). The output file format of the schematic editor of many circuit simulation programs may be identical to that of gschem, or then compatible, but i cannot try them all. I leave it to you to port it to any other circuit simulation program, or then to inkscape, if one wishes. I saw no reason to make it for inkscape, as who draws any circuit diagram, uses a schematic editor anyway, why use some other thing. Though inkscape may be more convenient for drawing these traces, gschem is a kind of rudimentary what concerns vector graphics, but then it's simple.

A video i found about gschem, so that you can see what it is  https://www.youtube.com/watch?v=m00pvtFB0oo . Don't be afraid at all, it is very simple.

Measuring power with an analog oscilloscope is though not very precise. Is it possible to achieve a 2% precision? Maybe, with great effort.
« Last Edit: October 13, 2016, 12:11:07 AM by ayeaye »

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #13 on: October 13, 2016, 04:52:24 PM »
Forest, yes, when you actually draw it on the oscilloscope's screen image, then it's not that simple. I included a screenshot to show how it actually looks like. There, the gschem window is on the gimp window where the oscilloscope's screen image is open, and is half transparent. The grid's scale space has been scaled down once in gschem. You see the voltage trace is actually drawn.

Open the oscilloscope's screen image in gimp. I had it 640 x 480, as i used the simplest webcam. The first thing, i increased the canvas size to 1024 x 768, and moved the image to the center. This is because when using the transform tools, the image goes over the size of the original image.

Open also the base sch file for drawing the traces (save it from the text i provided and name, say, power.sch). Better make both windows, gschem and gimp, full screen. Zoom it so that the upper trace grid is nice large, move it to the center. Scale down the grid space for higher precision.

Then the oscilloscope's screen image has to be transformed by the perspective tool, tools -> transform tools -> perspective, to compensate the wrong position of the camera. If you hold the camera exactly at the center of the screen, and turn it so that all lines are perfectly horizontal and vertical, then you save a lot of trouble. But it is very difficult to do by hand, you need a tripod, and even tripod is not enough.

Then put the gimp window on the gschem window. Select the scale tool in gimp, tools -> transform tools -> scale, and make the gimp window half transparent. Then when clicking at the center of the image, you can move the image. Move it so that the beginnings of the x axis are exactly at the same point. Make sure that in the scale tool dialog, maintaining the ratio is selected (x and y are connected). Then hold down the left mouse button and drag, changing the scale so that the right end of the x axis on the oscilloscope's screen image, exactly matches the right end of the x axis on gschem. Then click to the center of the image again, and move it so that both the x and y axis exactly match in gschem and gimp. Then scale the image. You may also do image -> flatten image in gimp, to make the rest of the canvas nice white.

Then make the gimp window opaque, put the gschem window on the gimp window. Select add -> line in gschem. Make the gschem window half transparent. Make again sure that the axis exactly match, like by moving the drawing in gschem. Click to the beginning of the x axis, and start the first line, move to the end of it, and click again. Then click to the end of the last line, and draw the next line, by the trace on the oscilloscope's screen image. To the end of the one cycle.

Drawing the lines is actually the easiest part there, and goes very fast. All this preparations and transforms, is what makes it difficult. But in case of pixel counting, all that should also be done, plus edge detecting and preparing the surfaces for flood fill. So doing it with pixel counting may not be easier at all, and the precision may even be worse, due to imperfections of edge detect and filling.

One uses what fits one best, of course, but when drawing the traces just manually with my method, with enough experience, a rough estimations of power can be found i think certainly much faster than with the pixel counting. Because all the image transforms can be omitted then, and even taking picture of the oscilloscope screen by camera. If this picture is not necessary to show that the trace drawings in gschem correspond to the image on the oscilloscope's screen. But for that the picture can be taken much less carefully, almost any picture or showing it in a video, will do then.

ayeaye

  • Hero Member
  • *****
  • Posts: 866
Re: Measuring power with analog oscilloscope
« Reply #14 on: October 14, 2016, 09:41:07 PM »
Please add here details of how to do it by pixel counting, if one thinks that it has to be done by pixel counting.

For pixel counting, the multiplication of the traces has to be measured, then the areas under the curves have to be flood filled, like the areas above and below the x axis with different colors. Like with gimp, or photoshop, likely the traces have to be made to more or less single lines, with edge detect. Then the pixels have to be counted separately above and below the x axis, like with ImageMagick. Then the number of pixels below the x axis has to be subtracted from the number of pixels above the x axis. That number has to be made to absolute. Then that number has to be multiplied by the scale of the power (how much power corresponds to one pixel in vertical), and divided by the number of columns of pixels, which is the width of the image, if precisely scaled and cropped. This is as much as i can say about how to do it by pixel counting. One should find out oneself, whether it's actually easier or better or not, than my method by using gschem , for ones's purpose or necessary precision.