November 23, 2009

Shift Registers are Important

I started out this week's lap looking at my options. I had a RS232 shifter board kit. Interesting, but that's mostly a bunch of boring soldering. I just received a cool new Arduino Duemilanove! Sweeter than sweet, but I don't have the required version of AVR-GCC installed (you need 4.3.3 for the ATmega328 due to a bug in older versions - I currently run AVR-GCC version 4.3.0). Compiling software is not how I planned on spending my Saturday, so nixed. The 16x2 LCD display I bought to monkey around with sounded pretty good.  Figured it should be fun figuring out how to display something childish and dirty to the little guy!

Knowing practically nothing about the display, I started with a close examination of the hardware. Nothing dramatic, besides the display screen, the only other outstanding feature on the display was 16 solder pads on the edge. To figure out which pad was for what, I consulted the data sheet - and almost fell asleep! OK, from an EE perspective, all that stuff is interesting, but I thought this was not quite the right doc to start with. Too low, like in the freakin weeds low-level. Being the impatient pragmatist, I want to see working examples and overviews first, and then later on maybe we can put a microscope on in to scope out the bit plumbing. I found better (better, I mean because I could at least identify what was useful) info on the manufacturer's sheet. Found out I have 8 data lines, power (Vcc, Vss), some adjustment inputs, register select and read/write controls, not to mention some ambiguously labeled control input called "enable" (insert Spock sound byte: 'fascinating!'). I think I may understand what most of these might do. Now was the time to dig deeper though, since I didn't have enough to go on yet.

When ferreting out more info on the unit, I discovered that the HD44780 character display seems to be a defacto standard. This means many different manufacturers make character displays, using the same basic interface. This is a good thing. Why? Well because this means I will likely never need to read the datasheet ever again, since many engineers have already done this and documented the living dogshit out of it prior to my arrival. Have I mentioned that at this point I felt all mushy and awkward toward Peter Ouwehand for having an entire site dedicated to HD44780 character displays? I'm gonna send him a fruit bastket just for saving us from that nasty datasheet. He has examples! Examples!

I jumped quickly to a linked AVR example. For whatever reason, the first thing to leap out at me was the 10K trimmer required for the contrast adjustment. Luckily, after digging through my stuff I found that my arduino kit included a 10K trim pot. Why the 74HC164 interface IC on there didn't register in my consciousness first is an utter mystery. It did eventually though. And when I finally figured out what "serial in, parallel out shift register" means I knew my day was destined for shortness. Yep, the 74HC164 takes serial input and then outputs to a parallel device. This whole time I guess I had assumed the LCD display somehow used serial I/O. I imagine the datasheet may have had this info somewhere between all the clock timing specs and register state bitmaps, but really just seeing 8 data I/O pins should have tipped me off! Hey well I do learn eventually.

Without a shift register, I was pretty much done. Ordering one right now so we can do this up later. I spent the rest of my project time soldering up the RS232 shifter board. Looking great! Except I couldn't find my dikes to snip the legs. So tune in next week! Does Chuck find his dikes? Will he also notice that the example uses a dissimilar AT90S2313 micro? Will he reread the evil datasheet and slip into a coma? Why is there a pizza in the first picture of this blog? The suspense! Have a great week, and happy hacking everyone.

No comments: