Electronic – how to create a square wave with large duration and high duty cycle

counterdelayduty cycletimer

For a "plant waterer circuit" I would like to add a safety feature that prevents watering for over ~3 minutes, and delays the next watering from occurring for ~12 hours.

Currently the circuit is constantly checking the water level to see if water should be added. Thus, it seems that if I could create a square wave that is high for ~12 hours (circuit "off" during this time) and low for ~3 minutes (circuit "on" during this time) then I could use some simple logic to achieve my goal, except I don't know how to create this wave.

Timing chips like the 555 would require unwieldy resistor and capacitor sizes, so it seems those by themselves are not suitable.

I am considering using counter chips, as I could achieve the period I need (~12 hours). However, these output a 50% duty cycle (or 33%, etc.) which I don't want. Rather, the square wave I described above has a duty cycle of about .0042.

Any suggestions? Thanks.

Best Answer

I am not going to answer your question, instead I'll answer a question that you didn't ask :)

You could implement a timer-based solution. However, it is actually going to be cheaper and more effective to use a microcontroller for your problem. The advantages of a microcontroller solution are:

  • Cheaper to build (I know it sounds crazy but it is true)
  • More flexible in the logic: you can change the logic with a few mouse clicks
  • More supportable: for many people it is easier to see the application code than understand why the RC time constant is not behaving as it should.

Some solutions to think about in the microcontroller world:

  • Arduino: starts at about $11 for Arduino Nano on ebay/DealExtreme, programmable over the USB port, more input and outputs than you'll know what to do with. Programmed in C/C++
  • Pure AVR: about $2 for the minimum chip, but requires ~$20 investment for an ISP programmer. Programmed in C/C++ or Assembly.
  • PICAXE. Do they make them anymore? Programmed in BASIC or Flowchart. About $3-$5 to get started. Programmed with nothing more than a serial port.
  • PIC Microprocessors. Similar to AVR, but it's kind of a Mac vs. PC thing from a few years ago. I am an AVR person, but there is a number of PIC people on this board, so if you go this route there is plenty of help too.

Basically, Arduino is an easier-to-use AVR\$^*\$, and PICAXE is an easier-to-use PIC. Between Arduino<->PIXAXE, Arduiono wins in popularity hands down: Arduino is extremely popular and well-supported. Between the underlying platforms (PIC/AVR), it isn't clear: both are popular. There are also other microcontroller options(Cortex M, Propeller, and many others) but the options mentioned in the bullets above are the easiest to get started with, IMHO.

* This is only 99.9% true because a few Arduino's use non-AVR Atmel chips.

By the way, I am not suggesting the you ditch your existing circuits and use a microcontroller for everything (whether that's a good idea or not is not relevant to your question). You can use a microcontroller for the purpose that you don't flood your house or overwater your plans as stated in your design goals. Here's what your solution would look like in microcontroller pseudocode:

loop:
   have 12 hours passed?
      yes: turn on output for 3 minutes
      no: don't do anything
   go back to loop:

There are all sorts of sophistications you might add, such as sleep, implementing the wake 12 timer hit as an interrupt, etc.