Separate CT Calibration

I hope this isn't a dumb question but I'm still getting the hang of all this!

What is the difference between the CT123_Voltage and CT123_Voltage_Interupt tx firmwares? It looks like the latter doesn't make use of the libraries to package up elements of the code, but I have the impression there is a more fundamental difference it how the code works. I'm not sure what 'interupt' means - what exactly is being interupted?!

I think I found some minor glitches in the interupt code, firstly the references in the code to currents 1 2 and 3 don't match up to the sockets labeled 1 2 and 3 on the board - this is a simple matter of swapping the pin references around in the code. Secondly, I have added a bunch of variables so that the raw current, rms, and then power are all calculated out in parallel so that I can monitor 3 types of usage within our building (e.g. light, small power and hot water). An important element of this (or so it seemed to me was separating out the three different calibration coefficients.

Does the attached code make sense?

<edit - chopped out ridiculously long code from post and attached in Arduino code file...>

 

Robert Wall's picture

Re: Separate CT Calibration

You need to read the fine print of the Atmel data sheet! It all relates to the ADC - the analogue to digital converter.

In the emonLib methods, they instruct the ADC to read a value, and it does so and hands that back to the library/sketch, which does whatever it needs to do with it.

In the interrupt-driven sketches, the ADC runs continuously on its own. The sketch feeds it the name of the next thing to read, when it's finished doing the one it is on at the moment, puts the answer in a standard place and it interrupts the main program to say "I've done that, the answer is here", then it gets on with reading and converting the value you previously asked it to. The result is the main program is handling the numbers fed to it by the ADC, at the same time the ADC is measuring inputs. So many more readings per second can be done.

The input pins were probably for the emonTx - they're not necessarily the same as anyone else's board. There's no problem with swapping them around.

[You need to tick "List" when you attach a file - else we can't see it. I'll go and do that for you. So I haven't looked at your code yet.]

toby.cambray's picture

Re: Separate CT Calibration

Thanks for your response Robert, that makes a lot of sense. Is the interrupt method more power intensive (just wondering in case I need to run off a battery)?

I am using an Emon TX, hence my confusion/concern.

Sounds like I have done it the hard way for my application, I've just been reading about the 3 phase monitoring where the interrupt approach seems more advantageous. Maybe I need to learn to walk before I can run!

Toby

 

Robert Wall's picture

Re: Separate CT Calibration

EmonLib was designed for battery operation - the example sketches measure 10 cycles per c.t., then it sleeps for 5 s. This is to economise on battery life, but it means that short dips or peaks might go unrecorded. The interrupt driven code runs continuously, I would not recommend battery operation (though with a suitable large capacity battery, it would be possible).

Comment viewing options

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