Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Voltage conditioning for ADC input

Status
Not open for further replies.

Daniel Wood

Member
Hi guys,
I'm currently working on an energy monitoring system and for the most part getting on pretty well with it.
I'm having a bit of a problem trying to work out the best way to interface the input signal with the ADC input of a PIC.
I'll be reading current with a CT so I should be able to get a steady signal of 50Hz at ideally 5V max depending what resistor I use across the transformer.

My best bet is to bias the signal, keep it AC and measure the peak of the wave. Problem with biasing is that if the CT picks up too much current, the waveform will be greater than the bias voltage and I'll end up putting either too much or negative voltage into the ADC.

Bridge rectification is out the window since I will loose signal information at low voltages due to the diodes forward drop voltage. Has anyone had experience with this type of problem?

Many Thanks!
 
Usual method is to use a zero crossing detector, and then a suitable delay to measure the peak voltage.

Over-voltage isn't a problem, as long as you use a suitable current limiting resistor the protection diodes in the PIC will clip it.

If you're looking for extended range and resolution, you could use a direct connection (via a limiting resistor) to one input, and an attenuator feeding a second input - if the reading is too high on the first pin, switch to the second - likewise, if it's too low on the second, switch to the first :D
 
Ha, Ian you read my mind.. that was just the CT I was looking at!
I think for now I will go with the technique on that web page for now.. Probably throw in a rail to rail unity gain op amp to clamp voltage spikes just to be safe.

Thanks Nigel.. I have a ADC routine at the moment

Code:
unsigned long getACfromADC(unsigned char channel)
{
    char x;
    char i;

    unsigned long tempresult = 0;
    unsigned long peak = 0;
    unsigned long result = 0;

    SetChanADC(channel);
    // Routine takes far too long.. try to fix it
    for(i=0;i<16;i++)
    {
        for(x=0;x<128;x++)
            {
                ConvertADC();
                while(BusyADC());
                tempresult = ReadADC();
                if(tempresult > peak) peak = tempresult;
                __delay_us(156);  //delay = 50ms (1 cycle) / 128 samples 
            }
        result += peak;

    }
    return result;
}

It seems to be doing the job really well when the figure is divided down, no flicker at all (for simulation).. although the routine takes 700ms to finish!
I'm going to have to find a way to make a rolling average instead of destroying the data each time i call the ADC :(

I have another question. I'll be displaying the result in KWh. Does anyone think inductive loads and power factor will have any effect on the measured current?
 
The idea of dropping the AC from 240vac to 9vac ( even 5vac ) is good.

I think the power factor has an effect, as most household appliances are inductive loads.... We aren't supposed to have a power factor below 0.9..... I know this is for businesses, not sure about household....
 
I guess if I use a VT, and then measure the phase between the signals I could calculate power factor.. but i don't think that's possible to do without actually probing the wires its self.
Anyway I should be fine once I get that ADC routine sorted!
 
Hi guys,
I'm currently working on an energy monitorHiing system and for the most part getting on pretty well with it.
I'm having a bit of a problem trying to work out the best way to interface the input signal with the ADC input of a PIC.
I'll be reading current with a CT so I should be able to get a steady signal of 50Hz at ideally 5V max depending what resistor I use across the transformer.

My best bet is to bias the signal, keep it AC and measure the peak of the wave. Problem with biasing is that if the CT picks up too much current, the waveform will be greater than the bias voltage and I'll end up putting either too much or negative voltage into the ADC.

Bridge rectification is out the window since I will loose signal information at low voltages due to the diodes forward drop voltage. Has anyone had experience with this type of problem?

Many Thanks!

Hi,

You might be confusing voltage rectification with current rectification. With voltage rectification you have a certain voltage and when you use diodes to rectify it you see a voltage drop of about 0.7v and so a 5v peak signal turns into a 4.3v signal, and a 0.8v signal turns into a 0.1v signal, and a 0.7v or lower signal turns into zero so we cant see it anymore.
However, when the signal is a current, this doesnt happen. If we have a 1ma current signal through a 1k resistor we see a 1v signal develop across the resistor. If we have a diode in series with that resistor, we see 0.7v across the diode but we still see 1v signal develop across the resistor, so we dont loose any voltage.

The idea with a current transformer is to rectify the current, not the voltage. If the burden resistor connects directly across the secondary of the transformer, then it's already converted into a voltage so it's too late...any diodes now will cause a drop in signal of 0.7v or about that. But if the diodes are placed in series with the windings BEFORE the burden resistor then we actually do not loose the diode voltage. The response may be a little non linear, but it should work much better. With a center tapped secondary it takes two diodes and one resistor with the center tap being the signal common.
 
The peak measurement assumes sine-waves. This is a good assumption for voltage, but usually it is not so for current. Many loads, such as computers, CFLs, LED lights, consume mostly at peaks and the current waveform doesn't look anything like sine wave. To get good results, you need to multply every current sample by corresonding voltage sample and calculate power.

rms_voltage = sqrt (sum(voltage^2)/n)
rms_current = sqrt(sum(current^2)/n)
power = sum(voltage*current)/n
power_factor = power/(rms_voltage*rms_current)
 
Hi NorthGuy,

That's a pretty good point. Many current waveshapes can be nasty, such as the excitation current of a transformer.
 
I think the power factor has an effect, as most household appliances are inductive loads.... We aren't supposed to have a power factor below 0.9..... I know this is for businesses, not sure about household....

There's no power factor measurement done on domestic meters, so while heavy business users are penalised for power factor errors, domestic users aren't.
 
Kettles are fine, no inductive (or capacitive) loading :D

But even if you do use inductive loads you aren't charged any extra.

I was at college directly opposite the Trebor factory (heavy sugar smells during the summer :D) and was always used as an example of power factor correction, as they had a special room full of capacitors and monitoring, with a guy switching capacitors in and out to correct their PF errors - you get charged HEAVILY for PF errors as a commercial user.
 
Kettles are fine, no inductive (or capacitive) loading :D

But even if you do use inductive loads you aren't charged any extra.

I was at college directly opposite the Trebor factory (heavy sugar smells during the summer :D) and was always used as an example of power factor correction, as they had a special room full of capacitors and monitoring, with a guy switching capacitors in and out to correct their PF errors - you get charged HEAVILY for PF errors as a commercial user.
So we only pay for resistive loads? Cool.....
 
In other words, the domestic meter measures real power, not apparent power. So if the OP wants to measure real power, then he needs either analog multiplier or fast enough sampling to have good accuracy.
 
In other words, the domestic meter measures real power, not apparent power. So if the OP wants to measure real power, then he needs either analog multiplier or fast enough sampling to have good accuracy.

Obviously - you can't just measure voltage, you need to measure current as well, and calculate accordingly.

However, there are specific IC's that do all this for you.
 
Well I've realised that I can't actually physically touch the mains terminals (part of the project spec / health and safety nonesense) so i guess that measuring any phase shift is out of the window.. Thanks Northguy for mentioning the RMS Values.. I will only be reading the peak voltage on the ADC since it would be near impossible to read an RMS waveform directly.. I'll be putting your calcs in my code ;).
I'll just have to make sure for the presentation that I apply only resistive loads instead of reactive loads, or (god forbid) loads that cause harmonic distortion:eek:
 
it would be near impossible to read an RMS waveform directly.

Shouldn't be a problem with PIC. It certailny depends on what PIC you have, but with most you can easily sample ADC at 20kHz, and if you try a little bit harder then at 50kHz.
 
Well I've realised that I can't actually physically touch the mains terminals (part of the project spec / health and safety nonesense) so i guess that measuring any phase shift is out of the window.
I don´t see why? You just need a standard small power transformer say 230V to 6V to get the voltage, and a current transformer to get the current. Both are well isolated and should pose no safety hazards whatsoever.
Then either sample both and multiply in software, or multiply in analog domain and sample the result.
 
I don´t see why? You just need a standard small power transformer say 230V to 6V to get the voltage, and a current transformer to get the current. Both are well isolated and should pose no safety hazards whatsoever.
Then either sample both and multiply in software, or multiply in analog domain and sample the result.
Yes Danny... I thought this what you were going to do..... I've got a few AC/AC adapters here, so I can send you one... If you get a wall transformer that gives 5vdc just open it up and lob the rectifier away...

Then work on the low AC...
 
Status
Not open for further replies.

Latest threads

Back
Top