5x7 Display
Experiments
Page3
REMINDER:
These are the items you need for these experiments:
- the 5x7 Display Project (fully
built),
- a 6v battery,
- an interface cable
(the components come with the kit)
- a computer.
The first 6 experiments are on:
"Experiments
Page1."
Experiments 7, 8, 9 are on:
"Experiments
Page2."
EXPERIMENT-10 START/STOP
ACTION!
This experiment takes the program from experiment 9 and adds a button
feature. Button A starts and stops the action. For this to be possible
the button routine must be in a part of the program that is constantly being
accessed. The routines are "Delay" for forward/back
motion and "Scan" for up/down motion. A CALL routine must be placed in each routine to check the state of
buttonA. The column LEDs will freeze but the row of LEDs will go out when
the buttons is pressed because the rows are scanned to produce the effect of
them being on at the same time.
Note the instructions to make button A (line RA2) an input.
|
Experiment-10
for "5x7 Display" Project
;PIC16F84 and only F84 chip
; "Button A" starts/stops action.
Start ORG 0x00
BSF 03,5
;Go to page1 for setting-up the ports
MOVLW 04h
;Put 04 into W
MOVWF 05h
; to make RA2 input
MOVLW 00h
;Put 00 into W
MOVWF 06h
;to make all RB lines output
BCF 03,5
;Go to Page0 for programming
GOTO Main
Back BSF 05h,1
BCF 05h,1
;Reset 4017 and allow 4017 to clock
MOVLW 00h
MOVWF 06h
;Turn off LEDs to prevent "streaking"
MOVF 19h,0
;Copy 19h into W
MOVWF 18h
;Copy W into file 18h
Back1 CALL Clock
DECFSZ 18h,1
GOTO Back1
MOVLW 7Fh
MOVWF 06h
;Turn on all 7 LEDs
CALL Delay
RETURN
ButtonA BTFSC 05,2
RETURN
;Button A pushed
GOTO ButtonA
Clock BCF 05,0
;Clock the 4017
NOP
BSF 05,0
RETURN
Delay MOVLW 03
MOVWF 1Ah
Delay1 DECFSZ 1Bh,1
GOTO Delay1
DECFSZ 1Ch,1
GOTO Delay1
CALL ButtonA
DECFSZ 1Ah,1
GOTO Delay1
RETURN
Scan MOVLW 080h
;Determines the number of scans before
MOVWF 1Ch
; incrementing routine
Scan1 BSF 05h,1
;Reset 4017
BCF 05h,1
;allow 4017 to clock via clock line
MOVLW 05h
MOVWF 19h
;File 19h counts the number of columns
Scan2 CALL Short
BCF 05,0
;Clock the 4017
BSF 05,0
DECFSZ 19h,1
GOTO Scan2
CALL ButtonA
DECFSZ 1Ch,1
GOTO Scan1
RETURN
;Short Delay
Short DECFSZ 1Bh,1
GOTO Short
RETURN
;Moves a colum of LEDs across the screen and back,
;then up and down the screen
Main MOVLW 05
MOVWF 19h
;Put 5 in the Count file for 5 columns
BSF 05h,1
;Reset 4017
BCF 05h,1
;allow 4017 to clock via clock line
Main1 MOVLW 7F
MOVWF 06h
;Turn on 7 outputs for LEDs
CALL Delay
MOVLW 00
;Turn off LEDs to prevent mirroring
MOVWF 06h
CALL Clock
;Clock the 4017
DECFSZ 19h,1
;Decrement the count file
GOTO Main1
MOVLW 03h
MOVWF 19h
;3 shifts - yes 3 shifts!
Main2 CALL Back
DECFSZ 19h,1
GOTO Main2
BSF 05h,1
BCF 05h,1
;Reset 4017
CALL Delay
;This illuminates the first row!
MOVLW 01
MOVWF 06h
;Turn on first LED
BCF 03h,0
;clear the carry flag
Main3 CALL Scan
RLF 06,1
BTFSS 06,7
;When 8th! output is HIGH, program repeats
GOTO Main3
MOVLW 20h
MOVWF 06h
Main4 CALL Scan
RRF 06,1
BTFSS 06,0
GOTO Main4
CALL Scan
;This illuminates bottom row!
GOTO Main
END
|
|
|
The block of
numbers below is the HEX file for Experiment-10. Copy and paste
it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-10.hex |
|
| :10000000831604308500003086008312372885145B
:10001000851000308600190898001720980B0D28CD
:100020007F3086001B2008000519080014280510E1
:1000300000000514080003309A009B0B1D289C0B40
:100040001D2814209A0B1D28080080309C00851460
:10005000851005309900342005100514990B2B28C4
:1000600014209C0B272808009B0B3428080005301F
:100070009900851485107F3086001B200030860093
:100080001720990B3B28033099000720990B45282E
:10009000851485101B200130860003102520860D55
:1000A000861F4E28203086002520860C061C5428EA
:0400B00025203728A8
:00000001FF |
EXPERIMENT-11 ELEVATOR
DISPLAY
This experiment demonstrates the type of display in a lift. It's a matrix of
LEDs and the floor-numbers move up and down according to the movement of the lift.
The input to our project is button A and B. Press button A and the display
glides UP, such as from the ground floor to the first floor. Press button B
and the display moves from the first floor to the Ground floor. The animation
below shows the first three numbers of the display in action. The project contains the complete
numbers G to 9 as shown in the table below. You can also introduce T for Terrace, M for Mezzanine, C for
Car park, B for basement etc. The numbers are held in a table with 9 at
the top and G at the bottom. In the program a pointer will "slice
off" one row of a number and add it to the top or bottom of the
"Ghost area" after the data in this area has been shifted one
place up or down. This Ghost area then gets copied onto the Video
Screen and the effect is the number has risen or fallen one
pixel.
This two-step jump from the table to the Ghost area to the Screen may sound
complex but it makes fairly easy programming.
We have already produced the routine for taking the data from the Ghost ara
and displaying it on the Screen, in the Testing
pages, Page2. All we have to do is create a routine to take the
information from the table and place it onto the Ghost area.
The program will start by displaying "G" and the UP button (button
B) will cause the screen to slide from G to 1.
The digits do not have to be put in a table in descending order. We
have done this to make it easier to understand how the program works.
The most complex part of the routine is keeping track of the
numbers on the display. The fact that we have an up button and a down button
adds to the complexity because the numbers are fed into the top of the
display for the UP button and into the bottom of the display for the down button.
We have provided a very clever method of keeping track of the positions.
File 17h keeps track for button A and file 19h keeps track for button B.
They are kept 8 units apart at the beginning of the program and kept apart
throughout the program by incrementing and decrementing both at the same
time.
|
Experiment-11
for "5x7 Display" Project
;PIC16F84 and only F84 chip
; ELEVATOR DISPLAY
Start ORG 0x00
BSF 03,5 ;Go to page1 for setting-up the ports
MOVLW 0Ch ;Put 0C into W
MOVWF 05h ; to make RA2 & RA3 input
MOVLW 00h ;Put 00 into W
MOVWF 06h ;to make all RB lines output
BCF 03,5 ;Go to Page0 for programming
GOTO Main
Table1 ADDWF 02h,1 ;Add W to Program Counter
RETLW 00h
RETLW 0Eh
;9
RETLW 11h
RETLW 11h
RETLW 0Fh
RETLW 01h
RETLW 11h
RETLW 0Eh
RETLW 00h
;8
RETLW 0Eh
RETLW 11h
RETLW 11h
RETLW 0Eh
RETLW 11h
RETLW 11h
RETLW 0Eh
RETLW 00h
RETLW 1Fh
;7
RETLW 01h
RETLW 02h
RETLW 04h
RETLW 08h
RETLW 08h
RETLW 08h
RETLW 00h
;6
RETLW 0Eh
RETLW 11h
RETLW 10h
RETLW 1Eh
RETLW 11h
RETLW 11h
RETLW 0Eh
RETLW 00h
;5
RETLW 1Fh
RETLW 10h
RETLW 10h
RETLW 1Eh
RETLW 01h
RETLW 11h
RETLW 0Eh
RETLW 00h
;4
RETLW 02h
RETLW 06h
RETLW 0Ah
RETLW 12h
RETLW 1Fh
RETLW 02h
RETLW 02h
RETLW 00h
;3
RETLW 0Eh
RETLW 11h
RETLW 01h
RETLW 06h
RETLW 01h
RETLW 11h
RETLW 0Eh
RETLW 00h
;2
RETLW 0Eh
RETLW 11h
RETLW 01h
RETLW 0Eh
RETLW 10h
RETLW 10h
RETLW 1Fh
RETLW 00h
;1
RETLW 04h
RETLW 0Ch
RETLW 14h
RETLW 04h
RETLW 04h
RETLW 04h
RETLW 04h
RETLW 00h ;G
RETLW 0Eh
RETLW 11h
RETLW 10h
RETLW 17h
RETLW 11h
RETLW 11h
RETLW 00h
RETLW 00h
;Ghost routine transfers data from the
; Ghost files to the Video Screen
; and scans the Video Screen ONCE
Ghost BSF 05,1
;Reset 4017
NOP
BCF 05,1
MOVF 11h,0 ;Move the data from the
MOVWF 06h
; Ghost files to
CALL DelA
; the output port
MOVF 12h,0
; and call a Delay so the
MOVWF 06h
; LED can be illuminated
CALL DelA
MOVF 13h,0
MOVWF 06h
CALL DelA
MOVF 14h,0
MOVWF 06h
CALL DelA
MOVF 15h,0
MOVWF 06h
CALL DelA
RETURN
DelA DECFSZ 1Bh,1
GOTO DelA
MOVLW 00h
MOVWF 06
Clk BCF 05,0
;Clock the 4017 to the
NOP
; next output
BSF 05,0
RETURN
;FillTop moves the 5 Ghost locations down one bit
; and fills the top row with new data.
;File 16h contains the new data for the 5 locations
FillTop RRF 11h,1
;Move each bit down the file
RRF 12h,1
; to make room at the top
RRF 13h,1
RRF 14h,1
RRf 15h,1
BCF 11h,6
;Clear bit 6 in each file = 7th row of LEDs
BCF 12h,6
; on the Video Screen.
BCF 13h,6
BCF 14h,6
BCF 15h,6
BTFSS 16h,4
;See if bit4 (the 5th bit) is 0 or 1
GOTO L
;If it's 0, go to the next test
BSF 11h,6
;If it's 1, set bit 6 of the Ghost file
L
BTFSS 16h,3
GOTO M
BSF 12h,6
M BTFSS 16h,2
;File 16h was generated by adding the value of
GOTO N
; of each pixel in the row of each number
BSF 13h,6
; see Table1 and diagram 1 for details.
N
BTFSS 16h,1
GOTO O
BSF 14h,6
O BTFSS 16h,0
RETURN
BSF 15h,6
RETURN
FilBott RLF 11h,1
;Same principle as above, but this time
RLF 12h,1
; the bits in the file are moved up to
RLF 13h,1
; leave a gap at the bottom.
RLF 14h,1
RLF 15h,1
BCF 11h,0
;Clear the lowest bit of each Ghost file
BCF 12h,0
BCF 13h,0
BCF 14h,0
BCF 15h,0
BTFSS 16h,4
GOTO P
BSF 11h,0
P
BTFSS 16h,3
GOTO Q
BSF 12h,0
Q
BTFSS 16h,2
GOTO R
BSF 13h,0
R
BTFSS 16h,1
GOTO S
BSF 14h,0
S
BTFSS 16h,0
RETURN
BSF 15h,0
RETURN
;FilGho fills the Ghost area with 7 rows of "G" data
;from Table1
FilGho MOVLW 08
MOVWF 1A
;1A is count file for 7 cycles of "FilGho"
MOVLW 58h
MOVWF 19h
;File19h is button B pointer for Table1
MOVLW 50h
;Jump down table1 50h locations
MOVWF 17h
;file17h is button A pointer for Table1
FilGho1 CALL Table1
MOVWF 16h
CALL FillTop
DECF 17h,1
;File 17h is the table pointer for button A
DECF 19h,1
;File 19h is the table pointer for button B
MOVF 17h,0
;Put pointer into W
DECFSZ 1A,1
GOTO FilGho1
RETURN
;MAIN ROUTINE
Main CALL FilGho
;Put "G" on screen
CALL Ghost
;Display whatever is in Ghost files
BTFSC 05h,2
;Test for button A
GOTO Main2
;Pushed
GOTO Main
Main2 MOVLW 08
MOVWF 1A
Main3 MOVLW 20h
MOVWF 18h
;File 18h holds number of scans before adding next
row
Main4 CALL Ghost
DECFSZ 18h,1
GOTO Main4
MOVF 17h,0
;Put table1 pointer into W
CALL Table1
MOVWF 16h
CALL FillTop
DECF 17h,1
DECF 19h,1 ;19h is pointer for
button B
DECFSZ 1A,1
GOTO Main3
Main5 CALL Ghost
;Display whatever is in Ghost files
BTFSC 05h,2
;Test for button A
GOTO MainA
;Button A Pushed
BTFSC 05h,3
;Test for Button B
GOTO MainB
;Button B pushed
GOTO Main5
MainA MOVF 17h,0
;Copy 17h into W
XORLW 00h
BTFSC 03,2
;Button A not to work. On floor 9!
GOTO Main5
GOTO Main2
MainB MOVF 19h,0
;Copy 19h into W
XORLW 50h
BTFSC 03,2
;Button B not to work. On G floor!
GOTO Main5
Main6 MOVLW 08
MOVWF 1Ah
Main7 MOVLW 20h
MOVWF 18h
;File 18h holds the number of scans before
adding next row
Main8 CALL Ghost
DECFSZ 18h,1
GOTO Main8
MOVF 19h,0
;Put table1 pointer into W
CALL Table1
MOVWF 16h
CALL FilBott
INCF 17h,1
INCF 19h,1
;19h is pointer for button B
DECFSZ 1A,1
GOTO Main7
GOTO Main5
END
|
|
|
The block of
numbers below is the HEX file for Experiment-11. Copy and paste
it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-11.hex |
|
| :1000000083160C308500003086008312B8288207E2
:1000100000340E34113411340F34013411340E34E1
:1000200000340E34113411340E34113411340E34C2
:1000300000341F34013402340434083408340834E2
:1000400000340E34113410341E34113411340E3493
:1000500000341F34103410341E34013411340E3483
:100060000034023406340A3412341F3402340234A9
:1000700000340E34113401340634013411340E349A
:1000800000340E34113401340E34103410341F3463
:10009000003404340C34143404340434043404348C
:1000A00000340E34113410341734113411340E343A
:1000B00000340034851400008510110886006D207E
:1000C000120886006D20130886006D201408860033
:1000D0006D20150886006D2008009B0B6D280030F0
:1000E00086000510000005140800910C920C930C7A
:1000F000940C950C11131213131314131513161ECD
:1001000082281117961D85281217161D8828131787
:10011000961C8B281417161C080015170800910D43
:10012000920D930D940D950D1110121013101410C3
:100130001510161E9C281114961D9F281214161DAA
:10014000A2281314961CA5281414161C08001514B4
:10015000080008309A005830990050309700072066
:10016000960075209703990317089A0BAF2808008B
:10017000A9205A20051DBD28B82808309A00203033
:1001800098005A20980BC128170807209600752060
:10019000970399039A0BBF285A20051DD228851D65
:1001A000D728CC281708003A0319CC28BD281908ED
:1001B000503A0319CC2808309A00203098005A2071
:1001C000980BDF281908072096008F20970A990AB4
:0601D0009A0BDD28CC288B
:00000001FF |
Go to the next page of experiments:
5x7
EXPERIMENTS: Page-4
|