emonTX autodetecting and autocalibration of CT's

I've just modified the emonTX sketch for autodetecting CT's and it works well with the CT's i'm using (SCT-013-030).

The CT's need to be plugged in but not connected to any live wire (so in theorie it should read a port value of 512 = Vref/2 )

In the setup part it reads the CT's ports (3, 0 and 1) and checks if the measured value is above 509. It tries this for about 30 seconds per port because after applying power for the first time to the emonTX the port value is building up and not available at first read. It could take a while before the analog ports are in 'rest' .

If a CT is found its sets the corresponding CTx value to 1 and sends out the value instead of 0 (it will sent out 0 if a CT is not connected) in the RF string.

Next thing I want to do is some sort of auto-calibration because i've noticed that each sct-013-030 has different offset when measuring the same source !

Robert Wall's picture

Re: emonTX autodetecting and autocalibration of CT's

"in theorie it should read a port value of 512 = Vref/2 )"

Not so in practice. The divider chain resistors supplied in the emonTx kit are +/- 10% tolerance, so you could have a quiescent value that lies between 460 and 563, or if you used 1% tolerance resistors between 507 and 517.

prensel's picture

Re: emonTX autodetecting and autocalibration of CT's

Yes i know, with the standard 10% resistors it will give a wide range of possible 'error' , thats why i'm considering changing the chain resistors to 1% and set the trigger value on 507 instead of 509.

For now it seems to work with 3 different emonTX's with the 509 value and 10% R but to get it more reliable i'll be using 1% R.

Is there another way of detecting an attached CT ?

Robert Wall's picture

Re: emonTX autodetecting and autocalibration of CT's

Why do you want to do this? Connecting the CTs should be a one-time exercise, done when you install the monitor. Unplugging a CT might be OK when it has an internal burden, but when it has not, unless you first remove it from the current-carrying conductor, you will have high voltages that might damage the winding and might hurt. (A CT of the size you have probably will not transfer enough energy to be fatal, but I would not want my fingers anywhere near. It is standard practice to short-circuit a CT if it has to be, or if there is a possibility that it might be, disconnected from the burden).

"Next thing I want to do is some sort of auto-calibration"

Are you confusing gain and offset? The offset is removed in software by the high pass filter in EmonLib, it will automatically self-adjust even if the offset drifts over time. The calibration constants in the software adjust the system gain, and you cannot measure that without a known primary current flowing. So the only way that you could auto-calibrate would be to connect a known load and then enter a calibration routine (a push-button labelled "Calibrate"?).

prensel's picture

Re: emonTX autodetecting and autocalibration of CT's

Well for the option of autodetection of ct's:

My primary use for the emon system would be at first for measuring the AC output of PV systems. I'm building a 15.000Wp PV system spread over different places and some systems are equiped with just one 500W inverter at this time but could be expanded with more inverters and by having an autodetection option i just have to plugin another CT, and i'm ready to go without software modification. For the CT's not connected the emontx just sents out value 0 instead of the random analog port value. When it detects a CT on startup it uses the real value instead of 0. So finaly i would have 10 emonTX with 30 CT's connected for the AC side of the system. I'm also thinking of setting up emontx for measuring the DC side of my systems.

I've modified the emonbase sketch so that it auto picks up another or new emonTX and start pushing out values power1,power2,power3, Vcc to the same pachube/emoncms feed used by the other emontx's  by preceding the values with the nodeID.

For autocalibration:

I've noticed there is some spread in accuracy between similiar type of CT's.  The correction factor in the sketch is just right for that particular CT but not for others although they are the same type. I already figured i need some sort of known current to calibrate the CT's by modifying the constant value in the sketch and write a new autocalibrated factor to EEPROM and use that for the CT connected.

Another thing i'm working on is how to differentiate between my emontx and a 'strange'  one. Say for example my neighbour is also going to use an emontx/emonbase for his PV system and i dont want to pickup his emontx values but just mine..








Robert Wall's picture

Re: emonTX autodetecting and autocalibration of CT's

Ah, now I understand, thanks. (I was a bit concerned that you might have been on a wild goose chase).

"The correction factor in the sketch is just right for that particular CT but not for others although they are the same type."

How much difference are you seeing? It is probably manufacturing tolerances, and it might be worth checking on the burden resistor if you are using the 30 A with a built-in burden, and if necessary replacing that with a 1% type. When I tested some 100 A CTs (current output, no internal burden), I had 1 from an early batch and 2 from a later batch. The second pair were almost indistinguishable electrically, but the first one had been underwound by nearly 8%. I would have thought that someone could wind 2000 turns to within a few, but 150 out is a bit much. I don't think that could have been due to manufacturing tolerance and would not have been surprised if I had been told it was done deliberately to save on copper.

Whatever the cause turns out to be, my inclination given your setup would be to trim the burden resistor (by adding high values in parallel) to make every CT develop the same voltage at a known current (say at around 80% of maximum to stay well out of saturation). Then you have one standard calibration for all.

"how to differentiate between my emontx and a 'strange'  one"

I think the "network group" does that for you. Just make sure your neighbour uses a different group (or different RF frequency).

prensel's picture

Re: emonTX autodetecting and autocalibration of CT's

I'm using either the SCT-013-000, the SCT-013-030 or the TA17L-04 as CT's at this time.

Because only the SCT-013-030 has the burden R built in, so for the other two i took the burden out of the emontx and moved them into the CT's jackplug: i'll never get 'hit'  by a loose CT on active current because of the always built-in burden and i can use the same emontx for all kinds of different CT's without soldering. Also for detecting any attached CT's i had to remove the burden from the emontx otherwise it would always have a port value of around 512 even without CT attached. I'm now working on using 1% or even 0.1% R for the burden and divider chain R's and have to do some more testing to get a clear picture of the real differences of the CT's.


About the network group: i've thought about that but its just a matter of time until all of my neighbours have an emontbase/emontx floating around with their networkgroups and nodeID's (just in theorie ;-)) so it will ruin my setup eventually. I'll need to make something better with some sort of handshake at first contact between emonTX and emonBase and use that for all further communication.

I' m thinking of a having all 'out of the box virgin' emontx's working on nodeID 1 and listening to an emonbase in the same network who will provide them their final nodeID, anything other then 1 and not in use already (by pressing pairing buttons or something) the final nodeID gets stored into the emontx EEPROM and used from that point on. Still this would not prevent any neighbour ruining my system so i will use some sort of key too which the emontx will use in the RF string when sending data.. Only known nodeID's with known keys will be accepted by the emonbase. I did some testing with the aProtocol and XRF modules but not with RFM sofar so and dont know (yet) if there are any other means of 'pairing'  emontx and emonbase.









prensel's picture

Re: emonTX autodetecting and autocalibration of CT's

In my quest for an emonTX with autodetecting and autocalibrating CT's i took a different route.

Sure the autodetecting did work but i was not happy with it.

The autocalibrating was probably not feasable at all so i let that idea go.

I've now decided to have the emonTX be configurable from the serial port (FTDI)  for the existence of CT's and their corresponding calibation factors. Much easier to setup, one sketch will fit all versions of CT's because you can set them later on and also the nodeID and group id are configurable. The config items are saved in EEPROM.

If someone is interested i can sent/upload the sketch somewhere.



glyn.hudson's picture

Re: emonTX autodetecting and autocalibration of CT's

Hi Prensel,

That sounds very interesting. It would be great if you could post up your code up on the forum. 

'pairing' an emonTx to a certian emonBase is not something we've touched on yet but am away it will be needed in the future. 

We are currently in the design phase for an emonTx SMT, I'm considering including a push button which could be configured for pairing. 

Comment viewing options

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