hello everyone, i want to build an AVR based system that can read voltage and current phase in a 3-phase distribution system whose frequency is 50 Hz using current and voltage sensor, and its output will be fed into ADC pin of the AVR....i am about to use ATMEGA324P as the main processor to read and process the information fed from current and voltage sensor, but is ATMEGA alone enough to calculate phase difference on AC voltage and current and determine if the phase is lagging or leading in a 3-phase system? any response is appreciated, thx
[ask] reading voltage and current phase in 3-phase distribution system
hello, anyone?
Impatient after a night's sleep, on a free forum, at a time when many of us aren't watching the site? Is the homework due today?
You could [IME] do one phase directly with an AVR, perhaps. I'd recommend using an "energy" chip with the proper facilities and compute the power factor with that. Search the forum for ade7753 ade7754 ade7756 or ade7758 for prior discussions. Maybe "power factor" as well.
It has been some years since I've worked with those chips, so there may well be models/brands that are alternatives to the Analog Devices line.
E.g. https://www.avrfreaks.net/commen...
We have also applied '7753 and '7763 in some test stands and specialized monitoring apps. Given the familiarity with the '7754 and faced with an app (for example) to measure/display/act on the phase difference between the AC current and voltage waveforms we applied the ADE chip though it was way overkill. Given the target market is energy meters that are produced in quantity, we have the advantage of being able to get a few at a very attractive price.
3-phase distribution system
Is the homework due today?
Homework with CAT III-600V safety requirements - err - I think not, and definitely hope not.
Using ATMEGA324P for this seems very underpowered, particularly in the A/D department. You will certainly need multiple independent ADCs for simultaneous sampling of each phase. 10-bit resolution is again insufficient.
Our sponsors have some information. I'm surprised you didn't find it.
https://www.microchip.com/design...
Working with Mains is very dangerous without proper training, what is your experience with this?
Jim
Before embark the project, see this video explaining basic info about 3 phase AC.
.
Don't miss the 03:00 minute when he tries to measure the outlet voltage by multimeter!
.
As @ki0bk mentioned, there is a SERIOUS DANGER working with mains, single or 3-phase, it kills!
Working with Mains is very dangerous without proper training, what is your experience with this? Jim
i am using sensor for reading voltage and current from mains anyway so i think i won't touch it directly and of course i already have experience with that :D
Before embark the project, see this video explaining basic info about 3 phase AC.
.
Don't miss the 03:00 minute when he tries to measure the outlet voltage by multimeter!
.
As @ki0bk mentioned, there is a SERIOUS DANGER working with mains, single or 3-phase, it kills!
don't worry i have certified multimeter that complies with IEC standard (not the cheap multimeter that is made in china), anyway i just want to know if atmega324p is strong enough to sample signal from mains and of course i don't put the mains directly into the MCU
Impatient after a night's sleep, on a free forum, at a time when many of us aren't watching the site? Is the homework due today?
You could [IME] do one phase directly with an AVR, perhaps. I'd recommend using an "energy" chip with the proper facilities and compute the power factor with that. Search the forum for ade7753 ade7754 ade7756 or ade7758 for prior discussions. Maybe "power factor" as well.
It has been some years since I've worked with those chips, so there may well be models/brands that are alternatives to the Analog Devices line.

anyway i also want to read phase difference between voltage and current in a 1 phase system, is it possible to do that using ADE chip?
That is what datasheets are for.!
Jim
but is ATMEGA alone enough to calculate phase difference on AC voltage and current and determine if the phase is lagging or leading in a 3-phase system?
If you have trouble with the most basic question, why are you attempting a project connected to 3 phase power lines??!?---that is not a good area for beginners to explore & should involve substantial safety equipment & safety protocols. In fact, in some companies it would be prohibited to have a single person working alone with such equipment. Why not build a digital stopwatch, or coin counter instead?
wow i didn't know there is actually an independent chip to read main
Wow!...you shouldn't have connected your grounded scope probe between two 440V phases until the 4th of July. Do you even have an isolator?
don't worry i have certified multimeter that complies with IEC standard (not the cheap multimeter that is made in china),
That is not the point! The point is how to use it.
in video he remarks a common mistake of trying to measure V while multimeter is at A mode.
.
Trial&Error method maybe safe in low current TTL level (5V DC)
But in 220V AC, first trial maybe deadly enough so there would not be a chance for second try!
anyway i just want to know if atmega324p is strong enough to sample signal from mains and of course i don't put the mains directly into the MCU
ATmega324P is capable enough to read ISOLATED, PULSED DC waves, 5V, 50Hz
.
Of course you need some safe electronic circuits/sensors to convert Mains 220V AC RMS(=620V Peak to Peak) into ISOLATED DC 5V singnal
.
Phase differences can be calculated by measuring the delay between isolated signals connected to 3 ADC channels.
I can't help thinking that folks that come to open forums asking the very most basic questions about 3-phase should not be messing with 3-phase !
Please find a mentor with extensive experience in your local area and get them to teach you on a one-to-one basis.
Possibly the best approach is academic guidance - the physics lab in any university should have the relevant equipment, personnel and all important experience.
The alternative could well be early death.
if i have experience about touching 20kV mains without getting burned would you like to help me guys? lol
i am here just asking about the ADC performance of an ATMEGA and i am really know what i am doing right now...because so far i only get about 30 samples on one period which is 200ms, but anyway thank you so much for warning me about how dangerous my project is....honestly i am aware about it
for the advise about visiting a physics lab, i am sorry i am living in a third-world country where anything related with technology is very limited, so i really need to do things manually
Of course you need some safe electronic circuits/sensors to convert Mains 220V AC RMS(=620V Peak to Peak) into ISOLATED DC 5V singnal
how do you get 620Vpp for 220VAC rms?
Phase differences can be calculated by measuring the delay between isolated signals connected to 3 ADC channels
can you give me some sort of clue about how to measure the delay you are talking about??
if i have experience about touching 20kV mains without getting burned would you like to help me guys?
this may help, but YMMV
I once worked briefly for an electric power utility and asked once what that suit of armor was for, and was told it was for when working on 345kv power lines.
It was not long after that I found a new job! q:-) <- me wearing a hard hat!
Jim
e0ne199 wrote:if i have experience about touching 20kV mains without getting burned would you like to help me guys?this may help, but YMMV
I once worked briefly for an electric power utility and asked once what that suit of armor was for, and was told it was for when working on 345kv power lines.
It was not long after that I found a new job! q:-) <- me wearing a hard hat!
Jim
lol it is nice to find a fellow who have once worked at electric power utility, i thought this forum is just for software nerds only...did you work on transmission line sector? why did you leave that job?
No I was a communications tech, installing and maintaining the utilities two way radio and microwave systems.
Since we often worked in substation and generation areas, we were required to attend company safety meetings were such things were discussed.
I left after a recruiter found more interesting work for me.
Jim
how do you get 620Vpp for 220VAC rms?
you don't know how to calculate Vp-p from Vrms, please don't mess with 220V
https://www.allaboutcircuits.com/tools/peak-to-peak-voltage-calculator/
Find something else to work on!
You don't even seem to have a clue as to what you are doing, can't even calculate RMS???
how dangerous my project is....honestly i am aware about it
That is not enough...what are you DOING about it? The first move is to go work on something else. Don't become a stupidity statistic.
i am here just asking about the ADC performance of an ATMEGA and i am really know what i am doing right now...because so far i only get about 30 samples on one period which is 200m
I wrote in post #4 that AVR ADC wasn't suitable. Didn't you believe me ?
If you cannot buy an Analog Front End from Analog Devices or Microchip then consider XMEGA.
Now the XMEGA ADC is very much faster than AVR and does stand a chance of doing these measurements. Can you buy XMEGA in your country ?
i am using sensor for reading voltage and current from mains anyway so i think i won't touch it directly and of course i already have experience with that :D
Tell us more about this sensor and how it isolates you from the line voltage; perhaps then all the warnings about safety may cease and we can get on with the electronics.
buy an Analog Front End from Analog Devices or Microchip
Maxim also have some interesting stuff in this line - IIRC, including some isolated stuff.
Also ST.
Find something else to work on!
You don't even seem to have a clue as to what you are doing, can't even calculate RMS???
how dangerous my project is....honestly i am aware about it
That is not enough...what are you DOING about it? The first move is to go work on something else. Don't become a stupidity statistic.
hey i am just asking for god sake and i am sorry for my lack of knowledge and my incompetence of it...but i still need to keep the project going :)
i am referencing to Vmax not to Vpp anyway
there is no XMEGA in my country so that is why i am asking here if ATMEGA is still sufficient for my project because it is only ATMEGA family i can only get my hands on without ordering from international shops like mouser and its friends
there is another brand like ST but i still doubt about its performance anyway
OK - so no XMEGA or Analog Front End (AFE).
So what about the sensors you mentioned in the Original Post #1. Part Number / Datasheet ?
Let's consider some calculations:
.
Assuming 3 phase signals 220Vrms=622Vpp converted and scaled down (ISOLATED, DC Sine wave, Vpp=1.1 V) connected to 3 ADC channels
.
ATmega324P has 2048 bytes SRAM
Assume 248 bytes for stack and some variables
Remaining 1800 bytes for sampling 3 buffer, 600 bytes each
For a complete sine wave, 1 sample of buffer would be 360°/600 = 0.6° of sine wave
.
With Vref=1.1v and 8 bit resolution for each sample:
Vsine(AC) = 622*(ADC/255)-311
.
Here is some of calculations I did by my spreadsheet:
.
@0° adc=127 Vsine(real)=0 Vsin(calc)=-1.22 err=-1.2
@0.6° adc=128 Vsine(real)=3.3 Vsin(calc)=1.22 err=-2
@1.2° adc=130 Vsine(real)=6.5 Vsin(calc)=6.1 err=-0.4
...
@88.8° adc=254 Vsine(real)=310.9 Vsin(calc)=308.56 err=-2.4
@89.4° adc=254 Vsine(real)=311 Vsin(calc)=308.56 err=-2.4
@90° adc=254 Vsine(real)=311 Vsin(calc)=308.56 err=-2.4
...
@178.8° adc=130 Vsine(real)=6.5 Vsin(calc)=6.1 err=-0.4
@179.4° adc=128 Vsine(real)=3.3 Vsin(calc)=1.22 err=-2
@180° adc=127 Vsine(real)=0 Vsin(calc)=-1.22 err=-1.2
...
@268.8° adc=0 Vsine(real)=-310.9 Vsin(calc)=-311 err=-0.1
@269.4° adc=0 Vsine(real)=-311 Vsin(calc)=-311 err=0
@270° adc=0 Vsine(real)=-311 Vsin(calc)=-311 err=0
...
@358.8° adc=124 Vsine(real)=-6.5 Vsin(calc)=-8.54 err=-2
@359.4° adc=126 Vsine(real)=-3.3 Vsin(calc)=-3.66 err=-0.4
@360° adc=127 Vsine(real)=0 Vsin(calc)=-1.22 err=-1.2
So in one post you write:
i am really know what i am doing right now...because so far i only get about 30 samples on one period which is 200ms, but anyway thank you so much for warning me about how dangerous my project is....honestly i am aware about it
Sort of says you know what you are doing, YET here you write:
i am sorry for my lack of knowledge and my incompetence of it...
I think the latter is more accurate than the former.
If you cannot calculate peak voltages from RMS I highly doubt(as others have asserted) that you are really out of your league on this.
Lemme ask you this....are YOU solely responsible for both the programming of the microcontroller, and the physical connections to the three phase lines, or are you just the software person and someone else is in charge of the physical stuff?
JIm
I think e0ne199 is largely misunderstood. I like to think that e0ne199 has appreciable knowledge in both high/medium voltage AC and working with Atmega MCU(s).
According to post #14, e0ne199 has been able to extract 30 samples from the AC mains (I suppose).
Firstly, we all agree that working with AC mains can be dangerous, especially for one with little knowledge about how it. So, be sure about what you (e0ne199) are doing.
I am designing (although I've suspended the project for a little while now) a similar project that samples AC voltage and current of a single phase in order to determine the RMS of both quantities as well as phase shift between them.
e0ne199, you need to provide more information about your progress thus far e.g.
1. The sensors used to measure the AC voltage/current. (very important).
2. Frequency of your MCU oscillator.
3. To what degree of accuracy are you expecting? (do you wish to detect at least 5 degrees or less between the two signals?).
And other relevant information.
Of course, you can use the ATMEGA328's ADC, but accuracy will be the major challenge.
Once you can successfully measure the required parameters for a single phase, you may then use same technique for the other two phases of the system.
But, like i said earlier, you must be very sure of what you're doing. Provide proper safety measures while working with the mains.