zaterdag 23 mei 2015

Oled fake plant

This geocache waypoint is supposed to really blend into the background. The fake plant is available in many geocache webshops and it comes in many different shapes. Not only the container may vary, you can also pick a plant that will suit its purpose best in the setting you have in mind. Off course, when you buy it, it comes with a small logbook and a tiny pencil to log the cache.

But my plans are usually a bit more nerdy so this thing was the ideal container for a design I had actually laying around for more than a year now. The major problem was that I just could not get ANY pixel light up in these Oled displays (dutch) that I bought in a major shopping mood.

Recently I made some serious progress in that area, especially with connecting them to Attiny 45 and Attiny 85 microcontrollers. I still use the Arduino environnement to program this, it's not necessary in this design but the vast library collection keeps me hanging on to this platform.

Anyway, this is the final result and I'm really pleased with it. I think the logo is really cool and I added an extra container to keep it a bit safe in the soil and even more important: its second container has some strong magnets glued in. These magnets will activate the magnetic switch on the lower side of the container with the display inside.

This is how it works:



Soldering

I've been improving my soldering skills for some time because these designs really need it. The Attiny 85 on this pcb is the really really small QFN package. It's only 4 by 4 millimeters in size, and it comes with 20 pins, 5 pins on each side of the chip.

The 'normal' SMD version has actual pins you can touch with a soldering iron, 1.27mm apart. This package was meant to be used with a reflow oven. There's no actual pins on the side, only on the bottom of the tiny chip. Instead of 1.27 mm , they're only 0.5 mm apart.

Now I don't have a reflow oven and I'm not planning on buying one in the near future. So I had to do this with a regular soldering iron. I bougth a soldering station with a tiny J-shaped tip and that really does the job. I actually heat the pcb pads instead of the ones on the chip. First of all, you really need a station and not a normal soldering iron. The pins on the pcb are so tiny that a slight touch of even a 25 Watt soldering iron just wipes away the small tracks.

My pcb software (freepcb) did not have a layout for this chip, so I took the datasheet and created my own. Its pads are only 0.25 by 0.80 mm. In real life, this is a really really small amount of copper and especially those pads that are not connected immediately detach from my pcb when you overheat them. With the soldering station and je J-shaped soldering iron, I keep the heat below 300°C and never had that problem again. It still takes some time, some boards and even a few chips before I got my first one really working. I have to kinda guess where the pads are, solder them one row at a time and then look through a microscope to see if they are aligned at all four edges. That took some time and practice.

PCB design
There's a tiny problem with my pcb designing technique. I used to design my own pcb, print two copies on a transparent sheet with a laser printer and glue them on top of eachother. That's a really cool way of making a 100% black pcb design which never fails. If your laser printer would leave out some tiny black dots because your room is a bit dusty (which nerd room isn't?), that does not cause any problem because you have a backup sheet on top. The chance of your printer failing to do its job on the exact same dot twice is almost non-existent.

The problem is: you have to get both sheets on top of each other 100% aligned. In this pcb design, the smallest distance between pads is 0.2 mm. It's just not humanly possible to get this design aligned on the whole sheet (I print at least 4 or 5 pcb's on one sheet, that's still a small board).

So I decided to skip that step (so only use one sheet) and try to work through the problem of the UV light touching the photoresist pcb at places that I can't predict. It worked out pretty well, it's now a combination of three things:


The etching tank gives me a 100% control over the etching process. This is SO important when working with these tiny pcb designs. You can see the etching process happening before your very eyes, which makes it easy to get the pcb out exactly one minute after you see the image appearing. When I think it's done, I wait one extra minute. When I look under the microsope, I can see that I need this minute to completely get all copper off, if I wait another minute, some existing 6 mils traces (= 0.23 mm) will start to dissolve. The etching solution actually runs under the copper pads after a while.




As you can see, it works out pretty well.

Only this one design (out of five) had a minor defect.

I do have to check them visually before soldering, measuring them out is just too hard.





The 14 pins connector of the Oled display was also a problem. The freePCB software can't handle smaller distances than 0.1 mm. The pads are 0.625 mm apart, which makes it impossible.

So I just created my own 14 pins connector with 0.60 mm spacing, and every 4 pins I add one at 0.70 mm. If you look in detail, it looks odd, but in real life it's just about perfect (note that the picture is a 15 pins connector from another display, 0.65mm apart, skip every 2 pins, but you get the idea, right?).


Software design

As I said, it's actually an Arduino sketch which makes things happen here. I'm not putting any code here just because I don't have one single working all purpose solution. I'll be happy to mail some code if you're interested. But there were a few major obstacles.

First off all, most of the small Oled displays on this blog (and anywhere else) are driven by an I2C interface. That's a bit of an issue when using Attiny 85 chips, because these chips don't really support the interface. They do have some basic pins that can act as an I2C interface with an extra library (I use TinyWireM , M stands for Master).

Since I only have 8kB of program memory, there's just no way to use a library to drive the display (all my monochrome Oleds have a SSD1306 chip). That means I had to write my own code. It basically sends existing bitmaps that are hardcoded into program memory to the display. I actually wrote the whole Verdana 12 alphabet (uppercase and lowercase) in MS paint and copied all characters one by one. I just had to make sure my bitmaps are a multiple of 8 in height, since I'm writing bytes vertically to the display. I did the same thing with the numbers in Verdana 28. As a result, I get a nice readable font of 16 pixels high (so two lines on this 128 x 32 display) and really clear and big numbers to display coördinates of 32 bits in height (one scrolling line on this display).

One definition of one charcter would look like this:
The PROGMEM keyword is very important, it keeps this static data in program memory, otherwise it would be stored in the SRAM of the Attiny chip, which is only 512 bytes big. Its program memory (flash memory) is 8kB (see Arduino link about memory usage).

The array represents a bitmap of the character 'm' , font Verdana 12 , copied to a bitmap of 13 pixels width and 16 pixels height. This nice tool does the conversion of a monochrome bitmap to an array style notation like we need (beware of the different variable declaration that is generated).

As for now, my software only allows Verdana 12 characters to be displayed with Verdana 28 numbers. An Attiny 85 has some extra space available for a logo, the '45 does not. It even crashes when I write more than 5 lines of text in total (tricky: the compiler never says it's out of memory when adding arrays to your program memory, it compiles perfectly and then crashes once and a while. Very amusing. Not.). Although this may seem a bit of a limitation, I think it's just awesome that a tiny controller can do these amazing things with a bit of code :)

Geen opmerkingen:

Een reactie plaatsen