Silicon ChipPIC-Based Flexitimer Mk.4 - June 2008 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: New Zealanders can legally do their own wiring - why can't Australians?
  4. Feature: DIY Electrical Work: Are Aussies Dumber Than Kiwis? by Ross Tester
  5. Feature: A Look At Crash Test Dummies by Peter Holtham
  6. Project: DSP Musicolour Light Show by Mauro Grassi
  7. Project: PIC-Based Flexitimer Mk.4 by Jim Rowe
  8. Project: USB Power Injector For External Hard Drives by Greg Swain
  9. Project: Balanced/Unbalanced Converter For Audio Signals by John Clarke
  10. Review: Altitude 3500-SS Stereo Valve Amplifier by Leo Simpson
  11. Project: A Quick’n’Easy Digital Slide Scanner by Brian Coulson
  12. Vintage Radio: The Pye TRP-1 portable HF transceiver by Rodney Champness
  13. Book Store
  14. Advertising Index
  15. Outer Back Cover

This is only a preview of the June 2008 issue of Silicon Chip.

You can view 34 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "DSP Musicolour Light Show":
  • dsPIC30F4011-30I/P programmed for the DSP Musicolour [1010708A.HEX] (Programmed Microcontroller, AUD $20.00)
  • dsPIC30F4011 firmware and source code for the DSP Musicolour [1010708A.HEX] (Software, Free)
  • DSP Musicolour User Manual (PDF download) (Software, Free)
  • DSP Musicolour Infrared Remote Control PCB pattern (PDF download) [10107083] (Free)
  • DSP Musicolour main PCB pattern (PDF download) [10107081] (Free)
  • DSP Musicolour display PCB pattern (PDF download) [10107082] (Free)
  • DSP Musicolour front & rear panel artwork (PDF download) (Free)
Articles in this series:
  • DSP Musicolour Light Show (June 2008)
  • DSP Musicolour Light Show (June 2008)
  • DSP Musicolour Light Show; Pt.2 (July 2008)
  • DSP Musicolour Light Show; Pt.2 (July 2008)
  • DSP Musicolour Light Show; Pt.3 (August 2008)
  • DSP Musicolour Light Show; Pt.3 (August 2008)
  • DSP Musicolour Light Show; Pt.4 (September 2008)
  • DSP Musicolour Light Show; Pt.4 (September 2008)
Items relevant to "USB Power Injector For External Hard Drives":
  • USB Power Injector PCB [07110041] (AUD $5.00)
  • USB Power Injector PCB pattern (PDF download) [07110041] (Free)
  • USB Power Injector front panel artwork (PDF download) (Free)
Items relevant to "Balanced/Unbalanced Converter For Audio Signals":
  • Balanced/Unbalanced Converter PCB [01106081] (AUD $5.00)
  • Unbalanced to Balanced Converter PCB pattern (PDF download) [01106082] (Free)
  • Balanced-Unbalanced Converter PCB pattern (PDF download) [01106081] (Free)

Purchase a printed copy of this issue for $10.00.

A new PIC-based Flexitimer Mk.4 Uses jumpers to set the timing periods H One-shot or continuous on/ off cycling H Independent on/off periods ranging from 1s to over three days. H By JIM ROWE Here’s a new and enhanced version of a very popular project: an easily-programmed lowcost electronic timer module. It’s compact, easy to build and offers a choice of either a single on period or continuous on/off cycling with independently programmable periods. I N THE MARCH 1991 issue of “Electronics Australia”, Rob Evans presented the design for a “cheap and cheerful” electronic timer module called the “Flexitimer”. It could be programmed using a set of wire links and also by changing the value of the timing oscillator components, over a range from a few seconds to approximately one day. It could also be set for either one-shot or continuous on-off cycling, although the on and off times were always the same. This simple, low-cost circuit offered a great deal of timing flexibility and as a result, it became extremely popular. An updated design was published a few years later and the parts retailers sold kits of both this and the original version for many years. It was partly because of the popular40  Silicon Chip ity of the original Flexitimer that we subsequently developed the Programmable Flexitimer, described in the August 2005 issue of SILICON CHIP. It was based on a PIC16F84A micro­ controller and was programmed rather like a microwave oven, using a set of pushbuttons and a small LCD screen. It worked well but in many ways it was “overkill”. It was rather expensive and as a result, it hasn’t been anywhere near as popular as the original Flexitimer. Despite that, it’s clear that many people still want a timer module that’s low in cost and just as easy to program as the original Flexitimer but which offers even more flexibility. For example, many people want independently programmable on and off times, as well as a considerably wider range of programmable times for each. This new Flexitimer Mk.4 fills the bill. Like the original, it’s cheap and easy to build but this new unit offers 54 independently programmable on and off time periods. These periods range from one second up to to 90 hours (or 3.75 days!) and are easily programmed using jumper links. In addition, the unit can operate in either of two timing modes – one-shot or continuous on/off cycling. Circuit details Fig.1 shows the circuit details of the Flexitimer Mk.4. As you can see, the hardware is very simple. That’s because all the timing “work” is done by a firmware program running inside IC1, a low-cost PIC16F628A microcontroller. The on and off timing periods are set by jumper shunts fitted to headers LK1-LK6, while the timing mode (one-shot or continuous on/off cycling) is set via another jumper shunt that’s either fitted to or left off LK7. The firmware in IC1 reads the status of all of these links when it starts following power-up (or is reset after switch S1 is pressed). It then uses these settings to determine the timing. siliconchip.com.au LK4: ON TIME x1/x10 LK6: OFF TIME x1/x10 LK3 A K 8 h 9 6 s 11 5 LK4 m 3 s 2 LK5 8 4 h OFF TIME s/m/h 12 D3 13 6 LK1 ON TIME D5 K A A K D4 A 1 18 K A D2 A K 14 Vdd RA4 K 17 K IN GND 100nF A + 12V DC INPUT – 470 F 16V 2.2k 22k LED RB4 K RA7 RB3 16 A 1-SHOT /CONT RB5 LED1 LK7 RB6 MCLR  K RB2 A RLY1 K D7 A 1k 4 IC1 7 RB1 PIC16F628A 1 LK6 3 10 7 m OUT D6 OFF TIME LK2 ON TIME s/m/h D8 REG1 78L05 2.2k NC1 COM1 NO1 NC2 RESET 10nF S1 RB7 COM2 NO2 RB0 RA3 RA2 CLK 15 OUT RA1 10k 2 C B E TP1 Q1 PN100 B TPG RA0 C Vss 5 D1 PN100 E 78L05 SC  2008 D7,D8: 1N4004 D1–D6: 1N4148 FLEXITIMER MK4 A K A K COM IN OUT Fig.1: the circuit is based on PIC microcontroller IC1 and this drives relay RLY1 via transistor Q1. Links LK1-LK6 program the on and off times, while link LK7 sets the timing mode (either continuous or one-shot). In operation, the PIC16F628A runs from an on-chip clock oscillator which is calibrated at the factory to have a frequency of 4MHz ±1%. As a result, this is also the timing accuracy of the Flexitimer Mk.4 (ie, ±1%), which should be close enough for the vast majority of timing applications. During its “on” timing periods, IC1 provides a logic high signal at pin 2 (RA3) which is used to turn on transistor Q1. Q1 in turn activates relay RLY1, to switch the control outputs. At the same time, LED1 turns on to indicate that the timer is currently in a “relay ON” period. Diode D7 protects Q1 from damage due to inductive transients when RLY1 is switched off, while D1-D6 are used to allow the firmware in IC1 to read links LK1-LK6 via a multiplexing routine. Relay RLY1 and LED1 operate directly from the 12V DC input to the module, via polarity protection diode D8. By contrast, IC1 requires a supply voltage of +5V and this is derived from the +12V line via a 78L05 regulator (REG1). The incoming supply to REG1 siliconchip.com.au is filtered using a 470mF electrolytic capacitor, while a 100nF capacitor filters any noise on the +5V rail. Construction All the parts used in the Flexitimer Mk.4 module fit on a small doublesided PC board coded EC8284 and measuring 42 x 102mm. Fig.2 shows the parts layout. As you can see, the timing circuitry and programming links are on the lower half of the board while the relay and its driver transistor (Q1) are on the upper half, along with REG1, the DC input connector and the output terminal blocks for the relay contacts. The assembly is straightforward but here’s a suggested order of assembly: (1) Fit the five resistors, followed by the three capacitors. Note that the 10nF MKT capacitor goes at lower Main Features & Specifications • Operates from nominal 12V DC, with low current drain: <50mA when relay is on, <5mA when relay is off. Relay status indicated via a red LED. • Outputs via the contacts of a DPDT relay (ie, 2x normally closed, 2x normally open), with 5A contact rating. • Jumper link selection for either a single ON timing period or continuous ON/OFF cycling. • Relay ON and OFF times separately programmed via jumper links for any of 54 different time periods; ie, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90 seconds, minutes or hours. • • • Timing accuracy is ±1% at all settings. Timer may be restarted at any time by pressing a reset pushbutton. Module fits inside a standard UB3 utility box. June 2008  41 (8) Install pushbutton switch S1 and relay RLY1. Take care with the orientation of the switch – it must be installed with its flat side to the left, as shown in Fig.2. (9) Complete the assembly by plugging microcontroller IC1 into its socket. Be sure to align its notched end with the notch in the socket – see Fig.2. Setting the jumpers With the board assembly completed, you now have to set the various jumpers to program the timer. As explained previously, these jumpers set the timing mode and the timing period (or periods) you want. The easiest way to do this is by referring to the Jumper Settings Table. The first jumper to set is LK7, which controls the timer’s operating mode. If you fit a jumper shunt across LK7, the timer will operate in continuous on/off mode, ie, it will activate the relay for whatever ON time you program, then turn it off for whatever OFF time you program, then turn it on again for the programmed ON time and so on. In other words, the relay will continuously toggle according to the programmed ON and OFF times. Conversely, if you leave LK7 without a jumper shunt, the Flexitimer will operate in one-shot mode. This means that the relay will be turned on for the Fig.2: install the parts on the PC board as shown in this overlay diagram and the accompanying photos. Table 2 shows how to set the various links, to program the timing periods and select the operating mode. right, while the 100nF multilayer monolithic goes on the left just below IC1. The 470mF electrolytic is at upper left, with its positive lead towards the bottom edge of the board. (2) Fit diodes D1-D6, followed by D7 and D8. Be sure to orientate each diode correctly. (3). Install an 18-pin DIL socket for IC1, taking care to orientate it with its “notch” end towards the bottom edge of the board. (4) Fit the three 8x2 DIL header strips to the board (for LK1, LK2 & LK3-LK6). These may need to be cut from longer strips using a sharp hobby knife. Then install the remaining 1x2 header at lower left for LK7. (5) Fit two PC board terminal pins to the board in the positions marked TP1 and TPG. (6) Install REG1, Q1 and LED1, again taking care with their orientation. Note that the boards supplied with the Jaycar kits will have multi-way pad “footprints” for REG1 and Q1, allowing you to mount these devices with their leads unsplayed if that’s how they are supplied. However, take care to avoid solder bridges when soldering the leads, as some of these pads are very close together (splay the device leads if you prefer). (7) Fit the DC input connector (CON1) to the upper left of the board, then clip the two 3-way screw terminal blocks together and fit them in the adjacent position. Table 1: Resistor Colour Codes o o o o o No.   1   1   2   1 42  Silicon Chip Value 22kW 10kW 2.2kW 1kW 4-Band Code (1%) red red orange brown brown black orange brown red red red brown brown black red brown 5-Band Code (1%) red red black red brown brown black black red brown red red black brown brown brown black black brown brown siliconchip.com.au Parts List Table 2: Flexitimer Jumper Settings Table RELAY OFF PERIOD RELAY ON PERIOD Time LK1 jumper positions 1 2 3 4 5 6 7 8  1 2 1 1 3 5 8  9 8  7  7  6  7 6  5  6 5  4  4  3  4 2  2  3 LK2 jumper positions Time  8  9 On Time Units & Mult LK4 & LK3 jumper positions LK4 (x10) Seconds Seconds x 10  LK3a (s)  Seconds x 10   Minutes  Minutes x 10    Timer Operating Mode (LK7) programmed ON time and will then be turned off again and remain off. Having set LK7, you then set LK1, LK3 & LK4 for the required relay ON time. As shown in Table 2, the basic ON timing period is set by a jumper for LK1, while the units (seconds, minutes or hours) are set by a jumper for LK3 and the multiplier (x1/x10) by a jumper for LK4. It’s all quite intuitive but note that to program LK1 for a time period of nine units, no jumper is fitted to any of the eight possible positions. To illustrate this by an example, the timer is programmed for an ON period of 90 seconds as follows: no jumper on any of the LK1 positions, a jumper on the first LK3 position (LK3a = seconds) and a jumper on LK4 (= x10). Get the idea? If no jumper shunt is fitted to LK7 to select the one-shot operating mode, there’s no need to fit jumpers for LK2, LK5 or LK6 because the OFF timing period won’t be used. Conversely, if a jumper is fitted across LK7 for continuous mode timing, you will have to set the LK2, LK5 & LK6 jumpers for the desired relay OFF period. siliconchip.com.au Off Time Units & Mult Seconds Hours Hours x 10 LK3c (h)  Minutes Minutes x 10 LK3b (m) LK6 & LK5 jumper positions LK6 (x10) LK5a (s) LK5c (h)      Hours Hours x 10 LK5b (m)     Jumper In: Continuous On/Off Timing Jumper Out: One Timing Period (Relay On) These are set the same way as LK1, LK3 & LK4. So for a relay OFF period of, for example, 40 minutes, you’d fit a jumper in the ‘4’ position for LK2, and also jumpers in the LK5b (minutes) and LK6 (x10) positions. Checkout time To check out your Flexitimer Mk.4 for the first time, try setting it up with the jumpers for one-shot mode (ie, no jumper for LK7) and 60 seconds of ON time, ie, jumpers on the ‘6’ position of LK1, on the LK3a position and on LK4. That done, apply 12V DC to the Flexitimer. LED1 and the relay should immediately turn on and remain on for very close to 60 seconds. They should then turn off and stay off indefinitely, unless you press the RESET pushbutton (S1). If the RESET button is pressed, they should immediately be turned on for another 60 seconds before they go off again. If this all works as expected, your Flexitimer is very likely to be working correctly and should now be ready for use. However, just to make sure, try setting it up for continuous mode by 1 PC board, code EC8284, 42 x 102mm 1 DPDT 12V relay (Jaycar SY4052) 1 PC-mount SPST pushbutton switch, red, (Jaycar SP-0720) 2 3-way PC-mount screw terminal blocks, 5.08mm or 5mm pitch 2 20x2 DIL jumper strips 7 jumper shunts 1 2.5mm PC-mount DC socket 1 18-pin DIL IC socket 2 PC board terminal pins Semiconductors 1 PIC16F628A microcontroller programmed with Flextime4. hex 1 78L05 regulator (REG1) 1 PN100 NPN transistor (Q1) 1 5mm LED (LED1) 6 1N4148 diodes (D1-D6) 2 1N4004 diodes (D7-D8) Capacitors 1 470mF 16V RB electrolytic 1 100nF multilayer ceramic (code 100n or 104) 1 10nF MKT polyester (code 10n or 103) Resistors (0.25W 1%) 1 22kW 2 2.2kW 1 10kW 1 1kW Where To Buy A Kit This project was developed by Jaycar Electronics and they own the copyright on the PC board. Kits will be available exclusively from Jaycar retail outlets and dealers (Cat. KC-5464). fitting LK7 with a jumper shunt and programming in an OFF period of, say, two minutes, ie, a jumper in the “2” position of LK2, a jumper across LK5b and no jumper on LK6. Now press S1 again. This should initiate a continuous sequence whereby LED1 and the relay are ON for 60 seconds, OFF for two minutes, ON for another 60 seconds, OFF for another two minutes, and so on. If it doesn’t work, check the frequency at TP1 using a scope or frequency meter. You should get a reading that’s very close to 1MHz. If not, check the soldered joints on the microconSC troller’s socket. June 2008  43