Presettable Light Box Timer

by throbscottle in Circuits > Electronics

584 Views, 1 Favorites, 0 Comments

Presettable Light Box Timer

IMG_3027.jpg

This was a great basic idea which works well, but was made worse by trying to make it better. Suggested modifications are included in the text.

Some time ago I made a UV light box for exposing PCBs. It works really well, but I've been relying on counting elephants to time the exposure. It takes 24 elephants get the best exposure.

But how long is an elephant? The length varies if I'm tired, excited, or drunk, so some of my PCB's might not turn out so well.

What is really needed is a timer which can turn the light box on the for same time, every time.

After looking at various digital modules which are available, and not wanting to use a long duration 555 timer circuit, I decided I wanted to set the time using a dial with numbers on it, using a control with 1 second resolution or better. It's important for the timer keeps it's setting when no power is applied, which is a natural trait of potentiometer setting, although it being knocked out of adjustment is a natural hazard.

The maximum interval is 120 seconds, the shortest is about 2 seconds.

The concept of a "second" is a slightly loose term here. Think of it as a more accurate version of "one elephant" or "one banana" or "one Mississippi". The timer isn't intended to be very precise, but to keep it's setting between power cycles, and be set with a reasonable degree of resolution.

I added some presettable controls which are switched in by tactile switches, flip-flops and an analogue multiplexer, but you could use another multi-pole switch, or interlocking switches instead. The preset switching circuit has a default setting it will always go to when it's powered on.

I included a live/dummy switch so that the setting can be checked without turning the UV on. The switch has a centre off position so it can also be used as a main power switch.

Some people are going to suggest that I should have used a micro-controller for this, and maybe they are right, but I am not a programmer and this is a simple circuit anyway.

Supplies

Main timer

  • 1x CD4060 (U1)
  • 1x switching diode, eg 1N4148 (D1) (catch diode for relay coil so exact type is not important)
  • 1x logic-level P-channel mosfet. I used AO3407 because it was cheap (Q1)
  • 1x DPDT or DPST relay (RL1a,b,c)
  • 1x momentary switch, tactile or panel mount (SW1)
  • 1x 10k resistor (R24)
  • 1x 220k resistor (R2)
  • 1x 680k resistor (R4)
  • 1x 2M2 resistor (R5)
  • 2x 100nF capacitor (C4, C9)
  • 5x 100k 1% resistor (R6, R7, R8, R9, R10) (You can use 5% types, but there will be more variance between the switched ranges)
  • 1x 6 way 2 pole rotary switch (also known as DP6T, 2P6T, 6 way rotary, 6 position rotary)
  • 1x 100k potentiometer (R1)
  • capacitors to make up timing value (see notes) choose film types as they are more stable and tend to have better tolerance (C1, C2)
  • terminals for power, load, and switches(PL1, PL2, PL3)
  • 1x 10u (or larger) capacitor (C5)
  • If using presets, white paint (eg, correction fluid) for position marker

Switch circuit for presets

  • 1x 74HC174 or equivalent (U2)
  • 1x 4051 or equivalent (U3)
  • up to 5x 100k, miniature vertical mount potentiometers. Choose a type which can be adjusted with a screwdriver.
  • up to 6x 1N4148 or similar (D2 to D6; D9, D10)
  • up to 6x tactile switches + caps (SW3 to SW7)
  • up to 10x 10k resistors. Use of SIL packaged resistors with a common terminal is strongly recommended (R18 to R22; R25, R26)
  • 1x 1k resistor (R15)
  • 2x 100nF capacitor
  • 1x 47k resistor
  • 1x 1uF capacitor, any type
  • 1x small signal type PNP transistor (I used an old 2SA1175 dismantled from something)

For the "dummy" light

  • 1x red LED
  • 1x double pole switch (centre off if also used as power switch)
  • 4x 1N4007 or 1x bridge rectifier for mains voltage
  • 1x 220n 630v capacitor
  • 1x 220 ohm resistor

Note: potentiometers have poor tolerances of +/-10% or more, so you may have to put a few K in series or a few M in parallel to get the correct value. 5k error represents about 2s of time. If the value is too low you won't get the full 20s range in the control, if it's too high you will get extra range. Either way, the scale will be off. Don't use more than about 10k in series though as it will take seconds off the low end of the range. If you can get a cheap pack of 10, you can just pick out the best ones.

Don't forget, this is NOT intended to be a precision timer!

How It Works

timer.sch-1.jpg

The circuit works by timing a short interval and multiplying it using cascaded flip-flops. The 4060 contains an oscillator and 14 stage divider, so it does both jobs nicely. Because it works on a half cycle you effectively get only a 13 stage division, so some extra stages would be desirable. You could use a chip with more stages, such as the 4521, or add a couple of extra flip flops, such as a 4013. I used the 4060 alone because it's cheap, simple and easily available. There's an argument to be made for using a 555 timer for the oscillator and a stand alone frequency divider, but that is a bridge to be crossed another day.

You might think the easy way to get switched different intervals is to simply change tap on the divider, but this doesn't get what you want. Each tap represents a halving or doubling of interval - which is no good when you want multiples of a single value. Using gated combinations of outputs could do the job, but it gets quite complicated.

The last stage of the divider controls the relay coil, which is connected in series with one pair of it's own contacts and a P-channel mosfet. The contacts prevent the relay activating as soon as power is applied, and the mosfet enables it to be turned off when the timer finishes. Because the transistor and contacts are in series, it doesn't matter which item is at the top, so put them whichever way is simplest to construct.

The start switch bypasses the relay contacts and the mosfet, energising the relay. At the same time it charges C10, creating a pulse which resets the 4060, setting it's outputs low, which turns on the mosfet. When the switch is released, the mosfet stays on and the relay remains in a self-sustaining state of keeping it's own contacts closed.

The timer runs for an interval determined by the period of the oscillator multiplied by 8,192 (or by less if you use a lower stage), at the end of which the output goes high, turning off the mosfet, which de-energises the relay. The figure used is actually 2^13, not 2^14 as you might expect because only a half-cycle can be used without extra circuitry.

The period of the oscillator is determined by a resistor and capacitor. Depending on whose data sheet you read, the formula to calculate the period is t=2.2*Rx*Cx or t=2.3*Rx*Cx. What I actually found is that the "2.2" constant is affected by the presence of switch and potentiometer wiring, so the calculation is not accurate in this case. To get an output based on 20 second stages using 100k resistors, the value in theory needs to be 11nF, but I found I actually needed about 15nF. Some refinement of the circuit appears to be necessary. Picking through an assortment of capacitors to find the right value may turn one up, but you will likely get a better value by connecting 2 or 3 in parallel.

I put 5 potentiometers in the circuit, 4 of which are intended to be set with a screwdriver as preset values, and one as a "random setting" control with a control knob. The potentiometers are selected using an analogue multiplexer which is is controlled by a flip-flop circuit which allows setting via tactile switches. Interlocking push-button switches would be much simpler for this, but also rather more expensive.

I discovered, far too late, two important factors which affect the operation of the circuit:

  1. the potentiometer values need to be bigger than the switched divider values to ensure that the ranges overlap, so I have included a suggested modifications to the circuit.
  2. leakage in the analogue multiplexer is enough that the presets can interacts, so adjusting one to it's extremes can affect the others by over a second. Two alternative modifications are:
    a) Use mechanical switches or,
    b) use much smaller resistors (which will also increase the shortest time available)

Every 100k resistor added into the circuit adds 20 seconds to the timer, so the rotary switch just adds an extra 20 seconds at each position. The potentiometer (wired as a rheostat) adjusts up to 20 seconds on top of each value. The oscillator stops when the resistance drops below a certain value, so timing an interval of less than about 3 seconds is not possible. The simple solution is to add a 6k8 resistor in series with the divider, however this puts the entire scale off by about 2.5 seconds. Without this resistor it's possible to put the timer in a "on forever" state, which is highly undesirable.

Small capacitor tolerances aren't too bad if you choose a film type, however potentiometer tolerances can be very poor. So the resistances for the switched dividers are based on an ideal situation where the pot is the value written on the casing. Here in the real world, I got a cheap multi-pack and picked the best and most-similar ones.

A second resistor is required for the oscillator to work, which needs to be between 2 and 10 times the value of the timing resistor. To cover all the ranges, 3 values are needed, switched by the other half of the range switch. (Being able to avoid this second resistor and simplify the switching is the main argument for using a 555 timer instead of the 4060's built in oscillator.)

Technical Trouble!

A couple of problems came to light after I had nearly finished the build, so I am suggesting some changes to the design which you might like to try:

The potentiometers I used are all slightly smaller than 100k. This creates a problem when switching between ranges because it causes a gap in the possible timings. Only an issue if the intervals I want to use are close to the 20 second boundaries.

There are 2 possible solutions for this:

  • Ensure the potentiometers are all on the high side of their tolerance so they are more than 100k in value. Although they exist, actually finding them may be rather impractical.
  • Ensure the main divider resistors are all smaller than 100k. This is much easier to do as you can choose from 91k, 82k, or a number of values in-between. For 91k you will need a 12nF capacitor, and for 82k you need a 13.5nF capacitor. Two 6.8nF in parallel should get you close enough.

But wait, there is another problem!

Because of the large resistances used, the leakage between channels of the analogue multiplexer is enough to change the period of the oscillator by up to 200uS when the de-selected potentiometers are adjusted to extremes. This amounts to 0.8S in the final timing. As I'm unlikely to adjust the presets to their extremes, and it's not intended to be a precise timer, I decided to leave it alone, but you might want to cure or mitigate the issue:

If you want the problem to disappear altogether, simply replace the entire switching circuit with a mechanical switch. It's more expensive and not as much fun, but your presets will be fully isolated.

To simply mitigate the problem, use lower value resistors for the switched divider. Use 43k resistors, and 47k or 50k potentiometers. You will need to change the capacitor to 25.8nF, which is an awkward value. Try a few different 27nF ones, or 18nF and 8.2nF in parallel. If you have a few to choose from you should get a combination that works. The "minimum value" 6.8k resistor will now add over 3 seconds to the timer so you need to account for this.

Another alternative, which I haven't actually tried, is to change the circuit so the potentiometers are in series, and the selection is made by switching a mosfet off, rather than on.

How to Calculate the Timing Components

265984.jpg

I'll put this here so that if you want to use a different scheme for setting the time, you have the essential information. (The caret symbol (^) means "to the power of"). n-1 is used instead of n because the interval is based on a half cycle, not a full one.

The period you need to calculate for the oscillator is given by:

p=t/2^(n-1)

where t is the time interval you want to be able to set with the potentiometer, and n is the number of divider stages you want to use. (The caret symbol ^ means "to the power of")

So for a 20 second interval and a 14 stage divider, it's p = 20/2^13 = 20/8192 = 0.00244

I chose 100k resistors so that the capacitors could be kept small, but without ending up with an extremely high maximum resistance, also considering cost and availability of different types of potentiometer. As it stands, the maximum possible resistance is 600k. It would be nice to use larger resistors and be able to use a trimmer capacitor, but this creates problems of it's own due to the high impedance.

The constant "2.2" shown below, taken from the 4060's datasheet isn't really real in this case. It varies between different versions of the 4060, and is also affected by the extra wiring in this particular circuit, so you may need to experiment a bit with different capacitors because of this.

The oscillator frequency of the CD4060 is calculated by p=2.2RxCx. (Some variants use p=2.3RxCx.) Re-arrange the formula a bit gives you Cx=p/(2.2Rx). For a 20 second interval with a 100k resistor, and using the previously calculated value of p, this gives 0.00244/(2.2*100k)=11.1nF.

Construction

IMG_2633.jpg
IMG_2638.jpg
IMG_2640.jpg
IMG_2641.jpg
IMG_2642.jpg
IMG_2645.jpg
IMG_2646.jpg
IMG_2647.jpg
IMG_2653.jpg
IMG_2655.jpg
IMG_2680.jpg

The circuit is built on perforated board and the connections are made using a home made wiring pen loaded with 0.1mm magnet wire. 0.1mm is a bit fine, but it's cheap and plentiful. The wire has a polyurethane coating which melts when you solder it. A standard iron will melt it very easily, but a temperature adjustable one will probably need to be turned up higher than you would normally use it. Beware of using "plain old enamel" wire which won't do this. It's uncommon but you might find it if you reclaim wire.

I used 2 double sided perforated boards, each with 24x10 holes, one for the preset switches and LEDs, and the other to mount the presets and the timer. The two boards are mounted on opposite sides of a piece of plastic so that the tops of the presets are nearly flush with the front panel. This way, when fitted to a panel, they can be adjusted with a screwdriver but can't be accidentally knocked out of adjustment.

The random setting potentiometer is mounted so that it can be fitted with an adjustment knob. The switch for it is off-set and has a different coloured button and LED.

The switched timing resistors R6-R10, are mounted on the pins of one half of the rotary switch. The other half of the switch has it's pins wired as a group of 2, a group of 3, and a single pin. R2, R4 and R5 are also mounted directly on the switch, connecting these sections together. This way the switch needs only 3 connecting wires.

Connect the timing capacitor directly to the switch at first because you will probably need to experiment with the value a bit and it's easier to do this way. When it's right, move the capacitor (or combination of capacitors) to the PCB.

The presets are mounted along the edge of the timing board so their mounting lugs are against it's edge. Each one has pins 2 and 3 shorted together. The mounting lugs are bent out a bit so they can be soldered together and the end 2 are bent over the edge of the board. This way the assembly is fairly firm.

Because the presets are wired as rheostats, it doesn't matter which way round you connect them. One pin of each is daisy-chained together and connected to a PCB pin. The other pin is connected to it's respective output on U3. Be careful when doing this as the outputs of the chip don't go in pin-order.

The decoupling cap for the 4060 is connected directly between it's power pins on the other side of the board.

I used a SMD version of the 4051 and had to bend the legs so that pins 2, 4, 5, 9, 11, 13 and 15 are up, I sited the "down" pins on pads of the prototype board and soldered them. Pins 6, 7 and 8 are all soldered onto one pad. I positioned it so that pin 3 is next to pin 10 of U1 so they can be easily connected. Because I used a DIP version of the 4060 I just bent the pin over to do this.

An 8 way right angle pin header is fitted at the left edge of the board, although actually only 7 pins are used (I used 8 for an earlier version of the design). Fit D9, D10, R25 and R26 between the pins and U3.

The power connectors are fitted into 3 way headers with Vcc in the middle to prevent accidental reverse connection.

The start switch is panel mounted, and connected with short wires. It shares a 3 way header with Vcc and Gnd, sharing the middle pin. If the header is accidentally connected the wrong way, no harm is done.

The relay and connector for the light box power (or some other device you decide to control with this) are mounted on the back of the board as they are too tall to fit between the timer and switch boards. The diode across the relay coil is mounted on the front of the board, within the relay's footprint.

Power for the circuit is provided by an old 5v wall-wart mounted inside the light box and wired to it's mains input.

Once assembled, print the dials for the presets and stick the sheet over the panel (cut the holes out first!). Adjust them to zero and mark the position on the end of each shaft with a dot of white paint (correction fluid works well). Cut out the dial for the random setting control and stick it on also.

Power Supply

IMG_2648.jpg
IMG_2649.jpg
IMG_2650.jpg
IMG_2651.jpg
IMG_2652.jpg
IMG_2668.jpg

The circuit is powered very simply from an old 5v wall-wart phone charger.

Because it has to fit inside the light box and be powered from the box's incoming mains cable, it was necessary to remove the plug pins. In order to do this I had to crack open the case and twist/hammer them out.

The easiest way to crack open this kind of glued together case is to squeeze it in a vice, and whack the end with a hammer.

I removed the pins by first twisting them so they can rotate completely, and then knocking them out with a hammer.

Which side of the mains is connected to live inside the wall wart shouldn't matter, but I was careful to connect blue and brown wires as the plug pins would have been anyway. At first I put these through the holes left from the pins, but later drilled new holes in the edge of the case.

I put the case back and held it together with tape. It's now clamped to the inside of the light box case using cut-out hardboard shapes and a piece of wood, which also make sure the tape won't come unstuck.

Deployment

Constant_current_x3_with_voltage_limiter-1.jpg
IMG_2656.jpg
IMG_2657.jpg
IMG_2658.jpg
IMG_2659.jpg
IMG_2660.jpg
IMG_2661.jpg
IMG_2665.jpg
IMG_2666.jpg
IMG_2667.jpg
IMG_2669.jpg
IMG_2670.jpg
IMG_2671.jpg
IMG_2672.jpg
IMG_2674.jpg
IMG_2675.jpg
IMG_2676.jpg
IMG_2682.jpg
IMG_2677.jpg
IMG_2687.jpg

The original idea with this was that the front and back PCBs would be mounted front and back of the light box casing with a cover over the front, and I chose the presets with this in mind, however the plywood I used for the casing proved to be too thick for this, so I opted to mount the boards on a piece of ABS (previously shown) and fit this behind a large hole in the light box casing, with a cover over the front.

Hindsight being the wonderful thing it is, what I should have done is dismantle the side from the light box, drill and rebate holes for the presets, then cut out a recess for the push-button switch panel, and fasten them together using magical sparkles. Never mind...

I used two sizes of hole saw and a wood rasp to make the cut-out in the light box casing, above the power supply. The mounting panel is fitted behind the cut-out, and another piece of plastic is screwed to the outside of the case with holes for the controls. You can see I accidentally drilled a hole for a control that doesn't exist, above the selector switch for the random setting control.

The PSU is wired directly to the box's mains input and is clamped in place using shapes cut out from hardboard which are glued to the case and a small wooden batten, which is screwed in place. I fitted ferrules to the mains and PSU wires to crimp them together, which simplifies insertion into the connector block. The wires are safely tucked out of the way.

The mains input for the light box's PSU is connected to the timer's external relay connection, and an extra wire is added to connect it to the mains.

The rotary switch proved to be too far back to fit a normal knob, so I enlarged the hole in the mounting board so the switch body fits through it, so the switch it now mounted on the front panel. Really it needs to be mounted somewhere in-between. A better alternative would have been a knob which extends through the panel, but I didn't have a suitable one.

Two extra holes are drilled in the light box. One is to fit the start switch. For this I used a forstner bit to create a counter-bore before drilling the hole so that the switch can be recessed. The other is to fit the live/dummy switch which is mounted on the other side of the panel. It's drilled using two sizes of hole saw to create a hole with a rebate. I used a 3 way slide switch with centre off which I bought some by mistake years ago. It's mounted on a small piece of ABS which is fitted into the rebated hole.

The dials are created in Inkscape, printed, laminated, cut out and stuck on. (Edit: they will be when I get round to it...)

I realised that the light box now has no indication that it's connected to mains power if the timer isn't timing, so added a neon pilot light.

Usage

The timer is simple to use.

If you are setting a new time interval:

  • Set the live/dummy switch to the "dummy" position.
  • Set the switch to the nearest multiple of 20 seconds below the time you want
  • Pick which potentiometer you want to use by pressing it's button. Use the default for your most commonly used setting.
  • Set the remainder of the interval
  • Press the start button.

With the dummy setting you can test and fine-adjust the interval using a stopwatch without turning on the UV light.

Once a preset has been set, you needn't ever touch it again. Just remember (or write down) the switch setting for each one.