KhaledOsmani
Full Member level 6
- Joined
- May 4, 2014
- Messages
- 384
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 18
- Activity points
- 3,933
Hi,
@Brian:
I should have read your post #135 more carefully. You gave all the information.
But somehow i missed it.
With U and I at the ADC, then the microcontroller has all information it needs. No need to input averag_power.
Non simultaneous ADC sampling.
The higher the sampling frequency (interleaved U and I) the lower the error.
And the error is known, so it is simple mathematics to compensate it. It is a fixed phase angle.
Klaus
1. measure voltage with one ADC input
2. measure current with a second ADC input.
3. XOR (use a logic gate such as 74LS86 or equivalent) the two waveforms, feed it through a low pass filter and measure the resulting voltage through a third ADC input.
As long as you 'square up' the voltage and current waveforms using an op-amp or comparator before feeding them to the XOR gate, it's output will be a pulse with width equal to the phase difference in the signals. If you filter it to find the average, you get an analog voltage proportional to the phase shift.
It isn't using the zero crossing method at all but it will allow you to measure V, I, apparent power and phase displacement using simple math.
Brian.
* measure voltage and calculate RMS_voltage
* measure current and calculate RMS_current
* multiply RMS_voltage x RMS_current and get apparent_power
* at every maesurement calculate actual_current x actual_voltage and get true_power
* Now just divide true_power / appareant_power and get cos(phi)
I tried to describe it in post #136.Please tell me how to calculate apparent power and true power using adc. A sample code would be helpful. You can show it for AVR.
#int_EXT
void ext_isr(void) {
disable_interrupts(INT_EXT_L2H);
set_timer1(0);
clear_interrupt(INT_EXT1);
enable_interrupts(INT_EXT1_L2H);
}
#int_EXT1
void ext1_isr(void) {
disable_interrupts(INT_EXT1_L2H);
timer_value = get_timer1();
process = 1;
clear_interrupt(INT_EXT);
enable_interrupts(INT_EXT_L2H);
}
Hi betwixt and others
Can OP use this circuit for voltage measurement ? (Considering the method mentioned by betwixt).
@KlausST
I have never done a AC RMS voltage or Current measurement using PIC. I use PIC and I know that you don't use PIC. If possible please provide AC Voltage, Current and PF measurement interface circuit for AVR and also C Code for it. I will port it to PIC for the OP.
- - - Updated - - -
Test this circuit. Use exact resistor values. measure all the voltages and post it here. You have to vary the current from 0 to 10A for your CT primary and it will give 0 to 50 mA at secondary then post just the voltages you get across the output of bridge rectifier and the two resistors for some random values between 0 to 10A. Don't connect it to PIC.
If the voltages vary properly then it can be connected to PIC and used with my code.
The voltage and current measurement circuits that I have provided doesn't work with KlausST's method.
You can't use 1k resistor across the CT's output because 50 mA * 1k = 50V.
@FvM
In the code you posted
Code:#int_EXT void ext_isr(void) { disable_interrupts(INT_EXT_L2H); set_timer1(0); clear_interrupt(INT_EXT1); enable_interrupts(INT_EXT1_L2H); } #int_EXT1 void ext1_isr(void) { disable_interrupts(INT_EXT1_L2H); timer_value = get_timer1(); process = 1; clear_interrupt(INT_EXT); enable_interrupts(INT_EXT_L2H); }
you are clearing INT0IF in INT1 ISR and INT1IF in INT0 ISR. why ?
As already explained in my previous post. There must be no pending events when reenabling interrupts. Otherwise the interrupt will be immediately entered although the event is long gone. It's one reason why your code is failing.you are clearing INT0IF in INT1 ISR and INT1IF in INT0 ISR. why ?
No. To calculate the true_power you need to know the ACTUAL apparent_power.Isn't a 3x3 keypad necessary such that a user can manually enter the apparent power?
Don't be afraid of it, you are a good programmer.I have never done a AC RMS voltage or Current measurement using PIC
If you use the digital output of the XOR gate directly you only have one period measurement to make so only one interrupt is needed but you have to locate both edges of it. You have to find the rising edge to start the counter then immediately change to looking for the falling edge to generate the second interrupt to stop the timer.
betwixt might help you. Wait for a while. I implemented his XOR method but he has not mentioned how to convert time delay to angle. I am waiting for his reply.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?