Is it possible to phase shift using the Arduino Uno?

Good day, apologies if the title is confusing as I'm not yet knowledgeable about Arduino Uno's functions.

A project I'm doing for school involves using an Arduino UNO, an OLED, and a CT and PT to create an energy meter but the issue is, is that the current and voltage input readings are out of phase and I am unable to reach my desired wattage for the load I've connected it to. Attached below is the voltage and current waveforms with voltage and current being blue and red respectively.

I wish to know if it is possible to phase shift the Current readings to be able to make it in-phase with voltage without adding additional components?

I had the idea that perhaps I could be able to phase shift the current by delaying its analog readings by a certain amount but so far I've no luck.

Attached is the code for obtaining the analog readings:

void setup() {
  Serial.begin(115200);
}

void loop() {

  int sensorValue = analogRead(A0);
  delay(500);
  int sensorValue2 = analogRead(A1);

  float voltage = (sensorValue - 87.978) * (5.0 / 1023.0); // -87.978 to center the voltage to 0
  float current = (sensorValue2 - 484.902) * (5.0 / 1023.0); // -484.902 to center the current to 0

   Serial.print(voltage); Serial.print(",");
  Serial.println(current);
  delay(1);
}

Do tell if I shouldve posted other essential details as this is my first time using this forum. Thank you!

In your code you are already "shifting" with
delay(500);

It was my attempt but when observing the serial plotter, it took a long time to see a plot of the waveforms and wondered if I was approaching the problem the wrong way

If you are measuring 50Hz AC then try delaying by 490.

Im measuring for 60 Hz AC but I've tried inputting 490, and theyre in-phase! but the readings are inconsistent

What's the whole point of shifting readings 0.5 seconds

1 Like

for 60Hz use 175ms or 25ms

Hi,
If your phase shift needs to be 180degres, then swap the coil connections on the current transformer.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

What is the time difference between a positive going voltage zero crossing and a positive going current zero crossing (in microseconds)?

I needed to shift readings to be able to accurately obtain Real Power without any losses, the problem being was how much time I needed to delay for current to be in-phase with voltage

few microseconds...

You are going about this the wrong way.

You are taking a single reading of the voltage/current at some random point in the 60Hz mains cycle, and expecting that single reading to be "representative" of the 60Hz waveform.

What you need to do is take multiple readings in quick succession throughout at least one whole mains cycle, and from those readings calculate the rms value of the voltage/current.

Ahh, using 25 ms delay works!


Maybe I can calibrate the meter to compensate for the inconsistency but this will help a lot thank you!

then 8ms should work as well?
anyway read what @JohnLincoln wrote

1 Like

FYI: 25ms at 60Hz = 1.5 cycles. So it's a 360 + 180 degree phase shift.

Sure, here's the diagram we used as a reference:
image

And here are photos of the actual circuit:

Here is a screenshot of our initial calculations, it was simulated in Matlab but in our actual circuit we've changed a few things:


Our input voltage was measured at 237.5 Vrms and we changed our CT's resistor from 200 Ohms to 100 Ohms

Here are also a close-up shot of the CT and PT (As i am unable to embed more than 3 photos)


Swap the ct cables and try it without any delays. What's the output?

1 Like

Take a look at the Open Energy Monitor code to see one method to measure AC power consumption correctly.

1 Like

There is lots of useful information about measuring electrical power/energy at openenergymonitor.org.

Have a look at how to build an arduino energy monitor in particular.

2 Likes