Go Down

Topic: Measuring phase angle and power (Read 9221 times) previous topic - next topic

Perfo

On a cloudy day I could then end up importing and wasting expensive energy where as I have a lot cheaper ways of heating water than doing it with electrickery. I may not use the solar energy for water heating it may be to charge my back up batteries etc I just want to make sure I use it.

pauldreed

How is this going? have you managed to detect power inflow/outflow yet?

Perfo

I've back burner'd this project a little and I didn't get a great deal of satisfaction trying to work out all the parameters. One method that does seem to work ok though is to put an optical detector on the little window of the meter and detect if the disc is spinning or not (my meter is the old type with a spinning aluminium disk in it). Some newer meters have a flashing LED which is even better. All that tells you is, you are importing as the disc stops spinning when I stop importing. So all you need to do is to put an ammeter on the incomer to your house to get a current reading then look if the disc is spinning or not. If it is then you are importing by that value and if not then you are exporting. What my trial set up did was to look at the current and disc every minute and adjust to load accordingly.

pauldreed

I'm trying to build this http://openenergymonitor.org/emon/node/105 and monitor solar generation and how much is currently being used. By subtracting one from the other, it will tell me how much unused power I can make use of.
However, not having used Arduino before, it's a steep learning curve!

Perfo

The problem I had was the PV inverter fed in to a consumer unit in my tractor shed which has got other circuits on it. This is then fed from my garage which has other circuits on it which then goes back to my main incoming consumer unit which has the house loads on it and of course the import meter. So yes in short it is an easy and relatively easy (theoretically anyway) idea to put CT's on all your incoming and outgoing circuits and simply sum them but in practical terms this wasn't possible for me. However if you can get away with multiple CT's then writing the code isn't difficult. I'll try and help if you tell me exactly what you want but I'm not very swift at this Arduino thing either so just post and one of the clever fellows will be along to sort you out.

pauldreed

Thanks for the offer of help, as I only got my first Arduino 2 days ago and have not yet got my head around the programming.
I have highlighted in blue areas where any help would be appreciated.
I was hoping to use the code http://bit.ly/jyKbGd which is a 2 channel energy monitor from this site http://bit.ly/bgoFro assigning the Solar Power clamp to ch1 and Home Circuit clamp to ch2.
Then a bit of extra code to do the calculation ch1 minus ch2 = Residual Power
If Residual Power is greater than 1000W, then provide an output
to switch a relay (just ordered an opto-isolated board from Ebay tonight) which will power a 1kw immersion heater (already fitted).
I would like to include some hysteresis, to prevent relay chatter and I have have today stripped out a 2 x 16 display LCD screen from a old alarm panel, and want to use that to display ch1 & ch2.

Paul

Perfo

Hello, sorry I've been a while to get back to you it's been a bit busy here. I tried to write this in my break so I haven't tested it on an Arduino and even if I had I'm not an expert but it should work or at least give you a good head start on making it work. I haven't re printed all the code in the link you sent me I've just added some bits in red.. so basically copy the code from the link you provided then add the bits in red from below.
The hysteresis should be provided by the anti chatter counter in that if the value is around 1000 w difference between ch1 and ch2 the output wont change until it has been that way for more than 2000 programe cycles. I  hope you find it helpful :)

int wavelengths = 50;                             //number of wavelengths to sample
int AntiChatter = 0; // used to ensure the output doesn't chatter
int inPinV = 1;                                   //Analog input pin number that voltage signal is connected to
int inPinI_1 = 0;                                 //Analog input pin number that current signal is connected to. Channel 1
int inPinI_2 = 2;                                 //Analog input pin number that current signal is connected to. Channel 2
int RelayOn = 4; // pin four is the one to connect the opto isolator to but you can pick any pin other than  0,1 or 2

void setup()
{
   Serial.begin(9600);
   pinMode(RelayOn,Output); // this sets the pin named RelayOn to an output
}
unsigned long wtime;


void loop()
{
  //-------------------------------------------------------------------------------------------
  // 1) Calculate energy monitor values
  //-------------------------------------------------------------------------------------------
  ch1.emon_calc(inPinI_1,ICAL_1);                                       //Energy Monitor calc function for channel 1, pass Arduino analog in pin nummber and calibration coefficient
  ch2.emon_calc(inPinI_2,ICAL_2);                                       //Energy Monitor calc function, for channel 2, pass Arduino analog in pin nummber and calibration coefficient
 
  //delay(2000);
  Serial.print("Channel 1 Real Power: "); Serial.println(ch1.realPower);
  Serial.println("");
  Serial.print("Channel 2 Real Power: "); Serial.println(ch2.realPower);

  If (ch1.realPower > (ch2.realPower +1000)) {
    // count the number of program cycles that ch1 is higher than ch2 by at least 1000
    AntiChatter ++ ;
    If (AntiChatter == 2000) {
      // the state ch1 > (ch2 +1000 ) has been true for 2000 cycles
      digitalWrite(RelayOn,HIGH); //turn the output on
      //minus one off the Antichatter variable to clamp it at a max of 2000    
      AntiChatter -- ;
       }
     }
  else{
  // if ch1 isn't > (ch2 +1000) then start counting down and when the AntiChatter counter reaches zero turn the output off
    If (AntiChatter == 0) {
      // the state ch1 <= (ch2 +1000 ) has been true for 2000 cycles
      digitalWrite(RelayOn,LOW); //turn the output off
      //add one off the Antichatter variable to clamp it at a min of 0
      AntiChatter ++ ;
     }
  }
 
  ch1.wh = ch1.wh + ch1.whInc;                                          //Accumulate wh for channel 1 until ethernet send
  ch2.wh = ch2.wh + ch2.whInc;                                          //Accumulate wh for channel 2 until ethernet send 
}

pauldreed

#22
Jun 28, 2011, 09:15 pm Last Edit: Jun 30, 2011, 11:14 pm by pauldreed Reason: 1
I'm not in a position to test it just yet, but have finished the hardware build today http://bit.ly/mIHC6L and just loaded up the OpenEnergyMonitor software and it seems to work (so far!).
I need to carry out the calibration first, then I will add in your code and run some further tests to see if it works.
I like the way that you have tackled Hysteresis, it seems a better way than changing the data itself (via feedback) and should stop the chatter.
My plan is to make changes one at a time, so I can always roll it back if things gets screwed up.
As you will see from the photo link, I have already attached the LCD, and loaded the 'Hello World' software, and that works just fine too.

Many thanks for your help, I will update you in a few days, when I have tried it.

UPDATE - found a couple of typos; IF = if, output = OUTPUT, otherwise it verifies OK.
UPDATE #2 - line 111 should read AntiChatter -- ; instead of AntiChatter ++ ;
http://pastebin.com/VCPXSbQw

Bill_Kerr

Hello Perfo

Quoting : As far as I know the only way I can detect if I'm importing or exporting is by measuring the phase angle between the voltage and current of the supply.

I am not absolutely sure your premise is correct about phase.
I recall theoretically for AC mains power the Voltage and Current should be in absolute phase to each other.  The phase can be changed by the inductive/capacitive loading on the network.  One reason AC motors may have a capacitor is too eliminate the phase difference created by the motor so that when measuring power usage; there is no power factor issue.  The capacitance cancels out the inductance of the motor, so that the effective load still appears to be resistive. 
Older watt-meters work with windings, so if you reverse the current through it, the meter runs backwards.

I leave my statements open to question, as I am not an expert, and quoting 30 year ago College electronics course ;^)

Don't you just hate ONE D 10 T problems?

Perfo

High Bill,
  I'm no expert either but I think the old style meters you mention did indeed have two coils in them set at 90 degrees apart, one being primarily set up to give a field depending on current and the other on voltage which then gave you a quite clever way of discerning the phase angle between them by the direction and speed of the rotating disc. If you are in perfect phase (phase angle = 0) as in your suggestion the old meter would stop turning. In practice it is quite tricky trying to maintain unity power factor in a house as you'd have to continually adjust the capacitor bank in relation to the inductance of whatever you switch on or off but would result in a low electricity bill :). This isn't (I don't think) the same thing as watt less current where you try and aim for 90 degrees and thus purely inductive. As the watts = VI cos phi and cos of 90 = 0 then watts is zero independent of what V and I are.  << going off on a tangent.

Ahh those old typos they always get me.... :)

pauldreed

Perfo, don't worry about the typos, the programme you wrote was very good and far beyond what I can currently write, and by working through your code I have learnt so much about the language, and feel more confident about tweaking it myself.
I have now got it up and working, and have connected it to a pair of current transformers monitoring the solar power system, and it ran very smoothly, albeit using an  LED to simulate the immersion heater load (my opto-isolated relay is mid way between China and the UK!).
Now that the first stage is  working, I am going to try and include the LCD library and LCDprint the readings to the 2x16 LCD screen.
I will keep updating the file to http://pastebin.com/VCPXSbQw

Thanks again Perfo.

Paul

Perfo

Are you using an SSR (solid state relay) and forget me if I'm wrong but i think you can get them with an opto built in and they are generally more reliable. Once you get this up and running your next step is to do a power controller so that you don't waste any. At the moment you only turn the immersion on once 1 kW differential has been reached but wouldn't it be better to capture all excess energy down to save 50w ?

pauldreed

It's a 5amp coil relay, driven through an opto-isolator, and yes you are correct, the immersion heater is only switched on when the 1kw differential is reached.
I would like to utilise all of the excess energy (especially in winter when the system would struggle to have 1kw spare), and eventually replace the relay with a power controller, such as a phase angle controller with a digital input, but they seem to be very expensive £300 - £500.
An option which I have not had chance to look at properly is a Proportional Power Controller http://bit.ly/mOqGT8 which has a DC 2 - 10V input and  costs about £85.
Another consideration (plan B!) is to maybe have 3 outputs from the Arduino - 250W, 5000W & 1000W, and have simple Triac circuits on each of the 250W & 500W circuits to restrict the respective power flow. It's a bit  messy, and not ideal, but I am looking at all options.

Perfo

I was thinking of something like these on flee-bay 250844628309  or   270774264382 the first one is too small in current capacity but shows how neat they can be and again I don't think you need opto isolation but that would have to be checked with each version of the SSR.
As for the power controller I gasp at the thought of spending large amounts of beer tokens something simple (read cheap) like www.nxp.com/documents/application_note/APPCHP6.pdf. You don't have to be too fussy how you control an immersion heater, it is after all only a piece of wire, so something cheap and dirty like the above would work no problems. You could even adapt a dimmer or something.
Using a binary approach and having a few heaters each double the capacity of the last then:-
10 heater = resolution down to < 1 w
7 heater (7 bit) = 142w
4 heater (4 bit) = 66 w
but using the Arduino with a firing circuit would probably work out a lot easier and cheaper.

pauldreed

Thanks Perfo, I'll have a look at those.
I've now got the LCD working but I'm just trying to sort out a little problem in that it does not consistently refresh every 2 seconds as per the delay(2000).

Sometimes it updates every 2, 3 or even 4 seconds, and you will see on line 102 that I have included  Serial.println(millis()/1000);  purely to highlight what I mean. By opening the Serial Monitor I see;

2, 4, 6, 8, 10, 14, 17, 21, 25, 27, 31, 33, 37, 39, 41, 43.......

Is there anything that I can do to get it to run smoothly and consistently?

Link to the code www.pastebin.com/fyiKCvCb

Go Up