9600bps clock source

Quick post from an old draft, mainly as documentation.

A 9600Hz oscillator circuit based on a 2.4576MHz crystal and a 74HC590 binary counter. The idea was to reproduce the set up from robotroom.com site with a bar crystal but I had some trouble making it work. The solution came from this document about crystal oscillator circuits that describes different circuits depending on the crystal frequency. Here you have the schema and a picture of the circuit:

9600Hz oscillator circuit

9600Hz oscillator circuit

Prototyping it in a breadboard.

Prototyping it in a breadboard. The DSO Nano is out of focus but shows a 9.60kHz signal.

PCB etching at home using vinegar

PCB etching is another big topic in the electronics DIY world. It’s something every electronics tinkerer ends up trying sooner o later. Even thou it’s a fairly simple procedure it requires some self confidence (or bravery) since it involves strong, smelly and hazardous chemicals.

Any etching procedure you read about can be described in 5 different steps: designing, transferring, etching, assembly and reuse or disposal. For every one of these five steps there are different options and there are thousands of web pages with instructions, recommendations, how-to’s… well, this is yet another one of those pages :)

First some background: I’m a newbie to etching (like that, in bold). I think it’s a natural evolution from breadboard prototyping, to semi-permanent perfboard or stripboard projects, to etching your own circuits at home, to sending your designs to a PCB fab house. But I was somewhat concerned about using toxic, corrosive, skin-burning acids like muriatic or environmentally problematic etchants like Ferric Chloride at home.

Then I found this post about Cheap home PCB etching with vinegar, and I thought I should definitely try it. Googling about it you can find half a dozen very good tutorials on the technique. I reckon I have no previous experience on etching so this is not going to be a “voice of the experience”-like tutorial, but a peer to peer one. If you have never etched your PCBs at home but you are willing to give it a try you are like me two weeks ago. Then maybe these words about the things I’ve tried and the mistakes I’ve done could be useful to you.

The etchant biting the copper

The etchant biting the copper


Let’s imagine you have some project already breadboarded and it works great. You probably already have an schematic of the project (you should!) made with Eagle, KiCad, Fritzing or any of the cloud-based EDA apps (Upverter, Circuits.io…). I am not going into the “which tool is better?” discussion, there are dozens of sites comparing them. Whatever tool you use, make sure it has a PCB editor or board layout design feature.

I use Eagle. Because it’s the one I have more experience with and because Sparkfun has great tutorials on creating schematics and board layouts with Eagle. I’m curious about KiCad and Upverter and I will eventually try them out but for now I am on Eagle.

My main source of information for PCB designing has been the aforementioned tutorial by Sparkfun, so read it. It is an end-to-end tutorial on schema and board layout design using a real case to explain the basics of a PCB, the techniques and tools involved and some useful tips about the software.

I will just stress three points here:

  • Use the 50mil rule: 50 mil wide traces and 50 mil clearances (for us SI guys 50mil is 50milli-inches or 1.27 millimetres). Once you have repeated the process several times taking note of the results you will probably be able to go down to 20 or even 10mil traces with home etching. But 50 is a good starting point. Trace width is critical when using high loads. This trace width calculator will help you decide the minimum trace width for your high current lines.
  • Leave enough copper around the pads to allow the solder to make the joint. Headers or diodes use to have thicker leads and you can use wider circles for them but be careful to leave enough clearance between them or they will eventually create copper bridges. For connected pads the trace itself can be used to solder the component, but you might also have non-connected pads. Using rectangular or elliptical pads can help. Some SMD components (like headers, opamps,…) are not hard to solder and using them removes the need to drill part of the copper off so they might be a good option as well.
  • If you will be using one side copper clads the try to draw all your traces on the back layer. It might not be possible, in that case you will have to wire the top layer traces.
  • Use copper pours for ground planes. Actually it has not to be ground but that’s the usual. Only if you are using antenae or high voltages a ground plane might not be a good idea. For the sake of home etching it has one great advantage: less copper to remove, and that means faster etching and less residue.
    Without ground plane, a lot of copper has been removed

    Without ground plane, a lot of copper has been removed (version 1.0)

    With ground plane, much less copper to remove

    With ground plane, much less copper to remove (version 1.1)


That is: transferring your design onto the PCB. The most common way is using an iron to transfer the toner printed on a glossy paper with a laser printer to a clad of copper. Again, I have never use it but I have the feeling that there are too many uncertainties about this method: the type of paper, the toner quality, the copper rugosity, the iron heat and time. It looks like you will go through a long trial and error process until you get it done right.

Using photosensitive clads of copper seems easier. You will need:

  • A photosensitive clad the size of your design or bigger (between 1 and 2€ for a 60×80 clad)
  • Transparency paper (this is costly, 80 cents the sheet of paper)
  • A laser or inkjet printer.
  • Positive photosensitive developer.
  • A (polystyrene) tray.
  • Safety glasses, dust mask and gloves.
  1. Print several copies (3-4) of your design to a transparency in high quality black and white. To get the circuit image from Eagle I use an Eagle ULP by Niels Springob to export the bottom, pads, vias and holes layers to SVG (get it here). Then I open the file with Inkscape to do the final touches: transform it to B&W, adjust some widths and pads and add a frame around the design. The frame will match the size of the board. I then group it all and make 3 or 4 copies side by side and send it to the printer. I don’t have a laser printer but an inkjet printer works just fine.

    Three in a row, ready to cut and stack

    Three in a row, ready to cut and stack (these are version 1.1)

  2. Cut them by the frame lines and stack them one by one using transparent tape to make sure they keep aligned. The goal is to prevent UV beams to pass through the dark parts, so the darker the better.

    Printed circuit in a transparency with and inkjet printer

    Printed circuit in a transparency with and inkjet printer

  3. Cut the photosensitive board to the size of the frame you have drawn in step 1. Depending on the wrapping this can be easy or not. I have used two different brands: one has a dark sticker covering the photosensitive side of the board, you can safely cut the board with the sticker on. The other comes wrapped in a black cardboard envelope ad if you want to cut it you have to do it in the dark. Here the goal is, again, to have less copper to etch.

    Several types and brands of photosensitve copper clads

    Several types and brands of photosensitve copper clads

  4. Now go to a dark room and prepare a sandwich. My way is a sheet of plywood, the clad of copper with the photosensitive side facing up (peel off the protection sticker first if any!), the stack of transparencies and an acrylic sheet. Everything held in place with a pair of sergeants. Take your time and check twice the orientation of the transparencies. Since they show the bottom layer the printed side should touch the clad.

    ON my second test I wronged the photosensitive side and ended up having a nice silkscreen

    On my second test I wronged the photosensitive side and ended up having a nice silkscreen

  5. Now it’s time for a sun bath. Ten minutes of direct sun works OK for me. Off course you can use those UV boxes but they are really expensive and some people have reported than using a regular fluorescent lamp (daylight range, about 5000K light temperature) works just as fine. Sun stays as the cheapest solution, thou. One advice: make sure the sun beams fall perpendicular to the clad, otherwise you will have some shadow due to the transparencies further from the clad that might prevent the copper in the clearances to be exposed to the acid, potentially creating short-cuts in your circuit. If that happens, like it did to me, you can use a cutter or the Dremel to cut them.

    A stack of four transparencies already under the sun

    A stack of four transparencies already under the sun

  6. In the meantime, prepare the developer solution. You can try to create yourself the solution at home using Sodium Hydroxide 1% (ten grams of NaOH pellets in a litter of pure water). Caution: Sodium Hydroxide is very caustic, it can burn your skin and you will have a very bad time if it splashes in your eyes. So this is the point when you have to put gloves, dust mask and glasses on. Some say the result quality is very sensitive to the concentration so I went the safe side and bought a bottle of developer (“revelador de placa positiva” in spanish) at the same store where I bought the photosensitive clads (3.80€ to get 3 litters of solution).
  7. The 10 minutes countdown is finished and you are back to the dark room with the clad. Now place it in the developer solution and agitate it (gloves on!). In a few seconds the traces will start to show up. Agitate and check every 10 seconds until you see no change in the contrast between the exposed and non exposed zones of the clad, the traces should be clear and well defined. The whole developing process takes about one minute. If you are using thin traces be careful not to let it too long in the developer or they might get damaged.
  8. Remove the developer from the clad surface with running water.

    The photosensitive clad just after developing

    The photosensitive clad just after developing

Now you have a ready-to-etch clad. The copper in the zones exposed to the sun beams will be removed by the acid in the next step.


Here it comes the critical and worrisome step. But it’s really easy. You will need:

  • Vinegar (acetic acid). I use cleaning vinegar, 7% acidity, 0.70€ the litter at the local supermarket)
  • Hydrogen Peroxide. Easy to find at any drugstore, the one I use is 3% peroxide in pure water, 1.20€ 1/2 litter.
  • Kitchen salt.
  • Acetone, nail polish remover.
  • Polystyrene tray. I guess any tray will do as long as the vinegar does not degrade it.
  • A brush. I use a teeth brush.
  • Plastic tongs to grip the PCB in the solution.
  • Again safety glasses, dust mask and gloves.
  1. Put your glasses, dust mask and gloves on. OK, this is not Hydrogen Chloride but it is still an acid and the residue is Copper Acetate which is toxic to humans and very toxic to plants, even in low concentrations.
  2. Prepare a 50-50 solution of vinegar and hydrogen peroxide in the tray and place the clad in the solution
  3. Heating the solution helps a lot. I place the tray with the solution in a bigger tray with hot water that I change every 10-15 minutes. Some people pre-heat the vinegar (alone) in the microwaves before adding the peroxide. I guess you could also use some double boiling technique or maybe a peltier cell bellow the tray to keep the solution warm.
  4. Kitchen salt also helps. With the clad in the solution keep pouring salt with a coffee spoon until the fizzing stays by itself.
  5. Brush the clad every few minutes to remove the Copper Oxide and Copper Acetate. You will notice that by the end of the process you can actually remove the remaining copper layer by brushing it off.
  6. If the fizzing seems to recess, add more salt. If that still doesn’t work add more vinegar and Hydrogen Peroxide. I always start with a 50-50 solution but a tend to add more vinegar than peroxide after that. Still trying to find the right ratio.

    The etchant bitting the copper

    The etchant biting the copper

  7. Once all the copper has been removed clean the board with running water and save the solution (see “disposal” below). Then remove the resist with cotton soaked in acetone or a brass sponge.

    Nice copper traces after etching and cleaning

    Nice copper traces after etching and cleaning

The process is very slow compared to etching with stronger acids but you can easily etch a medium size clad within an hour without complex tooling (bubble machines, heaters,…). The key is to keep it bubbling:


Drilling and soldering looked to me like being back to the comfortable zone. But I was wrong. You better have a very steady hand or some tooling aid. A drill press will ease thing a lot. I don’t have one so I suffered for what I’ve named the SDT or Syndrome of the Dancing Tip.

This is the best I could do in my first drilling test

This is the best I could do in my first drilling test

My not-so-good solution is to use the 565 Multipurpose Cutting Kit by Dremel leaving the nut loose to move the drill up and down. It still has some horizontal movement but I can safely drill in the copper pads.

Anyway, what you will need for sure is:

  • A drill with tiny bits (get three or four from 0.5 to 1.5 mm)
  • Again safety glasses and dust mask.
  • Solder iron and lead-free solder

There is not much to say. Maybe some tips:

  • Inhaling copper dust is really really bad on the long term. It can produce a wide spectrum of lung diseases and cancer. So always use a mask when drilling copper. Same for soldering fumes. Wash your hands when done.
  • If you can, avoid hitting the clad with the drill bit shank (where it gets wider). If you do you will get a nice volcanoe-like hole. Not something to throw your PCB to the trash but certainly ugly.
  • Test that your components fit in their holes. You will probably have to widen some of them.

    It took some time to accommodate the headers in their new home...

    It took some time to accommodate the headers in their new home…

  • I have not tested yet, but using Flux (Kontakt SK-10, for instance) on the copper side of the board before soldering should ease the process and flux doubles as protecting coating. You can also clean it with Isopropyl Alcohol before applying flux.
  • Have a copy of your schema and board layout at hand. Mind there is no silkscreen and it’s always a sinking feeling when you solder your component the other way round.
The final result is quite nice

The final result is quite nice


Please don’t pour it down the drain. Yes, wastewater treatment plants are there but it’s also our responsibility. Your first option is reuse. An old solution is yet slower than a fresh one but it can still bit some copper away. Once it’s no longer useful to etch you can dispose it in two ways:

  • Using baking soda (sodium bicarbonate). Add baking soda to the solution until it becomes cloudy and turns green. The result (Cupric Carbonate and Sodium Acetate) does not dissolve in water so it’s less harmful to the environment. You can then seal it in a plastic container and carry it to the closest disposal unity or place it in the trash.
  • Evaporating the etchant leaving it under the Sun. The result will be greenish crystals of Cupric Acetate which can be safely trash or even better: burn them in a camp fire to get nice green flames!

Whatever method you use manipulate the solution and the results using gloves.


Learning is a never ending work in progress. After the first 3 iterations I discovered a fatal error in the original design: the connector for the led matrix was upside down. The board is still usable with the help of some wires to fix the mistake but a new version is ready for the vinegar tray!

Fixing the mistake in the matrix connector with some jumpers

Fixing the mistake in the matrix connector with some jumpers

Version 1.2 of the board

Version 1.2 of the board


I’m adding here some web-references to pages I’ve checked during these last weeks.

Rentalito goes Spark Core

The Rentalito is a never ending project. It began as a funny project at work using an Arduino UNO and an Ethernet Shield, then it got rid of some cables by using a Roving Networks RN-XV WIFI module, after that it supported MQTT by implementing Nick O’Leary’s PubSubClient library and now it leaves the well known Arduino hardware to embrace the powerful Spark Core board.

Spark Core powered Rentalito

Spark Core powered Rentalito – prototype

Spark Core

The Spark Core is a development board based on the STM32F103CB, an ARM 32-bit Cortex M3 microcontroller by ST Microelectronics, that integrates Texas Instruments CC3000 WIFI module. It makes creating WIFI-enabled devices extremely easy.

The main benefits of migrating from the Arduino+RN-XV bundle to Spark Core are:

  • Powerful 32 bit microcontroller
  • Reliable WIFI connection (auto-reset on failure)
  • Smaller foot print
  • OTA programming (even over the Internet)

And of course it’s a good opportunity to add a couple of features: temperature and humidity sensor and IR remote control to switch the display on and off or fast forward messages.

MQTT support

Spark forum user Kittard ported Nick’s MQTT library to the Spark Core. Since the Spark team implemented the Wiring library for the Spark Core it normally takes very little effort to port Arduino code to the Core.

The library supports both subscribing and publishing. You can subscribe to as many topic as you wish and you get the messages in a callback function with the following prototype:

void (*callback)(char*,uint8_t*,unsigned int);

From here it’s very easy to just store the last value for every topic we are subscribed to, along with some metadata like the precision or the units.

Publishing is even easier. A simple call to publish method is all it takes:

bool PubSubClient::publish(char* topic, char* payload);

DHT22 support

DHT22 support is provided by another port, in this case from Adafruit’s DHT library for Arduino. Forum user wgbartley (this guy is from the Spark Elite, people that basically live on the Spark forums) published the ported DHT library for the Spark Core in github.

Recently another user (peekay123, also from the Elite) has published a non-blocking version of the DHT22 library. It uses interrupts to trap transitions on the data line and calculate timings and a state machine to track message structure. The previous one performs all the calculations in a single method call and disables interrupts to keep control over the timing.

HT1632C dot matrix display support

This one I ported it myself from my previous fork of the original HT1632C library for Arduino by an anonymous user. You can checkout the code at bitbucket (Holtek’s HT1632C library for the Spark Core). The library supports:

  • 32×16 displays
  • drawing graphic primitives (points, lines, circles,…)
  • drawing single colour bitmaps
  • printing chars and texts in fixed positions or aligned to the display boundaries
  • red, green and orange colours
  • 23 different fonts
  • 16 levels of brightness
  • horizontal and vertical scroll

It’s still a work in progress but it’s almost in beta stage.

IR remote support

I had an old-verison Sparkfun IR Control Kit (check it here) laying around and I thought it was a good idea to have a way to switch the LED display on and off. I struggled for a couple of days with the IRRemote library for Arduino (like some others) but finally I quit and I decided to implement my own simpler version.

The approach is very much the same as for the DHT22 non-blocking library before: an interrupt-driven routine that calculates and stores pulse lengths and a state machine to know where in the decoding process we are.

void ir_int() {

    if (ir_status == STATUS_READY) return;

    unsigned long now = micros();
    unsigned long width = now - ir_previous;

    if (width > BIT_1) {
        ir_pulses = 0;
        ir_status = STATUS_IDLE;
    } else {
        ir_data[ir_pulses++] = width;
        ir_status = (ir_pulses == 16) ? STATUS_READY : STATUS_DECODING;

    ir_previous = now;


Then in the main loop we check if the message is ready, perform the corresponding action and reset the state:

if (ir_status == STATUS_READY) {

    if (millis() > ir_timer) {

        int key = ir_decode();

        switch(key)  {
            case 10: next(); break;
            case 18: previous(); break;
            case 34: brightness(1); break;
            case 42: brightness(-1); break;
            case 2: toggle(); break;
            default: break;


    ir_status = STATUS_IDLE;
    ir_timer = millis() + IR_DEBOUNCE;


The decoding is a matter of translating pulse lengths to bits.

int ir_decode() {
    unsigned int result = 0;
    for (byte i = 0 ; i < 16 ; i++)
        if (ir_data[i] > BIT_0) result |= (1<<i);
    if (REMOTE_CHECK != (result & REMOTE_CHECK)) return 0;
    return result >> 8;

It’s very important to add some noise reduction components around the IR receiver, otherwise you will only get streams of semi-random numbers every time you press a key in the remote. You can check the datasheet for the specific model you are using (for instance, check the “application circuit” in the first page of the TSOP382 IR receiver Sparkfun sells) or check the schematic in the next section.

Schematic and layout

The project is mostly a software Frankenstein (well, not quite so, you can check the code in bitbucket). The hardware part is pretty simple. You can get all the information you need from tutorials and datasheets. My only advice is to add noise suppression circuitry around the IR receiver.



Next steps

I’m ready to try to do my first home etching experiment and this project looks like a good candidate. The first step was to create a board layout using Eagle. The board should be one-layered and the form factor the same as the Arduino, so it could use the same holes the Arduino did in the display frame.

And this is the result:

Board layout

Board layout

As you can see it’s mostly one-layered, I will have to use one wire to connect the DHT22 sensor VCC pin. The layout looks promising and I’m eager to see the final result. Hopefully I will post it here soon.

Thanks for reading!

Light table: a family project

My older daughter (she’s 4 years) loves drawing. My younger daughter (she’s 1 year old) loves doing whatever her sister does. So last Christmas the three wise men carried a new kids table for them. The “old” one was quite abused already. You get to know how tough things are when you let a kid play with them for a while… Anyway we had already thought about a second life for it.

The poor old IKEA Lack Table

The poor old IKEA Lack Table

Some time ago I stumbled on a great “instructables” by Mr. Chutney where he repurposed exactly the same IKEA table we had as a light table. It was very easy and the light table was going to be a great fun for our daughters so I ordered a methacrylate board from a local supplier and a really cheap LED Strip from Amazon Marketplace (mine included a 12V 5A EU-plug power supply) and waited patiently for them to arrive.

5 meters 5050 RGB Led Strip with remote & power supply (courtesy of Amazon.es)

5 meters 5050 RGB Led Strip with remote & power supply (courtesy of Amazon.es)

Bill of Materials

  • An IKEA Lack Table (6.99€)
  • Am 5 meters RGB 5050 LED Strip, with remote and power supply (I bought mine for 15.50€)
  • A 550x550mm methacrylate board, snow-translucent (44€ from local supplier). Have them drill 4 holes in the corners for you: 5mm diameter, 30mm from each side.
  • 4 20x5mm, round head, screws to fix the methacrylate sheet to the table (some cents)
  • A 2.1×5.5mm DC barrel jack for box mounting like this one (0.74€)
  • White glossy paint (optional but recommended)
  • Tooling (a Dremmel to cut the table although a cutter might do, a paint brush, masking tape, wires, ruler, pencil, safety glasses and a dust mask…)

Yep, that’s just about 67€ of materials. Not bad if we compare it with the 300€ of the cheapest ones you can find on the Internet.


Since Mr. Chutney article is very explanatory I will only comment the differences in my approach. He used two sheets of translucent material: a 8mm clear acrylic sheet that fits in the table hole and a second thinner 3mm “opal” one over it without covering the entire table surface. To do so he needed to recess the solid table legs in the corners to hold the first acrylic sheet which should fit exactly the hole dimensions.

Since “exactly” is too precise for me I planned a simpler solution. Besides, I wanted the translucent sheet to cover the whole surface of the table so I just cut the hole leaving 50mm each side (the size of the legs) and bought a 550x550mm translucent sheet with four holes where I would screw it to the solid legs. You can order the methacrylate sheet with rounded edges for a better finish but laser cut finish was OK for me.

Dremmel is my friend

Dremmel is my friend, sorry tindie…

Safety first

Safety first (yep, that’s me)

Use a screwdriver to lift the wood, it's glued to the underneath cardboard.

Use a screwdriver to lift the wood, it’s glued to the underneath cardboard.

Under the thin wood surface of the table there is a pattern of cardboard that provides consistency to the table while keeping it light. The cardboard is easily removable by hand leaving a nice space under the remaining table surface for the LED strip controller.

The cardboard patterm

The cardboard patterm

Removing the cardboard

Removing the cardboard

Once I had the interior clean I painted it with white glossy paint. As Mr. Chutney says it does make the difference. This was my 4 year old daughter task and she enjoyed messing with the paint (maybe too much).

The insides of the table painted white. My daughter painted too much...

The insides of the table painted white. My daughter painted too much…

Then I drilled a hole the size of your DC barrel jack near one of the legs. The barrel jack is a neater solution than having a cable hanging from under the table. My LED strip came with a short 2.1×5.5mm pigtail which I soldered to the terminals of the jack but you can just wrap the wires to them and use some glue, electrical tape or a small stretched plastic tube to keep them in place.

It was time to run a quick test to see if everything was OK. I connected the strip and the short power cable to the controller and the power supply to the jack under the table, pressed the ON button in the remote and the LED strip shined white. Good.

Next step was to plan how to stick the strip trying cover the whole surface evenly to have a uniform light. I tried a couple of approaches starting from the end near the controller. The final one is a “S” pattern but now that I’m thinking about it again I will probably try a new one next time I open the table: a squared ellipse going outside in. The wood surface is rough and chances are your strip wont stick long. I used some tape to keep it in place.

The LED strip in place

The LED strip sticked to the wood with the help of some tape.

I used adhesive white paper to hide some scribbles and stickers on the remaining surface of the table. Using some masking tape and painting it white would have been also an option.

Detail of the barrel jack from inside

Detail of the barrel jack from the inside

The jack from under the table, with the power supply plugged in.

The jack from under the table, with the power supply plugged in. What’s the other hole for?

Finally I screwed the methacrylate sheet to the table with four 20x5mm round head screws.

The table with the methacrylate sheet

The table with the methacrylate sheet without the screws while doing some final tests

The LED strip I used is an RGB one with 5050 chips. You can’t control the LEDs individually (they are not addressable) but you can set the whole strip to whatever color you want. The controller has a 2.1×5.5mm barrel jack for power input, a 4 wire connector for the LED strip and an IR receiver that reads the codes from the remote even through the sheet of methacrylate. So you just point to the table and select the color you want and voilà. My daughters love it!

The LED strip controller

The LED strip controller. The black thingy at the end of one of the cables is an IR receiver


This is a low-tech project but a very fun one. If you have kids they will love this table. My little one (1 year old) likes playing with some colored rounded glasses we have, spraying them over the table and changing the light color with the remote to see how the glasses change. The older one uses it to copy drawings or x-ray negatives and it doubles as a chillout/mood light for their bedroom!

X-ray negative on the light table

X-ray negative on the light table

The only issue I had was with the brightness control and the effects. Although the remote has a couple of buttons to rise and lower brightness it simply doesn’t work. And three out of the four color effects you can play with are just too psychedelic for my taste (strobing light, flashing,…).

But maybe I can do something about it… :D