This assignment consisted of creating a circuit for a 5x7 LED Matrix display
that would display an arbitrary character from the ASCII Code. The circuit uses
the PIC Logo chip's A and B ports which are connected to the pins of the LED
Matrix Display. The display works in matrix fashion where if column x is high,
determined by one of the A ports, and row y is low, determined by the B ports,
then the corresponding light to the high x and low y will illuminate. This if many
row are low, then many lights will light up in column x. Here is a diagram of the
circuit we constructed.
The program works by lighting up one column at a time, which is at most 7 LEDs lit at once.
However, it cycles through so fast that it appears that all the LEDs are lit all together.
The logochip knows what rows to light up through the information being passed to it
through its bus. The information being passed is an 8-bit digit which represents which
B ports to go high, and what B ports to go low. Remember, low will turn the LED on, in
the column that port A is making high.
constants
[[porta 5][porta-ddr $85]
[portb 6][portb-ddr $86]]
global [i]
global [a0 a1 a2 a3 a4]
global [b0 b1 b2 b3 b4]
to init
write porta-ddr 0
write portb-ddr 1
end
to clearB
write portb $FF
end
to getChar
loop
[
if newbus?
[
setbit 5 porta
setbit 4 portb
setb0 brcv
waituntil [newbus?]
setb1 brcv
waituntil [newbus?]
setb2 brcv
waituntil [newbus?]
setb3 brcv
waituntil [newbus?]
setb4 brcv
]
displayChar
]
end
to displayChar
setbit a0 porta
write portb b0
wait .4
clearB
setbit a1 porta
write portb b1
wait .4
clearB
setbit a2 porta
write portb b2
wait .4
clearB
setbit a3 porta
write portb b3
wait .4
clearB
setbit a4 porta
write portb b4
wait .4
clearB
end
to main
init
seta0 1 seta1 2
seta2 5 seta3 3
seta4 0
clearB
waituntil [newbus?]
if brcv = $180
[
getChar
]
end
main array [ b1 26 b2 26 b3 26 b4 26 b5 26 ] to fillArray ;A aset b1 0 $E0 aset b2 0 $7C aset b3 0 $DD aset b4 0 $7C aset b5 0 $E0 ;B aset b1 1 $00 aset b2 1 $A6 aset b3 1 $A6 aset b4 1 $A6 aset b5 1 $58 ;C aset b1 2 $48 aset b2 2 $B6 aset b3 2 $B6 aset b4 2 $B6 aset b5 2 $DA ;D aset b1 3 $00 aset b2 3 $B6 aset b3 3 $B6 aset b4 3 $B6 aset b5 3 $48 ;E aset b1 4 $00 aset b2 4 $A6 aset b3 4 $A6 aset b4 4 $A6 aset b5 4 $B6 ;F aset b1 5 $00 aset b2 5 $AE aset b3 5 $AE aset b4 5 $AE aset b5 5 $BE end to main bsend $180 fillArray loop [ beep bsend aget b1 0 bsend aget b2 0 bsend aget b3 0 bsend aget b4 0 bsend aget b5 0 wait 20 beep bsend aget b1 1 bsend aget b2 1 bsend aget b3 1 bsend aget b4 1 bsend aget b5 1 wait 20 beep bsend aget b1 2 bsend aget b2 2 bsend aget b3 2 bsend aget b4 2 bsend aget b5 2 wait 20 beep bsend aget b1 3 bsend aget b2 3 bsend aget b3 3 bsend aget b4 3 bsend aget b5 3 wait 20 beep bsend aget b1 4 bsend aget b2 4 bsend aget b3 4 bsend aget b4 4 bsend aget b5 4 wait 20 beep bsend aget b1 5 bsend aget b2 5 bsend aget b3 5 bsend aget b4 5 bsend aget b5 5 wait 20 ] end
In order to create the characters, we had to draw out what the character would look
like on the LED Matrix display. If we had the letter A and port A1 was high, which
corresponds to the first column, then we know that port B1, B2, B3, and B4 have to be low,
and B5, B6, and B7 have to be High (since a low signal indicates they will turn on).
This is shown in the diagram below.
Now that we know what ones should be on we use an 8-Bit number to mask the values.
Since B0 is used for receiving from the Cricket's bus, we always leave B0 as 0.
Then we continue on like this:
Port: 7 6 5 4 | 3 2 1 0 Value: 1 1 1 0 | 0 0 0 0 Hex: E 0