Phase shift.

With this command I can; subtract, add, multiply or divide value of those two signals.
Is there a command for that allow to subtract a phase shift of them ?

lcd.println(currentDraw - supplyVoltage);   // Subtract I from U

The posted command simply prints the difference between the numerical values of two variables.

The comment makes no physical sense.

But it is working.

lcd.setCursor(0, 0);
  lcd.print("V: ");              //B
  lcd.print(supplyVoltage);

  lcd.setCursor(0, 1);
  lcd.print("I: ");              //A
  lcd.print(currentDraw);

  lcd.setCursor(8, 1);
  lcd.print("W: ");
  lcd.println(currentDraw - supplyVoltage);   // Subtract I from U

There is no "command" for phase shift. You would have to measure the phase shift first. Then mangle it however you like.

But it is working.

I would hope so. Subtracting two numbers is pretty trivial stuff even for a microcontroller.
But the question is whether the subtraction has any useful, physical meaning. What useful result do you get from subtracting supply voltage from current draw?

Pete

Subtracting can be used for comparison of two signals = AC comparator.

el_supremo:
There is no "command" for phase shift. You would have to measure the phase shift first. Then mangle it
Pete

Maybe it exists - sample and hold?

If you have a sinusoid represented as a complex frequency then yes you could do arithmetic on
the phase and amplitude, but thats not the same as manipulating individual samples which are
in the time domain, where phase is a time delay (dependent on frequency).

Digital filtering techniques might be appropriate here, but you need to explain what you are
trying to do, not how you think it might be achieved in detail, because that's the xyproblem...

Hi,
Subtracting a voltage from a current does not give you the phase difference between them.
The values you have if read from analog input, are voltage and current amplitude.
The value has no information on their phase relationship.

Can you tell us what you want to accomplish.
What are your inputs and what do you want to output/display?

Thanks.. Tom... :slight_smile:

Hi Tom
I am looking for phase meter program which is not using hardware for zero crossing detection, I know that the function named in post #0 can't do that that why I started this topic.

I have a program for 2 channel Voltmeter with LCD, will be good to add phase shift value to it without additional hardware.

To recover the phase difference between two sinusoidal signals, simply use one signal as a reference, lagged by 0 and 90 degrees, and multiply with the other -- essentially doing a single frequency, discrete Fourier transform.

Not to be nit picking but I = amperage, U = voltage : currentDraw - supplyVoltage != Subtract I from U.

jremington:
To recover the phase difference between two sinusoidal signals, simply use one signal as a reference, lagged by 0 and 90 degrees, and multiply with the other -- essentially doing a single frequency, discrete Fourier transform.

If you are talking about quadrature detector, that may not work the signal is not FM modulated however if you re able to create code for that I will try it.

Danois90:
Not to be nit picking but I = amperage, U = voltage : currentDraw - supplyVoltage != Subtract I from U.

How this is related to phase shift ?

It isn't. Danois90 was pointing out that your comment not only makes no physical sense, it doesn't even describe the (meaningless) operation correctly.

If you multiply two sinusoids (of the same frequency) and low pass filter the result, the DC level will be proportional the cosine of their phase difference.

Hi,

  • What frequency do you want to measure phase shift at?
  • Why don't you want to use hardware to condition your input signals?
  • What voltage and current level are you sampling?
  • Is this a school/college project/assignment?
  • Can you please tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom.. :slight_smile:

  1. 10kHz
  2. I have a hardware - ad8302 - very simple phase detector IC and I want to replace it by program.
  3. 1V
  4. Hobby project.
  5. Electronics - good, programing - basic, Arduino ( IDE ?) - ok, hardware = electronics.

gfvalvo:
If you multiply two sinusoids (of the same frequency) and low pass filter the result, the DC level will be proportional the cosine of their phase difference.

you mean;

val1 = 50 + amp * sin(stp * i);
val2 = val1*;*
val1* val2 + f // f=filter software
I can do that in hardware , in programing ?

Hi,
If you are doing it at 10kHz, you will need to sample the waveform at a much faster rate to detect zero crossing points.

The Arduino AtoD cannot convert a negative input, so you are going to have to level change the input signals.
Or
Just use the positive part of the cycle and sample that to look for zero input and the instantaneous change as the waveform rises from zero input.

But the major parameter will be to sample fast enough to give you the resolution need to accurately detect zero crossing.

Tom... :slight_smile: