Hello everyone,
I write to ask for your help concerning the project I'm working on.
Turns out that I'm working on a Energy Meter for an Electric Power-Generator. The openenergymonitor.org web page helped me a lot, however I still have some drawbacks.
Although the Power Factor is OK, I can not determine the current and voltage values separately. In the schematic you will see that there are 2 test probes called "Current" and "Voltage" respectively, which are connected to the Arduino PWM read inputs (Pin 2, 3).
I've tried to measure the signals in A0 and A1 inputs; I've also measured the number of pulses at the output after the OPAMP (zero crossing), the smoothing code provided to make many measurements, PWM counter... but in all these cases described above, the measurement goes crazy without showing any stabilized values. : smiley-confuse:: smiley-confuse:
I know I have to make a formula corresponding to my values that would allow me to calculate the current and voltage, however, if these "values" are not stable, how do I then to calculate current and voltage?
These two signals: Current is a signal of very low amplitude (<1V AC) and also with freq = 60Hz coming from sensor SCT-013-060 (it's simulated with an alternator at 500mV, which would basically result into 30Amps).
For Voltage I use the ZMPT 101B sensor and get an output of approx 4.5 VAC for 170VAC of home electric outlet.
On the other hand, I have tried to stabilize the signals before passing through the XOR gate with capacitors (3300uF), but they damage the square wave that determines the Power Factpr at the end of the logic gate.
I need your help! Thanks in advance for your contributions and comments ![]()
PS: Schematic Attached below.
This is my code:
/*Power Factor calculator
* Prog mod by JCS Oct 25th, 2017 */
float x,y,z;
float current,voltage;
#define echoPin 7 // Digital Signal coming from XOR.
#define Corriente 2
#define Voltaje 3
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup()
{
pinMode(echoPin, INPUT);
pinMode(Corriente, INPUT);
pinMode(Voltaje, INPUT);
lcd.begin(16, 2);// set up the LCD's number of columns and rows:
lcd.setCursor(0,0);
lcd.print(" Welcome to the");
lcd.setCursor(0,1);
lcd.print("Energy Monitor");
delay(800);
lcd.clear();
}
void loop()
{
x = pulseIn(echoPin,HIGH); //reads duartion pulse in Microseconds
y = (2 * PI * x/16667); //Angulo en radianes
z = cos(y);
//Lectura pulsos para corriente y voltaje
current= pulseIn(Corriente,HIGH);
voltage= pulseIn(Voltaje, HIGH);
if (x>500)
{
//Printing Values of Power Factor
lcd.setCursor(0,1);
lcd.print("PF=");
lcd.print(z);
delay(10);
//Printing Current Values
lcd.setCursor(0,0);
lcd.print("I=");
lcd.setCursor(3,0);
lcd.print(current);
// Printing Voltage Values
lcd.setCursor(9,0);
lcd.print("V=");
lcd.setCursor(11,0);
lcd.print(voltage);
delay(1000);
}
}