Posts tonen met het label electronica. Alle posts tonen
Posts tonen met het label electronica. Alle posts tonen

woensdag 19 augustus 2015

Birdhouse Geocache part 1

I'm planning a new geoache and the idea for the final stash is to place an ammobox with a lock. This way I can make sure that not all visitors who find the box, will be able to open it. In fact, if you don't know how to achieve the key, you won't be able to reach the logbook in the box.

Next to the hiding place, a birdhouse will hide the key. It will take some effort to make this failsafe, but that will not be the main issue. The key will be released by some intelligent circuitry that understands your "secret knock". I'm thinking something like: knock x times, wait a bit and then y times. With x and y being some numbers of the last few waypoints.

The main issue is making the motor failsafe, and this is my first effort. I think the result is great, it's strong and fast enough to let the key come out of the birdhouse fast enough (12 seconds down, 17 seconds up, the 'up' speed needs more torque and has a lower pulses per second).

I'm using a bipolar stepper motor with reduction gears. The 24 volts will be supplied by a DC-DC convertor that boosts one or two 18650 batteries (so 3.7V or 7.2V) to 24 volts. I tried one model and it works great. I can easily draw 2A current out of one battery, or 1A out of 2 batteries to make a strong enough 24V power supply that should last for 2 to 4 hours 'motor movement'.

I made this construction with a 10cm shaft holding a spindle that winds up a small chain with a key attached at the end. The shaft can rotate freely due to the two ball bearings. The rigid shaft coupler connects the shaft to the motor. This video shows how it works:

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 :)

zondag 26 april 2015

7-Segment kokertje

Ik heb geprobeerd om mijn 7-segment potje in een andere vorm te gieten. In het filmpje zie je de metalen kokertjes die je vaak terugvindt als micro geocache, er zit dan een klein logboekje in of je kan er een papiertje met coördinaten in kwijt.

De uitdaging was hier vooral dat de batterij veel kleiner is en ik toch de symbolische grens van minstens 100 logs op één batterij wil behouden. Met het originele potje en dus een grotere batterij was dat geen probleem, tot nu toe heb ik nog geen platte batterijen gehad in dat soort potjes.

Om dat ook nu te vermijden is het contrast opnieuw wat lager (ik heb het ooit verhoogd in de originele potjes, maar dat verbruikt meer stroom) en de duurtijd van één weergave is verkort tot 30 seconden. Verder draait de klok van de microcontroller acht keer trager, ook dat spaart wat energie.

Ook nu is er een optie voor een kwikschakelaar maar dat was minder praktisch (te groot), dus deze wordt opnieuw geactiveerd met een magneet.



woensdag 17 december 2014

MP3 potje 3.0

Oef! Het is dan toch eindelijk gelukt. De hele toestand sleepte al enkele maanden aan, één van de belangrijkste redenen is het feit dat onderdelen uit China lang onderweg zijn, maar mijn opzet om mijn origineel MP3 potje te verkleinen tot het in een potje van glucosestrips past, is gelukt.

Het resultaat is dus klein, maar vooral heel erg zuinig. Niet enkel voor de portemonnee (enkele dollars onderdelen) maar vooral het stroomverbruik is nu 10 tot 20 keer lager dan het vorige model. Ik weet nog steeds niet precies hoe het komt, maar wel waarom het nu dus heel goed is. Ik gebruik geen versterker, geen SD-kaartjes meer en alles kan nu op een knoopcelbatterij tot 20u muziek maken.

Let wel, dat is een theoretische berekening (het ding verbruikt slechts 6 à 7 mA stroom, met oortjes zo'n 10mA) maar één praktijktest gaf al aan dat het zeker 7 uur is. Dan was de batterij leeg (gezakt van 3.2 naar 2 Volt) en de spraak was niet meer verstaanbaar (hij was er nog wel). Hoe lang het met een volle batterij duurt (dit was een gebruikte) weet ik nog niet, maar dat wordt snel duidelijk. Ik heb ook knoopcellen in de aanbieding die 550 mAh capaciteit bezitten, de huidige slechts 180. Dat is dus desnoods nog een optie.




Technisch

De Arduino sketch werkt in de microcontroller en haalt 8-bit mono samples uit het WinBond SPI flash geheugen van 4 of 16Mb. Ik soldeer voorlopig enkel de 4Mb chips, omdat ik daar al meer dan 4 minuten geluid op kwijt kan. Ik haal maximaal een samplefrequentie van 15kHz en dat is te wijten aan de vreemde opzet van het RAM-geheugen. Elke byte die je door de D/A convertor hoort, moet uiteraard eerst uit het geheugen opgehaald worden. Maar daarvoor moet ik seriëel eerst een commando en drie adresbytes sturen, dan ontvang ik één byte antwoordjes. Je zou per pagina kunnen lezen (en dus veel hogere snelheden halen), maar dat is geen optie omdat er dan geen constante stroom aan bytes naar de D/A convertor loopt. Daar komt bij dat de Attiny85 microcontroller zonder kristal werkt om energie te sparen, en dat halveert de snelheid.

Dat stelde wel enkele praktische problemen. Een samplefrequentie van 15 kHz kan ik niet creëren. De meeste gratis software kan wel downsamplen naar hele factoren, dus van 44 kHz naar 22 kHz, maar een exacte match kon ik niet maken (het is in 't echt 15250 Hz gemeten op de oscilloscoop). Die software heb ik dus zelf geschreven in Delphi XE.

Verder moet ik de samples van de PC in de geheugenchip krijgen en ook dat is niet simpel. Ik wil dat namelijk altijd kunnen, ook als de chip gesoldeerd is, en ik heb geen plaats voor een extra RAM-connector op mijn mini printplaatje waar ik hem mee zou kunnen programmeren. De enige optie was een seriële verbinding tussen mijn Delphi programma (dat toch al draait voor de conversie) en mijn Arduino sketch. Die geeft dan commando's door aan de RAM chip om bytes op de seriële poort (USB-poort) op te slaan.

Een derde functie die ik heb moeten programmeren is een RAM-browser. Ik moet kunnen zien wat er effectief in het RAM geheugen zit om fouten te kunnen opsporen. Ik heb mijn eerste chip al opgeblazen en hoe ie zich dan gedraagt, daar word je gek van. Effectief de golf in de RAM kunnen zien, had me toen veel problemen bespaard. Maar toen ik de browser klaar had, wist ik dus meteen dat mijn chip kapot was, hoewel je nog steeds geluid kon horen (wel behoorlijk vervormd).

Nu kan ik eindelijk mijn Rondje Vlaanderen Zwijndrecht weer online brengen. Ik kan immers dit potje overal verstoppen, de vorige verstopplaats was verdwenen, alsook mijn 2.0 potje van toen. Dat is nu ineens niet zo erg meer :)

zondag 23 november 2014

OLED Geocache Waypoint

Het eerste project is gelukt en dat is uiteraard heel fijn. Een tijdje was ik al op zoek naar goeie manieren om een Oled display te gebruiken in een geocache, maar eerdere pogingen liepen op niks uit.

Er was vooral heel wat programmeerwerk nodig. Dat komt vooral omdat ik beperkt ben in de mogelijkheden van kleine microcontrollers die ik wil gebruiken. Het doel is immers ook dat het ooit in een potje past waar ooit glucosestrips in zaten. En daar past geen Arduino in, ik mikte dus op een kleine microcontroller (Attiny 85) en een seriële verbinding naar de display. Die strenge eisen hebben me verplicht om het wiel opnieuw uit te vinden softwaregewijs, er bestaat immers geen goeie library die alles al voorgekauwd heeft en waarmee ik simpel kon zeggen: laat nu eens coördinaten zien op dat schermpje.

Hoe het dan wel moest? Tja, alle enen en nullen zelf naar het scherm sturen hé. Dat vraagt wat tijd en denkwerk en daar ging eerder al een heel weekend aan op. Dit weekend ging op aan drie ontwerpen voor de hardware waarvan dit dus het eerste is dat werkt. De volgende uitdaging is hetzelfde model van scherm, maar dan zelf gesoldeerd op één printplaatje. Het maakt alles zot goedkoop, alleen die connector solderen maakt me zenuwachtig.

Maar de verkeerspaal in mijn Rondje Vlaanderen geocache in Zwijndrecht zal binnenkort dus al oplichten met dit schermpje :)