Serious Error in "Arduino Projects to Save the World"

In the book "Arduino Projects to Save the World" by Emery Premeaux (with Brian Evans) published by Apress, which I downloaded from 93.50.110.7/~arduino/arduino_projects_save_world.pdf on 24/10/2013, there is a serious error in the calculation of real power in two sketches. On page 213 and again on page 226, the calculation of real power uses the expression

    sumP += abs(calibratedV * filteredI);

This is clearly incorrect, the absolute value should not be taken and the line should read

    sumP += calibratedV * filteredI;

In the case of a purely resistive load, the voltage and current waves are in phase and the power, which is the product of V and I, is always positive (diagram 1 below). In this particular case, the error in the book has no effect.

In the normal situation of a load with a slightly lagging power factor (diagram 2), there are points in the cycle where energy is returned to the supply (where the green power graph goes negative) and here the error starts to come into play - the erronoeus calculation will invert the negative loops making them add to the energy drawn from the supply rather than subtracting from it. The real power will be calculated larger than the correct value.

The true absurdity of the calculation is obvious when one considers the case of a load comprising a pure reactor. In diagram 3 I have drawn a purely capacitive load but the argument applies equally to a pure inductance. We know that a pure reactance absorbs no power whatsoever, in diagram 3 the green power curve is exactly balanced about the zero axis showing that energy oscillates between supply and load equally in both directions. However, redrawing this using the erroneous calculation results in diagram 4, where there is clearly power being consumed even though we know this not to be the case.

The error came to light as a result of a question from user shaulagara, who was puzzled because altering PHASECAL did not change the value of real power. As the phase angle between voltage and current increases, it is clear that the average power will reduce as an increasingly large part of the power curve goes negative. By inverting the negative part of the power curve, the effect will be to reduce the power much more slowly. This is why shaulagara could see no change in the real power for a relatively small change in phase angle.

I have not checked and do not intend to check this book thoroughly. Users are strongly advised to carefully check any design or example they copy and should approach the material presented with extreme caution.

shaulagara's picture

Re: Serious Error in "Arduino Projects to Save the World"

Thank you very much for sharing...

I understand now.

RobP's picture

Re: Serious Error in "Arduino Projects to Save the World"

Robert. That is well spotted. And a nice explanation too.

Comment viewing options

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