Arduino Due Calibrating Voltage sense +/- 0.1 at first, now +/- 0.3 what does it mean?


After running on the 12V PSU for 3 hours, the CPU is at 87° F and the regulator 81° F.
Room temp is 77° F. Board is on a table, in the open. i.e. not enclosed.

all of the ones I have on hand are switching.

I just want to verify something. The Arduino Due uses two linear voltage regulators, the DC barrel jack is converted to 5volts from the barrel jack and then later to 3.3v from the 5volts. Since those 2 regulators are linear, does it matter if the power supply feeding the Due is Linear or switching? Can the switching power supply still affect the Arduino Due and thus affect accuracy of the power measuring?

I don’t think that is correct. The circuit diagram I looked at showed a switched-mode buck converter deriving the 5 V from the 7-12 V d.c. input, but you’re correct in that the 5 V to 3.3 V regulator is linear.

But I did notice this:

I’d suggest that the W5500 could well be a serious source of noise on the 3.3 V rail, so splitting that off - either using a separate regulator or putting a filter in its feed - would be something to look into.

OH! Thank you. So if switch-mode converters introduce noise, maybe I should think about getting a regulated linear 5v power supply and bypassing that buck converter…

Also is putting a filter on the w5500 feed more than adequate or would it be much better to put it on a separate regulator?

A filter might be enough, and it’s probably easier and cheaper to try. A separate power supply is more likely to be better - but I wouldn’t guarantee anything where noise and interference is concerned.

1 Like

With my original question about using a switching power supply as the feed. When Power is converted from a switching source to a lower voltage using a linear regulator, would there still be any noise from the switching supply on the smaller voltage provided by the linear regulator?

What I am thinking is that maybe the 5V is not used for much on the Arduino Due? I know all of my CTs circuitry on the shield is tied into the 3.3v rail.

The reason I ask is that I am trying to verify that elliminating the switch mode power supply and even the switched-mode buck converterter deriving the 5v from the 7-12 V d.c. will likely show an improvement in accuracy.

If you’re interested in calibration accuracy, you need to look at all the possible things that influence the calibration and determine which one is / which ones are the source of the variation. The most obvious and the easiest to check is the reference voltage that the ADC in the Due uses. That is probably the 3.3 V rail (but check), and measure it. How stable is it as the board and the processor warms up? How stable are the resistors in the voltage divider against temperature, are they heating up and if so, by the same amount? These are the sorts of things you should be looking at and checking.

There could well be - it depends on how good the regulator is at rejecting noise and other variations in its input voltage. I can only say: Try it. Chasing down sources of interference and induced noise can be a matter of experience, intuition and an understanding of all the possible mechanisms that can be involved. You can read up of the last one, and then follow the rules, and all being well, you’ll see an improvement

1 Like

Thanks very much, appreciate all the great info.

Edit: Ok I got some stuff done with what I have for now.

I am now using the DC barrel jack instead of the usb port to power the Arduino Due, the power supply feeding the barrel jack is a 7.5VDC 700ma switching adapter, I plan to get a linear 5v supply and feed it directly to the 5v pin and ground later, but for now this will work.

I also wired up my 3.3VDC adapter directly to the w5500 ethernet module so that it wont be using the 3.3v rail on the Arduino Due.

I am going to check all calibration one more time and then put this system into use :slight_smile:

I first calibrated voltage, and then current.

my sketch:

// EmonLibrary examples, Licence GNU GPL V3
#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1;             // Create an instance

void setup()
  emon1.voltage(0, 161.9, 2.3);  // Calibration for AC-AC Adapter Voltage: input pin, calibration, phase_shift
  emon1.current(1, 104.3);       // Current: input pin, calibration.

void loop()
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

I am adjusting the phase shift so that realpower = apparent power.

a value of 2.3 gets me very close, realpower is just a little less than apparent power.
a value of 2.4 and i get readings that realpower is more than apparent power. I did not even know this was possible.

Is it ok to use values such as 2.31, 2.32 etc to further tune it? or no?

here is my log at a phase shift value of 2.3:

1881.93 2491.27 118.11 21.09 0.76 
1683.05 1837.30 117.63 15.62 0.92 
1577.77 1607.63 116.76 13.77 0.98 
1536.71 1541.41 116.21 13.26 1.00 
1527.87 1528.59 116.06 13.17 1.00 
1540.12 1540.26 116.41 13.23 1.00 
1532.95 1532.99 116.18 13.19 1.00 
1539.03 1539.07 116.40 13.22 1.00 
1539.07 1539.10 116.41 13.22 1.00 
1540.75 1540.77 116.46 13.23 1.00 
1540.83 1540.85 116.47 13.23 1.00 
1535.07 1535.12 116.26 13.20 1.00 
1540.48 1540.51 116.45 13.23 1.00 
1540.06 1540.09 116.43 13.23 1.00 
1541.57 1541.59 116.50 13.23 1.00 
1541.67 1541.67 116.50 13.23 1.00 
1540.95 1540.99 116.50 13.23 1.00 
1542.03 1542.06 116.52 13.23 1.00 
1535.23 1535.29 116.25 13.21 1.00 
1541.22 1541.27 116.47 13.23 1.00 
1542.28 1542.32 116.51 13.24 1.00 
1542.17 1542.21 116.52 13.24 1.00 
1541.25 1541.28 116.48 13.23 1.00 
1534.76 1534.78 116.23 13.20 1.00 
1541.10 1541.14 116.49 13.23 1.00 
1541.41 1541.43 116.48 13.23 1.00 
1536.14 1536.20 116.29 13.21 1.00 
1542.40 1542.43 116.53 13.24 1.00 
1535.99 1536.00 116.27 13.21 1.00 
1542.45 1542.49 116.52 13.24 1.00 
1542.63 1542.66 116.56 13.24 1.00 
1526.42 1526.46 115.92 13.17 1.00 
1542.30 1542.35 116.52 13.24 1.00 
1543.46 1543.48 116.58 13.24 1.00 
1545.63 1545.65 116.63 13.25 1.00 
1544.00 1544.03 116.59 13.24 1.00 
1543.54 1543.55 116.55 13.24 1.00 
1544.35 1544.36 116.60 13.25 1.00 
1528.99 1529.01 116.01 13.18 1.00 
1543.13 1543.18 116.54 13.24 1.00 
1548.38 1548.42 116.75 13.26 1.00 
1543.01 1543.03 116.55 13.24 1.00 
1541.97 1541.99 116.52 13.23 1.00 
1542.23 1542.27 116.51 13.24 1.00 
1542.04 1542.07 116.51 13.24 1.00 
1550.69 1550.73 116.85 13.27 1.00 
1542.82 1542.87 116.53 13.24 1.00 
1534.42 1534.43 116.23 13.20 1.00 
1542.29 1542.33 116.53 13.23 1.00 
1541.66 1541.69 116.51 13.23 1.00 
1542.33 1542.37 116.54 13.23 1.00 
1542.75 1542.78 116.55 13.24 1.00 
1542.56 1542.58 116.53 13.24 1.00 
1543.16 1543.17 116.56 13.24 1.00 
1536.44 1536.49 116.30 13.21 1.00 
1535.90 1535.91 116.28 13.21 1.00 
1542.47 1542.51 116.54 13.24 1.00

EDIT, actually upon watching more entries I occasionally get a realpower value higher than apparent power even with a phase shift of 2.3. For the most part a value of 2.3 gives me a realpower that is just a hair less than the apparent power.

In theory, it isn’t. What really happens is the algorithm that applies the phase shift compensation slightly alters the amplitude of the shifted wave for the real power calculation - and the apparent power calculation uses the original unshifted wave, hence the error. There’s more about this in ‘Learn’.

Why not? But values that large are increasingly distorting the voltage wave - as you see from the real power coming out greater than apparent power. Correcting that fault is a totally different story, however.

1 Like

From the Arduino website:
(of particular note is the line about feeding the board via the 5V pin)


The Arduino Due can be powered via the USB connector or with an external power supply. The power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board’s power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

  • Vin. The input voltage to the Arduino board when it’s using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or if supplying voltage via the power jack, access it through this pin.
  • 5V .This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don’t advise it.
  • 3V3 . A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 800 mA. This regulator also provides the power supply to the SAM3X microcontroller.
  • GND . Ground pins.
  • IOREF . This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V.
1 Like

If I remember correctly some of the power adapters in the emon shop work well with the phase shift value of 1.7 so I am guessing the reason I had to use a value of 2.3 is because of the AC-AC adapter that I am using. I have the realpower fairly close to the apparent power, but it would be nice to use an adapter that got this value closer to 0.

I still need to try modifying the ZMPT101B, to see how well it works without the op.amps. I may give that a try today.

Yes I had read that as well. So I went looking for first hand experience on other forums where people had done it anyway. Seems the important thing is that you dont get the polarity backwards, and also that your 5v source is a pretty good one, other than that I dont see an issue.

Not quite right - it’s the difference in phase errors of both the c.t and the v.t, plus the time difference between the two readings, that determines that factor. The transformers usually display a phase lead, and that usually varies - often in a complicated way - with the amplitude of the current or voltage being measured.

Ideally, you want to arrange things so the the lead of one plus the time difference equals the lead of the other.

1 Like

Could you please ellaborate on this point? do you mean arranging the order in which I take readings in my sketch?

What you said got me thinking about something, on the boredomprojects: Home Energy Monitoring System
he chose input 11 as the voltage input, on my project i chose input 0. I am now wondering if the analog input I choose for the voltage transformer has significance to the phase shift value, i did not think it would when i chose 0 as the input for my voltage transformer.

I used a 22ohm burden resistors on my Arduino shield for each CT input, as per the schematic on boredomprojects. I later found out that the CT’s that I ordered already have a built in burden resistor. I am using 4 of sct-013-020 and 7 of sct-013-030.

I used the calculator here: OpenEnergyMonitor Current Sensor Calculator
for my 3.3v due it says the ideal burden resistor is 78 ohms for a load of 30amps. however from what I have found on the web the SCT-013-030 has an internal burden resistor of 62, and that same calculator says that a burden resistor of 62 is good for 37.6 amps. So I am assuming that I will be using 30/37.6= 79.7% of my arduino’s ADC range, correct? also i’m assuming its 20.3% before the CT core is saturated? (or does the core get saturated at higher voltage than 1v, and if so at what point does it get saturated?)

From my understanding I would be less likely to saturate the SCT-013-030 core with 62 ohms instead of 78 ohms for the burden resistor.

Also I have to wonder why boredomproject chose a value of 22ohm as the burden resistor for all circuits, for circuits with a small load wouldn’t this be sacrificing lots of accuracy?

I could not find the ohm value resistor used for the sct-013-020 on the net so I decided to open one up, I can make out two smd resistors marked 1000 (100ohm) and 1201 (1.2kohm) for total of 1300 ohms? Whats going on with this one, this can’t be right:

I decided might as well open the 30amp one up too, i can make out one smd resistor marked 62R0 (62ohm):

The eqivalent value of those two in parallel is ~92Ω, not 1300. :wink:

One way to get the answer for two resistances in parallel
is to divide the product of the two values, by the sum of the two values.
i.e. 120000 ÷ 1300 which is approximately 92.3

1 Like

That could well result in a smaller (i.e. better) value for PHASECAL. The order in emonLib is “wrong” (it would be better if the order of readings were reversed) but to change it now would result in a support and backwards compatibility nightmare. All you can do is look at the numbers for the individual items you have and do the maths - and will include measuring the time between readings, which will, I think, depend on the resolution you have set in the ADC.

I don’t know your Duo - if there is only one ADC and the inputs are selected with a multiplexer (as in the Atmel '328P) then it won’t make any difference.

What that means is you forget all about burden resistors. The c.t’s output is exactly what the data sheet says - 1 V at the rated 30 A. A burden resistor is only necessary if you have
true current transformer that outputs a current (the clue is in the name). Using my rule of thumb (design for 1.1 V at the ADC input), which allows for component tolerances (and when I looked at one of those calculators - maybe that one - it didn’t, so it won’t give you a realistic and safe value), you’re using more like 91% of the input range. I wouldn’t worry about that unless your c.t. is seriously overrated. Also remember, your current waveform need not be a perfect sine wave. If you have (say) a rectifier load that hasn’t read the textbooks, the crest factor will be way in excess of √2 and a genuine 30 A rms current will be seriously clipped in the ADC

You’d better.ask him. Maybe it was to make all the inputs the same - pure and simple?

As Bill says, those look to be in parallel. You did the wrong sum. But as I wrote above - forget the burden resistor. That c.t. too gives you an output voltage.

If you’ve got a calculator, the easier way is

100 [1/x] 
1200 [1/x]
the answer.
1 Like

Thank you Bill and Robert very much! Will be removing the burden resistors today. I will then calibrate again, and while I am doing that I will see if reversing the order in the library gives me a better phase cal :slight_smile:

Very excited to start using this, hoping it will in the long run help to identify and reduce some of the power usage.

Snipped the burden resistors off the shield, and finished the calibration.

I did go ahead and switch the sampleI and sampleV around which shaved off about 0.1 from the phase shift calibration.

sampleI = analogRead(inPinI);          //Read in raw current signal 3.06
sampleV = analogRead(inPinV);          //Read in raw voltage signal 3.16

here is what the calibration ended up looking like, inputs 1-4 are 20a inputs 5-11 are 30a:

  emon[0].voltage(0, 161.74, 3.11);//Voltage: pin, calibration, phase_shift
  emon[0].current(1, 20.01);       //Current: pin, calibration
  emon[1].voltage(0, 161.74, 3.06);
  emon[1].current(2, 20.08);
  emon[2].voltage(0, 161.74, 2.49);
  emon[2].current(3, 19.89);
  emon[3].voltage(0, 161.74, 3.06);
  emon[3].current(4, 20.11);
  emon[4].voltage(0, 161.74, 2.17);
  emon[4].current(5, 29.83);
  emon[5].voltage(0, 161.74, 3.98);
  emon[5].current(6, 30.55);
  emon[6].voltage(0, 161.74, 2.43);
  emon[6].current(7, 29.87);
  emon[7].voltage(0, 161.74, 2.27);
  emon[7].current(8, 29.83);
  emon[8].voltage(0, 161.74, 2.36);
  emon[8].current(9, 29.85);
  emon[9].voltage(0, 161.74, 2.22);
  emon[9].current(10, 29.83);
  emon[10].voltage(0, 161.74, 2.46);
  emon[10].current(11, 29.89);

This loop takes about 1850ms to complete, so i have it set to post to emoncms every 2000ms.

    for (int i=0; i<NSENSORS; i++)
      emon[i].calcVI(20,2000);    // Calculate all. No.of half wavelengths (crossings), time-out 20 (20 = 1849ms loopSpeed)