24VAC irrigation solenoid controller - Page 1
Forum section: electronics / projects

author: ilium007
author_rank: Frequent Contributor
timestamp: June 26, 2021, 11:00:44 am
content: Hi all - trying to design an ESP32 based irrigation controller that I will use with ESPHome / HomeAssistant to control a number of 24VAC garden solenoids. I spent time learning about TRIAC's but a TRIAC optocoupler driving a TRIAC to switch 24VAC had relatively large losses. Instead I am looking at using an optocoupled MOSFET device suitable for AC as shown in the schematic I have put together below.Can I please get some feedback on the idea? I am unsure of how to properly protect against lightning, I have included a bi-directional TVS diode. Should I be including a MOV, gas discharge tube or something else? Should the protection shunt to ground / earth? To be honest, I don't really understand how the TVS diode provides protection, I found other designs that included one so I put one in my design. Any help appreciated.

author: thinkfat
author_rank: Unknown
timestamp: June 26, 2021, 11:37:06 am
content: I've used Opensprinkler hardware, which is effectively TRIACs driven by a HC595 shift register. The schematic is public and quite simple. I'm using a custom made board with a beaglebone wireless sbc. But Esp32 will do just fine.For lighting protection I use a bidirectional TVS and a spark gap, but I guess a MOV won't hurt.

author: Zero999
author_rank: Super Contributor
timestamp: June 26, 2021, 01:23:26 pm
content: Why not just use a mechanical relay? It's far more resistant to high voltage pulses, than transistors.If your circuit is struck by lightning, then it will be destroyed and there's virtually nothing which can be done to prevent it.+

author: ilium007
author_rank: Frequent Contributor
timestamp: June 26, 2021, 03:02:05 pm
content: Because they wear out and the contacts arc. And…. I want to play with IC’s.

author: AussieBruce
author_rank: Regular Contributor
timestamp: June 28, 2021, 07:13:27 am
content: This suggestion involves the solution that you don't want, but in case it helps in any way.....I've used the one home built retic controller for ages. The outputs are optocoupled MOC3021s driving BT136 triacs, with the few other passives exactly as per the 3021 datasheet. The only protection on the outputs is the standard fuse in the common line, no MOVs or other surge devices at all. The setup has run without a single failure of any sort for well over 20 years.

author: Zero999
author_rank: Super Contributor
timestamp: June 28, 2021, 08:13:19 am
content: Quote from: ilium007 on June 26, 2021, 03:02:05 pmThen that's the tradeoff you make. Solid state relays are very mechanically robust, but electrically vulnerable, whilst mechanical relays are the other way round.Since you're swiching AC, arcing is less of an issue. A snubber such as a transient supressor diode, MOV, or RC circuit, across the relay is a good idea with a mechanical relay and manatory for a solid state device, switching an inductive load.

author: emece67
author_rank: Frequent Contributor
timestamp: June 29, 2021, 12:48:40 pm
content: .

author: ilium007
author_rank: Frequent Contributor
timestamp: June 29, 2021, 12:59:44 pm
content: I haven't discarded it! I just thought there would be issues with voltage losses in the two triacs. If it works then I'll go this way.Would the TVS diode suffice instead of a snubber circuit? I have no idea how to work out the values for a snubber circuit and I don't have an oscilloscope to look at the transient voltages on turn off.

author: Zero999
author_rank: Super Contributor
timestamp: June 29, 2021, 03:17:27 pm
content: A TRIAC will typically drop around 1V, irrespective of the load current.TRIACs are typically rated of hundreds of volts, whilst the peak voltage of your 24VAC power supply is only 34V, so you have plenty of headroom. I'd use a 470R resistor, in series with a 100nF capacitor, across either the TRIAC, or solenoid.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 29, 2021, 10:41:08 pm
content: @Zero999 How do you calculate that resistor/capacitor combination? Isn’t the inductive spike from the solenoid coil going to be higher than the 34v peak AC voltage?

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 01:46:29 am
content: Quote from: thinkfat on June 26, 2021, 11:37:06 amThis is the AC driver schematic of the current v3 of the OpenSprinkler project. There are no optocouplers involved, gates of BT1308W TRIACs connected directly to the I2C shift register. I don't understand the ACRET, assume AC Return, connected to an LM358 Op Amp.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 01:50:26 am
content: Quote from: Zero999 on June 29, 2021, 03:17:27 pmSo if I used the 470R / 100nF R9 / C1 would I still need the TVS diode D5?Do I need a resistor to limit current to the TRIAC in the MOC3023M (R10)?if R10 is needed I can't work out how to calculate value. All I can find in datasheet is ITSM Peak Repetitive Surge Current at 1A. Would this mean at 33VAC peak I would need a 33Ω current limiting resistor?

author: AussieBruce
author_rank: Regular Contributor
timestamp: June 30, 2021, 07:35:17 am
content: Just noticed this, you may already be onto it already. The value of the current limiting resistor on your opto input looks way too high if as indicated it's driving an LED. I'd expect something under 1K.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 07:42:03 am
content: Quote from: AussieBruce on June 30, 2021, 07:35:17 amahh yes, it should have been 330Ω as an initial value. Picked up the wrong part in KiCAD.**Updated schematic in thread**

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 09:15:22 am
content: I have updated my schematic for two solenoids.

author: Zero999
author_rank: Super Contributor
timestamp: June 30, 2021, 11:03:45 am
content: I can't see any of the schematics at the moment, as they're blocked by the firewall. Please attach them to your posts so I can see them.The optimum values of R and C in the snubber, depend on the coil's inductance and resistance. Ideally the circuit should be critically or overdamped, so there's no high voltage kick-back. In reality, it's not that critical, so long as enough of the energy is dissipated in the resistor, to save the TRIAC from damage.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 11:57:05 am
content: Quote from: Zero999 on June 30, 2021, 11:03:45 amDamn it... I will go back and re-upload the images.I don't yet have the solenoids in hand so I am unsure of inductance / resistance.

author: Zero999
author_rank: Super Contributor
timestamp: June 30, 2021, 12:47:03 pm
content: Quote from: ilium007 on June 30, 2021, 11:57:05 amYour circuit is fine. I've just remembered that there won't be much of a high voltage pulse, because the TRIAC always turns off, hen the current is near zero, which limits in considerably.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 02:17:10 pm
content: Quote from: Zero999 on June 30, 2021, 12:47:03 pmAny tips on the resistors R9 and R10? I am not sure if they are required.

author: Zero999
author_rank: Super Contributor
timestamp: June 30, 2021, 08:58:29 pm
content: Quote from: ilium007 on June 30, 2021, 02:17:10 pmThey're there to limit the gate current spike, before the TRIAC fires. The data sheet for the MOC3023 recommends 180R for 120VAC and 24VAC is ⅕ of that so will require ⅕ of the resistance, which is 36R. It's not that critical. You'll probably find it's good with 27R, or 47R, but 33R the is common in the ballpark.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 09:47:56 pm
content: Thanks. 33Ω is what I came up with back in this thread. I’ll go with that.

author: Circlotron
author_rank: Super Contributor
timestamp: June 30, 2021, 11:51:51 pm
content: Quote from: Zero999 on June 28, 2021, 08:13:19 amA mechanical relay might have a lifetime of 100,000 operations under full load. With a bit of attention to snubbing of the contacts you can likely get quite a bit more out of it. What is the lifetime of the water solenoids by comparison?But... wanting to play with ICs is a good enough reason for me.

author: ilium007
author_rank: Frequent Contributor
timestamp: June 30, 2021, 11:54:44 pm
content: Quote from: Circlotron on June 30, 2021, 11:51:51 pmI appreciate that.. I wanted to use this project to understand more about AC and TRAIC's. Yes, a relay would have been far easier and this project would be in the garden now but I wouldn't have learnt anything!!

author: ilium007
author_rank: Frequent Contributor
timestamp: July 01, 2021, 12:20:05 am
content: I am close now to ordering parts to prototype this design, the only part that I am still unsure of is a resistor from TRIAC trigger to M1 as this particular component is considered a 'sensitive gate' TRIAC -https://www.ween-semi.com/sites/default/files/2018-10/z0109mn0.pdfIs R21 required, if so how do I calculate value? I assume it is there to set a minimum voltage at the gate before triggering and stop noise / transients from triggering the main TRIAC. This TRIAC has a Vt of approx 1.4V

author: Zero999
author_rank: Super Contributor
timestamp: July 01, 2021, 08:28:59 am
content: R21 prevents any leakage through the opo-coupler from triggering the TRIAC. Frustratingly, the minimum trigger current is often not specified on the TRIAC data sheet, but the minimum voltage is, which is 0.2V. Looking a the graphs on the opto-coupler data sheet gives a maximum leakage of 4µA, so a <50k resistor would be required to ensure a voltage drop of under 0.2V. Intuitively, I think it will be fine without R21, but resistors are cheap.

author: ilium007
author_rank: Frequent Contributor
timestamp: July 01, 2021, 12:34:47 pm
content: Quote from: Zero999 on July 01, 2021, 08:28:59 amThanks! This is the last piece of the schematic puzzle for me. I am going to try and incorporate a PCB spark gap as well, that's going to be another rabbit warren to go down with KiCAD.

author: thinkfat
author_rank: Unknown
timestamp: July 01, 2021, 12:44:31 pm
content: Custom pad shapes are how you do spark gaps in KiCAD. Don't forget to remove the solder stop mask.

author: ilium007
author_rank: Frequent Contributor
timestamp: July 01, 2021, 01:14:03 pm
content: Quote from: thinkfat on July 01, 2021, 12:44:31 pmYeah, I played around with them a while back. Hoping to find someones footprint library in GitHub.

author: ilium007
author_rank: Frequent Contributor
timestamp: July 01, 2021, 01:30:02 pm
content: Quote from: Zero999 on July 01, 2021, 08:28:59 amIn the datasheet for the Z0109MN0 it says min Gate Trigger Current is 0.4mA = 400µAhttps://www.ween-semi.com/sites/default/files/2018-10/z0109mn0.pdfSo the optocoupler leakage current at 4µA isn't enough to trigger the Z0109MN0 TRIAC? What triggers the TRIAC? Voltage or current?

author: Ian.M
author_rank: Super Contributor
timestamp: July 01, 2021, 01:46:09 pm
content: Quote from: ilium007 on July 01, 2021, 01:30:02 pmNow *THAT* is a philosophical question! The gate is effectively part of a BJT so a semiconductor physicist or an engineer performing quantitative circuit analysis would say Voltage and trot out an exponential equation for the resulting gate current, but a technician or hobbyist would say Current . . .

author: ilium007
author_rank: Frequent Contributor
timestamp: July 01, 2021, 01:48:55 pm
content: Quote from: Ian.M on July 01, 2021, 01:46:09 pmhahahah I thought the answer would be along those lines

author: Zero999
author_rank: Super Contributor
timestamp: July 01, 2021, 02:04:37 pm
content: Quote from: ilium007 on July 01, 2021, 01:30:02 pmThat's a better data sheet, than the one I found. Good, then you don't have to worry about the resistor.QuoteUnless it's a superconductor, there can't be one, without the other!

author: markitus
author_rank: Newbie
timestamp: January 20, 2022, 01:50:07 pm
content: I’m also trying to learn about the opensprinkler design and looking at the schematic I can’t understand why the mcu pin does not get fried.For example P0 when it’s HIGH (5v / 3.3v) by the MCU or the shift register it turns ON the triac, but it’s aparently connected with a pulldown to the ACRET which I understand it closes the AC part of the circuit to energize the solenoid. How this 24VAC don’t destroy the MCU pin /multiplexer/shiftregister connected to it?

author: SeanB
author_rank: Super Contributor
timestamp: January 20, 2022, 07:02:26 pm
content: Resistor is also there to reduce false triggering due to noise on the mains, which can capacitively couple either through the PCB traces, or through the TRIAC itself. Easiest to keep it there, as while the TRIAC is likely not to trigger with 4uA of current flowing into the gate, with the gate at 0.15V, it is a lot less immune to noise then, and only a tiny bit more can start the triac conducting, and with it then slowly turning on from limited gate current, the voltage across it will be high while the current is rising, leading to very high instantaneous power dissipation. This can long term damage it, as the die area closest to the gate is stressed by heating, and this degrades that area of the junction. good reason why you have a gate pull down that handles any leakage, and you drive with more than the minimum gate current.

author: thinkfat
author_rank: Unknown
timestamp: January 20, 2022, 07:51:26 pm
content: Quote from: markitus on January 20, 2022, 01:50:07 pmIf I'm not mistaken the whole circuit GND "rides" on one of the AC lines. On the controller side, ACRET is likely connected to GND. I've made my own version of the OpenSprinkler circuit as a cape for the BeagleBone Black Wireless a few years ago. Looking back at the schematic, this is how I did it.