Simple phototimer controls load

-April 18, 2002

In industrial and home applications, the need sometimes exists for a device that, after activation by some physical effect, such as light, temperature, or sound, switches a load on for a predetermined time. The load, such as a lamp, motor, solenoid, or heater, usually derives its power from the ac line. The phototimer in Figure 1, based on an inexpensive MC68HC705KJ1 microcontroller, is a simple and inexpensive way to satisfy this need. A load switches on when it becomes dark and stays on for an interval that an operator sets with the Hours pushbutton switch. A seven-segment LED display shows the interval. The time value is a function of the design objectives, the microcontroller software, and the display-interface complexity. The design in Figure 1 is simple, because it needs only one pushbutton switch and a single-digit display.

The heart of the design is the microcontroller software (Listing 1). The routine serves manual and automatic operating modes. The initialization process sets the manual, or continual, mode. This setting means, that after a 30-sec delay, the load switches on and stays on until you press the Reset pushbutton. The 30-sec delay allows you to change your mind and choose an automatic mode. During the manual mode, the display exhibits "C" for continual. The dot on the display lights every time the load is on, a useful feature when the timer and the load are far away from each other. By pressing the Hours pushbutton, you change the manual mode to an automatic one. In the automatic mode, the display exhibits a time delay in hours. When you press and hold the pushbutton, the digits increment automatically from 1 to 9 every second. This feature comes about by using counter modulo 9 in the external interrupt-service routine (lines 85 to 92 in Listing 1). Click here to download a zip file with both the Word version of Listing 1 and a Word document containing the software associated with this circuit.

After the time-delay setting elapses, the microcontroller waits for night—in other words, for a high level on the Photo input—to switch on the load. During that wait, the dot in the display blinks in 1-sec intervals. When it becomes dark, the LM393 voltage comparator's output switches high and triggers the program to continue. The load switches on, and the dot in the display stops blinking and stays on. The display digit shows the elapsed working time. When this time expires, the load and the dot in the display switch off, and the display exhibits "E." You can stop the process at any time by pressing the Reset pushbutton. Otherwise, the microcontroller automatically repeats the entire sequence every night. The circuit in Figure 1 is extremely flexible. The circuit can switch on the load using any physical effect just by changing the sensor on the comparator input. You can also modify the software for different time delays. As an example, you might want to display two-digit hours and two-digit minutes. In this case, you should use decoder/drivers, such as the CD4511 or MM74HC138, to configure an interface with the display.

Is this the best Design Idea in this issue? Select at

Loading comments...

Write a Comment

To comment please Log In