Driving LED displays from a PIC is quite straightforward, but devising a minimum pincount approach needs a little more thought. I have standardised on the following design, which I'll describe in text rather than attempt a circuit diagram. This design will drive 8 digits and can be easily extended to larger digit counts. For 8 digits, the duty cycle is 1:8 which is about as far as I like to go, brightness will suffer beyond this point. 1. Take one PIC of any sort, even the 12C509, and connect 3 I/O lines from this to two cascaded 4094 CMOS shift registers (the lines are clock,strobe and output enable). These devices are (a) widely available and (b) very cheap. You now have a 16 bit serial latch connected to a PIC. The top 8 bits (or the bottom, your choice) are digit select, and you should set only one of these low at a time. The bottom 8 bits are then the direct drive to the seven segment displays, which are common anode types. 2. Although you could in theory drive a very low current display directly from the 4094 lines, I would use a UDN2803 octal darlington, again, a widely-available part. Connect the cathodes of the displays to this device via 68 ohm resistors and wire all the cathodes across in parallel to all 8 displays. 3. The anode of each display is connected to the collector of a small PNP transistor which can switch around 200mA, such as a BC640 (or is it a BC639, damn old age creeping up on me here) and all the emitters of the 8 transistors go to +5V. The bases go via 2.2K resistors to the top 4094 shift register. Pulling a line low turns the transistor on. 4. You might want to connect a 10K resistor from output enable of the shift registers to ground. This prevents the line floating around when the whole thing is powered up. 5. To drive the display, shift in the digit select pattern followed by the 7 segment pattern then pulse the strobe line high briefly. You must take OE high to enable the outputs, normally this is done once you've got your first data set up and clocked, so as to avoid flashes at power up. After that, you can leave OE high permanently unless you want to flash the display, for instance. Note that pulling OE low turns off all the anode drivers, so you can only flash the entire display with this approach. 6. This is not a minimum parts count approach but it is pretty cheap. Normally the displays are the dominant cost - for an 8 display setup the cost of the other parts is pretty negligible unless you can buy displays real cheap. In addition, only 3 lines are used from the PIC. You can share the clock and data lines for other purposes if needed since unless you activate the strobe line, no data is latched to the display. I have used that trick to share these lines out to an I2C EEPROM, for instance (e.g if you share the data line only, you can wiggle it around with gay abandon since neither the display or the EEPROM will do anything with it unless you toggle the associated lines). 7. The 74HC/LS165 is a useful chip to do the reverse; if I want to read n switches with only a couple of I/O lines, then this device will latch them in parallel and serially clock them into the PIC. The PIC is marvellous for serial I/O because it can do it so fast. > ---------- > From: Mike Ghormley[SMTP:mikeg@BLACKSAND.COM] > Reply To: pic microcontroller discussion list > Sent: Friday, January 30, 1998 11:07 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Driving LED's -- was Driving LCDs > > Rajnish wrote: > >Would appreciate if you can send me your asm code for the ICM7218. > > Rajnish, > > I'm afraid that I can't be of much help. I wrote the code a while ago > for a > client > and didn't keep a copy per his request. I wrote it in FORTH for the > 8051 > family, at > any rate. > > The `7218 is pretty straight-forward, though. It has four data lines > for the > digit > values (0-9 plus A-F in one mode and 0-9 plus "-HELP" in another), > plus one for > the > decimal point if you need it. It has three address lines to select > digits 0 > thru 7, > and a low-active write line. > > Just output your data and address logic and then toggle the _WRITE_ > pin low. As > I > recall, there was a small problem with timing. Mostly because I > didn't > understand > their verbiage in the specs. As long as you adhered to a low _WRITE_ > pulse of > 400nS > or more -- and keep the data/address info stable for 125nS *after* the > _WRITE_ > strobe > goes *HIGH*, you'll have no problems. Of course if you have a slower > clock > speed > then this won't even be a concern. > > The `7218 is such and expensive chip and is limited to only 8 LED's, I > want to > design > a PIC-based controller to do more LED's at a cheaper price. I am a > consultant > working away from home right now (thus the delay in responding), but > when I get > back > home (~late Feb.) I want to make a `54-based 7-segment LED controller > which does > at > least 12 digits for a clock project that I have. I could keep you > posted on my > progress if you like. > > Sorry I can't be of more help. Good luck on your project. > > Michael > > When the way of the Tao is forgotten, kindness and ethics must be > taught. > Men must learn to pretend to be wise and good. -- Lao Tzu >