Hello,

I am building my data acquisition system and I had some questions in regard to the analogic part of the data acquisition system.

My current setup consists in a PIC24 with the adc configured correctly. I am able to sample voltages on its pins successfully and the values are the right one. I also have SCT-013-000 current transformer with a burden resistor to have 0-15A range. I use a half wave rectifier to generate a proportional voltage that is scaled to be 0-3.3VDC in the 0-15A range. My problem is that because of the diode, I can't read anything below 0.3volts (10% of my range).

The circuit is the following. I have dual diodes to protect the analog input of overvoltage. :

I wanted to know how the analog acquisition circuit in the EmonPI worked, because I can't seem to find a solution to my circuit other than a precision rectifier.

Does the following circuit allow to read the full range of 0 to 3.33V, and if not, how does it work? What I understand from this circuit is that it offsets the AC voltage by 3.33V/2 to have a sinusoidal signal with peak to peak voltage of 3.33V centered around 3.33V/2.

What I do not understand is how the software acquires the value of the wave if it is indeed a centered sinusoidal wave without using excessive sampling of the whole wave. Thank you for your help.

## Re: Data acquisition

The emonPi, and for that matter the emonTx, both work in exactly the same way. They do, as you express it, perform "excessive" sampling - though we do not share your view there - of the waveform and the rectification is done in software. That is our solution to the rectification problem, there is also a very useful side-effect: the true rms value of the wave can be calculated, and if both voltage and current waves are sampled, then the true average real power can also be obtained. This is the quantity that your electricity provider charges for. The maximum input of the emonPi current input circuit is approx. 1.1 V rms developed across the burden resistor (22 Ω in this case).

As you rightly say, in your circuit you need a 'precision rectifier' circuit in order to overcome the diode forward voltage, and even then you will only be able to measure the rectified average current. You can multiply by the appropriate form factor (1.11 for a sine wave or a full-wave rectified sine wave) to get what you hope is the rms value, but that only works if the waveform is close to a sine wave. That is often not the case for the current waveform, though it will usually be close enough for the voltage.

## Re: Data acquisition

Is the DC offset 3.3V/2 considering there is a diode, or is it 3.3/2 - Vdrop?

Also, can I get any tips as to developping software for rectifying? I currently am able to obtain peak voltages by continuously sampling the sinusoidal input and comparing the result to a minimum and maximum value, but are there other more efficient ways to sample the ac voltage developped at the burden resistor of the current sensor.

My final question is,if I use a constant rms ac voltage value (because of the lack of time and the lack of ac-ac adapter), will i be able to have an average real power reading, or because I use a constant rms voltage, I will have to convert my current reading to an average rms value, rendering my software rectifing useless without ac voltage sampling.

Thank you.

## Re: Data acquisition

All our software is available on Github, so you can see exactly how we do it. As I wrote above, we rectify in the software as part of the process of calculating the rms value (remember: squaring is rectifying - yes?), we don't use a diode rectifier; so your question about the mid-point bias does not make sense. Take a look at Resources > Building Blocks where you'll find all the theory explained.

If you don't measure the voltage, you don't know the phase relationship between voltage and current, so you can never know real power, you can only estimate the apparent power. It is an estimate because the mains supply voltage fluctuates as the load on the network varies from minute to minute, whereas you will be using the nominal value.

## Re: Data acquisition

1. I thought that electric companies in North America (Canada) charged only for apparent power (KWh)? Also, law of average means that if I set the constant voltage value to an average one, there will be as many readings above, as readings below the average value, therefore making the error factor very small. Is this assumption correct?

2. There is a diode in your schematics (Highlighted), doesn't it cause a voltage drop to the DC Offset?

3. I am not sure of how the code works, as it is quite complex. From what I understand, I :

1.Square each sample

2.Sum the squared samples

3.Divide the sum of the squared samples by the number of samples

4.Take the square root of step 3..., the mean of the squared samples

But could it also work on a half wave rectified signal that is rectified at a high voltage (18V-20V, below sct-013-000 clamping range) and then voltage divided to the 0 - 3.3, therefore, the ~0.4 voltage drop of a schottky diode is scaled down to about ~0.075 voltage drop, that is negligeable. By only monitoring the upper half of the signal, the resolution is theoretically doubled ?

Thank you.

## Re: Data acquisition

There was no need to post your comment twice. Please look at "Read this before posting".

1. How far have you got in your electrical engineering course? Wh is real energy, W is real power, VA is apparent power, and var is imaginary or reactive power. All can be prefixed with the appropriate multiplier or sub-multiplier (mW, MW, kVA, etc.)

Your assumption about the average will be correct if you choose an average value where that is true! And to find that, you've got to measure it. That average probably won't be the nominal value of your supply. One method of calibration is to adjust your scale factors a little at a time so that long-term you have good agreement with your supplier's meter.

2. No. Look where it is.

3. That's correct. rms is an abbreviation for "root mean square" - the squareroot of the mean square.

Modern SCT-013-000 CT's clamp the output at about 8 V, so that idea won't work. Besides which, does the SCT-013-000 have a high enough VA rating to drive 18 - 20 V? A side question that you should think hard about: How do you overload a (normal) voltage transformer, and how do you overload a current transformer? In reality, there's little point in doubling the resolution if you add a large and non-linear error at low currents - it's a bad trade-off. You would probably be much better off by putting a full-wave Schottky bridge rectifier before the burden resistor, taking advantage of the fact that a CT - as its name suggests - is a current source. But experience tells us that our method of doing it all in software, even with only a 10-bit ADC, gives acceptable accuracy down to about 2% of maximum current. But below that, the accuracy decreases dramatically due to errors both within the CT and in the conversion process - at 2% current, the signal is only 20 counts peak-peak.

## Re: Data acquisition

Thank you alot for your help, everything is more clear now. I am in first year and my teacher assured me that electric company billed only real power (W) with no power factor correction and I misunderstood Kwh therefore that's why I used it and dislexia'd apparent instead of real into my post.

I will work on the software aspect of things and try to implement your code on a PIC24. It is well documented and I should be able to translate it ( I hope ) as your method looks like the most accurate.

Again, thanks for you time and for sharing your knowledge and saving me alot of time.

## Re: Data acquisition

If you search these forums, you might find something about a PIC. I remember seeing something, but the details are long since forgotten.