you, me, shield and 3 phases of confusion

Hello!

I'm new happy owner of emontx Shield that i've coupled with current sensor and AC-AC sensor from guys here doing the good work. Also got 4 temp sensor running across muchos cat5 wire.

But I ran into a problem with 3 phases. My house receives 3 phases from the grid, not splitting one into 3 inhouse..

Problem was not apparent when i monitored just one phase but with multiple, i start getting negative and conflicting values.

From what i gather, solution with one ac-ac source is adressed by Glyn in this fine example for emontx:

https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTx_C...

 

Now, I'm not yet a programmer, more like copy-paste warrior in them interwebs, as much as i can make sense of different parts of code. But trying to mix Glyn's example for emontx with whats my working base:

https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTxSh...

I'm a little overwhelmed.. shield doesnt define any pins, does tricks by going directly to RF (?) and ...

TLDR: In short, could anybody please find time to copy paste an example together for shield 3 phase (4?) sketch.. using one AC-AC (let's say on CT1) as a voltage reference for all phases..

Maybe being so nice to point out what parts got replaced with what? :)

In any case, thank you in advance for your time!

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

There seem to be just two simple problems: you need to take the pin designations from the Shield sketch and plant them in the 3-phase sketch; and you need to keep the calibration constants from the shield sketch.

From memory (I've not checked) you don't need to do anything with the radio - other than get the frequency right.

So basically, for the emonTx, the input pins are

int inPinV = 2;   /* Voltage */
int inPinI1 = 3;  /* CT 1     */
int inPinI2 = 0;  /* CT 2     */
int inPinI3 = 1;  /* CT 3     */

And for the shield these are 0, 1, 2, 3. (You knew that! - Clue: those are the first parameter in "ct1.current(1, 60.606);" etc.)

You need to change the 3 Ical values to 60.6 as a starting value (you'll change this to calibrate the inputs). It assumes CT1 is on the phase that you measure the voltage of. If you get negative powers on the other phases, swap CT2 & 3.

I think it should work then. Bear in mind phase calibration can be tricky but there are notes in the comments at the top of the sketch.

(BTW, Glyn didn't write the 3-phase sketch.)

xmasta's picture

Re: you, me, shield and 3 phases of confusion

Thanks for the reply Robert, 

I did not know that theses are pins on the ct parameters, the comment states "setup emonTX CT channel" - now i know it means board pin, thank you :) 

I will see how far i get with these pointers!

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

"I did not know that theses are pins on the ct parameters,"

If you look at the source code for emonLib, it's actually written out there. You do need to be careful because some methods use "channel" as a route to a pin look-up table that is inside the library (and for emonTx only), the older methods use the pin number directly.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

grr.. got the sketch together i think but stuck with calibrating.. Put the CT's onto same 60watt lamp lane and now struggling to get the thing to show the correct values.

Main problem atm is that the calibration page:

http://openenergymonitor.org/emon/modules/emontx/firmware/calibration

tells me "the expected range for the CT calibration is 109.44 – 112.78" - but this is for emontx i presume, because shieldtx example comes with the value being set to: 60.606 so there must be totally different resistance in the mix that comes up with this number, but I can not find what is the range for CT for shield.. anyone? please?

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

Don't expect to be able to calibrate with a load as low as 60 W. You are not fully out of the area where random noise is having an influence. The calibration was indeed written for the emonTx - I warned you above that the starting value is about 60. If you follow the maths, you should be able to work out the range for yourself - and learn a bit about it in the process. I don't know what your max. current is, but you should be calibrating at around 60% of that, or the highest current that you can measure if that is lower.

[Edit: for people who can't work out what 60.6 ± 4% is, I've added the numbers.]

glyn.hudson's picture

Re: you, me, shield and 3 phases of confusion

I've ported the emonTx 3-phase example over the the shield (simple changed the port numbers and calibration). Plesae could you test if it works for you. I don't have access to three-phase. If it works I will push the example to GitHub

[Edit by RW: This is the standard single-phase sketch, NOT the 3-phase.]

xmasta's picture

Re: you, me, shield and 3 phases of confusion

Hey Robert, dont be a meanie! I did not know that 60.6 is the middle from what to calculate up and down, now i do, thank you :)

 

Will test it out in 24h Glyn, away from home atm, will report back.

Before going away had real trouble getting 1st phase socket to be as precise about that 60w bulb as other 3 are.. no matter what phase reader I used. Could it be that I have really bad "random roll" of resistors as they are 5%.. would it be fine to replace those with 1% parts of same rated resistance? and could those be the trouble makers?

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

We had this discussion some time ago, but in a slightly different context: I think if you change the resistors you may see an improvement - even using a different one from the same batch. Changing them to 1% may or may not make a difference, because 1 step of the ADC is around 0.1% and you're looking at positioning the quiescent input at somewhat better than that. Changing the burden to 1% will improve the certainty of your measurement and reduce the band that the calibration constant occupies. But realise that by far the largest contribution to the error comes from the internal bandgap reference, ~ 11%. That will affect all inputs equally, and if you haven't calibrated that you might need constants way outside the range mentioned (and in case you are wondering, the stability of the internal reference is a lot better than most other sources so once calibrated all should be well). But I have to reiterate: Depending of course on your voltage and the maximum current that your c.t. expects, 60 W might be 250 mA which is 0.25% of full scale. You're expecting a lot to measure that with any degree of accuracy with a 10-bit ADC that needs at least 5 bits, preferably ± 5 bits, to get anywhere near to a decent representation of a sine wave.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

Let me throw in some background :)

Here sits a guy that does not really know how AC works, who has put together some electric bikes, done some other layman level tinkering with stuff and can clearly see that Robert does what in the poker world is called "overleveling the opponent" - assuming the other guy knows a lot more than he really does and acting based on that assumption :D

I write all that in a good spirit, i'm glad you explain stuff and i'm trying to take away from it as much as I can. Reason that I use 60w pulb is that I do not have AC clamp thingys and thats the first thing around i found with wattage that I think i can somewhat reliably believe in. I have electric heaters and stuff but I'm absolutely not sure if 1500w heater really draws exacly that etc, and no way to make sure. I'm definitely not building my stuff to be monitoring some 60w rates, my house draws stupid amounts of electricity and i'm building it to be in position I would call "if you can measure it, you can improve it".

Now, I would hope I'm not completly hopless, just that this far i've been reading and teaching myself mostly about DC and batteries, related to ebikes etc. Sinewave's and phase angles on AC stuff.. "holy kittens some deep stuff here" was the first reaction. After buying all parts and running it on 1 phase, I kinda went into checking the wiki and yeah, there's a lot for me to learn I believe :D

Here's the result using Glyn example, but thats on the same 60w bulb and one phase, didnt make it to cellar yet. Here you can see how the reading differs from ports. No corrections or calibrations are made for results on this image:

From Roberts explanations I now understund that I'm toying around in a really small "spectrum of the AC?" with this 60w load but what i see from other ports are pretty reasonable in my oppinion, just the first port overshoots. I'm using only two clamps atm, designated "C1" and "C2", third in mail.

Will log some more results tomorrow in the cellar with different source phases!

Oh.. but the theme is confusion and here's some more of it..

I believe that because I have 4 ports for phases, I can skip the messing around with resistors and other drama on port 1 and use 3, 4, 5. But I can not see on the Glyn example where does it define.. that all calculations for realpower are done using the same power source.. or that port 1 is the reference? is it? no.. the voltage port is.. no, the voltage reading is stored and shifted and.. magic.. atleast on the emontx 3phase example.. how did Glyn now manage to do without all that?? I should sleep.. educate me a little more pls.

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

"Here sits a guy that does not really know how AC works"  Go here and read the first 2 items listed under "Electricity Monitoring" - S L O W L Y. Don't rush it, and make sure you've understood one before you move on. You may want to quickly scan the 3rd, then read the 4th, which explains your 3-phase supply.

I don't want to write any more now because you'll no doubt have a lot of questions from those.
And let's leave the 3-phase sketch until you're happy you know how a 3-phase supply works.

What you're showing when you move the same c.t. to inputs 2,3 & 4 is the tolerance of the burden resistor. 2, 3 & 4 appear to be reasonably close. 1 does appear to be reading high. Do you have 5% resistors for the burdens ( orange orange black gold) ? If so, my guess would be that you have three that are low and No.1 is high. Your two c.t's are also different (they can have 3% error). What I would do here is dedicate a c.t. to its own input, put all three on the same wire and adjust the calibration constants so that they all read the same (or as close as seems reasonable) on a reasonable load - significantly bigger than 60 W, like your 1500 W heater. That's part of the reason why the calibration constants are there, after all.

There's just one thing I could mention: You're allowed to lie to c.t's.  If you pass the wire to your 60 W lamp through the c.t. twice, it will measure the current twice and it'll appear to be a 120 W lamp, three times - 180 W and so on. (You don't think I actually used 250 A when testing the c.t's ? ! ! ! ).  You will probably find you get much more consistent results at higher powers.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

Thanks for the links and showing what to read up on, I will do that. Before that, as i'm more hands-on guy I jumped to my board and discovered, that resistors I got with the kit are actually 1% ones.. hmm, I bought the kit from this site, didnt use any of my own parts, mby should have said that earlier. (here's a linkie of me putting it together! http://www.youtube.com/watch?v=1roh8-MZ_pI )

Now, i did not find on wiki or schematic page what resistors do you mean by "burden resistors" exactly, I assumed the three behind the CT1 port? 33R 470K 470K? ( http://solderpad.com/openenergymon/emontx-shield/ )

I dont see any other resistors coming in parts of 4 to be port exclusive so like by process of elimination i assume nothing else could be difference maker in here? The 10u capacitor is the only other part but that.. cant make for the reading error i think. Guess I should remove the three and check them out with a tester, maybe there's a faulty one in the patch?

* fixed links

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

The burden resistor is specifically the one that is connected across the c.t. secondary - the 33 Ω in your case. (It is the one that provides a load - 'burden' to the c.t.  In the good old days before electronics, the burden would have been a meter - a moving iron ammeter or the current coils of a wattmeter.  The 2 x 470 kΩ are the "bias" resistors that set the quiescent working point to half-supply voltage. The 10 µF capacitor bypasses the bias resistors - it gives a near short-circuit to a.c. and connects the "earthy" end of the c.t. to ground.

I was a bit surprised you said 5% because I thought all the kit resistors were 1%. I would not risk damaging the board by trying to unsolder anything. If you read approx. half the supply voltage (= 1.65 V) at the junction of the two 470 kΩ resistors, that's good enough. It doesn't have to be exact. The 33 Ω is probably more accurate than your meter on that range, so measuring that will not prove anything - we know from the numbers it's not all that far out.

Have you tried a higher current to see what the match is like then?  You haven't said which c.t. you are using, I'm assuming it is the 100 A YHDC SCT-013-000, and you haven't said what your system voltage is either, so I'm assuming 240 V. (Power means nothing to a c.t. - it only knows about current!)

If you really want to know how the errors build up, there's this to read. I don't think you necessarily have a faulty component in there, I think it is simply a case that the tolerances have added up badly.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

Robert, the voltage on my screenshot above is shown on each line. And i'm indeed using yhdc sct's.

Desodlered burden resistor, checked, seemed fine. 33.1, put it back together again. -- readings went better.. not sure what was the cause, maybe the foami thing i used under the arduino .. anyway, got them somewhat balanced now cheating with dual-triple loops on 60w. I still do not understand complicated stuff about how the math actually goes, but calibration numbers are beating me..

Initially for shield they are 60.606 - that reads about correct, now.. isnt it one number "60.606" but somehow two values for some equasion like 60 and 606 ?? because I ended up on 57.586 giving me closest to 180w (triple loop) like ~183, but if i changed it to 57.566 it is jumping up to ~187 ... whats the logic here..

Results with Glyn example:

switching CT to another phase gives false readings.. please advise. Needs some voltage storing phase shifting magic i think..

I also tried some self copy pasted fixed version of the emontx sketch, similar results, difference was that it's results had negative value.

 

forgot to explain: changes in example sketch I made -- disabled CT4 and pasted in my temperature stuff (last 4 numbers)

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

"maybe the foami thing i used under the arduino"

You should not have anything under the Arduino. If you mean the black anti-static foam that the chips are packed in, that conducts electricity and it is anyone's guess what that will do to your readings. You must not have that around once the I.Cs are inserted in their sockets on the PCB.

If you read the current on one phase and the voltage from a different phase, the rms current and rms voltage will be read correctly (of course) and the apparent power (VA) will read correctly too, but the real power will be seriously wrong because of the phase shift of 120° between the two waves. You have read the 3-phase article now, haven't you? What you need to do is explained towards the end of that piece, and that's what the 3-phase sketch does.

"self copy pasted fixed version of the emontx sketch"

I don't understand what that is.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

"self copy pasted fixed version of the emontx sketch" - that was the sketch i copy pasted together from emontx 3phase sample and your pin teaching above at the thread start.

I managed to get that "monster" to measure correct numbers:

current 3 should be 120w so i got it pretty close, you can see settings of sketch for calibration too.. 3rd CT still havent arrived so I'm messing with two atm.

 

Now the Glyn example results following: (and made me reverse the current 3 CT on phasewire vs "emontx" sketch running previously)

It seems to be missing a "double" ? I can not get it to show 120w in 0.0 to 2.0 phasecal value. But it does show pretty accurate 60w (half) at 0.2 phasecal for that phase.

Need coding help, thread first post has the link for sketch that contains the math required for this doulbe trick i believe.. not sure i can manage to sort it out and put into right place

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

I can't interpret what your problem is now. Post the sketch you are using as a file attachment and say exactly where your voltage monitor is and where your c.t's are.

xmasta's picture

Re: you, me, shield and 3 phases of confusion

sorry, english is not my first language, i can be hard to understand at times, i'm sure.

What i ment is, using the emontx 3phase code mixed for shield, i got the correct reading, look at Current 3 on first screenshot. Thats running on different phase through doublecheat 60w lamp, that is 120w.- this is correct.

Attatched under : emonTxShield_CT1234_3Phase_VoltageTemp.ino

The second screenshot, third column is phase 3, running through same loop and not reading 120w but 60w, using glyn posted sketch as a source, attatched under: PhaseExShield_CT1234_Voltage.ino

So my understanding is, that the Glyn example for shield above is missing a doubling.. variable..?

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

OK, I can see the sketches. Thanks.

At this time, I am only looking at the sketch "PhaseExShield_CT1234_Voltage.ino"

This is a single-phase sketch and you must have the three c.t's on the same phase as the voltage measurement. If you do not, you will get results that are wrong. To understand why, you need to know how the sketch measures real power: It measures the instantaneous voltage and current, multiplies them together to get the instantaneous power, and then does that for 10 cycles (20 crossings) of mains (0.2 s). Then it calculates the average power over this time. If the voltage wave and the current wave belong to the same phase, that will be the correct answer. Now look at the diagrams here and if you imagine the current is the red phase and the voltage is the blue phase, you can see that because the waves are 1/3 cycle out of step, you are multiplying the wrong two numbers together each time and you will get the wrong answer.

I cannot see a mistake in the sketch so if your c.t. "phase 3, running through same loop and not reading 120w but 60w," was on the same cable as the voltage sensor, then there is a fault somewhere that must be found and corrected before you try to get the three-phase sketch working.

To get your three-phase sketch working, I need to know what is your mains frequency, 50 Hz or 60 Hz?

xmasta's picture

Re: you, me, shield and 3 phases of confusion

I'm from Estonia and.. googling around found this page that lets me believe we are at 50hz - http://www.mainsfrequency.com/

I'm not sure did you miss Glyn's post? :) It is 7th in this thread, that is why I'm even messing around with that shield sketch you looked at.

And I dont have any trouble getting readings for one phase working, I'm, as the thread name states too, messing around to get a shield sketch going for 3 phase system, using one voltage reader on phase 1 :)

From the screenshots above you can see I got correct reading with emontx 3phase messy sketch.

I'm always measuring voltage from 1st phase and there is no problem with ct or realpower on it, what I'm failing at is trying to make Glyn's sketch to do the same 3 phase trick :) Reading voltage from 1st phase and then phaseangling it around for calculations with ct's on second and third phase for realpower.

Hope this made things clearer and thanks for helping me :)

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

Thank you for explaining. I have FINALLY realised what has happened. I am sorry it took me so long:

Submitted by glyn.hudson on Fri, 01/11/2013 - 08:52.

I've ported the emonTx 3-phase example over the the shield (simple changed the port numbers and calibration). Plesae could you test if it works for you. I don't have access to three-phase. If it works I will push the example to GitHub

Attachment Size
emonTxShield_CT1234_Voltage.tar.gz  2.41 KB

That is not a 3-phase sketch, it is the single phase sketch!  It will never work for 3 phases because it does not have the array to record the voltage and 'play it back' 8 and 17 samples later for the second and third phases. It also explains why your current on phase 2 is half what it should be and negative - that is exactly the value I expect when the c.t. is on the wrong phase.

I cannot believe Glyn made that mistake - but he has. Over the next day or two, I shall port the original 3-phase sketch for the Shield, but it will be almost exactly the same as your port so you should use that. When I've done that and tested it, I'll send it to Glyn and I'll tell him (away from the forum!).

 

promy's picture

Re: you, me, shield and 3 phases of confusion

I would also like to monitor my 3 Phase installation with 3xCT and 1x voltage sensor.

Am I correct that the files on the git in the dir "emonTxFirmware / emonTxV2 / emonTx_CT123_3Phase_Voltage" (changed november 8 2013) are the correct and latest ones I should use?

I build my own emonTx around a meduino nano (3.3V 16MHz Mega328 arduino comatible board) with 3 CT sensors and 1 voltage sensor. 

Robert Wall's picture

Re: you, me, shield and 3 phases of confusion

Is this https://github.com/openenergymonitor/emonTxFirmware/blob/master/emonTxV2... the sketch you mean?  I have not been involved with any changes so I cannot comment on whether this sketch will work unchanged on your hardware. If you will not be using the emonTx, then you must either change the ports in the sketch to match your new hardware, or build your hardware to match the emonTx.

calypso_rae's picture

Re: you, me, shield and 3 phases of confusion

I posted a sketch here on 17/10/13 which provides four continuous sets of real power measurements (two on each of the phases that are being measured).  All six analogue inputs are sampled in turn: voltage on two phases, and four current.  The resulting power values are dispatched by RF with no interruption of the sampling process.

It would not be difficult to change this to three voltage and three current measurements.  That would allow three continuous measurements of real power, one on each phase.

When using all six of the analogue inputs in this way, the emonTx hardware is not well suited for this task.  But the alternative hardware that I posted should be fine, with minor changes as necessary.

Comment viewing options

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