In my Lighthouse work we came across this problem. Here's the basic issue: how do you keep people from running a pump too long and flooding the bathroom? The pump is run off a 12V solar charged battery system, and controlled by a simple mechanical timer: turn to 30, then back to 5 so it runs for 5 minutes. But there are some who insist if 5 is good, 30 is better, so they set it for 30 and walk away. Flood ensues, no hilarity.
To replace this I design a simple to use timer (see attachments for schematic). The user interface is a single push button, push to start and it times for a predetermined number of minutes. Press again and it stops. A beeper is also there to alert how long the delay is, and when the delay is over.
If you press and hold the button for 10 seconds, it goes into a program mode where you can set the time delay. This is why there is also a beeper in there.
Let's review the design. The expected load is a pump motor using some 10 to 15 amps when running, more when starting. While isolation was not required an inexpensive 40 amp solid state relay was picked to drive this as a drop in pre-tested good solution. Also, should it fail it is connected by screws to it is field repairable.
Here's the block diagram:
A full schematic is in the attachment; it's a little too large to put on here.
Timing is done by a PIC micro controller. The requirements (small package, internal oscillator) were easily met by the PIC12F629T-E/SN.
To convert the 12V power to 5V for the PIC the MIC5236-5.0YM low dropout regulator was chosen for it's small size, tolerance for a 60V input, and the enable pin.
Normally the regulator U2 is off, kept off by R2 pulling the enable low. This means there is only a tiny current (less then sleeping the PIC) when not being used. When pressed SW1 kicks on the regulator thru R1 & D2. One of the first things the PIC does on power up is drive GP5 high to drive the enable high thru D3. Thus the PIC can turn the power off when the time is complete. Essentially, D2 and D3 form an OR gate so the button can start the regulator, the PIC can keep it on then turn it off when done.
D1 prevents reverse power polarity from taking out everything. It's cheap protection. The external button SW1 is a sealed switch with gold contacts that should survive a bathroom drenching.
SW1 also drives the PIC GP3 pin so the PIC can read the button to stopping or program the unit.
A MOSFET is used as a driver to chirp the speaker. Another MOSFET pulls the drive side of the SS relay low to turn it on.
The unit was made on a small PCB proto boards with 0.1" plated thru holes. a 16 pin SOIC to DIP adaptor was used to hold the two ICs, and most of the components were added to the thru pin side. 0805 SMD parts fit very well on these boards, as do SOT-23 transistor packages. on board wiring was done with Kynar 30 AWG (i.e., wire wrapping wire) as I find it simple to work with. I keep manual wire wrapping tools to strip the ends. Wires going off board were #22 or #24 (junk box wire, don't really know the size) as they need to be more substantial. The large motor current is contained to the SSR so the wiring I add does not need support this current.
The unit will live in a standard workbox. A blank faceplate was obtained and a central hole drilled to hold the button. The box is from a Radio Shack Project Enclosure #270-1801 (3x2x1") was used to contain the control board, and 4 matching holes were also drilled into the faceplate to attach this. Note the metal top from the box made a great template to get these holes in proper position. The back of the box had 2 holes drilled to hold the SSR.
A very observant reader may note I had no 25 ohm resistors on hand so I used 4x 100 ohm units in parallel.
Programming was done under the (free) Microchip XC8 C compiler. Timer 1 is set to trigger an interrupt about every 32 mS. The ISR keeps track of time passing in the Ticks variable. It also debounces the button by verifying the raw switch input is the
same over 2 reading 23 ms apart.
As the Ticks variable is an integer it may be changed by the ISR while being used by the main routine. To prevent this a simple macro is used:
This will assign the Ticks value to any other variable and test the value is correct. The process gets repeated if Ticks changes while being copied, ensuring an accurate ("thread safe") time reading.
Main loop first initializes the PIC and turns on the power pin. Then the button is observed. A long press puts us into programming mode, short is timing.
A timing cycle begins with a beep for every minute the timer will time for, then the pump is turned on. Each passing minute is also noted with a count of how long much time has passed. Finally, the pump is turned off, the total time is noted, a long lower note is played. The power pin is set low to disable the regulator, and the PIC loops until
it is off.
A program cycle starts with a long high note followed by one short high beep to note it has 1 minute ready to program. Subsequent short presses increment the new time up to the max, then it resets back to 1. A long press will save the value, beep high long to signal success, then beep the new setting counts. A long no-press will abort the programming function, make a long low note. Both methods will then set the power off.
The finished unit is still on my desk till the next tour date when I have access to install this. Later I will report how the unit is received and how it works in the field.
Other views...
Top View:
Side View:
Bottom View showing the SSR:
To replace this I design a simple to use timer (see attachments for schematic). The user interface is a single push button, push to start and it times for a predetermined number of minutes. Press again and it stops. A beeper is also there to alert how long the delay is, and when the delay is over.
If you press and hold the button for 10 seconds, it goes into a program mode where you can set the time delay. This is why there is also a beeper in there.
Let's review the design. The expected load is a pump motor using some 10 to 15 amps when running, more when starting. While isolation was not required an inexpensive 40 amp solid state relay was picked to drive this as a drop in pre-tested good solution. Also, should it fail it is connected by screws to it is field repairable.
Here's the block diagram:
A full schematic is in the attachment; it's a little too large to put on here.
Rich (BB code):
BILL OF MATERIALS
Ref Des Description
------------------------------------------------------------
C1, C3 0.1uF 0805 SMD cap
C2 10uF Tant SMD cap
D1 CGRM4007-G diode
D2, D3 1N4148W diode
MOV1 ERZ-V07D330 Surge Absorber
J1 6 pin 0.1" space pins
Q1, Q2 BSS123LT1G MOSFET, SOT-23
R1 - R3 20K Resistor, 0805 SMD
R4 25 ohm Resistor (make from 4x 100 ohm 2512)
SP1 273-092 Speaker (Radio Shack)
SW1 GPB556A05BR Switch
U1 PIC12F629T-E/SN Microcontroller, SOIC-8
U2 MIC5236-5.0YM LDO Regulator with enable, SOIC-8
U3 SSR-40_DD 40A Solid State Relay (EBay)
To convert the 12V power to 5V for the PIC the MIC5236-5.0YM low dropout regulator was chosen for it's small size, tolerance for a 60V input, and the enable pin.
Normally the regulator U2 is off, kept off by R2 pulling the enable low. This means there is only a tiny current (less then sleeping the PIC) when not being used. When pressed SW1 kicks on the regulator thru R1 & D2. One of the first things the PIC does on power up is drive GP5 high to drive the enable high thru D3. Thus the PIC can turn the power off when the time is complete. Essentially, D2 and D3 form an OR gate so the button can start the regulator, the PIC can keep it on then turn it off when done.
D1 prevents reverse power polarity from taking out everything. It's cheap protection. The external button SW1 is a sealed switch with gold contacts that should survive a bathroom drenching.
SW1 also drives the PIC GP3 pin so the PIC can read the button to stopping or program the unit.
A MOSFET is used as a driver to chirp the speaker. Another MOSFET pulls the drive side of the SS relay low to turn it on.
The unit was made on a small PCB proto boards with 0.1" plated thru holes. a 16 pin SOIC to DIP adaptor was used to hold the two ICs, and most of the components were added to the thru pin side. 0805 SMD parts fit very well on these boards, as do SOT-23 transistor packages. on board wiring was done with Kynar 30 AWG (i.e., wire wrapping wire) as I find it simple to work with. I keep manual wire wrapping tools to strip the ends. Wires going off board were #22 or #24 (junk box wire, don't really know the size) as they need to be more substantial. The large motor current is contained to the SSR so the wiring I add does not need support this current.
The unit will live in a standard workbox. A blank faceplate was obtained and a central hole drilled to hold the button. The box is from a Radio Shack Project Enclosure #270-1801 (3x2x1") was used to contain the control board, and 4 matching holes were also drilled into the faceplate to attach this. Note the metal top from the box made a great template to get these holes in proper position. The back of the box had 2 holes drilled to hold the SSR.
A very observant reader may note I had no 25 ohm resistors on hand so I used 4x 100 ohm units in parallel.
Programming was done under the (free) Microchip XC8 C compiler. Timer 1 is set to trigger an interrupt about every 32 mS. The ISR keeps track of time passing in the Ticks variable. It also debounces the button by verifying the raw switch input is the
same over 2 reading 23 ms apart.
As the Ticks variable is an integer it may be changed by the ISR while being used by the main routine. To prevent this a simple macro is used:
Rich (BB code):
// "thread safe" macro to read current Ticks
#define GetTicks(Dest) while(Dest != Ticks) Dest = Ticks
Main loop first initializes the PIC and turns on the power pin. Then the button is observed. A long press puts us into programming mode, short is timing.
A timing cycle begins with a beep for every minute the timer will time for, then the pump is turned on. Each passing minute is also noted with a count of how long much time has passed. Finally, the pump is turned off, the total time is noted, a long lower note is played. The power pin is set low to disable the regulator, and the PIC loops until
it is off.
A program cycle starts with a long high note followed by one short high beep to note it has 1 minute ready to program. Subsequent short presses increment the new time up to the max, then it resets back to 1. A long press will save the value, beep high long to signal success, then beep the new setting counts. A long no-press will abort the programming function, make a long low note. Both methods will then set the power off.
The finished unit is still on my desk till the next tour date when I have access to install this. Later I will report how the unit is received and how it works in the field.
Other views...
Top View:
Side View:
Bottom View showing the SSR:
Attachments
-
231.3 KB Views: 77