ParkingLotLust
Member
My final goal with this project is as follows: Id like to measure (in real-time) frequency, voltage, apparent power, and power factor (among others that may be added later) of the feed for my house. It is a 200A service, in Canada, so 60Hz.
In this post, Im going to go through all of my thought process and what I have now. It wont take too long, but Id like to put up everything Ive done so that, if Ive done something wrong, or there's a better way, it can be addressed.
First, I needed a way to measure frequency. Im using a dsPIC30F4011 (learnt it in a class a couple semesters ago so Im familiar with it), and a zero-cross circuit a friend & I came up with. The input-capture module of the chip measures the time between zero-cross pulses, and determines the frequency. This part works no problem.
The reason I used a zero-cross circuit was to create a 5v pulse that wouldnt hurt the micro. I read about simply hooking a 1M resistor from an IO pin to mains, but thatd require an isolation transformer for me to scope around, and I was afraid of the second half of the AC waveform causing a negative voltage on the pin, and damaging the micro.
I read an excellent zero-cross article after doing some research at sound.westhost.com, and came across **broken link removed** schematic. I sim'd it and it appears to work. I sent it to a friend, who sent back a **broken link removed**, which he scoped and it worked in real life (with an iso xformer).
Now, to measure voltage, I have a couple options. I could rectify the voltage, attenuate and measure the DC voltage, and calculate backwards, but I fear this wont be as accurate as it could be. The other option I read about, was sampling the AC wave, faster than 60Hz of course, and using the instantaneous values to calculate the RMS value. This would also allow me to see the peak value. I would prefer to go this route, but Im not sure I understand the process of calculating the RMS voltage. If anyone has any uC code, app notes, or can offer any insight into coding for this, thatd be very helpful.
Next, measuring current. Initially I researched an Analog Devices chip, the ADE7757. However, a problem arises out of this - I would need a freaking huge sense resistor! I managed to find one that would work, from Mouser, but its a bit too expensive. Not to mention the fact that Id have to get an electrician in to hook the darn thing up.
So breaking the line is out. That leaves me with using a current transformer. I found one that had a split core, and could be attached around the wire, but it was $100, again, out of my price range. Further research lead me to using a Rogowski coil plus an integrator, to obtain a voltage proportional to current. I will likely make my own coil, as I can just borrow a clamp-on ammeter to calibrate it. Fortunately, this is another hurdle somewhat solved. Again, any input on the topic is welcome!
However, I havent reached my biggest problem: how do I calculate power factor? I realize it is the ratio of real power to apparent power. Apparent power can be calculated from E*I, once I measure it. But what is real power? In my research, a lot of people suggested measuring the phase shift between the current and power waves - using a comparator and XORing the outputs to create a pulse - but I fear the current pulse could be non-sinusoidal if there are SMPSs or things like that (and measuring an entire house, Id expect this).
What should I do here? Ive done a lot of reading and am getting weary eyed, so my biggest question is simply what is the best way in my situation to calculate PF?
In this post, Im going to go through all of my thought process and what I have now. It wont take too long, but Id like to put up everything Ive done so that, if Ive done something wrong, or there's a better way, it can be addressed.
First, I needed a way to measure frequency. Im using a dsPIC30F4011 (learnt it in a class a couple semesters ago so Im familiar with it), and a zero-cross circuit a friend & I came up with. The input-capture module of the chip measures the time between zero-cross pulses, and determines the frequency. This part works no problem.
The reason I used a zero-cross circuit was to create a 5v pulse that wouldnt hurt the micro. I read about simply hooking a 1M resistor from an IO pin to mains, but thatd require an isolation transformer for me to scope around, and I was afraid of the second half of the AC waveform causing a negative voltage on the pin, and damaging the micro.
I read an excellent zero-cross article after doing some research at sound.westhost.com, and came across **broken link removed** schematic. I sim'd it and it appears to work. I sent it to a friend, who sent back a **broken link removed**, which he scoped and it worked in real life (with an iso xformer).
Now, to measure voltage, I have a couple options. I could rectify the voltage, attenuate and measure the DC voltage, and calculate backwards, but I fear this wont be as accurate as it could be. The other option I read about, was sampling the AC wave, faster than 60Hz of course, and using the instantaneous values to calculate the RMS value. This would also allow me to see the peak value. I would prefer to go this route, but Im not sure I understand the process of calculating the RMS voltage. If anyone has any uC code, app notes, or can offer any insight into coding for this, thatd be very helpful.
Next, measuring current. Initially I researched an Analog Devices chip, the ADE7757. However, a problem arises out of this - I would need a freaking huge sense resistor! I managed to find one that would work, from Mouser, but its a bit too expensive. Not to mention the fact that Id have to get an electrician in to hook the darn thing up.
So breaking the line is out. That leaves me with using a current transformer. I found one that had a split core, and could be attached around the wire, but it was $100, again, out of my price range. Further research lead me to using a Rogowski coil plus an integrator, to obtain a voltage proportional to current. I will likely make my own coil, as I can just borrow a clamp-on ammeter to calibrate it. Fortunately, this is another hurdle somewhat solved. Again, any input on the topic is welcome!
However, I havent reached my biggest problem: how do I calculate power factor? I realize it is the ratio of real power to apparent power. Apparent power can be calculated from E*I, once I measure it. But what is real power? In my research, a lot of people suggested measuring the phase shift between the current and power waves - using a comparator and XORing the outputs to create a pulse - but I fear the current pulse could be non-sinusoidal if there are SMPSs or things like that (and measuring an entire house, Id expect this).
What should I do here? Ive done a lot of reading and am getting weary eyed, so my biggest question is simply what is the best way in my situation to calculate PF?
Last edited: