Saturday 21 September 2013

The ring cycle continues...

So back to the drawing board I went.  I knew it was very important that I kept the ring as small as possible... Anna likes dainty stuff, not big jewellery, but you need a particular size to make something useful... to use an engineering stereotype, we like building stuff that is functional rather than just ornamental.  I don't know if that's because engineers aren't good at making things pretty (not necessarily true!), but we know when something is functional... determining whether it's pretty is up to the beholder.

I figured that the maximum I could get away with was an inch square and a few mm tall (oops, forgive the mixed units)... ideally as narrow as I could possibly do.  The smallest battery I could find of suitable size with a LiPo unit of around 120mAh capacity.   The battery in the middle is quoted as 23mm square with a thickness of 3mm... that's just about tolerable.



The one on the right is tiny... but couldn't really run anything substantial.  It's about 30mAh which would be tons for a memory LCD but I was now aiming for something hungrier.  I wanted a colour OLED display so that I could display photos on the ring.  A bit of research led me to one from a company called Densitron.  I presume they get made by a far east company as multiple companies seem to badge the same display, but 96x64 pixels sounded just about enough.... in any case, I couldn't find anything else this small with a higher res!  I could put it in the portrait orientation to minimise the width of the unit, so 23mm width was still on...

It offers SPI-like and parallel interfacing.  I did fancy a parallel interface but recognised I might end up short of pins... here's it hooked up in a basic fashion using the official test board from Densitron...


Because it uses the SSD1331 controller, it offers some hardware acceleration of lines and rectangles, which is very handy when your processor is a bit weak.  However, I'd been having a think about the processor options available, and I quite fancied giving the PIC32 a go.  It features a relatively powerful MIPS based processor core at typical speeds of 40MHz or 80MHz, with more IO than you can shake a stick at... variants offer USB, Ethernet and I2S functionality.

The latter in particular might be useful for audio projects, so this might be a great opportunity to learn a new platform.  The chips are cheap enough and getting started in development should be fairly easy.  I had read of Microchip's policy of crippling the MIPS GCC compiler they distribute (disabled -O2 and -O3 optimisation), charging ~$1000 to fully remove the restrictions, but that didn't feel like a major stumbling block... I could live with -O1 optimisation to start with or if I really needed more speed, use a different compiler.

So I started off by ordering a PICkit 3 and a few chips, building myself a little development board.  I went for the PIC32MX250F128B.  This 32-bit microcontroller features a spacious 128KB (yes, a whole 128 kilobytes!) of flash and 32KB of RAM.  While it had plenty of RAM, the Flash felt like it might be a bit short for photos.. I had wanted to go with the many pinned 128D variant, in QFN form, but when I started the project they were unobtainium!  This meant I had to go with the 28 pin variant.  This was going to be tight...


I built a little prototyping board with the header, and hooked it up to the PICkit 3.  No go... it didn't seem to understand the PIC32MX250 series... it was not aware of their existence!  I tried updating the firmware but that didn't seem to help either.  Grr.  So I ended up buying a Microstick II.  Unlike the PICkit 3, this actually worked properly and recognised the chip... which is not that surprising as it was designed as a small development board and comes with PIC32 chips included, along with dsPIC, I think.


Getting a good battery life from such a chip wasn't going to be straightforward.  Unlike the lower end chips that Microchip produce, the PIC32 is a relative power hog in comparison... while there are sleep states, it isn't as advanced power management-wise as something like the Gecko controllers, which are Cortex-based.  I was aware of the Gecko, but it lacked the same degree of I/O and the whole developing package didn't seem as straightforward.

Starting at the charging side, the logical source of power to charge the lithium battery is a USB input.  A MicroUSB connector is very small and almost ideal for charging a small lithium battery at around 4.1-4.2V from  approximately 5V.  The charger chip I ended up going with is another Microchip part, the MCP73811.  I was not consciously trying to pick a Microchip part, but it is a little SOT23-5 device that is cheap and perfect for the job.  It gives you the choice of either charging at 85mA or 450mA with no resistors... from looking at the datasheet, it looked safe to leave the PROG pin floating, which defaults it to 85mA... if I ever want to use the project with a much beefier battery, I can tie it high instead.

So that's the battery charging sorted.  Now there are the requirements for the various parts.  To do that, I'd need to know what needed powering...

I hadn't decided entirely what I wanted on the ring, other than a display for photos.  Audio might have been an option, but space didn't really allow a decent speaker.  I noticed that Murata make some very funky flat piezo speakers that with a bit of work could probably produce adequate sound quality, but there wasn't really the room in the design... I had a width of 23mm and really didn't want to increase that any further.

What else... well, a microSD slot would be nice, then there would be no practical limit to the storable pictures!  With a 96x64 display, the processor would either spend most of its time resizing or the card would be mostly empty.  Hm.  While a slot could have been crammed on sticking the card out of the side, it would be tricky while keeping it to a 2 layer PCB... I didn't want to go to 4 layer not for cost reasons but for modifications... I didn't want to have to get the board remade many times so wanted to do one rev, fix the issues on the PCB itself, and then have a final rev... or in a really unrealistic world, get everything right first time... :)

Okay... so maybe not ideal.  What about an accelerometer?  Mmm... that sounds like it could be good.  It can be quite an effective control interface when done right, and they are compact and not too expensive.  I decided that I wanted to go with an analogue output one as it just felt more comfortable, and the packages weren't quite as evil... I ended up choosing the ADXL335 - this is a 3-axis +/- 3G accelerometer in a package which is only semi-evil.  They call it a LFCSP... and it's one of those blasted leadless things.  Thankfully most of the pins aren't used, and you could easily dead-bug it, but that isn't much good on a PCB.  I'd need a different approach...

In any case, the accelerometer is perfectly happy in the 2.5V to 3.3V range... great,same as the PIC32.  Looking at the OLED, that is also happy in the 2.5V to the 3.3V range.  Marvellous... looks like we're on for a 2.5V main digital rail.  There's a whole bunch of choices for buck converters with identical pinouts, but I ended up going for the TPS62205.  This is a high efficiency buck converter which looked on paper that it'd do a great job, and if it didn't, there were load of other options I could try in the same footprint.

Ah... the OLED doesn't have an integrated booster for the actual display.  From looking at the datasheet, it looks like it'll need 14V.  Hm.  Not ideal... I've not exactly got lots of room free on the PCB, so it needs to be a very small boost converter, with an equally small (and shallow!) inductor.

This time the ideal choice came from Linear Technology... a part called the LT3494.  The first thing to note about this part is that it's small.  Very small.


And all the pins are on the blessed underside... not only that, but it has a big grounding pad which you must connect.  So I did another search... and no, couldn't find anything else in a SOT23 that was quite as good.  Ah well... the only way this is really going to happen is with a hot air gun... so I bought one of the low cost Atten ones, as mentioned in a previous blog entry.  With some solder paste and a stencil, I might just stand a chance here...

Good.  So we have charging circuitry, power for PIC32, OLED VDD, OLED VCC, and the Accelerometer.  What else?  Well... if you want to use the USB on the PIC32, that wants a 3.3V supply for the transceiver module.  Okay, no problem... this will be powered directly off the USB port, so a linear LDO is fine, giving a smaller footprint than a switched mode one.  I went for a simple LP2985.

So that's the power done... what about input?  Well, a few physical buttons are definitely a good idea.  With the 28 pin package, I'm really limited for inputs, particularly given the analogue-out accelerometer, so how about a resistive divider?  Yep... sounds good.  Every button has a different pull down to ground from a known resistance to the digital rail.  Let's make it 100K to keep the efficiency nice and high.  Then the first (most commonly used, preferably) button can be 100K, next one, 50K, next one after than 25K, and so on.  The nice thing about this arrangement is that providing your A/D is not rubbish, you can get a good 5-6 buttons and also detect combinations of buttons too!  Nice.

Now there's a few buttons and an accelerometer.  But I really wanted a touch screen.  REALLY wanted a touchscreen.  The problem I found was that no-one made one this small... at least not that I could find - sure, I saw touchscreen phones with something suitably small, but they are both expensive and there'd be a chance I'd fail to reverse engineer the protocol, or just break the blessed thing, leaving me with an expensive piece of junk.

All I was after was a suitable overlay.  I could get hold of ITO film, but building a touchscreen is far more complicated than just taking a couple of sheets... you need a spacer layer as well, and then to fabricate the whole thing neatly.  It sounded like a step too far, but I thought I'd experiment anyway... I'd found a cheap watch on eBay (one of a few million you can probably get) - what made this one special is that it looked like it may have a proper touchscreen... reason being that I saw it had a calculator application, not just the whole touch left side, touch right side going on.

So I bought one... and waited... and waited.  After about a month or so, it eventually turned up...


Yep, seems to work, let's try the calculator...


Not too bad, actually!  Seems to work okay... but... mm... that's just a grid of conductive material, isn't it?  Let's have a look inside...


Simple piezo element in the back, classic epoxy bob of a processor, along with what you'd bet money on was a 32.678kHz crystal.  Let's see if we can take a peek at the actual display...

 

Okay... so a zebra connector down to the touch panel, which... yes... is a grid.  Bah.  If I followed the grid and the dimensions perfectly, I might be able to use it, but I just don't have enough IO pins for a row/column arrangement... at most I might have been able to multiplex with the accelerometer's 3 pins... so no go.  At least it was cheap... and there's always a little fun to be had reading the manuals for these things...


Not that my Chinese is anywhere near as good!

In any case, the I/O and power were finalised, so now could get on with the PCB...

No comments:

Post a Comment