Having trouble with Single Phase Power

I have recently been taking up tutorials of emoTX. I built my system using a breadboardand taking the emontx3 as a base . my current sensors are standard SCT-013-000, voltage sensor i used a power transformer 230-09V, .

1)CT = Burden resistance = 33 ohm , Capacitor  is 10UF , calibration 60.6

2) V =  10k and 100k divider , 470k divider  , 236Vac supply  output of my VT = 

i attached everything to a relay so you will see my relay code 

supply is 5 volts

Using the arduino Mega 2560 

###1###The problem i am facing is even when taking reading of items below 50W if measuring from 1 source i get the correct reading .but when i measure from three sources all the values become distorted . Is there any reason to this . I am measuring a single phase system and my at the plug side . so i am connecting my cellphone ,laptop , soldering iron and glue gun. Sometimes i put a 60W bulb and it gives me readings of up to 100W. I dont know if this is normal ###.2##Secondly was wondering if i can print or call each variable individually.because i saw a sketch here but kept getting errors . ( https://github.com/openenergymonitor/emonTxFirmware/blob/master/emonTxV2/Guide/c_ACVoltage/c_ACVoltage.ino ) 

 Below is a sample of my code .... 

#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1, emon2, emon3, emon4,realPower,apparentPower,Vrms,Irms,powerFactor;             // Create an instance
#define RELAY1  2 
#define RELAY2  3                        
#define RELAY3  4                        
#define RELAY4  5

 
 void setup()
{  
  pinMode(RELAY1, OUTPUT);       
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  digitalWrite(RELAY1,LOW);           // Turns ON Relays 1
   delay(2000); 
     digitalWrite(RELAY1,LOW);           // Turns ON Relays 1
   delay(2000);
     digitalWrite(RELAY2,LOW);           // Turns ON Relays 1
   delay(2000);
     digitalWrite(RELAY3,LOW);           // Turns ON Relays 1
   delay(2000);
     digitalWrite(RELAY4,LOW);           // Turns ON Relays 1
   delay(2000);  
    
  Serial.begin(9600);
  
  emon1.voltage(0, 244.7, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 60.6);       // Current: input pin, calibration.
  emon2.voltage(0, 244.7, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon2.current(2, 60.6);       // Current: input pin, calibration.
  emon3.voltage(0, 244.7, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon3.current(3, 60.6);       // Current: input pin, calibration.
  emon4.voltage(0, 244.7, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon4.current(4, 60.6);       // Current: input pin, calibration.
  
}

void loop()
{
   Serial.print ("ct1");
    Serial.print ("");
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

 Serial.print ("ct2");
  Serial.print ("");
  emon2.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon2.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

 
 Serial.print ("ct3");
  Serial.print ("");
  emon3.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon3.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

 Serial.print ("ct4");
  Serial.print ("");
  emon4.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon4.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

}

 

Robert Wall's picture

Re: Having trouble with Single Phase Power

Yikes! What have you done here:

EnergyMonitor emon1, emon2, emon3, emon4, realPower,apparentPower,Vrms,Irms,powerFactor; // Create an instance

EnergyMonitor is a Class definition, and inside it you can have 'methods' that are equivalent to functions, and data members, that are equivalent to variables.

If you look at the declaration of EnergyMonitor in emonLib.h, you'll see some of each. calcVI is a method, and (this is where you've got in a tangle) realPower, apparentPower, Vrms, Irms and powerFactor are members.

So you should not use those names as instances of the class, because what you have there is four class instances called emon1, emon2, emon3 and emon4, which is fine, and 5 more. The fun begins, answering your other thread, when you want the real powers, because if you put the correct statements in setup( ), you could have
realPower.realPower
as a data member. I'd need to check the language spec to see if that's legal, but for sure you'll confuse all mere mortals.

So you need to tidy up the instances of EnergyMonitor, and you need to look at the library to see what values you can print. They are listed as "public" and are basically the ones that you wrongly had as class instances.

You get at the values of them with lines like

Serial.println(emon1.realPower);
Serial.println(emon3.powerFactor);

I think you need to read up on C++.

Reference Textbooks
My bible for C is of course "Kernigan & Ritchie" http://www.amazon.co.uk/C-Programming-Language-2nd/dp/0131103628/ref=sr_.... This is the standard text book. The normal place I point people at who want to move up to C++ is http://www.relisoft.com/book/index.htm and that assumes you know C. Because the Arduino environment normally uses a very small subset of the language, neither are the best place for a beginner to start, nor are many of the other on-line tutorials. I'd still suggest you have both of those, and maybe Bruce Eckel's "Thinking in C++" http://www.planetpdf.com/developer/article.asp?ContentID=6634 available for reference.

However, there is this: http://www.me.umn.edu/courses/me2011/arduino/arduinoGuide.pdf which does look to be a good starting place for a beginner. It does not go as far as classes and methods that are used here, though.

nigel91's picture

Re: Having trouble with Single Phase Power

thank you for your fast response ,, works like a charm . however i am still getting the weird reading from the results.. is this normal .can i counter it .or maybe add component. i am mildly familiar with C programming . but a bit rusty 

Robert Wall's picture

Re: Having trouble with Single Phase Power

If you paste the output into a message, I might be able to help. But without knowing exactly what 'weird' means, I can't do much. But first of all, try using a sensible load. The system you're describing is designed for "whole house" measurements up to 100 A, that's about 24 kW. A load of only 60 W is below the point where we expect even reasonably accurate results with an emonTx, so you might be measuring noise from the digital circuits inside your Arduino.

Think about the input to the ADC in your Arduino. If 100 A gives you the maximum peak-peak input (not exactly, but it's a good rough approximation) and the ADC output is 10 bits, then how much of the ADC range does 60 W cover in terms of bits?

hanguyen's picture

Re: Having trouble with Single Phase Power

How can we measure the noise from the digital circuits inside your Arduino ?

Robert Wall's picture

Re: Having trouble with Single Phase Power

If you measure an input when there is none, that must be noise. The place to look is probably on the supply pin to the analogue circuitry, AVCC, as we think that the route the noise takes is onto the digital supply pin VCC then, provided there's no filter between the two as is the case with at least some Arduino boards, into AVCC and into the ADC via the voltage reference (the supply voltage). But you should not discount ground loops, nor inductive or capacitive coupling to the analogue input pins.

nigel91's picture

Re: Having trouble with Single Phase Power

Thank you all you are really helpful.i am considering placing a voltage regulator for my 5v input to the circuit to stabilise the input. Maybe it will help. May I ask for energy calculations do I just use the pulse measurement sketch because for me I do not get any reading..

dBC's picture

Re: Having trouble with Single Phase Power

Yes, a ripply Vcc from a poor choice of power supply is a common cause.  There's some more on that here:  http://openenergymonitor.org/emon/node/10111

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.