jarrah31
Posts: 124
Joined: Wed Oct 10, 2012 10:16 am

Re: Detecting 250VAC voltage/current of deep well pump motor

Sun Nov 01, 2015 5:00 pm

Thanks again for your help - just one more question please.

The R1/R2 resistor I choose ended up being a minimum 5000 item order, so my only other option is a 500V resistor. Would this be too low?

http://uk.farnell.com/multicomp/mcpmr02 ... dp/1973211

Power Rating: 2W
Resistance: 270kohm
Resistance Tolerance: ± 5%
Resistor Case Style: Axial Leaded
Resistor Element Material: Metal Film
Temperature Coefficient: ± 400ppm/°C
Voltage Rating: 500V

Thanks.

BudBennett
Posts: 89
Joined: Fri May 17, 2013 2:45 pm
Location: Westcliffe, Colorado, USA

Re: Detecting 250VAC voltage/current of deep well pump motor

Sun Nov 01, 2015 9:00 pm

That resistor is too big - it is a 2W resistor that has a body that is too large. Digikey will ship to the UK...for 12 GBP, which is like robbery. Can you try to contact the local Stackpole sales office (sales@vtm.co.uk) maybe they can give you some free samples?

I tried to find some appropriate high voltage resistors on the Farnell website, but either the quantities are huge or the physical sizes won't fit. Are there other electronics hobbyist sites in the UK you can try?

I looked at the voltage ratings of the 500V rated resistors you selected and the surge ratings seemed a bit low to me - just for safety's sake.

Bud.

jarrah31
Posts: 124
Joined: Wed Oct 10, 2012 10:16 am

Re: Detecting 250VAC voltage/current of deep well pump motor

Mon Nov 02, 2015 8:10 pm

Hi Bud,

Thanks again for your help. I've tried quite a few different UK online shops today and it seems they either don't stock the right spec'd resistor, or if they do delivery charge is £12.

I think I'll order the resistor from Digikey but buy 30 of them to make the most of the delivery charge, then if any other UK guys reading this thread want some of those resistors, I can post locally.

I've emailed VTM sales as well so will wait to see what they say first before I order.

As it stands, my shopping list from Farnell is as follows (as a reference for others who are interested in this project and are UK based).

Q1 - http://uk.farnell.com/nxp/bc856b-215/tr ... dp/1081243
C1 - http://uk.farnell.com/avx/tajr106k006rn ... dp/1135071
D1, D2 - http://uk.farnell.com/multicomp/1n4148/ ... dp/9565124
C2 - http://uk.farnell.com/avx/08051c104k4t2 ... dp/1833888
Opto Isolator - http://uk.farnell.com/vishay-semiconduc ... dp/1612456
R1/R2 - http://www.digikey.co.uk/scripts/DkSear ... 2599053643

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Fri May 17, 2019 7:33 pm

post to rpi forum

Hi, Bud,

Thank you for this post!

I have a simpler use case: I just need to know when my deep well pump cycles on and off.

While my well pump runs on 220VAC, I'd prefer to source this with just one of the hot leads and the neutral, so I'm only bringing 110VAC to your invention.

To the point: Is there a simple way to modify your design to accommodate 110VAC input vs 220VAC?

Obviously, I'm new to this, and I'm sure the answer is out there on the inter-webs, but I thought I check with you first, since it's your design, and you have so thoroughly researched your options for the design.

Thank you again!

buzz

BudBennett
Posts: 89
Joined: Fri May 17, 2013 2:45 pm
Location: Westcliffe, Colorado, USA

Re: Detecting 250VAC voltage/current of deep well pump motor

Sat May 18, 2019 4:04 am

I believe the simplest approach would be to change the two 270kΩ resistors to 120kΩ. I think the circuit would not care if one of the leads was neutral as long as the differential voltage was 110VAC @60Hz. Probably still a good idea to use the Stackpole resistors for safety reasons. — Bud.

User avatar
omegaman477
Posts: 140
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: Detecting 250VAC voltage/current of deep well pump motor

Sat May 18, 2019 1:02 pm

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.

Design Requirements:

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.

Some Background:

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):

optoCapDetector.png

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:

ResistorFailureModes.png

CapacitorFailureModes.png

[1] 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.

[2]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.

Component Ratings:

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."

Still Searching:

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.
I must be missing something here. Sensing the presence of 250VAC at the pump motor indicates nothing. The pump could be jammed, stalled, open circuit or blocked, and this sensor would not detect any of these failure conditions. At very minimum you should be sensing that the motor is in fact drawing current (ie operating) . Even then this would not detect a blocked pipe. Ideally you should be sensing water flow in the pump discharge pipe, examining actual flow rates wil tell you a lot about the bore, pump and pump efficiency conditions. Also level sensing of the cistern would be advisable.
..the only thing worse than a stupid question is a question not asked.

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Sat May 18, 2019 7:42 pm

Bud,

Thank you for your quick reply!

Time to order parts!

buzz

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Sat May 18, 2019 7:46 pm

omegaman477,

For my situation, just knowing that juice is flowing from the control box to my deep well pump is good enough. If the pump's not working, I'll know very quickly when I open a faucet. This happened to me a bit over a year ago.

For my project, I assume that my pump is good. I just need to know when it begins to cycle too quickly, usually due to the air-over-water (no diaphragms) pressure tanks becoming waterlogged over time. At some point, I'll just upgrade my pressure tanks to the diaphragm style, but this project will help me know when to purge and re-pressurize them.

Bud's design fits my use case really well.

buzz

erichabg
Posts: 13
Joined: Sat Jun 01, 2013 9:29 am

Re: Detecting 250VAC voltage/current of deep well pump motor

Mon May 27, 2019 10:09 am

For all those who want to detect AC voltage without coming into contact with 230V -> Use a smartphone charger and two resistors with i.e. 100k. Connect the smartphone charger to AC and use the two resistors as as a voltage divider on the 5V output to get 2,5V instead of 5V. Thats all.

BudBennett
Posts: 89
Joined: Fri May 17, 2013 2:45 pm
Location: Westcliffe, Colorado, USA

Re: Detecting 250VAC voltage/current of deep well pump motor

Mon May 27, 2019 4:52 pm

Hmmm...that solution won't fit in the space that I have available.

LTolledo
Posts: 1406
Joined: Sat Mar 17, 2018 7:29 am

Re: Detecting 250VAC voltage/current of deep well pump motor

Mon May 27, 2019 9:39 pm

to detect presence of 250vAC, use a relay with coil rated 250vAC.
the switch contact can be connected to the RPi's GPIO in the same manner as one would connect a tact switch.

for current sensing, a non-invasive current sensor (one where you just pass the wire through, not needing to splice the wire) is what I recommend. just select the one with rating about twice the maximum your pump requires.
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Tue May 28, 2019 1:44 am

ericabg,

I found that I can get to 3v3 with R1: 1700 and R2: 3300.

How would I integrate the 10K pulldown resistor to ensure the RPi GPIO doesn't float when the wall wart is not powered?

Thanks!

buzz

User avatar
ptimlin
Posts: 87
Joined: Tue Jan 08, 2019 7:44 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Tue May 28, 2019 9:10 pm

buzzle wrote:
Tue May 28, 2019 1:44 am
I found that I can get to 3v3 with R1: 1700 and R2: 3300.

How would I integrate the 10K pulldown resistor to ensure the RPi GPIO doesn't float when the wall wart is not powered?
You don't need a 10k pulldown. Output of charger is +5V, one side goes to the GND of your Pi. The other side goes through the 1700 resistor into your GPIO pin while the 3300 goes from the same GPIO pin to ground. When the charger is powered the GPIO pin sees 3.3V. If the charger is not powered (or unplugged) than you only see the 3300 connecting the GPIO pin to GND.

To be safe I would check whatever charger you use to make sure that when not drawing much current that its output doesn't float up to something above 5V or else your "3.3V" voltage divider will be too high. Or as suggested just make your voltage divider even so you get about 2.5V when the power is on which probably is high enough to be detected (anyone know what the minimum high voltage is to guarantee seeing a "1" on the GPIO?).

erichabg
Posts: 13
Joined: Sat Jun 01, 2013 9:29 am

Re: Detecting 250VAC voltage/current of deep well pump motor

Wed May 29, 2019 10:11 am

I think all above 1,5V will be seen as "High". Therefore two identical resistors will fit. They also have the advantage that they cannot be mixed up.
And don't use a very old charger if the on-times are longer. Modern chargers doesn't consumpt much energy when plugged in without load, olders do.

pcmanbob
Posts: 5948
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detecting 250VAC voltage/current of deep well pump motor

Wed May 29, 2019 11:31 am

ptimlin wrote:
Tue May 28, 2019 9:10 pm
as suggested just make your voltage divider even so you get about 2.5V when the power is on which probably is high enough to be detected (anyone know what the minimum high voltage is to guarantee seeing a "1" on the GPIO?).
The minimum input voltage for a solid on is 1.8V below that you may find it will switch from on to off randomly.
So 2.5V if good and it gives you a bit of head room should you input voltage drift high over time.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Wed May 29, 2019 11:10 pm

Thank you for the replies.

I found that when I used a 110VAC to 3v3 wall wart, I would not get a LOW condition on the GPIO, even having waited several minutes after unplugging the wall wart.

I'm guessing that's because there's too little load to pull the voltage down to give the GPIO LOW condition.

My log indicated a GPIO HIGH condition, until I plugged the wall wart back in, then it would indicate LOW for about 400ms, then go right back to HIGH. I cycled it many times (on for 1 minute, off for 2 minutes), and consistently saw this behavior.

FYI: I'm using a simple circuit with a 10K pulldown resistor (GND side) and a 1K current limiting resistor (to the GPIO), not the circuit described in the original post. By the way, I tried adding another 10K in parallel with the other 10K pulldown, which reduced the number of HIGH entries in my log, but didn't fix the problem. Adding a 3rd 10K in parallel just dorked it up. :) So, I went back to the single 10K pulldown.

I'm concerned the 5v charger will give me the same result (too slow of a discharge, if my assumption is correct), but I'm willing to try.

Thanks again!

buzz

User avatar
rpdom
Posts: 14151
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Detecting 250VAC voltage/current of deep well pump motor

Thu May 30, 2019 6:37 am

buzzle wrote:
Wed May 29, 2019 11:10 pm
I'm concerned the 5v charger will give me the same result (too slow of a discharge, if my assumption is correct), but I'm willing to try.
I'm pretty certain you will find that you are correct.

Most power supplies will have capacitors on the outputs to smooth out the voltage and act as a little "reservoir" of power. With a very low current load, such as you would be giving it, that reservoir will have enough power to last quite a while after the supply had failed.
Signature is on holiday.

pcmanbob
Posts: 5948
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detecting 250VAC voltage/current of deep well pump motor

Thu May 30, 2019 8:39 am

If you use a psu with the smallest current output , and decrease the value of the resistor you can draw more current which will cause the voltage to fall away quicker.

For example I have a 5v 2A psu , connected LED with 470 ohm current limiting resistor , on switch off LED goes out within 7 seconds, current drawn 8mA.

but if I add a 270 ohm resistor in parallel with the LED, then the LED goes out in just 4 seconds, due to the current being drawn is now 26mA

So what is the current ratting of your 3.3v psu ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

buzzle
Posts: 6
Joined: Fri May 17, 2019 5:54 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Thu May 30, 2019 12:26 pm

The wall wart's output is rated for 3v3 at 2 amps. It does seem like a lot of juice to dissipate for what I'm trying to do.

pcmanbob
Posts: 5948
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detecting 250VAC voltage/current of deep well pump motor

Thu May 30, 2019 1:13 pm

buzzle wrote:
Thu May 30, 2019 12:26 pm
The wall wart's output is rated for 3v3 at 2 amps. It does seem like a lot of juice to dissipate for what I'm trying to do.
I would look for one with a lower current rating, 500mA or less at 3 to 5V is what you are looking for , then you can do some simple testing like I did and find a suitable resistor so that the psu drops the voltage quickly, a 5v version would just need a potential divider circuit to both drop the voltage to 3v and drop the voltage to zero quickly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
ptimlin
Posts: 87
Joined: Tue Jan 08, 2019 7:44 pm

Re: Detecting 250VAC voltage/current of deep well pump motor

Fri May 31, 2019 8:39 pm

buzzle wrote:
Thu May 30, 2019 12:26 pm
The wall wart's output is rated for 3v3 at 2 amps. It does seem like a lot of juice to dissipate for what I'm trying to do.
One quick and dirty method to dissipate the wall-wart energy is to put a low resistance across the output (tens of ohms). Then to the Pi you feed this through a diode to isolate this from your Pi, then into your Pi's GPIO pin with a weak pull down to GND (your 10k resistor for example). When the wall wart is ON, then the voltage into your Pi will be around 3.3V-0.7V = 2.6V which is a safe voltage and high enough to trigger a "1". When the wall-wart turns off, the (for example) 100 ohm resistor will kill the energy stored in the wall wart quickly and the 10k resistor will ensure than your GPIO pin gets pulled low.

And it doesn't have to be a resistor across the wall wart. You could use another higher current device such as a small incandescent lamp, a tiny DC motor with nothing on the spindle, or whatever else you find that can eat up the excess energy out of the wall wart.

Return to “Automation, sensing and robotics”