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

Thread Starter

Bhante

Joined Dec 15, 2009
64
Thanks for your response. Note that I've turned everything the other way around. With the revised circuit, everything - except the heater circuit - comes from the inverter AC (and including +5V supply) so the 130V can only occur on the SSR output side. The other thing is that I need to combine the PWM signal from the MCU with the output from Opt1; if I can conserve Q1 then I can also keep the current on R1 and R2 down at the same time which is better for me, and kill two birds with the same stone. Besides getting very hot and needing new resistors, all that power on R1 and R2 also has to come from the battery. Would that work using Q1?
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
Here is my modified draft circuit:
Power-splitter-heater-draft2.png
PS - I think I have that MCU connection wrong actually, how should I connect it? I reckoned if I put it between Q1 and +5V the PWM would be inverted (which is not so serious but a bit of a pain). Maybe doing it as above requires changing Q1 to a PNP, does it? The only PNP I have is a BC851 but it is SMD and I am using veroboard! Fiddly, but possible. In a junction between tracks it will just fit. The inverter produces 230V AC, reasonably steady as long as it is not overloaded and the battery is not too low.
 
Last edited:

Thread Starter

Bhante

Joined Dec 15, 2009
64
Why do you need the opto or associated components if the heater is controlled by the MCU?
Doesn't the heater have it's own thermostat?
Good question! The machine has a pressure-based control of boiler temperature, which is usual for such machines. There is no thermostat (apart from a bimetalic thermal override on the heater element). This has advantages and disadvantages, but in particular it is very inaccurate and has very high hysteresis. My aim in installing the PWM control is to make the temperature control much more accurate and stable, much more adjustable, but maintaining the pressure limits set by the pressostat as an upper bound for safety reasons (controls can always fail).

The heater is actually modulated by the MCU rather than controlled by it. Obviously it would be perfectly possible to rip out the entire electrics and replace them with a complete new control system based on the MCU, but I don't want to do that. Superficially it seems like a funny sort of way to control temperature using a pressostat, but on the other hand if you think of pressurised boiling water at up to 2 Bar and up to about 120 degrees Celsius, that is a potential bomb, and if something goes wrong with the temperature control it could be very nasty.
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
Oh you folks won't let me have my cake and eat it!

OK, I can connect the opto directly to the MPU.

Power-splitter-heater-draft3.png

I can drive the IO directly from the opto ... a few components can be dropped. Maybe C1 is no longer required?
 

sghioto

Joined Dec 31, 2017
8,758
I still don’t understand why you need the opto. When the inverter is powered up it turns on the 5 volt supply that powers the MCU.
 

opera

Joined Jul 4, 2021
4
As long as you are happy with 130V on your heaters, why doesn't the relay switch in and out a boost transformer? Two relays for different voltage levels.
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
I still don’t understand why you need the opto. When the inverter is powered up it turns on the 5 volt supply that powers the MCU.
OK I think I understand now the root of your misunderstanding - sorry my labelling of "Inverter AC 1 and 2" is a bit misleading. Those terminals represent the connectors inside the machine that would normally connect to the heater. When the heater is supposed to be on, those terminals are connected to the Inverter AC, when the heater is meant to be off they are disconnected. It is not a direct connection to the inverter. I need that other electronics in the machine, that is why I need to combine both signals.
 

sghioto

Joined Dec 31, 2017
8,758
sorry my labelling of "Inverter AC 1 and 2" is a bit misleading.
OK that makes sense. May not need C1 or move C1 across R3. You also mentioned the resistors are getting hot. At 230 volts the resistors should be rated 1 watt. Another scheme replaces the resistors with capacitors. Try .068 uf caps rated at 200 volts.
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
I should be able to reduce R1 and R2 I think as I don't need much current to drive the I/O pin on the MPU. Is 1mA about the minimum useable input current for the opto? That would be for R1 and R2 100K each. Allowing for a bit of heat inside the coffee machine I should get about 50% CTR. As I understand, the digital input on the ATmega328 would either be tristate, or with an internal pullup of about 20 to 50 ohms. Probably I would be using it as the default tristate (high impedance). I didn't manage to find the minimum current currrent for a digital input on the 328, but probaly it is in microamps?? The closest I found in the datasheet was for the serial port where it was using 10uA.
 
Top