How to use a signal from mains to control a DC relay?

Thread Starter

Bhante

Joined Dec 15, 2009
64
I am using an espresso machine in highly adverse mains conditions - voltage fluctuates wildly and is often far too low. The heater (1400W 220V) works OK, but the main problem is with the pump which greatly suffers when the voltage dives too low. Mostly the supply voltage is around 170 to 180, if I am lucky 200, but sometimes goes as low as 130V. Maximum I have seen is 230V (only late at night!).

The solution I want to use is to drive the pump from a 12V battery and inverter, while the rest of the machine runs directly off the mains. Thus, I need a circuit in the machine to replace the pump which creates a small signal to switch the relay on a completely separate 220V AC circuit driven from the battery and inverter. The pump is an Ulka EP5 48W 230V vibration pump (standard in most espresso machines).

Could someone kindly help me with a simple solution?

(Although the inverter is nominally 2000W, the battery is not able to supply enough energy for running the machine completely from the inverter, the battery would run down too fast).

Another constraint is that access to electronics parts where I am is very limited. No US or European parts are available, only Chinese, Japanese or Korean, and even then rather specialised or high-tech parts are rather unlikely to be available. I do have a few parts in my spare parts box; including for example an opto HCPL817, an NPN transistor BC338, and various SSD's. I plan to get a standard 12V DC relay, something along the lines of Golden Relays GH-1C-12L.

What about, for example, connecting the 2 inputs of the HCPL817 to the connectors where the pump normally goes, via 10k Ohm resistors on each input pin? Maybe also a capacitor across the input pins? At 230V input RMS current should be about 12mA, peak 16mA. At 130V RMS 6.5mA peak 9.2mA which should be enough to drive the opto. Is that sufficient protection against reverse voltage (absolute max reverse input voltage 6V) or do I need additional diodes?

On the output side, I would drive the relay coil from the 12V battery, with the BC338 on the output of the opto. Relay needs about 33mA.

Many thanks in advance for any assistance.

(Sorry about the crappy circuit diagram, I have no simple way of drawing it - a recommendation for a very simple free circuit drawing program, someone?)
Split-power-pcb.gif
 

Attachments

crutschow

Joined Mar 14, 2008
34,437
Yes, you need to protect the opto input from the large reverse voltage.
To minimize the ripple from the AC input you could drive the opto from a 4-diode bridge (which would also protect the opto input from the large reverse voltage). The input resistors will drive the bridge.

To further smooth the AC ripple you can add a 3.5kΩ resistor in series with the base of the transistor (typically you use a base current about 1/10th the collector current to fully turn on the transistor), and add a capacitor (30μF or more) from the opto output to ground.

Also you must add a diode across the relay coil (e.g. 1N4841), cathode to +12V, to protect the transistor from the inductive transient when you turn the transistor off.
 

AlbertHall

Joined Jun 4, 2014
12,346
I would remove the capacitor across the HCPL817 input and replace it with a reverse diode (1N4148 would do nicely) across that input.
The output of the HCPL817 will be a series of pulses which the relay may not like. To solve that connect a capacitor (perhaps 100uF) across the HCPL817 output.
 

Ian0

Joined Aug 7, 2020
9,816
The ULKA pump runs off DC (You'll find a diode in the lead), you could make it work by stepping the battery to 240V DC, then pulsing the pump at 50Hz with a MOSFET.
Alternatively, buy a 12V ULKA pump.
 
Last edited:

Ian0

Joined Aug 7, 2020
9,816
If it's the type of machine I'm thinking of, it's quite primitive - a heating element controlled by a bi-metallic thremostat. At 180V it will still heat up, people will just have to wait longer for their coffee.
 

sghioto

Joined Dec 31, 2017
5,390
(Sorry about the crappy circuit diagram, I have no simple way of drawing it - a recommendation for a very simple free circuit drawing program, someone?)
Actually that is one of the better hand drawn schematics seen on this Forum. I don't know what kind of computer or OS you have but I use Windows Paint for all my drawings. Below is your circuit with some of the recommended mods drawn using WP.
1613321059256.png
 

DickCappels

Joined Aug 21, 2008
10,179
I must be missing something. I think you can just connect the espresso machine motor to the coil of an AC relay and use the normally-open contacts of the relay to switch the inverter on and off.

I don't see the need for more than a relay to be added. What did I miss?
 

AnalogKid

Joined Aug 1, 2013
11,044
1. As above, replace the capacitor across the opto coupler LED with a diode, I suggest something more hearty, such as a 1N4004 or 1N4006.

2. Add a 10K resistor from the BC338 base to GND (0 V). This assures a quick and complete turn-off.

3. Add a capacitor from the BC338 base to GND to reduce ripple through the relay coil and assure that the contacts stay firmly closed. 100 uF should be fine. If the components are rearranged a bit, the capacitor becomes much smaller. I'll post a schematic later today.

Do you have access to a small diode bridge, something rated for 1 A and 400 V? Or four 1N4004 diodes?

ak
 

AnalogKid

Joined Aug 1, 2013
11,044
Here is a re-do of your schematic. Your overall plan is good, but it needs adjustments.

1. Note that the power dissipation in the two input resistos is above 1 W each. At 2 W each they will get too hot to touch, but should run ok.

2. Using a diode bridge doubles the frequency of the pulses through the optocoupler. This reduces ripple voltage and current, and allows a smaller filter capacitor. You can stay with the one diode across the optocoupler input if you want.

3. Your 240 ohm base resistor is too small. It would allow almost 50 mA through the transistor base, which is a very high value for a small-signal transistor. Increasing it to 2.2K (R3) protects the transistor and makes the filter capacitor (C1) smaller.

4. As above, R4 makes sure the leakage current through the optocoupler output transistor does not cause problems.

5. Moving R3 and C1 makes for a much smaller capacitor. Now, the cap charges all the way up to almost 12 V. As the input power line goes down through a zero-crossing and the optocoupler turns off, C1 has to discharge through R3 and the transistor all the way down from 12 V to 0.6 V before the transistor starts to turn off. Because the optocoupler is on at least weakly for a large portion of every AC half-cycle, the calculated value for C1 to hold Q1 on throughout an AC cycle is approx 1.0 uF. Anything at 2.2 uF and above will work.

5. Your BC transistor and HCPL optocoupler are fine for this application. My schematic shows parts I already have in my design libraries.

ak
AC-Sense-Relay-1-c.gif
 

AnalogKid

Joined Aug 1, 2013
11,044
Here is another version. This one uses Q1 as an emitter follower. This eliminates the base resistor R3, and reduces slightly the peak voltage across the relay coil. R4 is increased to 100K so it steals less current away from the transistor at 12 V.

Because C1's filter action prevents the transtor from turning off rapidly, it is arguable that D2 is not needed as there is no inductive kick / voltage spike.

ak
AC-Sense-Relay-2-c.gif
 
Last edited:

Thread Starter

Bhante

Joined Dec 15, 2009
64
Wow! What wonderful responses, thank you so much all of you! And especially of course AnalogKid.

@Ian0 - "If it's the type of machine I'm thinking of, it's quite primitive" - Actually no. It is a small commercial machine, with three solenoid valves, a Parker-Sirai pressure switch, a Gicar control circuit, etc. Definitely bad news if they go wrong.

@Ian0 again - Oh, that HCPL814 is a very nice device, I'd have a lot of uses for some of those, besides this project. I see there are also Chinese and Japanese versions (i.e. EL814 and PC814) so I will definitely look for them, although they fall in the rather specialist category for where I am so I don't rate the chances of finding them all that high. If not, I will get some next time I travel.

@atferrari "Do you take for granted it is going to work OK with such extremely low voltages?" No, I don't take it for granted, I know from experience that it works fine except the pump. Definitely not very good for the working life of some of the parts though, like solenoid valves etc. I need a quick solution for the pump, but I am also looking at a longer term solution which isolates the heater instead of the pump (there might be circuitry complications but I am not sure until I get my defective multimeter replaced. Access to the wiring is exceedingly difficult).
 

MrAl

Joined Jun 17, 2014
11,480
I am using an espresso machine in highly adverse mains conditions - voltage fluctuates wildly and is often far too low. The heater (1400W 220V) works OK, but the main problem is with the pump which greatly suffers when the voltage dives too low. Mostly the supply voltage is around 170 to 180, if I am lucky 200, but sometimes goes as low as 130V. Maximum I have seen is 230V (only late at night!).

The solution I want to use is to drive the pump from a 12V battery and inverter, while the rest of the machine runs directly off the mains. Thus, I need a circuit in the machine to replace the pump which creates a small signal to switch the relay on a completely separate 220V AC circuit driven from the battery and inverter. The pump is an Ulka EP5 48W 230V vibration pump (standard in most espresso machines).

Could someone kindly help me with a simple solution?

(Although the inverter is nominally 2000W, the battery is not able to supply enough energy for running the machine completely from the inverter, the battery would run down too fast).

Another constraint is that access to electronics parts where I am is very limited. No US or European parts are available, only Chinese, Japanese or Korean, and even then rather specialised or high-tech parts are rather unlikely to be available. I do have a few parts in my spare parts box; including for example an opto HCPL817, an NPN transistor BC338, and various SSD's. I plan to get a standard 12V DC relay, something along the lines of Golden Relays GH-1C-12L.

What about, for example, connecting the 2 inputs of the HCPL817 to the connectors where the pump normally goes, via 10k Ohm resistors on each input pin? Maybe also a capacitor across the input pins? At 230V input RMS current should be about 12mA, peak 16mA. At 130V RMS 6.5mA peak 9.2mA which should be enough to drive the opto. Is that sufficient protection against reverse voltage (absolute max reverse input voltage 6V) or do I need additional diodes?

On the output side, I would drive the relay coil from the 12V battery, with the BC338 on the output of the opto. Relay needs about 33mA.

Many thanks in advance for any assistance.

(Sorry about the crappy circuit diagram, I have no simple way of drawing it - a recommendation for a very simple free circuit drawing program, someone?)
View attachment 230366
Hello,

I am not sure i understand your problem specification exactly. Are you saying that you need to keep the pump running and it wont run sometimes because the 230vac mains drops too low, and you would like to find a way to keep 230vac going to the pump even when the 230vac mains drops?

If so, the simplest solution that comes to mind is to use an AC conveter/inverter that takes 110vac to 230vac (nominal values) and puts out a constant 230vac.
Next in line would be a converter that takes 110vac to 230vac input and puts out a constant 120vac, then use a step up transformer 120vac to 230vac to drive the pump.

Batteries are always high maintenance so you want to keep away from them if you can. Only when you absolutely need energy storage should you go to a battery. In your case, you have a constant source of power it is just the voltage that varies, so as long as you can get the power you can find a way that does not require a battery.

This is all if i understand your problem spec correctly. You may have other requirements too but that sounded like the main one.
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
@AnalogKid - circuit AC Sense Relay 2

I have some bridge rectifiers (photo). As far as I can remember they are about 1A, but I can't find any datasheet at the moment.

20210215_211528-1.jpg

"Note that the power dissipation in the two input resistos is above 1 W each. At 2 W each they will get too hot to touch, but should run ok."

Oh, I hadn't noticed it would take so much power from such a low current, because I hadn't worked it out! What about increasing the resistors? I am unclear from the HCPL817 datasheet how low the current IF can be. Does it mainly depend on Q1? Would 1 mA work OK? Less than 1mA?

If 1mA is OK, using 2x 56k should give RMS current 2mA / power 0.47W at 230V, 1.3mA / 0.2W at 150V, and 1.2mA / 0.15W at 130V. 72k should give 1.6mA /0.37W at 230V, 1.0mA / 0.16W at 150V, and 0.9mA / 0.12W at 130V. It should switch the pump reliably above 150V. Between 130V and 150V is a rather extreme condition anyway, so I would regard that as less critical; if it switches OK that is fine, but if not the pump should remain off and nothing should burn out, i.e. nothing drastic. (I am assuming low IF cannot give rise to a situation where the pump switches on but fails to switch off).
 
Last edited:
Top