Silicon ChipLED Ladybird: An Eye-Catching Electronic Beetle - April 2013 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Our new website is up and running
  4. Feature: How To Get Digital TV On Your Laptop Or PC by Jim Rowe
  5. Feature: The New SILICON CHIP Website by Nicholas Vinen
  6. Project: LED Ladybird: An Eye-Catching Electronic Beetle by John Clarke
  7. PartShop
  8. Order Form
  9. Project: High-Performance CLASSiC DAC; Pt.3 by Nicholas Vinen
  10. Project: Deluxe GPS 1pps Timebase For Frequency Counters by Jim Rowe
  11. Project: A Rugged 10A Battery Charger From Bits & Pieces by Ross Tester
  12. Review: Siglent SDG1050 50MHz 2-Channel Function Generator by Nicholas VInen
  13. Vintage Radio: The First "Trannie" – The Regency TR-1 4-transistor radio by Ian Batty
  14. Book Store
  15. Market Centre
  16. Advertising Index
  17. Outer Back Cover

This is only a preview of the April 2013 issue of Silicon Chip.

You can view 22 of the 96 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 "LED Ladybird: An Eye-Catching Electronic Beetle":
  • LED Ladybird PCB [08103131] (AUD $5.00)
  • LED Ladybird prototype PCB [08103131] (AUD $1.00)
  • PIC16LF88-I/SO programmed for the LED Ladybird [0810313A.HEX] (Programmed Microcontroller, AUD $15.00)
  • Firmware for the LED Ladybird [0810313A.HEX] (Software, Free)
  • LED Ladybird PCB pattern (PDF download) [08103131] (Free)
Items relevant to "High-Performance CLASSiC DAC; Pt.3":
  • CLASSiC DAC main PCB [01102131] (AUD $20.00)
  • CLASSiC DAC revised main PCB [01102134] (AUD $25.00)
  • dsPIC33FJ128GP306T-I/PT programmed for the CLASSiC DAC v1.02 [0110213B.hex] (Programmed Microcontroller, AUD $25.00)
  • Red & White PCB-mounting RCA sockets (Component, AUD $4.00)
  • SMD parts for the CLASSiC DAC (Component, AUD $80.00)
  • CLASSiC DAC front & rear panels [01102132/3] (PCB, AUD $20.00)
  • Firmware for the CLASSiC DAC [0110213B.HEX] (Software, Free)
  • CLASSiC DAC main PCB pattern (PDF download) [01102131] (Free)
  • CLASSiC DAC front and rear panel PCB patterns (PDF download) [01102132/3] (Free)
  • CLASSiC DAC front & rear panel artwork (PDF download) (Free)
Articles in this series:
  • High Performance CLASSiC DAC; Pt.1 (February 2013)
  • High Performance CLASSiC DAC; Pt.2 (March 2013)
  • High-Performance CLASSiC DAC; Pt.3 (April 2013)
  • High-Performance CLASSiC DAC; Pt.4 (May 2013)
Items relevant to "Deluxe GPS 1pps Timebase For Frequency Counters":
  • Deluxe GPS 1pps Timebase PCB [04104131] (AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Deluxe GPS 1pps Timebase PCB pattern (PDF download) [04104131] (Free)

Purchase a printed copy of this issue for $10.00.

LE D L A DY B I R D . . . an eye-catching electronic beetle Be the light of the party with this unique electronic brooch. Or just build it as an interesting novelty piece. Tired of lacklustre fake precious-stone brooches and ornaments that have no life? Why not build a vibrant electronic brooch or ornament instead? LED Ladybird uses high-brightness LEDs for its eyes, wings and abdomen and it flashes these in a fetching moving pattern. Call it LED animation if you will but it is certainly eye-catching! By JOHN CLARKE I F YOU ARE AFTER something different to wear at a party or dance, it’s hard to look past the LED Ladybird. Suitably fitted with a clasp, you could wear it as a brooch, or you could attach it to a headband or maybe even use it as an earring or pendant. Perhaps you could just build it as a fascinating coffee table piece, a school project or an executive toy. Apart from that, it’s a great little project for honing your “surface-mount” assembly skills. So why have we called it a “LED Ladybird”? Well, first, because it’s shaped like a real ladybird and second, because it incorporates LEDs. We’ve taken a few liberties with the colours though. A real ladybird has an orange body with black spots but that’s impractical for our electronic version because there are no black LEDs. As a result, we’ve reversed the colours, using a black PCB to make up the body and 20 orange LEDs for the spots. Two high-brightness red LEDs are used for the eyes. We’re not too sure what colour eyes a real ladybird has but red looks pretty good in our opinion. Besides, they needed to be different to the orange LEDs used for the spots. As shown in the photos, the PCB’s outline matches the shape of a real ladybird beetle; ie, it’s roughly pearshaped. Along with the LEDs, we’ve also fitted six wire legs and two antennae to the PCB, to make it more ladybird like. There’s also a pushbutton switch to turn it on or off and it’s all powered from a single 3V lithium cell slung underneath the insect’s belly. LED sequence When you turn it on, the LEDs flash in an intriguing and fascinating sequence. This sequence is designed to mimic the flapping of a ladybird’s wings, from take-off to landing. These four diagrams show the basic LED flashing (flying) sequence. First the red eyes come on and the orange LEDs for the right wing flash. The left wing then flashes, then both wings and then all the LEDs flash, including those down the middle. In practice, it’s a bit more complicated than that so take a look at the video on our website (see text). 26  Silicon Chip siliconchip.com.au siliconchip.com.au  K K K DATA K SC 2013 K A A A  LED18 LED14  A K K  LED9 LED20 A K K A  LED13 LED11  A K K  LED17 LED15 Vss 17 RB0 Vss RA0 16 RA7 13 RB7 7 3 RB1 RA4 RB2 8 S1 START/STOP 6 1 18 RA1 RA2 15 RA6 12 11 RB6 RB5 AN3/RA3 2 220 IC1 PIC16LF88– I/SO 5 A A LED19  LEFT WING CLK K K  A K K K K LED22  A LEFT EYE  LED21 A C RB4 10  LED16 LED10 A RIGHT WING  K LED7 K LED5 K  LED6 A  A  LED4 A  LED2  A RIGHT EYE LED1 A LED3 A  BODY LEDS Q1 BC807 E B 2.2k 9 RB3/PWM RA5/MCLR Vdd   LED8 K A A A A A 14 4 Vpp Vdd 10k Fig.1: the circuit uses a PIC16LF88-I/SO microcontroller to control two red LEDs for the eyes and 20 orange LEDs for the wings and body. The LEDs are pulsewidth modulated to ensure constant brightness, while power comes from a 3V lithium cell. LED ladybird  LED12 A E B K MMC Continuous party mode Normally, the LED Ladybird runs through a single cycle of its entire LED lighting sequence and then automatically switches off to save power. It can be run again at any time simply by pressing the pushbutton power switch. Alternatively, it can also be set up to continuously repeat its LED lighting repertoire until switched off with the pushbutton switch. This continuous mode setting is ideal if you want to wear the LED Ladybird to a party or use it as a display in a shop window or on a Christmas tree. Switching the unit to operate in continuous mode is easy – just hold the pushbutton switch down for several seconds when switching on, until the right eye blinks off briefly. We estimate that the lithium cell will last for about 10 hours when the unit is operated in continuous mode. If you require longer than this, then K C BC807 K D1 LEDS 3V BUTTON CELL 1 F D1 SM4004 K First, the two red eyes come on one after the other (and stay on), then the eight central LEDs (six abdomen and two rear) flash once in a chaser sequence. Once that’s completed, the six orange LEDs making up the righthand wing begin flashing, slowly at first then gradually increasing in speed before slowing down again. These six right-wing LEDs then ex­ tinguish and the six left-wing LEDs repeat the sequence, after which both sets of wing LEDs flash together. The eight central LEDs then get in on the act, two at time, with all LEDs on the beetle (including the eyes) then flashing together. After that, there’s some more fancy footwork with the eight central body LEDs entering a chase sequence while the other LEDs all flash at a rapid rate. The unit then goes into a power-down sequence with the central LEDs going out and the wing LEDs flashing at a decreasing rate until they extinguish. Finally, the eight trail LEDs and the red eyes flash once in a chaser sequence, from rear to centre, after which the two eyes extinguish and the unit automatically powers down. Alternatively, you can switch the unit off at any time while it is operating by pressing the power switch. Of course, it’s far more interesting when you see it in action. So don’t just rely on the written description. Instead, take a look at the video at siliconchip.com.au/videos/ledladybird April 2013  27 220 Q1 2.2k – Vss Vpp 1 D1 BUTTON 10k IC1 PIC16LF88 DATA CELL HOLDER 13130180 CLK 08103131 S1 Vdd 1 F TOP VIEW + BOTTOM VIEW Fig.2: install the parts on the PCB as shown in these diagrams and photos, starting with IC1 and the other surface-mount devices on the bottom. The LEDs can then be installed on the top, then the cell holder on the bottom and finally switch S1 on the top. the unit can be powered from two AA cells (or any other external 3V supply) connected via a length of twin cable. Circuit details Take a look now at Fig.1 for the circuit details. It’s really very simple and uses an 18-pin PIC microcontroller (IC1), 22 LEDs and not a lot else. All the clever stuff is hidden inside the microcontroller which is programmed to control the LEDs. As shown, the 3V supply rail (from a lithium cell or two AA cells) is bypassed with a 1µF ceramic capacitor. Diode D1 provides reverse polarity protection – it conducts and limits the voltage applied to IC1 to just -0.6V should the supply be connected in reverse. This diode is a 1A type if using a 3V lithium cell but should be upgraded to a 3A type if using an external supply (see parts list). Note that a Schottky diode should not be used here. These have significant reverse leakage and would draw tens of microamps continuously from the cell, flattening it prematurely. IC1, a PIC16LF88-I/SO, is a surfacemount SOIC low-power version of the PIC16F88. This device can operate down to just 2V. Diode D1, transistor Q1 and the 2.2kΩ and 220Ω resistors are also all surface-mount devices. IC1’s MCLR input (pin 4) is tied to the +3V supply rail via a 10kΩ resistor, so that the micro resets at power-on. Pin 14 (Vdd) of the micro connects directly to the +3V rail, while on/off switch S1 connects between its RB0 input (pin 6) and ground. This RB0 input is normally pulled high to the +3V supply rail via an internal pull-up resistor but is pulled low each time S1 is pressed. Normally, IC1 is asleep, with its 28  Silicon Chip internal oscillator stopped and the microcontroller section not running. This places IC1 in its lowest current draw state. It typically draws 100nA in this mode but we measured just 11nA for our prototype. Pressing S1 pulls RB0 (pin 6) low. This wakes IC1 and starts the software running. Pressing the switch while IC1 is running places it in sleep mode gain. LEDs1-22 are driven directly by IC1’s output ports, without currentlimiting resistors. This was done both to save on the parts count and because there’s no space for current-limiting resistors on the PCB. Driving the LEDs in this way is quite acceptable provided we don’t cause too much current to flow in the output pins. In this circuit, the maximum supply voltage is around 3.3V (with fresh cells) and this prevents each output from sinking more than about 21mA. This is within the limits allowed for both the microcontroller’s output pins and for the LEDs. How do we arrive at that figure? Well, the impedance of the output pins is typically 70Ω and there will be 1.8V across each LED when it is on. This means that, with a 3.3V supply, the voltage across the 70Ω output impedance will be 1.5V, so the current through the LEDs will be 1.5V ÷ 70Ω = 21mA. As the cell voltage falls, so does the LED current. For example, at a cell voltage of 2.2V and with 1.8V typically across the LEDs, there is just 0.4V across the 70Ω output impedance and so the current is just 5.7mA. That means that the average LED current and hence the LED brightness would be dependent on cell voltage unless steps are taken to prevent this. So, to maintain a constant LED brightness independent of cell voltage, the 10k RESISTOR DETAIL ALONG CENTRE LINE 1 F PCB D1 Fig.3: this sectional view shows how the 1μF capacitor is installed at the rear of the PCB, with one lead routed over the top of D1. LEDs are driven with a variable pulse width modulated (PWM) supply. In this circuit, the LEDs are switched on and off at a 1kHz rate, with the duty cycle varied to provide constant brightness. At a 50% duty cycle (ie, LEDs switched on and off for equal periods), the average LED current is half that compared to a 100% duty cycle (ie, LEDs switched on all the time). So by varying the duty cycle, we can control the average current through the LEDs. IC1’s PWM output is at pin 9 and this drives PNP transistor Q1. This transistor in turn switches the supply to all the LEDs which have their anodes wired in parallel. This means that the supply to the LEDs switches off each time the PWM signal goes high (Q1 off) and switches on when the PWM signal goes low (Q1 on). The duty cycle is set to produce consistent LED brightness over the cell voltage range from 2-3.3V. Measuring cell voltage In order for IC1 to correctly vary the PWM signal, it needs to accurately measure the cell voltage. That’s done indirectly by first switching Q1 fully on and taking IC1’s RB4 output (pin 10) low to drive LED21 via a 220Ω resistor. The resulting voltage across the 220Ω resistor is then measured by IC1’s AN3 analog input (pin 2) and this is then used to calculate the correct PWM duty cycle to drive the LEDs. siliconchip.com.au This measurement is made at the start of each LED flashing (or flying) sequence (ie, when power is applied or at the start of each sequence if the unit is operating in continuous mode) . Once this measurement has been made, the RB4 output is set as an input, AN3 is set to an output and the PWM signal operates at the required duty cycle. That way, LED21 can now be driven directly by the PWM voltage at Q1’s collector and RA3 (ie, the 220Ω resistor is taken out of circuit). This LED is on when RA3 is set low, while the other LEDs turn on when IC1 sets their respective outputs low. Note that while the two eye LEDs are driven independently, the remaining LEDs are driven as sets of two in parallel. When the circuit is running and flashing the LEDs, the current drawn from the cell averages out at about 8mA. Building it OK, let’s put LED Ladybird together. As shown in Figs.2 & 3, all the parts are mounted on a PCB coded 08103131 and measuring 43 x 32mm. Start by checking the PCB for any faults such as shorted tracks and undrilled holes. The PCB supplied by SILICON CHIP Partshop and from the kit suppliers will be double-sided, plated through, solder masked and screen printed. These are high-quality boards and are unlikely to have any defects but it’s always a good idea to check. Having checked the board, begin the assembly by installing the surface Above: another view of our prototype LED Ladybird, along with a diagram showing the LED numbering scheme (right). mount parts on the underside – see Fig.2. IC1 should go in first. This is an 18-pin SOIC package and it’s relatively easy to solder in place due to its 0.05-inch pin spacing. You will need a fine-tipped soldering iron, some solder wick and (preferably) a magnifying lamp to do the job. The first step is to position the IC on top of its pads, making sure that it is orientated correctly. That done, solder pin 1 to hold it in place, then check to make sure that all the pins are correctly aligned with their pads. Adjust its position if necessary, then solder all the remaining pins, starting with the diagonally opposite pin (pin 10). Don’t worry if you get solder bridges between adjacent pins during this process; they are virtually inevitable. Once all the pins have been soldered, any bridges can be cleared by pressing solder wick against them using the hot tip of a soldering iron. This will soak up the excess solder while leaving the solder joint between the bottom of the pin and its pad intact. The 2.2kΩ and 220Ω SMD resistors are installed next. It’s just a matter of soldering these at one end first, then making sure they are correctly positioned before soldering the other ends. Once they’re in, you can install SMD transistor Q1. Now flip the PCB over and install the 10kΩ resistor. This is a conventional leaded part and it must be installed with its ends cranked slightly as shown in Fig.2. This resistor must also be offset to the right, ie, the righthand lead must be bent close to the resistor’s body. This is necessary to ensure that, when the LEDs are later installed, one Australia’s Lowest Priced DSOs Shop On-Line at emona.com.au Now you’ve got no excuse ... update your old analogue scopes! Whether you’re a hobbyist, TAFE/University, workshop or service technician, the Rigol DS-1000E guarantee Australia’s best price. RIGOL DS-1052E 50MHz RIGOL DS-1102E 100MHz 50MHz Bandwidth, 2 Ch 1GS/s Real Time Sampling 512k Memory Per Channel USB Device & Host Support 100MHz Bandwidth, 2 Ch 1GS/s Real Time Sampling 512k Memory Per Channel USB Device & Host Support ONLY $ Sydney Melbourne Tel 02 9519 3933 Tel 03 9889 0427 Fax 02 9550 1378 Fax 03 9889 0715 email testinst<at>emona.com.au siliconchip.com.au Brisbane Tel 07 3275 2183 Fax 07 3275 2196 362 Adelaide Tel 08 8363 5733 Fax 08 8363 5799 inc GST Perth ONLY $ Tel 08 9361 4200 Fax 08 9361 4300 web www.emona.com.au 439 inc GST EMONA April 2013  29 Par t s Lis t 1 PCB, code 08103131, 43 x 32mm (with black solder mask) 1 SPST vertical mount microswitch with 6mm actuator (Jaycar SP-0603, Altronics S1421) (S1) 1 20mm button cell holder (Jaycar PH-9238, Altronics S5056) 1 CR2032 lithium cell 1 200mm length of 1.25mm enamelled copper wire 1 40mm length of 1mm enamelled copper wire Semiconductors 1 PIC16LF88-I/SO micro­controller programmed with 0810313A. hex (IC1) 20 3mm orange LEDs, 1700mcd (LEDs1-20) 2 3mm red LEDs, 1000mcd (LED21,LED22) 1 BC807 (SOT-23) surfacemount PNP transistor (Q1) 1 SM4004 1A diode (D1) Capacitors 1 1µF MMC Resistors (0.25W, 1%) 1 10kΩ axial lead 1 2.2kΩ SMD 1206 (3216 metric) 1 220Ω SMD 1206 (3216 metric) Alternative external 3V supply 1 SM5404 3A diode or use an axial-lead 1N5404 across the supply (D1) 1 dual AA-cell battery holder 2 AA cells 1 length light-duty figure-8 wire LED’s lead will straddle the central section of the resistor’s body, while the leads of the adjacent LED to its left will be clear of the resistor end cap. That way, the LEDs that straddle this resistor will have their leads clear of the end caps – a necessary precaution to avoid possible short circuits. Diode D1 (another SMD) can now go in. It must be installed with its cathode end towards the bottom edge of the PCB (ie, towards the rear of the Ladybird). Once it’s in, the next step is to install the 1µF MMC capacitor in parallel with this diode. This capacitor will need to have its leads bent so that it sits vertically between LEDs 7 & 8. The top lead is then run across the top of diode D1 (ie, between LEDs 5 & 6) 30  Silicon Chip and soldered to the diode end adjacent to the 10kΩ resistor. You can now install the 22 LEDs. These must be fitted with their cathode leads (indicated by a flat edge on the LED bodies) orientated as shown. Start with the central LEDs, then work your way outwards, as this will make the job much easier. These LEDs should all be stood off the PCB by about 3mm and this can be achieved by pushing each LED down onto a 3mm-high spacer before soldering its leads. Note that some of the centrally-located LEDs will have to have their leads soldered on the top side of the PCB, since IC1 prevents access to their pads on the underside. The cell holder is next on the list. This sits against IC1 and must be orientated as shown in Fig.2 and the photos. Push it down onto the PCB as far as it will go before soldering its positive and negative pins. The positive pin is soldered from the underside of the PCB, while the negative pin is soldered from the top. The parts assembly can now be completed by installing switch S1. This has to be left until last, otherwise it’s too difficult to solder the adjacent negative pin of the cell holder. In-circuit programming Note that Fig.2 indicates the external connections for Vdd, Vss, Vpp, Data and Clock. These allow a PIC programmer to be connected if you want to program the PIC yourself with software downloaded from the SILICON CHIP website (ie, before the battery holder is installed). Alternatively, pre-programmed PICs for this project can be purchased from the SILICON CHIP on-line shop and will also be supplied by kit suppliers. Fitting the legs The PCB assembly can now be completed by fitting the legs and antennae. Six 25mm lengths of 1.25mm diameter enamelled copper wire are used for the legs, while 15mm lengths of 1mm wire are used for the antennae. The first step is to straighten the 1.25mm-diameter copper wire by clamping one end in a vice and then pulling on the other end with a pair of pliers to stretch it slightly. That done, cut the wire into 25mm lengths, strip the enamel from both ends of each wire and solder them to the spare PC pads around the edge of the body. The free end of each leg can then be covered with a solder blob, to form the feet. Once that’s done, the two 15mmlong antenna can be fitted in similar fashion. The wires are then bent to shape using needle-nose pliers, as shown in the photos. Check out This is the easy part – simply insert a 3V lithium cell into the holder (positive side outwards) and check that the LED Ladybird works when switch S1 is pressed. If it’s working correctly, the left eye LED will appear to quickly come up to full brightness when the cell voltage is around 3V. As the cell voltage drops though, this LED will initially ramp up to a lower brightness before then jumping to full brightness. Basically, this jump in brightness is small when the cell voltage is close to 3V but gradually increases to a 50% jump in brightness as the cell voltage drops to 2V. This provides some indication of the cell’s condition. Once the LED’s brightness has been set (ie, by the micro monitoring the cell voltage and adjusting its PWM signal), the right eye LED will come on and then the flashing LED sequence for the wings will start. Single or repeat mode As stated previously, the LED Ladybird is programmed to cycle through its LED flashing sequence just once, then automatically switch off. An entire cycle takes about 1 minute and 20 seconds (80s) but as mentioned, it can be stopped at any time by pressing S1. If you want the LED sequence to cycle continuously, switch off, then press switch S1 and hold it down for several seconds until the right eye LED blinks off briefly. When you do this, the left eye LED will flash continuously (to indicate continuous mode) until S1 is released. To go back to single sequence mode, switch the LED Ladybird off, then press S1 and hold it down until the right eye flashes. Attaching the LED Ladybird The LED Ladybird can be easily attached to clothing by sewing a few cotton loops over several legs. Alternatively, if you are using a lithium cell to power the unit, a strong rare earth magnet can be used to “clamp” the SC LED Ladybird in position. siliconchip.com.au