Close
0%
0%

Appliance Timer

Rugged & simple timer to control everything from room lighting to air conditioners.

Similar projects worth following
Timer is a versatile, rugged, and easy to use indoor / outdoor appliance timer. It can be used with lights and other household appliances that require regular on-off cycles and has two main modes: Timed and Night. In Timed mode the unit is on for a set number of hours in each 24-hour period. In Night mode the unit turns on when dark and remains on for a set number of hours (or all night). Timer is unique in that there are no displays, buttons, or dials to set or break. Instead, setting up Timer is done by simply waving your hand over its light sensor.

Timer is rated for 15 amps, 120 VAC RMS and has automatically resetting over-current / thermal protection.

Have you ever done a project that was supposed to be quick & simple, but instead takes on a life of its own, you're never satisfied, and is never done?  For me that's Timer.

It started out as a solid state design to replace the crappy electro-mechanical timers used for decorative lighting.  While cheap, I got tired of replacing them because of exposure to the elements.  All I wanted was a timer to run 24h cycles that was weather proof, could switch light loads., and would last forever.  Here's the prototype.

It had a jumper to set a 4/8h on cycle.  The giant toroid (all I had on hand) is for the isolated gate drive in the MOSFET based solid state relay (SSR). It used a PIC16F616 controller and could handle a 2 amp load.  The board in the upper right is a 5V logic supply hacked from a phone charger.  Worked great but not too flexible and certainly not weatherproof.

Miniaturizing & weatherproofing went pretty quick but then I kept wanting more:  more features, higher loads, how much can you do with a timer?  Apparently a lot because two years and few dozen iterations later I've taken the design in its current form about as far as it can go.  A reboot is in order which is why I've marked this as an on-going project.  But it's not a priority for me right now so it will take a while.

timer-v6_0_b67.zip

Source for v6.0 that adds support for turning on by temperature.

Zip Archive - 34.03 kB - 05/21/2019 at 16:14

Download

timer_5-x-manual-user.pdf

End user instruction sheet.

Adobe Portable Document Format - 84.59 kB - 07/15/2018 at 14:31

Preview

timer-mplab_5-1.X.zip

MPLab code & project files.

Zip Archive - 355.25 kB - 07/15/2018 at 00:09

Download

timer-eagle-180123.zip

Eagle PCB schematic & PCB.

Zip Archive - 109.26 kB - 07/15/2018 at 00:09

Download

timer-bom-180123.xlsx

Bill of materials

sheet - 16.03 kB - 07/15/2018 at 00:09

Download

  • Version 6 Firmware - Temperature Support

    Brian Cornell05/21/2019 at 16:26 0 comments

    Timer is a project I work on in between bigger things.  Partly because of its simplicity but more importantly its versatility.

    For some time I've wanted it to be able to run by temperature but didn't pursue because of the self-heating effect and lack of processing power.  But it can get reasonably close to ambient when off and isn't burdened with current sampling.  So I wrote v6 to add a simple 'timed temperature' mode.

    This mode starts a timing cycle when the temperature is greater / less than a set value.  It runs for a set time (the same as set for 'timed' mode) and turns off.  It resumes sampling after a fixed cool-off period of 20 minutes.

  • Reboot

    Brian Cornell07/16/2018 at 01:51 0 comments

    Timer needs a reboot.  I love the simplicity of the gesture interface but as the feature set has grown it has become a pain in the ass.  It's easy to lose your place and what & how much you can communicate is limited.  It's also a hassle to setup if it's plugged in under a table or something.  For me it's really important to keep the box clean - no buttons, switches, dials, etc.  That means some sort of remote control.

    Right now the plan is to use Bluetooth, probably Microchip's RN4678 and data exchange over the GATT profile talking to a smartphone appl.  This will make configuration a snap, along with changing them during operation.  New features can also be added.  To accommodate this and keep the same PCB / case footprint several things need to happen.

    1. Reevaluate the logic supply's capacity.  The mechanical relay requires 40mA.  The controller & SSR require up to 20mA.  That only leaves 40mA for Bluetooth with no headroom.  A slightly larger supply will likely be required but must be condensed to a smaller footprint than the existing one.
    2. The continuity sense circuit's PCB footprint must be condensed.  Possible & necessary to make room for Bluetooth module.
    3. Review MCU capability against Bluetooth requirements and additional features.

    In parallel enough work should be done on the smartphone appl to ensure that protocol overhead and its impact on the MCU are accounted for before the hardware design is frozen.

    I'll probably start with #s 1 & 2 and some rework on the PCB but not sure when that will happen.

  • Description of Operation - Firmware

    Brian Cornell07/15/2018 at 19:55 0 comments

    First an apology:  the code is sloppy.  It reflects its slow organic growth and part-time attention.  And, I'm still surprised at how such an outwardly simple gadget can have disproportionately complex software.  Still, the firmware is mostly conventional in structure so I'll only give a brief overview and focus on the secret sauce.

    There are three basic sections:  boot, menu, and run.  The boot section initializes the MCU's peripherals, calibrates the ADC, and gets the real-time clock going.  The ADC is calibrated because Vdd is used for +Vref for the widest dynamic range.  Parameter checking is done throughout and out-of-bound values will halt the boot process.  This includes a review of the power control & status registers:  anything other than a power-up will halt the boot process on the premise that a serious fault was encountered.

    Once boot is complete the menu is entered which gives the user the opportunity to set operating mode & options.  This is done by gesturing over the light sensor.  The menu exits to the run section automatically when the user stops gesturing.

    The run section is the typical infinite loop that controls timing cycles.  It can only be exited thru a reboot.  The design philosophy of the run (and menu) section is that all data required to control operation be available by polling variables thru each loop.  Anything that is timing or safety critical is handled by the interrupt vector (ISR).  The ISR is also expected to handle data acquisition and the hardware interface.  It can be thought of as a primitive hardware abstraction layer.  This allows the run loop to focus on functionality while the ISR does the heavy lift and keeps things safe.

    The ISR is responsible for:

    • Calculating AC RMS current
    • Disabling the AC output when the current limit is exceeded
    • Switch from SSR to mechanical relay when SSR current limit is exceeded
    • Disabling the AC output when the temperature limit is exceeded
    • Sensing light level and interpreting a gesture
    • Maintaining chronological time
    • Maintains various timers used in the menu & run sections
    • Monitors AC continuity logic signal, handles de-bounce, sets status

    The tricky piece in the ISR is calculating RMS current.  The square root sum-of-squares method is used.  This requires many samples and is computationally intensive.  It's really a job for a DSP or at least a 16-bit processor but that was part of the fun and required some creativity. (it also kept costs & complexity down)  What really made it possible was a low bar for accuracy:  Timer needs to know approximate current values and the hardware can tolerate several hundred milli-amps of error.

    So the Nyquist criteria is violated and only ninety (90) samples are taken during a 60Hz sine cycle (16.66666mS).  At 90 samples / cycle there is ~ 185uS between them.  To make this work the PIC is run at its maximum instruction speed of 8MHz.  Timer four generates an interrupt every  ~ 46uS.  The service block for timer4 works in four sequential steps, each being performed on a given interrupt and incrementing to the next step on the next interrupt:

    1. AD conversion of current value
    2. Read & square obtained current value, start light acquisition
    3. AD conversion on light, sum squared current value
    4. Read & evaluate obtained light value, start current acquisition

    This is the most time sensitive work in the overall ISR and is placed at the top.  The remaining sections of the ISR complete the data processing and set the data objects used by the foreground code.

    Timer0 runs at 20mS intervals and controls AC RMS data acquisition cycles.  It also completes the RMS calculation by taking the square root of the summed values.  It's interval is deliberately longer than a 60Hz cycle.  When a full set of samples is ready for RMS calculation the timer4 AC calculations are bypassed until the sample...

    Read more »

  • Description of Operation - Hardware

    Brian Cornell07/15/2018 at 18:46 0 comments

    This post describes the overall function of Timer.  I'll talk about the challenging & interesting areas of the design in a separate post.

    The TI UCC28880 is a monolithic direct off-line switch mode controller functioning as a non-isolated buck to provide a regulated 5VDC and maximum of 100mA.  It is a variable frequency/duty cycle controller with a maximum switching frequency of about 80kHz.  C9, C10, and L2 filter differential mode noise and also provide bulk capacitance to supply.  L3, C12, and C13 form the output LC filter and D4 is the free-wheeling diode.  Q6 & Q7 and the associated resistors provide temperature compensated and level shifted feedback to the controller.  For details on this see my project Temperature Stabilizing the TI UCC28880.

    Q8, Q9, U5, and their associated diodes & resistors form the continuity sense circuit used by the application override feature.  This is accomplished by injecting a low AC voltage (13V), very low current to the output.  When the circuit is closed Q9 is biased and it's collector output is amplified and shaped into a logic signal that can be processed by the controller.  For details on this see my project In-Line AC Continuity Sense.

    The AC switch circuit is a hybrid of mechanical & solid state.  This is done to extend the life & reliability of the unit.  How:  loads below ~ 2A are handled exclusively by the SSR.  The majority of applications that household timers are used for is lighting which will likely be below this.  So the cycle count on the mechanical relay is greatly reduced and there is no concern that light loads won't be sufficient to properly 'wet' the relay contacts.  MOSFETs Q3 & Q4 dissipation is low and hence no heat sink or thermal management is required.

    Loads exceeding the MOSFET's safe threshold use the mechanical relay.  The SSR is also used to reduce the switching stress on the relay.  First, all turn-on events are done with the SSR.  Current is constantly sampled and when it exceeds the SSR threshold for 2S the relay is turned on.  After a brief overlap period the SSR is switched off.  At the end of the timing cycle, before turning the output off, the SSR is switched back on, the relay is then turned off, and after a small delay the SSR is turned off.  This methodology operates the relay zero voltage / current conditions and thus prevents arcing & the associated carbon build-up on the relay contacts.  Under these conditions the MOSFETs are switched on under 0 volts / current but the turn-off is done under full load.  However, the duration of the event, along with the shaped turn-off and selected SOA of the MOSFEts prevents failure or the need for additional thermal management.

    Q2, L1, D1, and their associated components form the isolated gate drive necessary for the MOSFET-based SSR.  Turn on/off times are generally less than 100uS.  See project MOSFET Based Solid State Relays (SSR) for a detailed examination on this approach and shaping switch times.

    U3 is a 20A hall effect current sensor that provides a resolution of 100mV/A centered at Vdd/2.  This value is continuously sampled by the controller to control the switching function and provide over-current protection.  U2 is an active, linear temperature sensor with a resolution of 10mV/C and used to provide thermal protection to the unit.

    Q1 is a photo-transistor that along with C4 & R2 output a voltage that is logarithmically related to the luminous energy it senses.  This is processed by the controller to interpret gestures, set the status LED brightness, and control the output when used in light sensing modes.

    U1 is a Microchip 8-bit, midrange, controller that manages all aspects of operation.  Y1 is a 32.768kHz tuning fork crystal connected to the controller's secondary oscillator and used maintain chronological time with an accuracy of about two minutes per year.

  • Design Goals & Background

    Brian Cornell07/15/2018 at 15:14 0 comments

    Expanding on simple & reliable.  I wanted a small form factor and something that could be put together without custom enclosures or special milling & routing.  That meant nothing more than a hand drill.

    It also had to be weatherproof and relatively inexpensive to build.  And at the time I wasn't interested in remote control or a smartphone interface.  That meant no buttons, dials, or switches.  So it would need some form of sensory input for control.   I looked at light, sound, even vibration (like tapping the box) but opted for light since that allow light-based timing cycles.

    I settled on a single pole Solid State Relay (SSR) for the switching.  No relay eliminated problems with arching, carbon on the contacts, or poor conduction due to not meeting the minimum current requirement.  I stuck with the flyback gate drive from the prototype and settled on a 6.3mm dia toroid.  With 26/28AWG wire and a handful of turns it's easy to build and mounts directly to the board.

    I chose the same ABS case I had used for the Triple5:  cheap & small form factor.  Seals well and easy to work with.

    Surprisingly I spent a lot of time on finding the right strain reliefs.  They needed to mount in a drilled hole, be weatherproof, and not too bulky.  With a home build it seemed harder than it should have been.  I started with the compression bushings you see on a lot of small appliances but they are not weatherproof.  I then went to PG9 spiral reliefs which are strong & weatherproof but very bulky & expensive.  I finally settled on molded strain reliefs (the kind normally molded to the cord) after I found a glue that secured them to the cord.

    I stuck with a PIC MCU and went thru several variants in the 8-bit midrange family before finally settling on the 16F18324.  More on that later.

    The logic power supply took some time.  It needed to be cheap, compact, and simple but provide all the requisite protections (over-current, thermal, etc.).  So far the TI UCC28880 has served me well.  It's a monolithic, non-isolated buck solution that requires just over a dozen components.  The topology is flexible, with some design trade-offs, and I found it necessary to modify the reference design to temperature stabilize it.

View all 5 project logs

  • 1
    Build Tips

    Assembly is straight forward but:

    1. Make sure to use a 2oz cu PCB.  The high current paths on the AC side are generouse and include traces on both sides but 2oz is required to keep temperatures down.
    2. Use 16AWG stranded copper cords if possible.  Check drill hole diameter if you do.  I've used 18AWG and have gotten away with it running a 1300 watt space heater but the plug gets hot - like 50C.  Measured case temp is around 35C.  Note, the internal temperature sense is set to trip at 100C.
    3. Making the flyback inductor is easy..  What's most important is the winding polarity.  For ease of winding & handling I use 26AWG although there's no penalty for 28AWG or even 30AWG on the secondary; it just gets fragile.  I use MW35-C HY magnet wire.
      1. Primary:  Np=6.  Start winding to right side (wire pointed away from body) with wire coming out bottom of core.
      2. Secondary:  Ns=17.  Start winding to right side (wire pointed away from body) with wire coming out bottom of core.  Start same side as primary termination.  Wind each side secondary half-way around core.
      3. Both windings should be evenly spaced around the entire core to minimize leakage inductance.
      4. Here's a picture of the completed primary:
      5. And with the secondary (primary @ top of pic, secondary @ bottom).  Note that the top right wire (primary) is on top and the bottom right wire (secondary) is coming out the bottom of the core) - that is the correct polarity.

      6. Don't worry if the loops are a bit loose like those in the picture or the spacing isn't perfect.  The ferrite core has a relatively high permeability and is forgiving in that respect.  Be sure the wire isn't nicked and test for shorts when done.

View all instructions

Enjoy this project?

Share

Discussions

deanplusman wrote 12/24/2022 at 17:42 point

This project is genius. I often wish I had something to make my old Samsung clothes washing machine turn on when I was at work to clean my clothes when I was away, because it was so loud I preferred to be out of the house when it was on. My friend works for Appliance Repair Waco so I'm going to pass this on to him and see what he thinks. This could end up on Shark Tank or something. All the best!

  Are you sure? yes | no

odouglas.pavan.1k wrote 08/17/2021 at 01:22 point

Hey, can you please share the complete detail of your program? I want to try it for my website, you can see here https://bestelectricappliances.com/

  Are you sure? yes | no

Brian Cornell wrote 11/11/2020 at 16:04 point

Hi Thomas, thanks for the feedback.

  Are you sure? yes | no

Brian Cornell wrote 07/26/2018 at 00:08 point

Dissipation.  A typical TRIAC has a forward voltage drop of 1V, so at 2A RMS there's 2W of dissipation.  That's more than can be safely handled on a small PCB in an air-tight ABS box that must operate in 50C ambient.  Compare to two MOSFETs in series with an Rds(on) of 69mΩ each:  I^2R = 2^2 * .069 = 276mW x 2 = 552mW.  25% the dissipation and well within safe thermal margins.

  Are you sure? yes | no

TheGrim wrote 07/25/2018 at 17:55 point

Question: How come you decided to use two MOSFETs rather than a nice stout TRIAC controlled by a MOC opto-coupler? Just wondering. Thanks.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates