cosax
Posts: 13
Joined: Tue Apr 30, 2013 1:18 pm

Sense direction of power flow

Tue Apr 29, 2014 2:22 pm

Hello everyone,

I have recently completed a project where i read the blinking LED from my electricity meter using a light depended resistor in order to measure the power flow (eg http://www.raspberrypi.org/forums/viewt ... 37&t=21793). I also have photovoltaic panels installed at my house and connected to the electricity grid based on the net-metering plan, and sometimes I import power and on sunny days I export. Unfortunately, my electricity meter does not provide a usable indication for the direction of power flow. Is there some clever idea or some device i can buy or build that will sense and give me the direction of power flow?

Thanks!

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Sense direction of power flow

Tue Apr 29, 2014 2:35 pm

Hi,
cosax wrote: the direction of power flow?
You could inset in path a resistor with very small resistance (mili Ohms) and amplify voltage drop on it. Polarity of this voltage drop indicates power flow.

This is quite widely used method of current measurement and I'm sure you can find ready-made modules. While accuracy is not important for you, pay attention that the polarity information is available.
If you're dealing with high voltages, make sure that you insert this module in low side path (ground) and take care about proper insulation (optocoupler?) between the module and RasPi.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Sense direction of power flow

Tue Apr 29, 2014 7:57 pm

Don't! insert a resistor. Theoretical it sound nice but practically you should not add a resistor to your main network.
There are current sensors which use the hall effect and go around the wire. They are also safe to use as they are galvanic separated.
A bit more expensive but much safer!

cosax
Posts: 13
Joined: Tue Apr 30, 2013 1:18 pm

Re: Sense direction of power flow

Wed Apr 30, 2014 5:36 am

Thanks for the info. Yes, in fact I wouldn't feel comfortable with the resistor solution.
Since I lack experience with all this power components, any suggestions for hall effect sensors that could do this job will be very much appreciated.

User avatar
Cancelor
Posts: 757
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Sense direction of power flow

Wed Apr 30, 2014 7:05 am

Are you measuring the 240v AC?

Am I having a mental block here .... doesn't AC flow in both directions?
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

cosax
Posts: 13
Joined: Tue Apr 30, 2013 1:18 pm

Re: Sense direction of power flow

Wed Apr 30, 2014 8:52 am

Yes the 240V AC. As I understand it, the phase difference between the ac voltage and the current determines the direction that the power flows. The following link may be useful http://openenergymonitor.org/emon/build ... troduction.

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Sense direction of power flow

Wed Apr 30, 2014 10:43 am

Hi,
Gert van Loo wrote:Don't! insert a resistor.
Aren't shunt resistors widely used in instruments ?


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: Sense direction of power flow

Wed Apr 30, 2014 2:21 pm

with ac power, it is not as simple as just measuring the current. the current has an average value of zero and changes direction 100 times per second. to know which way the power is flowing you need to also measure the voltage, and compare the polarity of the voltage and the current waveforms. if current and voltage has the same polarity you know the power is flowing in one direction, if the polarity is the opposite you know that power is flowing in the opposite direction.
however, with ac power it is more complicated as you do not only have resistive loads, you have capacitive and inductive loads, and nonlinear loads that distort the current waveform. so a measurement circuit that works well with resistive loads may have trouble when there is a phase shift in the current, or the current waveform is distorted.
you probably need a current transformer to measure the ac current. and it would be safest to use another (ordinary) transformer to measure the voltage, so you are totally isolated from the mains voltage and the electrical hazards. when you have these two transformers you can work with the low amplitude signals that show current and voltage waveforms, and invent a circuit that works for your purpose.

User avatar
Burngate
Posts: 6013
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sense direction of power flow

Wed Apr 30, 2014 3:47 pm

FLYFISH TECHNOLOGIES wrote:Hi,
Gert van Loo wrote:Don't! insert a resistor.
Aren't shunt resistors widely used in instruments ?
Yes, for example DVMs use shunt resistors internally, and you can get shunts that fit the sockets of DVMs to extend their range to 10A and above.

But for mains - 220v or 110v AC - if you put the shunt resistor in the live feed, all your equipment is at the live voltage - probably not wise
If you put it in the neutral feed, then equipment neutral isn't the same as everything-else's neutral, and when things go wrong, you could still end up with everything live.

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Sense direction of power flow

Wed Apr 30, 2014 4:01 pm

Hi,
Burngate wrote:If you put it in the neutral feed, then equipment neutral isn't the same as everything-else's neutral, and when things go wrong, you could still end up with everything live.
For any equipment we can find equal worst case scenario.
I think that this is properly handled with earth (which might not be the same as ground).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Burngate
Posts: 6013
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sense direction of power flow

Wed Apr 30, 2014 4:48 pm

FLYFISH TECHNOLOGIES wrote:For any equipment we can find equal worst case scenario.
I think that this is properly handled with earth (which might not be the same as ground).

Best wishes, Ivan Zilic.
I didn't mean to give the impression I thought you didn't know what you're talking about - you probably know more than I
It just seemed advisable to point out some of the elephant-traps when playing with mains

User avatar
Cancelor
Posts: 757
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Sense direction of power flow

Thu May 01, 2014 11:37 am

I'll be the one to draw attention back to the original question then :lol:

Ultimately we want to find if the house + photovoltaic panels is importing or exporting power.

If we connect a small isolating step down transformer to give lets say 12vac can we tell the direction of the mains power by looking at that lower voltage? ..... and feed the result to a RPi of-course!
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
joan
Posts: 14270
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Sense direction of power flow

Thu May 01, 2014 11:43 am

Cancelor wrote:I'll be the one to draw attention back to the original question then :lol:

Ultimately we want to find if the house + photovoltaic panels is importing or exporting power.

If we connect a small isolating step down transformer to give lets say 12vac can we tell the direction of the mains power by looking at that lower voltage? ..... and feed the result to a RPi of-course!
UK?

A chap I know regales us with how much he earns from selling overpriced electricity to us ordinary mortals. He has a meter which shows his input/output. I assumed it was a standard feature of the set-up.

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Sense direction of power flow

Thu May 01, 2014 11:52 am

The old meters would have a rotating metal disk which reverses direction if you export power.

Measure the current and voltage at the same time! Multiply the two. The result is your power.
To get the two values at the same moment in time use two sample-and-hold A to D converters
and set them up so the sample-trigger input is the same.
I would think that if you can measure .e.g. at 1000 Hz you are sampling each voltage/current sine wave 20 times which
gives a reasonable accurate idea of the power.

cosax
Posts: 13
Joined: Tue Apr 30, 2013 1:18 pm

Re: Sense direction of power flow

Thu May 01, 2014 5:02 pm

Gert van Loo wrote: Measure the current and voltage at the same time! Multiply the two. The result is your power.
To get the two values at the same moment in time use two sample-and-hold A to D converters
and set them up so the sample-trigger input is the same.
I would think that if you can measure .e.g. at 1000 Hz you are sampling each voltage/current sine wave 20 times which
gives a reasonable accurate idea of the power.
Can this be done through a step down transfomer as Cancelor suggested?

User avatar
Cancelor
Posts: 757
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Sense direction of power flow

Thu May 01, 2014 5:37 pm

Gert van Loo wrote:The old meters would have a rotating metal disk which reverses direction if you export power.

Measure the current and voltage at the same time! Multiply the two. The result is your power.
To get the two values at the same moment in time use two sample-and-hold A to D converters
and set them up so the sample-trigger input is the same.
I would think that if you can measure .e.g. at 1000 Hz you are sampling each voltage/current sine wave 20 times which
gives a reasonable accurate idea of the power.
...but!!! :twisted: .... how can we tell if it is positive or negative? ... okay you can't have negative power but the thread is asking how to Sense the direction of power flow. :arrow:
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Sense direction of power flow

Thu May 01, 2014 6:18 pm

okay you can't have negative power
We are talking about power FLOW. So you have power and a direction.
Positive or negative depend on your definition of direction.
If you think of your cash flow: into the house would be negative, out of the house would be positive.
(The electricity company would see that just the other way around.)

Most of the time it should be obvious what the power direction is.
e.g. I doubt you will generate electricity when it is night.

User avatar
Cancelor
Posts: 757
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Sense direction of power flow

Fri May 02, 2014 10:51 am

Correct, how do you 'sense direction of power flow' ?
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
Burngate
Posts: 6013
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sense direction of power flow

Fri May 02, 2014 11:17 am

Cancelor wrote:Correct, how do you 'sense direction of power flow' ?
Instantaneous Volts is positive and instantaneous Amps is positive => Volts times Amps is positive => power flows that way
Instantaneous Volts is negative and instantaneous Amps is negative => Volts times Amps is still positive => power still flows that way

Instantaneous Volts is positive but instantaneous Amps is negative => Volts times Amps is negative => power flows this way
Instantaneous Volts is negative but instantaneous Amps is positive => Volts times Amps is still negative => power still flows this way

A small step-down transformer giving 12v will give you the instantaneous Volts, but you still need to measure the instantaneous Amps

cosax
Posts: 13
Joined: Tue Apr 30, 2013 1:18 pm

Re: Sense direction of power flow

Tue May 06, 2014 1:18 pm

Thank you all for your input. It sounds doable but complicated ...

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Sense direction of power flow

Tue May 06, 2014 4:56 pm

Nah.... we just make it sound complicated to keep our salaries up.
Basically you need to :
Take two ADCs, one voltage transformer, one current transformer.
Take voltage transformer to one ADC
Take current transformer to other ADC
Read Vadc, Read Iadc (Both must return a signed number.)
P = Vadc * Idc
if (P>0)
current_is_one_way
else
if (P<0)
current_is_other_way
else
there_is_no_current

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Sense direction of power flow

Wed May 07, 2014 8:59 pm

Hi

How does the current transformer/ADC know power direction?

Has anyone considered that the wires (aka meter tails) from the consumer-unit to the meter have resistance, maybe as much as 100uOhm, that's 100uV/per amp. So an OPA with gain of 100 (and very limited bandwidth) with -input wired to one of the neutral tail and +input to the other end of the neutral tail would produce 10mV per amp with sign. (I mean of course the +/- inputs to the configured amplifier not the OPA itself).

OK so it's not easy to do. The whole of the kit would have to be floating, the environment is noisy, the signal small (but just look at the source impedance). How to get the signal out? - two optos, one indicating direction and the other driven by a voltage to frequency converter.

Simple really. Probably not 100% legal in UK though- IET regs and all that. If I had to defend it I would point that the tail is intact and the extra wiring is at neutral potential, and insulated, and isolated.

scotty101
Posts: 3721
Joined: Fri Jun 08, 2012 6:03 pm

Re: Sense direction of power flow

Thu May 08, 2014 8:51 am

grahamed wrote: Simple really. Probably not 100% legal in UK though- IET regs and all that. If I had to defend it I would point that the tail is intact and the extra wiring is at neutral potential, and insulated, and isolated.
No. Just no. Leave the wires totally intact. Do not damage the wires insulation and sense the voltage and sense using current and voltage transformers.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
Burngate
Posts: 6013
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sense direction of power flow

Thu May 08, 2014 9:33 am

grahamed wrote:How does the current transformer/ADC know power direction?
It doesn't! It knows - or rather it tells the Pi which tells you - which direction the current is flowing, and since you know the voltage at that time, you know the direction.
Has anyone considered that the wires (aka meter tails) from the consumer-unit to the meter have resistance, maybe as much as 100uOhm, that's 100uV/per amp. So an OPA with gain of 100 (and very limited bandwidth) with -input wired to one of the neutral tail and +input to the other end of the neutral tail would produce 10mV per amp with sign. (I mean of course the +/- inputs to the configured amplifier not the OPA itself).

OK so it's not easy to do. The whole of the kit would have to be floating, the environment is noisy, the signal small (but just look at the source impedance). How to get the signal out? - two optos, one indicating direction and the other driven by a voltage to frequency converter.

Simple really. Probably not 100% legal in UK though- IET regs and all that. If I had to defend it I would point that the tail is intact and the extra wiring is at neutral potential, and insulated, and isolated.
OMG
OMG!
What's wrong with a current transformer?
It'll give you exactly the same information, with less hassle, more safety, totally legal. It doesn't rely on the copper having a known resistance, doesn't need a high-gain amp, doesn't require the neutral to be at zero relative to earth (which it won't be) ...

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Sense direction of power flow

Thu May 08, 2014 6:23 pm

Hi

Meter tail intact. Why would it require N=E? Specifically I say the thing is isolated.

Better than introducing an additional resistor, aka a current shunt, in the line.

Current transformer? How does it know the sense of the flow?

OK, I do know how to do it, but it is not a voltage transformer/ADC and a current transformer/ADC, with both ADCs sending asynchronous data to a Pi which then "knows" the direction of flow.

Most simple a.c. measurement schemes -
rectify the a.c. from the transformer
charge a cap to the peak value
ADC the value
divide by root2

Which is no help at all as you need to know the VI phase, as someone pointed out early on in this thread, but seems to have been missed.

There are many, many threads around where people are willing to connect to a.c. mains with (in some cases) seemingly no idea what they are doing. I merely suggest connecting a wire in parallel with neutral.....pointing out the need for insulation and isolation to the standard required of a live wire.

And does anyone really think that current transformers are actually safe devices?

Try disconnecting the load - like when the wire slips out of the breadboard someone would try to use - watch the sparks fly, I mean like arcing, ionising the air, etc

To steal a bit from wikipedia - "Care must be taken that the secondary of a current transformer is not disconnected from its load while current is in the primary, as the transformer secondary will attempt to continue driving current across the effectively infinite impedance up to its core saturation voltage. This may produce a high voltage across the open secondary into the range of several kilovolts, causing arcing, compromising operator and equipment safety, or permanently affect the accuracy of the transformer."

Aside from anything else I'd like to know how to pass the neutral (or live) through the CT without disconnecting the connector at some point. Maybe there are CTs which split like a clamp meter.

Return to “Automation, sensing and robotics”