StackBook part 3 - the motherboard and the screen
14 08 09 - 22:35 If you haven't been following: Part 2 and Part 1Alright, so it's getting to be about time to start moving this thing off a breadboard.
I've begun the task of soldering up a motherboard. First a 10-pin programming header was added. This is for programming, but more importantly power. A power LED was then added, but a high value resistor was used to cut back the power draw.
After putting an ATMega32 in the socket, the programming was tested and it actually works (always good). However, it had no I/O pins (yet), so it's back to the breadboard because I didn't have any to solder in. $30 of them just came from Electus and I've had to start a second box of electronics junk - I've got a _ton_ of IC sockets, pin headers, plugs, IDC connectors etc etc (and a solder sucker - the "undo" button for soldering).
Of course, we're going to need some way of outputting the data. For this we will require a screen. This came from an online electronics store in Hong Kong (like most of my box of junk, and half of the random gadgets here) - Sure Electronics' creatively-named 2002 LCD Module black character no backlight.

Reading the datasheet tells you it has a "KS0076B" controller chip. This may look obscure from the Google results - but it's also much more commonly known as the hd44780 - and that chip is in almost every character LCD out there. The Arduino library for it is called LiquidCrystal.
I didn't have pin headers at the time, so I soldered LEDs across the header, then trimmed all the legs. Works reasonably well. The key to success in electronics is always improvisation.
After making a 16-pin cable to replicate this over to the breadboard, I messed around quite a bit but still couldn't get the display to output anything. I tried inputting power to the connector on the left, bridging the solder division to enable it, but still nothing. Hmmmm. Then I re-read the datasheet and figured out that in Section 4, the parameter "VDD - V0" having a range of 4.4 to 5.1v actually means that this voltage is negative relative to VDD. In other words, that pin is to be provided with -0.1 to 0.6v for a 5v input. Since 0 is within that range, I just tied the pin to ground (I should use a 10k potentiometer to set contrast, I'll rewire it when i have one). And suddenly the screen came on. After a bit more fiddling, it even displayed something!

I wired up the 16-pin ribbon cable before I'd read the specs for the LCD though. You actually don't need all 16 pins. Read the datasheet for further details: but in short, pins 1-6 and 11-14 are all you really need. So I split the cable into 6 and 4 pins, then crimped a 16-pin connector with them in the right place. After some messing around, it works!
The point of this was so that I could put a smaller 10-pin header on the motherboard instead but still have the LCD work. Which I did - and put it in the top left, which by necessity, is closest to port A. Unfortunately this is the analog input port... but oh well. It's closest, and there are still two analogue input lines available. I also wired the pins into them in the order for which it is physically easiest - it just took a bit of multimeter poking to figure out what was what so I could tell the software what went where. One more pin was saved from the AVR by simply grounding the R/W line - we don't plan to read from the LCD display. I am told by a friend of mine, though, that reading back from it is useful because you can check the busy flag and slow down the data transfer if it's not ready, but this display seems to cope fine. YMMV.
Anyway, it works (which is always good):

And a close-up view:

I think I need to get a less anger-inspiring test sentence...
Trackback link: http://gm.stackunderflow.com/blog/pivot/tb.php?tb_id=126