Project: AT89S52-based Multi-Coloured LED Heart Kit

As my radio kit-building adventures have reached the “bottom” of the eBay well, with most of the kits available being built, I decided to branch out into other “low cost” kits to see what they are like. Most of the really low-cost kits were only modules with very few components, so I decided to pass on them to something a little more substantial.

That’s when I stumbled on an unbranded kit, featuring 32 colour-changing LEDs arranged in a heart shape and an Atmel AT89S52 80C51 microcontroller for just AU$4.66 including postage. For that price, I couldn’t even get the microcontroller or the LEDs locally, so I thought it would be good even if just for parts. But on the whole, I usually don’t want to have such garish items.

But instead of scrapping it for parts, I decided to take the challenge. It was like an “endurance” race – the kit was going to be repetitive and tedious, but at the same time, it was something I wanted to do to prove that I could do it. Another reason this particular sort of kit appeals to me is because of the Velleman kit known as the Flashing LED Sweetheart. This was just a flasher with 28 single-coloured red LEDs, but it was part of the high-school electronics program, which we adapted to a blinking outline of another shape (by drilling LEDs into perspex and wiring them up to the heart-shaped PCB). To actually build something more sophisticated, and cheaper, over 10-years later is a sign of technological progress.

The Bits

2016110409239059

Another day and it’s another semi-anonymous zip-lock plastic bag filled with “bits”. As usual, it’s bring-your-own solder, iron and side-cutters.

2016110409249060

Rather surprisingly, inside, we get a few tape section resistors, a smattering of capacitors, a crystal, a power switch, a DC jack, a USB to barrel jack cable (which will be handy for other things), a bag of LEDs and the IC with its corresponding socket. It is poked into foam to protect it in transit, although it doesn’t look like any ESD precautions were taken.

2016110409349071

Taking the chip out of the foam, it shows that it wasn’t even carefully put in – two of the pins were quite bent. Some careful manipulation restored their alignment without breaking them.

2016110409279061

The board itself is roughly square in size, and is of very good physical build quality. It’s a single layer board, with silkscreen on the top and a fibreglass substrate, but the top seems to have a very smooth, almost coated finish. It makes it both shiny and smooth, which is nice. The silkscreen has values printed, which is good as no notes accompany the board. The board does have several silkscreen glitches though – the label for C3 is where the drill-holes are, the word “LED” is just sitting in the middle of nowhere, and D31’s text is sitting inside D32’s footprint. Nothing show-stopping, as the numbering of the components really doesn’t matter anyway. The board also has many holes which are not indicated for components and terminate in either isolated pads or solid areas – in some sense, similar to protoboard. If you like, you could use them to build additional external mods, or it could be used educationally as a “test solder area”.

2016110409279062

The pads on the rear are finished in a nice shiny tin coating, and bright-blue soldermask is applied which should make soldering a breeze, although some of the spacings can be a little narrow for the beginner. Everything used is through-hole, so it should be a breeze.

Reverse Engineering

The Board

This project is so simple, that I can’t even be bothered to draw a schematic. Basically, the 5v positive supply comes in via the DC jack and is interrupted by the switch. From there, it feeds all the LEDs in a ring, and the IC. The IC is also connected to the negative. Each LED occupies one output of the IC and is driven through a 510 ohm resistor for current limiting (to avoid damage to the IC predominantly). Of the 40 pins, 32 are used by LEDs, leaving 8 pins. Of these eight pins, three are used for power supply (Vcc,Vpp,GND), two are used for crystal driving for time reference, two are not connected (/PROG,/PSEN) and the last pin is RESET which is tied down with a resistor. In all, the IC is directly driving each LED and will be sinking/sourcing all current. A small 10uF capacitor is supplied to bypass the power supply at the IC. The negative is supplied through a wire link. It’s rather disappointing to see no voltage regulation or reverse polarity protection – in fact, the wire link could easily be replaced with a power diode to provide the latter.

Which leads me to the question of how many solder joints are involved in completing the kit?

32 LEDs = 64 joints
33 Resistors = 66 joints
3 Capacitors = 6 joints
1 Crystal = 2 joints
1 IC = 40 joints
1 Power Socket = 3 joints
1 Switch = 6 joints
1 Wire Link = 2 joints
Total = 189 joints

I suppose that could make for very quick boredom for some, but I enjoy doing these sorts of things …

The Program

Before I build the device, I wanted to see what the IC was holding inside. Using my trusty MiniPro TL866CS, it seems that the device was unlocked, allowing for a full dump and (likely) future reprogramming if desired. That’s a very nice feature.

readout-chip

Those who are interested, the software can be downloaded here. As I’m not particularly familiar with 80C51 code, a quick glance seems to show only 4357 bytes of the 8192 bytes available are used, so there could be space to add more features to it. I decided to load it into IDA Pro for a quick squiz, and it seems the program has a main loop which calls subfunctions in sequence – this is probably it calling each of the lighting effect sequences in turn. The other code structures are probably set-up or debug code which I’m not sure how it’s being invoked.

ida-breakdown

The LEDs

Normally when I think of colourful LEDs, I think of RGB LEDs which have either a common anode or common cathode and four connections. Instead, these LEDs only had two connections, which immediately led me to think “have I been ripped off?”

2016110516029097

2016110516039098A closer look at the LED makes it clear that I haven’t. In fact, these LEDs are a little different. Notice the large black rectangle inside?

A look straight over the top provides a distorted view of the internals with some visual disturbances because of the plastic itself. It seems the complex structures inside have led to air bubbles in the moulded plastic lens as well. Tilting it somewhat allows us to get a closer look at the components inside.

2016110516039099

This grey rectangle is a silicon die which controls the whole show. Basically the LEDs each have their own IC. A total of five wire bonds attach to the LED, namely the anode and cathode connection, and the anodes of each of the three LEDs – red, green and blue. The chip itself autonomously sequences the LEDs to create the colour-change effects, and probably also limits the current to some degree.

2016110516059100

Each of the three LED chips can be seen at the end of their wire bonds, which is just a small square inside their respective air-bubbles. The resulting light sequence looks like this:

single-led-animIt’s not particularly good looking, and it’s a bit blinky towards the end. But because the LED is being directly imaged, the “mixing” of the colours isn’t apparent. Just testing a single LED and resistor combination powered at 5v on my Picoscope shows the following

flashing-led-current-overview

Each LED on a channel is expected to consume about 4.5mA at its highest. The patterns cause rather significant swings in current, so the average current is likely to be lower. A full cycle of the LED takes about 10 seconds to complete.

Because of this, it’s not possible to individually “address” and set the LEDs to a given colour. The colour changing effects rendered have to be a careful combination of power-on/off time based on the LED’s nominal colour cycling behaviour.

Construction Experience

There’s really nothing to it – everything is straightforward and success is almost assured provided you take note of LED and capacitor polarity. Construction time is approximately 1.5 hours, or roughly one joint every 30 seconds. Interestingly, this kit uses the IC socket to provide Z-height clearance under the chip for the crystal and capacitors to mount. Note that the electrolytic is to be mount bent-over. The middle leg of the crystal is a can-ground leg, and no provision is made on the board to accommodate it, so it must be clipped flush to the can.

2016110411049083

The above is the board prior to mounting the IC. Nice and neat. Ensuring the LED’s alignments did need some care, although even then, perfection is not to be expected. Some of the LEDs had mould-flash protrusions which prevented them from sitting flush, so some attention with a knife was required.

2016110411049084

The pads soldered up mostly easily, although sometimes the close spacing did make getting the iron into optimal contact with the pads a little difficult.

2016110411069085

A slight tweak to the chip legs, and it’s safely put into the socket and ready for powering up. A nice perk is that the guys haven’t been bean-counters and seemed to have just “thrown in” some extras just in case.

2016110411069086

There are a total of 18 spare 510 ohm resistors, one spare 10k ohm resistor, two spare 22pF capacitors and two spare LEDs. I can’t complain about that! That’s almost too many spares.

Testing

Plugging it in and turning it on, and it works first time. So I took the opportunity to make this short demo video of it running, to thank my readers:

The LEDs are water-clear lensed, so they put out a very focused beam. Looking at it without any diffusing is quite glary and unpleasant, so I wrapped it in paper to diffuse it and help mix the colours better. I wondered how long the effects go for, so I scoped the LED25’s pin to see what the waveform looked like.

loop-led25

From the scope trace, the effect seems to go for 2 minutes and 35 seconds before repeating itself. I decided to look more closely at the voltages on the pins.

h-to-l-curr

Because the LEDs are provided positive on the outer ring, the LEDs are off when the chip output is high, as there is no potential difference over the LED. However, when the drive pin goes low, then the LED is powered up.

We normally think of high and low as being 5v and 0v in such a system, but in reality, there is a range of acceptable voltages, and due to the internal resistances in the chip, when high currents are being drawn, the voltages will stray from their ideal voltages. In the trace above, we can see that the voltage across the LED initially is about 2.75v, increasing to the full 5v at the end as the loading of the LED and loading on the chip changes (e.g. other LEDs turn off).

pwm-fade

Looking at the current itself, we can see that the LED utilizes its own internal PWM for dimming, at a rate of about 245Hz.

How stressed is the chip? Well given that I previously ascertained that each LED can draw about 4.5mA given the full 5v, each pin could be exposed to this much current. In reality, it’s likely less as the average current is less, and the pin wouldn’t be providing a perfect low output for the full 5v across the LED and resistor combination.

The chip is rated for a maximum of 10mA per pin, up to 15mA absolute maximum before damage occurs. This level is roughly half the maximum of each pin, so it checks out. The total of all current on each 8-bit port is 26mA for Port 0 and 15mA for Ports 1, 2 and 3. This seems to be violated, as eight LEDs at 4.5mA could potentially draw 36mA. The total current for all pins is 71mA, which is also exceeded, as all LEDs on will draw 144mA or around twice as much as the limit.

However, this probably is still okay, as the sheet states that the pins are not guaranteed to sink current greater than the test conditions – under 1.6mA current on a low output, the voltage is to be a maximum of 0.45v. It’s likely this just means that the output voltage will fall at least 0.45v, and the current to the LEDs will be accordingly reduced somewhat. Even if you do go over-spec a little, as long as the chip’s power dissipation is limited, damage is probably unlikely. It is a little hard on the chip and it’s why LED driving is better done with dedicated chips or MOSFETs where currents are not trivial and brightness is a requirement.

Conclusion

Another cheap kit is done and dusted. This one is cheap, and not very “useful” in the strict sense of usefulness. It’s also somewhat repetitive and boring to construct. But it does use a fairly beefy microcontroller, and each of the LEDs was its own little “surprise” in having its own control IC internally. It’s a wonder how they could make and supply the whole kit at the price that they do, especially when there are a few extra components as well. The board quality is also exemplary. The result is rather glary, but I suppose there’s some flexibility if you develop your own code for the 80C51. I suppose if you have a hankering to do lots of through-hole joints for not-much-of-a-reward, or it’s almost Valentine’s Day, maybe it’s worthwhile.

As it turns out, I have a second kit … that I’ve kept for parts … but maybe one day, I could challenge my future girlfriend to construct it. A love test, maybe?

About lui_gough

I’m a bit of a nut for electronics, computing, photography, radio, satellite and other technical hobbies. Click for more about me!

This entry was posted in Electronics and tagged , , , , , . Bookmark the permalink.

5 Responses to Project: AT89S52-based Multi-Coloured LED Heart Kit

  1. Everything about this post made me smile. That you do such thorough analyses of things that seem trivial at first glance is such a delight. Any time I see an IC or epoxy blob on little trinkets like this my gut reaction is always “I want to dump and disassemble the code”, but I’ve never had access to any of the tools nor knowledge of how to do it. So thank you for allowing me to vicariously enjoy tearing down various odd gadgets!

    We’ll all patiently wait for the follow-up wherein the future Mrs. Lui assembles the other kit.

    On an unrelated side note, this post marks the second time (as far as I could ascertain) that you’ve used the word “squiz”, which my American ears were totally unfamiliar with until a few weeks ago when my wife and I recorded an “Australian Slang Challenge” video for our vlog. With your permission I’ll post a link to it, in hopes that hearing one of your readers mangle your local idiomatics will make you also smile.

    • lui_gough says:

      Thanks for the positive comment, and by all means, happy for you to share. I’m sure we’ll all enjoy it.

      – Gough

        • lui_gough says:

          Definitely an … interesting way to interpret those words. As an Australian-educated person, these words are almost second-nature to us, and it’s amazing to see them misinterpreted. The logic is quite funny – but it does point to an obvious problem with language, namely that words that sound similar often have completely different meanings! Ideal way to cause some embarrassment … especially for those otherwise unaware.

          I’m sure that you guys could equally compile a list of American-English terms that would flummox most of the Aussies as well :).

          – Gough

  2. William Harrington says:

    I am glad I ran across this post for the DIY SCM heart kit. I purchased three of these and two of them had a program that faded the LEDs simultaneously. The third chip I tested had the program with a few different routines and provided a nice light show. Once the programmer arrives, I’ll program the other chips and perhaps write my own program. Depending on the source of product, I ordered mine through Banggood, I’m suspecting that they have a giant bin of these parts with different programs in the microcontrollers. http://www.banggood.com/DIY-SCM-Colorful-Glare-Heart-shaped-Light-Kit-Electronic-Teaching-Training-Kit-p-1078378.html

Error: Comment is Missing!