BudBennett wrote: ↑
Tue Aug 27, 2013 8:32 pm
My Project Rationale
I have a home automation project that I am just beginning. A 600 foot deep well provides water to my house. The well only produces 8 gallons/hour. Therefore I also have a 1700 gallon cistern to store the water before it is pumped into the house for use. There is a float valve that turns on the deep well pump when the cistern level drops to a certain level below full and turns off the deep well pump when it is full again. The pump is a 1hp 250VAC induction motor.
My project is to monitor the status of the cistern to make sure that it doesn't run dry. I thought that the easiest way to do this would be to monitor how often, and for how long, the deep well pump is running. I assumed (assume = ass of u and me, more on that later) that simply detecting a voltage applied to the motor would be a good indicator of this, so I proceeded to design a circuit for detecting a 250VAC signal and presenting to the Raspberry Pi as a GPIO logic level.
1. Safety: 2500-3500V galvanic isolation between motor circuit and RPi circuit.
2. Cool Operation: low power dissipation…
3. Simple, two-wire interface: GND and GPIO signal to the RPi. No power supply signal required.
4. Small size - it has to fit inside the well "pump-saver" box that is mounted on the garage wall, and it won't be the only circuit in the box.
There is another forum thread that covers a lot of this: http://www.raspberrypi.org/phpBB3/viewt ... 01#p237701
. Here is the circuit that I came up with after reading this posting and the associated links (and digging a bit deeper in other areas):
I think that this is IMHO probably the simplest and most straightforward approach. Design requirements #1-3 are met quite easily. Power dissipation is below 10mW.
Note that there are a few extra components and some values have changed. R1 and R2 are optional - they are only there if you don't want to be zapped by any residual charge on C1 if you happen to remove the circuit and put any of your body parts across the input terminals. Note that you need two of them if you use carbon or metal film resistors that are rated for working voltage between 125V and 200V. Most of us don't even know what the maximum working voltage of the small (i.e 1/4W) resistors that we have around the shop.
D1 can be removed if you use an opto-isolator that includes a reverse clamping diode, such as the H11AA1. The requirements for D1 are so relaxed in terms of reverse voltage and forward current that almost anything will work. The 1N4148 is cheap and ubiquitous.
R3 is there to protect the opto-isolator LED against transients, such as surges or spikes, that can happen on 250VAC wiring. Alternatively it can act as a fuse, but I think that a real fuse should be employed (more on that later).
C1 controls the amount of current flowing in the opto-LED. I've sized C1 to produce 5mA peak:
XC1 = reactance of C1 = 1/(2*Pi*F*C1) , where F = 60Hz and Pi = 3.1415926…
Ipeak = Vpeak/XC1 = sqrt(2)*250V*2*Pi*60*0.039uF = 5.2mA peak
Note that the sqrt(2)*VAC converts from RMS (root-mean-squared) voltage to peak voltage (for a sinusoid waveform).
Why 5mA instead of 10mA? There is an aging factor in opto-isolator LEDs. The LED output decreases over time, but the aging process is directly proportional to the LED current, so the aging process is half as fast with 5mA as 10mA. 5mA is plenty of LED current, even with a 20% CTR (Current Transfer Ratio) and considering temperature and aging, given that the load is only 3.3V/50k = 66uA. Also, according to data sheets that I've seen on common opto-isolators the 5mA CTR peaks about 20-30% above the 10mA CTR.
Why 5mA instead of 1mA? The opto CTR tends to fall off rapidly when you get below about 2mA. You can go there, but you will have to use a 4N35 or 4N36 or 4N37 or similar opto-isolator with a higher CTR (near 100% min).
C1 must be a safety rated (type X1 or X2) capacitor if it is going to be connected to the mains power. If you go to Digikey and plug in X2 and 0.039uF and 250V you only get one capacitor: http://www.digikey.com/product-search/e ... geSize=500
Note the size of this component: 0.689" L x 0.217" W x 0.512" H (17.50mm x 5.50mm x 13.00mm) This thing is huge! The fuse will not be small either, so this circuit won't work for me. But it could work for applications with more relaxed space requirements.
R4 prevents the opto NPN from turning on from Collector-base leakage current at high temperature. It degrades the CTR slightly. If you aren't worried about high temperature operation (even in a fault mode) then you can probably delete it.
The opto-isolator is acting as a switch to GND that closes every 1/60 seconds. C2 filters out the 60 Hz information and turns the output voltage into a steady state voltage that is either high when there's no AC voltage, or low when there is. The value of C2 is found by asking how much ripple you can tolerate on the output voltage. I thought 100mV would be acceptable - the VCEsat of the opto NPN when added to the ripple voltage must be less than the logic low level (VIL) of the GPIO input. When AC input voltage is present the opto NPN transistor will drive the output voltage to near GND every cycle and then turn off and let the GPIO pull-up resistor (50k min.) try to pull the capacitor toward 3.3V. You can treat the pull-up resistor as a constant current source since the voltage variation across it is small:
dV/dt = I/C gives:
C2 = 3.3V/50k * 1/(60Hz*100mV) = 11uF => 10uF is close enough
When the AC voltage turns off the rise time of the output voltage will be 65k * 10uF = 0.65 second. That should not be a problem for my application.
Effect of Component Failures:
These circuit should be evaluated for failure effects to see what bad things happen when components fail. I did some investigating of how and why electronic components fail. Here's some of what I found:
 Failure mode data was taken from a combination of resistor manufacturer's recommendations, MIL-HDBK-978, "NASA Parts Application Handbook," 1991; MIL-HDBK-338, "Electronic Reliability Design Handbook," 1994; "Reliability Toolkit: Commercial Practices Edition," Reliability Analysis Center (RAC), 1998; and "Failure Mode, Effects, and Criticality Analysis (FMECA)," RAC, 1993.
Failure mode data was taken from a combination of MIL-HDBK-978, “NASA Parts Application Handbook”, 1991; MIL-HDBK-338, “Electronic Reliability Design Handbook”, 1994; “Reliability Toolkit: Commercial Practices Edition”, Reliability Analysis Center (RAC), 1998; and “Failure Mode, Effects, and Criticality Analysis (FMECA)”, RAC, 1993.
Capacitors normally fail with a short circuit. Film resistors most likely fail with an open circuit, but can fail just as often with a parameter change, and only fail shorted 5% of the time.
If R3, D1, F1, or the opto LED shorts or opens there is no harm done - the circuit continues operating or fails without further consequences. If C1 short circuits in the above circuit then R3 and the opto-LED get hit with all of the mains voltage. This causes the dissipation in R3 to increase from 2.7mW to 31W! Yes, it would be nice if it blew up and put itself out of it's misery. But can you count on it? And what happens to the shrapnel? The fuse is nicely contained in a glass tube.
Only use components rated to withstand the electrical environment to which they are subjected. Design for Reliability guidelines suggest that resistors be derated to 60% of maximum operating limits for voltage and power dissipation. This was an eye-opener for me. This is serious stuff and a failure could cause a fire or other serious issue that places the occupants of the house in danger. It gives credence to the people who say "Don't play with the mains."
While this circuit is very attractive, and will satisfy the vast majority of applications out there, I'm working on a couple of other approaches that are probably not as general purpose, but will satisfy my objectives. I will post more info on that soon.