piclist 1998\07\27\140451a >
www.piclist.com/techref/displays.htm?key=leds
BY : paulbEraseME@spammidcoast.com.au

James Cameron wrote:

> I think I might use this idea, but I would imagine the coding to be a
> challenge.

Well, the coding to operate a random LED array of course would be much
the same whichever way you do it, but I presume you refer to the driving
of seven-segment displays from a lookup table.  I don't think it's that
hard!

Considering the case of nine displays, driven by the eight bits of
port B and one from port A.  As I see it, you end up with a segment mask
derived from the lookup table for the desired digit (character) value,
plus a position mask for the particular display.

The position mask is used to set the port register (B) (sets "strobe"
line) and is used to mask the corresponding bit (if indeed, any) of
character to be transferred to the "wild" bit in tris register A.  It is
then used to mask *out* a bit of character before writing this value to
tris B, and the "wild" bit of port A is set if position (and thence port
B) was zero.  Much easier to tabulate than describe:

"Position"   12345678  ("0"=ninth position)         A
e.g.      00010000  (fourth digit)             F  B
G
"Character"  pabcdefg  ("p"=decimal point)       E  C
e.g.      01111001  (digit "3")                D

Port B      00010000  Position
Tris B      10000110  .NOT. (Position .OR. Character)
Port A      000nnnn0  Bit 0 = (position == 0)
Tris A      000xxxx0  Bit 0 = (position .AND. .NOT. Character)

This coding is for a character code where 1 = lit to make the bitmaps

The hardware structure to implement this is quite simple.  There are
eight port B drive lines distributed as segment drives (cathode) to all
digits.  Each digit in turn takes its common anode drive from one of
these lines and for that digit, the segment drive which is usurped comes
from the ninth, "wild" line instead.  The ninth digit of course takes
its common anode drive from the wild line.

Hey, I'm not infringing anyone's patent here, am I?
--
Cheers,
Paul B.

<35BCBBDB.683D@midcoast.com.au> 7bit