Bus Controlled 7x5 LED Display

Developers:

Wiring - Tom Kneeland
Logo Program - Adrien Grise

Debugging of both the hardware and software was done by both developers.

Objective:

Build a Handy Cricket Bus Device that allows the display of ASCII characters no a 7x5 LED Dot Matrix Display (LITEON LTP-747HR).

Schematic:

Implementation:

The 7x5 LED Dot Matrix Display is configured as a grid where rows are controlled as if they are active low, and columns as if they are active high. This means that when no voltage is present on the pin controlling a row, and voltage is applied to one or more pins controlling a column, the LEDs on that row in those columns will illuminate.

This leads to a type of rudimentary scan line algorithm for displaying characters. Basically a program "loops" over all the pins controlling the rows activating and deactivating them in order. While a row is active, the appropriate columns are activated to display the dots that comprise the character for that row.

In our configuration the columns are controlled by the Logo Chip's Bus A. Asserting the pins for the appropriate columns or a given row is as easy as writing a Hex value on Bus A. For this reason characters in our system can be represented as a collection of seven Hex values (one for each row). At the time we implemented our bus device, Arrays were not supported by the version of LOGO executed by the Logo Chip. Therefore the program executed on the bus device is just hard coded to support the letter "A" and null "". There is a way to work around this limitation, but we did not have time to do so.

It should also be noted that the voltage requirement of the 7x5 LED Dot Matrix Display is <= +3.4v. We accidently supplied +5v to the display and "blew out" a couple of the dots. In looking at our diagram one would notice that we do not have any resistors in line between the Logo Chip's bus pins and the LED Display. Although the Logo Chip's bus pins produce +5v, the "strobbing" nature of our algorithm appears to protect the display from over heating. We did try adding various resistors to prevent overloading the display. The results however were unsatifactory since the display became too dim to read.

Things to Note:

  1. Pin 4 of Bus A on our Logo Chip does not seem to work. Therefore A5 is used instead, which requires a slight modification to our Hex values for controlling the dots of a particular row.
  2. The main routine running on the Logo Chip was designed using a mini-state machine that allows us to toggle between watching for ClassIDs and Characters on the bus without having to perform a Waituntil instruction. This allows us to continuously update the display even while bus transmissions are occurring.
  3. Our bus device was not fast enough to read the ClassID and Character from the bus without having the Handy Cricket insert a 5ms delay between them. This is probably due to the "idling" we perform in the display function to combat bleeding. There are a few things we can do to combat this behavior. First we could loop over the columns writing hex values to toggle the rows, this would cut down on the time needed to write a character to the screen. Also instead of idling to prevent bleeding we could return to read from the bus.

Logo Chip Code:

; Some Global Variables
;   cat - Just a dummy variable used to introduce some delay
;         when displaying rows of dots.
;
;   curr_char - The current character being displayed
;
;   command_chk - State variable controlling reading from the bus
;
global [cat curr_char command_chk]

; Constants for controlling the Logo Chip's Bus A and B
constants [[portb 6][portb-ddr $86][porta 5][porta-ddr $85]]

; Generic Character Display routine.  The 7 values passed to this
; function control the columns of the display (one value for each
; row).
;
; NOTE:  The repeat statement is used to delay the transition from
;        one row to the next.  This seemed to help the "bleeding"
;        that occurred between the dot of some rows.
;
;        The order of the rows are also jumbled to help with "bleeding"
;        as well.
;
to display_generic :b1 :b2 :b3 :b4 :b5 :b6 :b7
  ; 1st Row
  write portb $FE
  clearbit 1 portb
  write porta :b1
  repeat 32 [ setcat 1 ]

  ; 4th Row
  write portb $FE
  clearbit 4 portb
  write porta :b4
  repeat 32 [ setcat 1 ]

  ; 2nd Row
  write portb $FE
  clearbit 2 portb
  write porta :b2
  repeat 32 [ setcat 1 ]

  ; 5th Row
  write portb $FE
  clearbit 5 portb
  write porta :b5
  repeat 32 [ setcat 1 ]

  ; 3rd Row
  write portb $FE
  clearbit 3 portb
  write porta :b3
  repeat 32 [ setcat 1 ]

  ; 6th Row
  write portb $FE
  clearbit 6 portb
  write porta :b6
  repeat 32 [ setcat 1 ]

  ; 7th Row
  write portb $FE
  clearbit 7 portb
  write porta :b7
  repeat 32 [ setcat 1 ]
end

; This function simulates a look-up table to determine the Hex
; values needed to display a character.
;
; NOTE:  There seemed to be a problem with our Logo Chip's pin 4 of
;        port A.  Therefore the 5th bit of our hex value is really
;        set in the 6th bit position (hence values starting with $2x
;
to display :character
  if :character = 65
    [display_generic $0E $21 $21 $2f $21 $21 $21]

  if :character = 0
    [display_generic $00 $00 $00 $00 $00 $00 $00]

  ; more if statements
end

; Our main routine.  It simply loops endlessly watching for a new character
; to appear on the bus, while continually updating the display with what ever
; the last character was on the bus.
;
to main
  ; Configure ports A and B for output, with the exception of pin 0 on
  ; port B which is used for bus input. 
  write portb-ddr $01
  write porta-ddr $00
  write portb $FE
  write porta $00

  setcommand_chk 1
  loop [
    if newbus?
    [
      ifelse command_chk = 1
      [
        if brcv = $180
        [
          setcommand_chk 0
        ]
      ]
      [
        setcurr_char brcv
        setcommand_chk 1
      ]
    ]
    display curr_char
]
end

Handy Cricket Code:

; Very simply Logo program to continually display the letter A on the
; bus device for 2 seconds, followed by a null for 2 seconds.
;
; NOTE:  The 5ms waits are to prevent the Handy Cricket from transmitting
;        faster than our display device can read from the bus.  We were loosing
;        characters and control words on the bus device, probably due to the
;        delay in updating the display.
;
to main
  bsend $180
  wait 5
  bsend 65
  wait 20
  bsend $180
  wait 5
  bsend 0
  wait 20
  main
end