# Cypress Developer CommunityTM

## phase and power calculations

Summary: 3 Replies, Latest post by danaaknight on 20 Jul 2015 03:12 AM PDT
User
3 posts

Hi, as an intern student I am new at Psoc 4 and I am stuck with a problem. I have been given a project on home energy monitoring, therefore I have to make some calculations like phase difference, active and reactive power. I want use a shunt resistor with small value to measure the current passing through the system. However, because the harmonics are crucial for power calculations and we want to observe detailed features like "harmonic signatures" of the devices, we want to make like 1000 measurements per second. And the magnitude of the current is expected to be in the range of 10mA-10A.  According to my employer, although the bandwidth of the current is broad, the shunt resistor approach is fine. Until here, everything is okay, but the problem is I am having trouble on these calculations. I know, I should use a SAR ADC to pass the measurements into the digital and maybe a PGA if the current is too low for ADC, but after passing to the digital I do not know how to calculate phase and power. For example, does the fact that I have to measure the current and voltage 1000 times in a minute mean that I should calculate phase and power(both active and reactive) in each time? Or is the phase difference constant as in simple circuits? As an approach, could I find the phase difference by finding when the current and voltage achieve their peak values in a period then by subtracting these values and dividing the result by the line voltage period( 1/50Hz )?

I know, I asked lots of questions and my writing is a little bit messy. I will be grateful for any help&idea,

Thanks.

User
7646 posts
1. The range 10 mA to 10A, I assume you want a resolution of 1 mA or something like that.

that means you want ~ a 10,000 : 1 ratio of measurement, so a 14 bit A/D will do OK. So use

DelSig, that will yield 133K SPS, more than enough.

1. At each sample point you are getting instantaneous and V values. This ap note might help with the requisite calculations.

You are going to have to establish a period of the fundamental, that’s nothing more than a zero cross detector. Complicate dby need for AGC loop, or just use the sample set to find the zero cross assuming one period to the next values are stable, or use signal averaging to eliminate chenage in load effects.

Regards, Dana.

User
3 posts

Thanks Dana, I have been studying the concepts you mentioned. However, I could not have found a way to implement them. Could you give more details or circuit schematics?

User
7646 posts

The core of the approach is using an A/D converter, there are several example projects

on Creator Start page, "Find Example Project" link.

The A/D will measure voltage, and if you insert a low value R in one leg of the load, the V

drop across that R which indicates current. To get period you can either detect that in code

looking at your samples, or use a comparator signal conditioned to the AC line, its output

connects to a timer enable, and you measure the time from start of comparator trip to its

end, thats 1/2 period.

Tackle each phase of this 1 step at a time, and google searches will give you many hints,

references to work from.

1) Implement A/D, get it working, and measure voltage. Scale the line input to meet

PSOC limitations.

2)  Implement comparator and timer to measure period. Use PSOC to generate a frequency

of your choosing as your signal to measure. Again there are example projects for timer and

comparator use.