Irrigation valve controller by TvE build log

Are there many bi stable solenoid irrigation valves?

Bi-stable valves certainly exist, but they’re not common, at least not for irrigation. Except for battery operated valves, those are either bi-stable or motor-driven as far as I can tell.

Alright, thanks for the nudge… This is the result (X axis is 50ms/div, yellow is the control input to the N-FET, cyan is the solenoid current):
Valve drop 2020-11-20 22:20:16

Next step is to see whether I can detect that spike in on-current using the ADC. (Note that the average solenoid current during PWM is very low because the duty cycle is 4.3%.)

My previous message showed a scope capture for the 24 VAC irrigation valve. I tried the same experiment with the 12V “DC” valve and I can’t make out where the valve closes. I know it closes in the region indicated by the arrow but there is no current change I can make out (I did zoom in and look more closely).

Valve drop 12vDC 2020-11-20 23:21:29

There is motor driven valves, so they are stable at a certain position

For irrigation, I guess that is not a critical application time wise. So you could use a thermo activated valve

http://www.ventilationcontrolproducts.net/actuators-and-valve-adaptors

It turns on in about 1 minute, uses 2W when activated. About 15USD per valve

There is a bump closer to the falling edge. Are you sure this is not the closing time?

Anyway, you were trying to find the status of the valve, right?

Is it possible in a test setup to move the valve manually? If so, measure the inductance over the valve position (use scope, recording voltage and current into the coil)

After the above explorations, I decided to take the plunge and have some PCBs made. I ended up picking a cheap box to put the irrigation controller into and designed a PCB to control 12 valves using PWM.

The result came out relatively large (I tend to make postage-size stuff) and has lots of discrete components. So I looked into JLCPCB and their SMD assembly service. I picked as many parts from their “basic” set as possible, leaving me with the esp32 module, the Vreg, a TVS diode, a poly fuse, and connectors to hand-solder.

Ten days after pressing the buy button I got the resulting 5 boards in my mailbox (78mm x 68mm for $42 including components, assembly, and shipping – totally insane, subsidies to kill manufacturing everywhere else :frowning: ).

Looks really nicely made with nice soldering and no crooked parts. The mounting holes even fit the enclosure for which I only had a spec sheet, yay! Time to add the missing components and then a stiff drink to build courage to test…

Hello world worked right off the bat :slight_smile: (I actually first checked power traces, then added the Vreg and tested that, then added the USB connector and checked the USB enumeration, etc…)

One issue is visible in the photo, which is that the blue LED is too dim. I used a 33Ω resistor and that’s too much. I ended up soldering a second one in parallel on top and that now looks OK. Next time I’ll stick to red/green/yellow, getting these resistors for unknown LEDs right seems to always be trial and error.

Another issue I hit is that the connectors I picked are going to be too cumbersome given the space left in the enclosure. I hadn’t properly visualized the space nor the depth of the enclosure:

To the left of my finger is a connector the way it’s supposed to be mounted. Just above my finger the same connector set on its back: that would be much better. To the right is the back of a connector: I think I can cut one row of pins, bend the other one, and add two pins for mechanical stability… So that’s what I did:


And the result:

I checked the catalog and the vertical version of this connector doesn’t have the same row-to-row pin spacing, so I couldn’t use it, I could order a different connector, though. I think in the end I’ll just hack the 10 connectors I need.

Some lessons learned:

  • I need to spend more time figuring out the right resistor for LEDs, although the datasheets leave a lot of room for variation in the actual forward voltage (unless one orders specific batches in volume)
  • I have two N.P. components but forgot to have the value (“NP”) show on the silk screen, so at first I thought I had forgotten to spec them for assembly
  • total absence of test points and of 0Ω resistors, oops! (“go for broke?”)
  • need to spend yet more time on enclosure and specifically the overall fit of everything

NB: I moved this thread to the build logs

Schematic in case anyone is interested:
esp32-watering-v1.pdf (138.2 KB)


There’s definitely room for improvement!!

Well done. I like it. I could use one immediately, although I’d use one channel for pump control. Looking forward to hearing of your test results.

What have you selected for front panel buttons? I’m looking at a series from one of my wholesalers “LAY5 Industrial Power Switches”, often seen in crane control boxes.

Thanks!

I did some PWM tests and that looks great (will post some scope shots when I have time). For pump control I would use a relay or SSR. There are a couple of PCB mount SSRs that don’t break the bank ($10-$15 range), but it depends on how beefy your pump is.

I haven’t fully decided on buttons yet. I live in the dry part of california so waterproofing is relative. I bought some cheap membrane buttons and want to experiment with those, they’re similar to


and I want to glue them to the top of the clear cover and either put some clear tape over them or some conformal coating around the perimeter. I haven’t examined them under the microscope. Plan B is to get some “waterproof” buttons with through mount, but these are either expensive or the “waterproof” needs to remain in quotes…

I should say that I do all the irrigation programming and reporting over MQTTS to the esp32 so the display and buttons are only there for maintenance, e.g., turning a valve on to check that all the sprinklers are working and stuff like that.

Since I posted the schematic I should write some (random) design notes:

  • I opted for 12 valves 'cause that fit the esp32 pin count without pushing to the limit, it would be possible to go to 16 with compromises
  • the design is for two valves to be active simultaneously allowing for a master valve and 11 branch valves
  • valves are expected to consume < 1A under DC drive, traces and some components would need beefing up for higher currents
  • there is a 1Ohm current sense resistor, I’m using a 1/4W SMD, which should be OK, but I added through holes for a 1W part just in case
  • the display is minimal and, together with the buttons, is intended for troubleshooting, e.g. to manually turn a valve on to check sprinkler operation. The irrigation schedule programming is intended to happen over the network
  • the usb connector is for programming/debugging purposes, I included the cp2104 because it ended up being cheap and I had never done that before, normally I use just an FTDI serial interface and my PCB has holes for a 1.27mm FTDI connector in case I botched the CP2104 hook-up
  • The “meter” connector is for a hall-effect flow meter
  • The esp32’s IO4 pin is unused and there’s a through hole for a connector in case it’s needed
  • The connectors are designed for 5-conductor direct burial low voltage 18ga cables (which are common at home improvement stores around here): one conductor carries 12V the other four drive GND to each of four valves. Hence 3 connectors for 3 cables for 4 valves each.

Lots of good work.

  1. I recommend that you have isolation from the AC line. You don’t want ground faults.

  2. I had a small COTS timer running my sprinklers and there was a lightning strike nearby. All those control wires had induced voltages high enough to toast the controller.

  3. I would have considered drivers based on current rather than voltage as there could be long cable runs and poor connections.

@iabarry thanks for the comments! The input to the board is 12VDC, the isolation from A/C is done in the wall wart or equiv. Maybe that’s what you mean?

Interesting comment about lightning. Fortunately lightning is very rare hereabouts. But what should I have done? Add an 18V 20A MOV across each valve? Something like https://www.bourns.com/docs/Product-Datasheets/MLA.pdf ? I could retrofit that manually…

I’m not sure how current drivers would work. The PWM drive works real well and reduces the power consumption of the solenoids (and thus their heating) significantly, and the current consumed by the various valve types varies quite a bit.

You could reduce the component count of this project by 90% if you could use the ULN2803 type ICs. They contain an array (normally 8 identical circuits) made to drive inductive loads like relais. It contains the pull down / free wheel diode and darlington output. At a one of price of $0.15 for an IC with 8 drivers on board you can not beat this with a discrete solution.
image

1 Like

If you have 2 valves open for a total of 2A then you have reduced Vgs voltage on the FETs due to the 1 ohm source sense resistor. Only 1. 3V left for the FET and it won’t turn on fully

1 Like

Interesting! Thanks for the pointer! I had looked for FET arrays but not darlington NPN. The chip you mention doesn’t have the drive strength needed in this application (more than 500mA) but a quad version like the ULN2066B does. I wasn’t aware of this ULN series, good to know :grinning:.

Looking at efficiency, the quad NPN chips don’t come in small SMD packages, so they end up using just about the same board space as discrete FETs + diodes + pull-down. In terms of cost, the jlcpcb jelly bean parts and automated assembly are hard/impossible to beat. But if I had to hand-assemble I would gladly pay extra to solder a 16 pin DIP over all the discrete parts.

Yup, you are totally correct. That’s one of the areas where I don’t know what the outcome will be. I had a 1 Ohm assembled by JLCPCB but put a footprint for a large discrete resistor right next to it in parallel. I could populate that easily with another 1 Ohm to cut the drop in half or even a std jumper to be able to select.

The expected mode of operation is to drive a valve at 100% duty cycle for 200-300ms and then switch to PWM at 30%-50% duty cycle. The highest current is during the initial 100% and I’d like to accommodate as high as 1A, although the valves I tested draw < 600mA. Thereafter, during the PWM on-time the current is less than half of that. I’m planning to avoid turning two valves on at the same time in the software, and I’m pretty sure I can set-up the PWM so they are phase shifted as well.

The thought that made me keep the 1 Ohm resistor is that it provides a bit of short-circuit protection by turning the FET off if the current becomes excessive. What I don’t know is whether the circuit can sit in a half-on state that kills the FET due to excessive heat. Then it may have been better to “let the current though” and rely on the poly fuse?

Normally you would use a small sense resistor, and then let a comparator or the micro if fast enough to turn off the FET in case of a short

Limiting the current with a 1R resistor is not a good idea as it likely will overheat the mosfet as the Vgs drops to low. It can work but than you must lower the sense resistor and sample the voltage over this resistor or use a comparator in order to take action when an overcurrent occurs. Without taking action it will likely overheat the mosfet. At 0R25 the voltage drop is 0.5V at 2A which might work. I like your idea of relying on the poly fuse. In that case you might as well do away with the resistor completely. This also simplifies your circuit.