@bzublin: thanks (and sorry to hear that your post disappeared: I did recently discover our spam filter had false positives so several posts got incorrectly flagged). About PWM control of solenoid: very clever. As I said, it reminded me of motor or stepper controller: it would be interesting to see if we can use a monolithic motor controller to do the job, releasing the microcontroller from having to carry out the sampling and control loop, though using microcontroller does provide the benefit of software-defined current control, which is handy. I am mainly thinking whether I could change the current OpenSprinkler main controller design to use this method as well, but since each controller can handle up to 72 zones, it’s probably not feasible for one microcontroller to perform that much ADC sampling (which also takes a lot of cycle time). What’s why I am thinking whether you can delegate the job to a monolithic motor controller. In contrast, the nice thing with your 2-wire decoder design is that each decoder has its own dedicated microcontroller, so it doesn’t require one central mcu to handle all valves.
Regarding setting addresses: one method is as you said, turn on each decoder one by one. The main controller can be set in ‘discovery’ mode and continuously send out probing signals, any decoder that has already received a permanent address would not respond, while a newly turned on decoder will respond and obtain the current address, then the main controller increments the address and the user turns on the next decoder. This way the user can simply turn on each decoder one by one, and they will get sequential addresses that way.
Another method is by using the ‘old-school’ dip switch: a 8-bit dip switch can set up to 256 unique addresses. This way there is no need for the controller to discover decoders, however the burden is on the user to make sure each decoder gets a unique index.
About ‘regulated low voltage (5V or 3.3V) from the 30V’ — I have plenty of experience with using switch regulator for this. You are correct that linear regulator is not efficient (unless if we are talking about very low current draw). I’ve seen commercial sprinkler controllers that simply use a zener diode based linear regulator, which really only works if the circuit draws less than 10mA, otherwise too much power will be wasted on the current limiting resistor. Using switching regulator, the old school MC34063 is super cheap and can supply up to 500mA, though it’s relatively low frequency and noisy (under small load you may hear inductor humming). The current OS 3.x design uses XL1509, which is also a low-cost chip that can supply up to 1.8A.
Regarding surge protection, the typical approach is TVS diode and/or MOV (sometimes in conjunction with each other). I’ve taken apart some motorized ball valves which have built-in circuit, and those are pretty much what they use for protection.