Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Power factor measurement using PIC18f4520

Status
Not open for further replies.

KhaledOsmani

Full Member level 6
Full Member level 6
Joined
May 4, 2014
Messages
384
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Activity points
3,933
Hello

I have a PIC18F4520, connected to a 16*4 LCD. [Properly working].
I have an 10'' square fan, with 0.06/0.08Amps, 220/240V, 50Hz, properly working.
I want to measure digitally the power factor of the fan, under all possible circumstances (voltage fluctuations, source dampings, etc..).

I've read about Zero Crossing Detection Method, that enters the analogue quantities of voltage/current consumed by the inductive load (fan), uses LM358 (op-amp), then using a specific code, it sets a timer, from the moment the voltage tends to 0, until current tends to 0, then according to this timer, pf is calculated as delay between voltage and current crossing zero.

I have found the following related link: https://microcontrollerslab.com/power-factor-measurement-using-microcontroller/

The above link, uses img1 as prototype schematic, where a shunt transformer from 240 to 5V, is connected between fan terminals, and a series current transformer is also connected between one terminal of the fan.

The two terminals of the two transformers, are connected to current/voltage limiter of 4kohms, then fed into an LM358 opamp, then directly connected to analogue input of PIC (in the link the PIC used is PIC16F877).

My first question is, is that circuit (img1) safe to use? I didn't see any bridge rectifiers, and signals are assumed to still be AC, so how come they can be fed into the PIC? Plus only in AC zero crossing takes place, how come in DC (after supposed rectification that must be done) we can know that the AC version of the signal crossed zero?

Also if the circuit is safe, and ideal to be practiced, what is the current transformer ratings? what is the maximum input current to the PIC analogue pin?

Thanks
img1.jpg
 

My first question is, is that circuit (img1) safe to use? I didn't see any bridge rectifiers, and signals are assumed to still be AC, so how come they can be fed into the PIC? Plus only in AC zero crossing takes place, how come in DC (after supposed rectification that must be done) we can know that the AC version of the signal crossed zero?
* it seems to be safe in the meaning of safety. It provides galvanuc isolation between mains and PIC supply.
* from function side, i don't like the circuit. Missing biasing resistors, i'd use a comparator instead an opamp.
* a bridge rectifier is not necessary.
* the presence of AC is no problem, as long as the voltage fed to the PIC is within the PIC's io specification.

Also if the circuit is safe, and ideal to be practiced, what is the current transformer ratings?
As said before the circuit is not good. CT's need a load resistor to calculate the output voltage.

what is the maximum input current to the PIC analogue pin?
This is a typical question that is answered in the PIC datasheet. Read it.

Klaus
 
If you are using a current transformer without a burden (parallel) resistor, you will totally destroy your circuit, give yourself a nasty shock, or both.

The value of the required burden resistor varies with each transformer, and is provided in the datasheet.

Check for instance, on the plot how rapidly the output voltage increases with the increasing resistor value. Please note, the scale are logarithmic.

https://media.digikey.com/pdf/Data Sheets/AlfaMag Elect PDFs/CT1050.pdf
 
Last edited:
* it seems to be safe in the meaning of safety. It provides galvanuc isolation between mains and PIC supply.
* from function side, i don't like the circuit. Missing biasing resistors, i'd use a comparator instead an opamp.
* a bridge rectifier is not necessary.
* the presence of AC is no problem, as long as the voltage fed to the PIC is within the PIC's io specification.


As said before the circuit is not good. CT's need a load resistor to calculate the output voltage.


This is a typical question that is answered in the PIC datasheet. Read it.

Klaus

Klaus,

Do you have a better circuit diagram? The burden resistor is branched along the CT two terminals?
 

Hi,

Do you have a better circuit diagram? The burden resistor is branched along the CT two terminals?
Yes.
You will find the information in the CT´s datasheet.

Klaus
 
KlausST,

Thanks.

Assuming you don't have any "better" circuit for pf calculation, and since I will be using the one uploaded, I have found the followings as Current Transformer, and Voltage Transformer:

[NOTE: PIC's maximum input current is of 20mA, but for better safety, I've chosen a CT whose maximum output is of 5mA; i will later do an according table to make the calculations in the code]

as for CT: **broken link removed** >> According to its datasheet, I must connect in parallel of pins 1 and 2 a burden of 200 ohms.

as for VT: **broken link removed**


About LM358 opamps: LM358 I connect to Vcc and GND a voltage source of 12V, then after series connection of 4kOhms resistor, I input the first terminal to 1IN- and the other to 1IN+, I take the output of 1OUT to the pic analogue pin (porta); this is done for the two terminals of the two transformers (CT, VT).

Before talking about code, do you have any notices/restrictions concerning connections?

Thanks
 

Hi,
I recommend a comparator instead of an opamp.

PIC's maximum input current is of 20mA
You don't give current to the PIC, but voltage. Intput current to PIC pin is near zero.
The burden need to be calculated, that with max expected input current the output voltage is within the comparator's input voltage specification.
The voltage of the CT is fed to the comparator, not to the PIC.
You need to limit the input voltage to the pic. The output of the comparator is too high

****
If your pic has two ADC inputs, you could input voltage signal and current signal to the pic. No need for a comparator.


Klaus
 
I think you are trying to make a simple thing complicated. it does not help anyone. Please clarify:

1. I presume that your frequency of operation is reasonably low (mains 50-60Hz; your setup max 1000Hz);
2. You are wisely using a current and voltage transformers to get the information;
3. Both current and voltage transformers provide reasonable isolation (safety);
4. You can use resistor voltage dividers to handle large currents/potentials;
5. Most PIC have multiple ADC channels and you digitize both the current and voltage signals in PIC;
6. Calculate powerfactor in software and send it to display.

Why so much of unneeded mess?
 
Apparently, the "CT+VT+LM358" schematics linked in post #1 and post #4 are intended to give only voltage and current polarity (zero crossing) information, a simple and straightforward method to measure displacement power factor. Distortion power factor is ignored by this circuit, I presume that's O.K. according to your project specification.

Of course processing voltage and current polarity is much simpler than multiplying and integrating voltage and current adc samples as a full featured power meter does.

Some problems of the circuit have been already mentioned like missing CT termination. The circuit misses also a correct OP input bias, and the LM358 supply voltage must be either limited to 5V or a clamp circuit is needed to protect the OP inputs.
 
Some problems of the circuit have been already mentioned like missing CT termination. The circuit misses also a correct OP input bias, and the LM358 supply voltage must be either limited to 5V or a clamp circuit is needed to protect the OP inputs.

Does your OP, refers to OPAMP? By input bias, were you referring to other than 4kOhms resistors value? What is a clamp circuit, and if I supplied the "OP" with 5V only, won't I need it? After all how to calculate the correct resistor values for the "OP"?
 

Yes OP means operational amplifier.

The circuit has at least these problems:
- Missing current transformer termination
- OP inputs are floating
- The OP output voltage with about 35 mA short circuit current will damage the microcontroller inputs
 
Yes OP means operational amplifier.

The circuit has at least these problems:
- Missing current transformer termination
- OP inputs are floating
- The OP output voltage with about 35 mA short circuit current will damage the microcontroller inputs

Could you help modify it?
 

That's great, much thanks, I still need to get the burden of the CT as well as input bias for the LM358.
Such gettings, are based on the fact that no maximum output bigger than 5V are fed to the PIC. (Right?)

- - - Updated - - -

What about the following diagram:

2917930900_1456088892.jpg
 

Of course processing voltage and current polarity is much simpler than multiplying and integrating voltage and current adc samples as a full featured power meter does.

I presume you are suggesting the following steps:

1. Watch the voltage and current values at regular intervals using PIC;
2. Monitor (or estimate) when the voltages become close to zero;
3. Note the time difference between these two zero crossing events;
4. Measure or assume the period;
5. Convert the time difference into an angle;
6. Calculate power factor from the angle;
7. Repeat the process/ steps above.

By the way, what is displacement power factor?
 
I agree with the your explanation. The principle is to determine period and voltage to current phase shift based on the zero crossings.

Displacement power factor is cos phi. Total power factor is displacement power factor multiply distortion power factor, see https://en.wikipedia.org/wiki/Power_factor
 

Could you please provide resistors value? I cannot exactly understand the idea, about opamp functioning within the circuit.
What I know is that, the V and I are input to it, to max output a voltage of 5V to PIC ADC input. Cannot know how, and according to what KlausST has earlier said, that we cannot input a current to PIC, so I assume that the LM358, makes a source transformation of current, to input a voltage to PIC?

From another side, if I branch the terminals of the multimeter to the output of the opamp, one terminal at it, the other at the common ground, shouldn't I see a zero value (even if fastly occured) at a certain moment on the multimeter lcd?
 

Could you please provide resistors value? Cannot know how, and according to what KlausST has earlier said, that we cannot input a current to PIC, so I assume that the LM358, makes a source transformation of current, to input a voltage to PIC?
The thing to remember:
All of the ADC inputs, whether integraded into a microcontroller port or implemented by a separate IC, read voltage.

The burden resistor actually converts the CT's current output into a voltage.
You don't require any further conversion other than amplification, since the developed voltage is usually quite small.
 
Simple and well understood, much thanks.

I feel less lost now!

In the datasheet of CT: **broken link removed** , the burden is of 200ohms, but what about the values for biasing resistors? are the 4k (other than bias) are accepted?
 

They are of little consequence, except that limit current in case of a latch-up. You can use any value from 1K to 10K (hence 4K is good value). The best accuracy is obtained when the input voltage is close to 1V. You can clamp the input voltage with a zener and work on the software.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top