Spectrum Lab User's Group is a Restricted Group with 914 members.
 Spectrum Lab User's Group

 Restricted Group,
 914 members
PowerMeter
 I built a powermeter for mains and try to calibrate the whole thing via
the soundcard.
Is it possible to make a script for a realtime powermeter?
That is:
1. signed multiply channel L and R
2. integrate for one or multiple unit of line frequency (e.g. 20ms for
50Hz). In discrete time steps or better continuous.
3. dump result into FFT window
I'm not sure which way to go and looking for help there.
regards 
Henry

ehydra.dyndns.info  Hello Henry,
The script can control the signal analysis functions, but it's impossible to run the stream of audio samples. There are multipliers which can be switched into the signal, but one of the multiplier's input is always a numerically controlled oscillator. For a wattmeter, we'd need a multiplier which takes the inputs from both branches of the signalprocessing chain.
I will implement such a multiplier as part of the 'DSP blackbox' for the next version.
To measure the DC component in the output one could use a simple lowpass filter with sufficient rejection at the mains frequency.
Main problem: You will still need some way to calibrate this setup, at least with a digital voltmeter to adjust the soundcard's input volume controls.
Best greetings,
Wolf .
Am 05.11.2011 22:59, schrieb ehydra:I built a powermeter for mains and try to calibrate the whole thing via
the soundcard.
Is it possible to make a script for a realtime powermeter?
That is:
1. signed multiply channel L and R
2. integrate for one or multiple unit of line frequency (e.g. 20ms for
50Hz). In discrete time steps or better continuous.
3. dump result into FFT window
I'm not sure which way to go and looking for help there.
regards 
Henry

ehydra.dyndns.info
 Fine Wolf. Calibration is not a problem with a Scope and a resitive load
like a bulb.
 Henry
wolf_dl4yhf schrieb:> I will implement such a multiplier as part of the 'DSP blackbox' for the

> next version.
>
> To measure the DC component in the output one could use a simple lowpass
> filter with sufficient rejection at the mains frequency.
>
> Main problem: You will still need some way to calibrate this setup, at
> least with a digital voltmeter to adjust the soundcard's input volume
> controls.
ehydra.dyndns.info  The multiplication of two input channels is already working now. Still
missing is a way to retrieve the DC component of the product, but I
think I will abuse the 'DC removal' filter for this purpose  it already
detects the DC component, all that is missing is a function for the
interpreter to read this value.
Ok about the light bulb  if you measure the voltage and current
simultaneously, there's no problem. But due to the temperature dependent
resistance of the filament, you can't imply the current from the
measured voltage (or vice versa). If the filament is very thin (as in
240 Volt bulbs), there may even be a slight phase shift between voltage
and current caused by this effect.
New version (beta) will be available in a few days.
Cheers,
Wolf .
The multiplication of two input channels is already working now. Still
missing is a way to retrieve the DC component of the product, but I
think I will abuse the 'DC removal' filter for this purpose  it already
detects the DC component, all that is missing is a function for the
interpreter to read this value.Wolf,
Is it possible to take the inputs to the two sounds channels (A and B) and display the freuency spectrum of (A+iB) and (AiB) where the i is a 90 degree phase shift? I want to tell more than just if A and B are 90 degrees out of phase  I want to tell which direction (which of A or B, leads the other). I am doing radio astronomy and I think that there is useful information that can be extracted from comparing two signals that I think will be already in quadrature.Thanks,
David
N4HBO
Original Message
From: wolf_dl4yhf <dl4yhf@...>
To: SpectrumLabUsers <SpectrumLabUsers@yahoogroups.com>
Sent: Mon, Nov 7, 2011 4:30 pm
Subject: Re: [SpectrumLabUsers] PowerMeterThe multiplication of two input channels is already working now. Still
missing is a way to retrieve the DC component of the product, but I
think I will abuse the 'DC removal' filter for this purpose  it already
detects the DC component, all that is missing is a function for the
interpreter to read this value.
Ok about the light bulb  if you measure the voltage and current
simultaneously, there's no problem. But due to the temperature dependent
resistance of the filament, you can't imply the current from the
measured voltage (or vice versa). If the filament is very thin (as in
240 Volt bulbs), there may even be a slight phase shift between voltage
and current caused by this effect.
New version (beta) will be available in a few days.
Cheers,
Wolf . wolf_dl4yhf schrieb:
> The multiplication of two input channels is already working now. Still
Why not go over FFT to extract power? A FFT will always remove DC. A FFT
> missing is a way to retrieve the DC component of the product, but I
> think I will abuse the 'DC removal' filter for this purpose  it already
> detects the DC component, all that is missing is a function for the
> interpreter to read this value.
>
will show the instantaneous power budget too. The harmonics are heavily
depend on current phase value of the input signal!!! So one can choose
integration time by defining the FFT time window.
Hm. I think we need a LP filter/FIR to integrate after the FFT.
> Ok about the light bulb  if you measure the voltage and current
Yes. I know this. The factor is approx. 510 times. Posting was late in
> simultaneously, there's no problem. But due to the temperature dependent
> resistance of the filament, you can't imply the current from the
> measured voltage (or vice versa). If the filament is very thin (as in
> 240 Volt bulbs), there may even be a slight phase shift between voltage
> and current caused by this effect.
day time for me ;)
A power resistor is the way to go.
BTW: Even <cheap> resistors are considerable momentary voltage dependent!
>
Thank you. It doesn't hurt.
> New version (beta) will be available in a few days.
 Henry

ehydra.dyndns.info  Hello David,
You asked:Is it possible to take the inputs to the two sounds channels (A and B) and display the freuency spectrum of (A+iB) and (AiB) where the i is a 90 degree phase shift?
Not sure if this would give almost the same result as the "RDF spectrum". It delivers the amplitude (as colour intensity) and the phase difference (as colour hue). That's much more than only telling if A and B are 90 degrees out of phase. If you really try it, you will see that A leading B, or A lagging B in phase makes a big difference (in the colour hue, and also in the displayed angle when hovering the mouse across the RDFspectrogram.
If input B really was to be shifted by 90 degrees before entering the FFT, it would cause a large CPU load.
All the best,
Wolf .
I want to tell more than just if A and B are 90 degrees out of phase  I want to tell which direction (which of A or B, leads the other). I am doing radio astronomy and I think that there is useful information that can be extracted from comparing two signals that I think will be already in quadrature.Thanks,
David
N4HBO
Original Message
From: wolf_dl4yhf <dl4yhf@...>
To: SpectrumLabUsers <SpectrumLabUsers@yahoogroups.com>
Sent: Mon, Nov 7, 2011 4:30 pm
Subject: Re: [SpectrumLabUsers] PowerMeter
The multiplication of two input channels is already working now. Still
missing is a way to retrieve the DC component of the product, but I
think I will abuse the 'DC removal' filter for this purpose  it already
detects the DC component, all that is missing is a function for the
interpreter to read this value.
Ok about the light bulb  if you measure the voltage and current
simultaneously, there's no problem. But due to the temperature dependent
resistance of the filament, you can't imply the current from the
measured voltage (or vice versa). If the filament is very thin (as in
240 Volt bulbs), there may even be a slight phase shift between voltage
and current caused by this effect.
New version (beta) will be available in a few days.
Cheers,
Wolf .
 Is it possible to take the inputs to the two sounds channels (A and B) and display the freuency spectrum of (A+iB) and (AiB) where the i is a 90 degree phase shift?
Not sure if this would give almost the same result as the "RDF spectrum". It delivers the amplitude (as colour intensity) and the phase difference (as colour hue). That's much more than only telling if A and B are 90 degrees out of phase. If you really try it, you will see that A leading B, or A lagging B in phase makes a big difference (in the colour hue, and also in the displayed angle when hovering the mouse across the RDFspectrogram.Thanks, Wolf.
I was hung up on trying to get something numerical  I'll see how this works!
David, N4HBO
Original Message
From: wolf_dl4yhf <dl4yhf@...>
To: SpectrumLabUsers <SpectrumLabUsers@yahoogroups.com>
Sent: Tue, Nov 8, 2011 12:16 pm
Subject: Re: [SpectrumLabUsers] PowerMeter for quadrature signalsHello David,
You asked:Is it possible to take the inputs to the two sounds channels (A and B) and display the freuency spectrum of (A+iB) and (AiB) where the i is a 90 degree phase shift?
Not sure if this would give almost the same result as the "RDF spectrum". It delivers the amplitude (as colour intensity) and the phase difference (as colour hue). That's much more than only telling if A and B are 90 degrees out of phase. If you really try it, you will see that A leading B, or A lagging B in phase makes a big difference (in the colour hue, and also in the displayed angle when hovering the mouse across the RDFspectrogram.
If input B really was to be shifted by 90 degrees before entering the FFT, it would cause a large CPU load.
All the best,
Wolf .I want to tell more than just if A and B are 90 degrees out of phase  I want to tell which direction (which of A or B, leads the other). I am doing radio astronomy and I think that there is useful information that can be extracted from comparing two signals that I think will be already in quadrature.Thanks,
David
N4HBOOriginal Message
From: wolf_dl4yhf <dl4yhf@...>
To: SpectrumLabUsers <SpectrumLabUsers@yahoogroups.com>
Sent: Mon, Nov 7, 2011 4:30 pm
Subject: Re: [SpectrumLabUsers] PowerMeterThe multiplication of two input channels is already working now. Still
missing is a way to retrieve the DC component of the product, but I
think I will abuse the 'DC removal' filter for this purpose  it already
detects the DC component, all that is missing is a function for the
interpreter to read this value.
Ok about the light bulb  if you measure the voltage and current
simultaneously, there's no problem. But due to the temperature dependent
resistance of the filament, you can't imply the current from the
measured voltage (or vice versa). If the filament is very thin (as in
240 Volt bulbs), there may even be a slight phase shift between voltage
and current caused by this effect.
New version (beta) will be available in a few days.
Cheers,
Wolf .  New version with the twochannelmultiplier uploaded to the website (nonbeta).
Documentation of the multiplier:
http://www.qsl.net/dl4yhf/speclab/circuits.htm#adder_or_multiplier
To measure the DC part in the product, use this function:
http://www.qsl.net/dl4yhf/speclab/circuits.htm#DC_reject
Henry wrote:> Why not go over FFT to extract power? A FFT will always remove
DC.
Overkill. And no, the FFT does never remove DC  why should it ? The DC component is in the first 'frequency bin' of the real FFT.
To measure the power (Wirkleistung) when measuring current and voltage, an FFT isn't necessary.
Also the harmonics contribute to it, in fact to measure the total (effective) power, you MUST take the harmonics into consideration.
Maybe, it really doesn't matter. The bulb (or resistor) doesn't care. If 100 Volts * 1 Ampere are floating through it, *IN PHASE*, it will dissipate 100 Watts regardless of the frequency (oh well, the filament will emit a bit of light..).The harmonics are heavily depend on current phase value of the input signal!!!
Integration time, why ? All you need to make sure is that the lowpass (which retrieves the DC component in the product) has a corner frequency lower than 50 Hz (or your mains frequency). The edge frequency of the 'DC' voltage measurement mentioned above has a corner frequency of approximately 0.1 Hz, which should be ok.So one can choose integration time by defining the FFT time window.
All the best,
Wolf .
 wolf_dl4yhf schrieb:
> New version with the twochannelmultiplier uploaded to the website
Thanks! I will look on it.
> (nonbeta).
>
> Documentation of the multiplier:
>
> http://www.qsl.net/dl4yhf/speclab/circuits.htm#adder_or_multiplier
>
> To measure the DC part in the product, use this function:
>
> http://www.qsl.net/dl4yhf/speclab/circuits.htm#DC_reject
>
> Henry wrote:
OK.
> > Why not go over FFT to extract power? A FFT will always remove DC.
>
> Overkill. And no, the FFT does never remove DC  why should it ? The DC
> component is in the first 'frequency bin' of the real FFT.
>
Is it still possible to direct the multiplied signal then to the FFT window?
> To measure the power (Wirkleistung) when measuring current and voltage,
Yes. I want to see all harmonics too. And want to configure the LP
> an FFT isn't necessary.
> Also the harmonics contribute to it, in fact to measure the total
> (effective) power, you MUST take the harmonics into consideration.
>
corner frequency for integration myself.
>
No, misunderstood, sorry. I mean Phasenwinkel!
>> The harmonics are heavily depend on current phase value of the input
>> signal!!!
>>
> Maybe, it really doesn't matter. The bulb (or resistor) doesn't care. If
> 100 Volts * 1 Ampere are floating through it, *IN PHASE*, it will
> dissipate 100 Watts regardless of the frequency (oh well, the filament
> will emit a bit of light..).
>
Read: The harmonics depend on the time point in the voltage waveform. If
a dimmer switches on, this time point will emit a harmonics burst, all
other point of one period will be smoother.
>
As already noted, one can measure power on different time scales.
>
>> So one can choose integration time by defining the FFT time window.
>>
> Integration time, why ? All you need to make sure is that the lowpass
> (which retrieves the DC component in the product) has a corner frequency
> lower than 50 Hz (or your mains frequency). The edge frequency of the
> 'DC' voltage measurement mentioned above has a corner frequency of
> approximately 0.1 Hz, which should be ok.
>
 Henry

ehydra.dyndns.info  Hello Henry and group,
you wrote:
Yes, and that's part of the fun: To test it, I fed the multiplier with a 1 kHz sinewave, and checked the squared output on the spectrogram. Result: One "peak" at 0 Hz (=the DC component), and another one at 2 kHz (which doesn't contribute to the power measurement).
Is it still possible to direct the multiplied signal then to the FFT window?
In that case, you could use the FFTbased filter in the center of the circuit window to apply any lowpass filtering you like. I didn't try this, but it should work.
Yes. I want to see all harmonics too. And want to configure the LP
corner frequency for integration myself.
So much for now, good luck,
Wolf .
 I will try this out.
Thank you again 
Henry
wolf_dl4yhf schrieb:> you wrote:

>>
>>
>> Is it still possible to direct the multiplied signal then to the FFT
>> window?
>>
> Yes, and that's part of the fun: To test it, I fed the multiplier with a
> 1 kHz sinewave, and checked the squared output on the spectrogram.
> Result: One "peak" at 0 Hz (=the DC component), and another one at 2
> kHz (which doesn't contribute to the power measurement).
>
>>
>> Yes. I want to see all harmonics too. And want to configure the LP
>> corner frequency for integration myself.
>>
> In that case, you could use the FFTbased filter in the center of the
> circuit window to apply any lowpass filtering you like. I didn't try
> this, but it should work.
ehydra.dyndns.info  I added one little feature for the DC reject / DC measurement function:
This time constant is now adjustable (formerly fixed to approx. 10 seconds).
So you can adjust the 'speed' of the measurement, and make the power
measurement as slow as necessary (to defeat impulsive noise or
similar). You can now measure the DC component *without* removing it,
if necessary.
It's in the context menu of the "DSP Blackbox", and so far hasn't been
documented in the manual.
Regards,
Wolf .