Page8
This experiment covers another sub-routine called WIPE-DOWN. It is very similar to WipeUp, except the effect is the reverse. The fully-lit screen gradually turns off from the top row to the bottom row.
In the program below, we have combined it with experiments 18 and 19 to get the 5-cell animation (fan-effect from right-hand corner), then WipeUp, then WipeDown.
You may thing our programs are very long, but you need to remember you are “talking directly to the microcontroller” with each of the instructions and each instruction can only ask one thing to be done.
If you introduce a HIGHER LEVEL language such as BASIC, or C or any language that requires a single line to perform a complex instruction, the language will have a set of instructions (just like ours) hidden away in a routine, so that the operation can be performed.
If you want to perform operations via a single line of code you can get a complete set of routines from our Library of Routines chapter. We have created sub-routines to toggles a line, produce a pulse, etc etc and these have been brought together in an enormous chapter.
Once you complete this project you will be able to advance to the next stage of programming, and these sub-routines will be very helpful.
Experiment-20 for “5x7 Display” Project
;PIC16F84 and only F84 chip
5-cell animation with WipeUp and WipeDown.
Start ORG 0x00 BSF 03,5 ;Go to page1 for setting-up the ports MOVLW 00h ;Put 00 into W MOVWF 05h ;to make port 5 (port A) all output MOVWF 06h ;and make port 6 (port B) all output BCF 03,5 ;Go to page0 for programming GOTO Main Cell1 MOVLW 01h ;place the 5 values into the 5 MOVWF 11h ; files to produce the first cell MOVLW 01h ; as shown above. MOVWF 12h MOVLW 01h MOVWF 13h MOVLW 01h MOVWF 14h MOVLW 01h MOVWF 15h GOTO Scan Cell2 MOVLW 08h ;place the 5 values into the 5 MOVWF 11h ; files to produce the second cell MOVLW 04h ; as shown above. MOVWF 12h MOVLW 04h MOVWF 13h MOVLW 02h MOVWF 14h MOVLW 01h MOVWF 15h GOTO Scan Cell3 MOVLW 40h ;place the 5 values into the 5 MOVWF 11h ; files to produce the third cell MOVLW 20h ; as shown above. MOVWF 12h MOVLW 08h MOVWF 13h MOVLW 04h MOVWF 14h MOVLW 01h MOVWF 15h GOTO Scan Cell4 MOVLW 00h ;place the 5 values into the 5 MOVWF 11h ; files to produce the fourth cell MOVLW 00h ; as shown above. MOVWF 12h MOVLW 60h MOVWF 13h MOVLW 1Eh MOVWF 14h MOVLW 01h MOVWF 15h GOTO Scan Cell5 MOVLW 00h ;place the 5 values into the 5 MOVWF 11h ; files to produce the fifth cell MOVLW 00h ; as shown above. MOVWF 12h MOVLW 00h MOVWF 13h MOVLW 00h MOVWF 14h MOVLW 7Fh MOVWF 15h GOTO Scan Scan BSF 05,1 ;Reset 4017 NOP BCF 05,1 MOVF 11h,0 ;Move file 11 into W MOVWF 06h CALL DelD MOVF 12h,0 ;Move file 12 into W MOVWF 06h CALL DelD MOVF 13h,0 ;Move file 13 into W MOVWF 06h CALL DelD MOVF 14h,0 ;Move file 14 into W MOVWF 06h CALL DelD MOVF 15h,0 ;Move file 15 into W MOVWF 06h CALL DelD RETURN DelD DECFSZ 1Bh,1 GOTO DelD MOVLW 00h ;Zero port B to prevent mirroring MOVWF 06 Clk BSF 05,0 ;Clock the 4017 NOP BCF 05,0 RETURN WipeUp MOVLW 0FFh MOVWF 11h MOVWF 12h MOVWF 13h MOVWF 14h MOVWF 15h MOVLW 80h MOVWF 0Ch GOTO YY XX RLF 11h,1 BCF 11h,0 RLF 12h,1 BCF 12h,0 RLF 13h,1 BCF 13h,0 RLF 14h,1 BCF 14h,0 RLF 15h,1 BCF 15h,0 BTFSS 15h,7 RETURN YY DECFSZ 0Ch,1 GOTO ZZ MOVLW 80h MOVWF 0Ch GOTO XX ZZ CALL Scan GOTO YY WDown MOVLW 0FFh MOVWF 11h MOVWF 12h MOVWF 13h MOVWF 14h MOVWF 15h MOVLW 80h MOVWF 0Ch GOTO BB AA RRF 11h,1 BCF 11h,7 RRF 12h,1 BCF 12h,7 RRF 13h,1 BCF 13h,7 RRF 14h,1 BCF 14h,7 RRF 15h,1 BCF 15h,7 BB DECFSZ 0Ch,1 GOTO CC MOVLW 80h MOVWF 0Ch BTFSS 15h,0 RETURN GOTO AA CC CALL Scan GOTO BB Main MOVLW 0F0h ;Each 10h represents 100mS MOVWF 0Ch Main1 CALL Cell1 ;Display Cell 1 for 1/2 sec DECFSZ 0Ch,1 GOTO Main1 MOVLW 40h ;Each 10h represents 100mS MOVWF 0Ch Main2 CALL Cell2 ;Display Cell 2 for 400mS DECFSZ 0Ch,1 GOTO Main2 MOVLW 30h ;Each 10h represents 100mS MOVWF 0Ch Main3 CALL Cell3 ;Display Cell 3 for 300mS DECFSZ 0Ch,1 GOTO Main3 MOVLW 20h ;Each 10h represents 100mS MOVWF 0Ch Main4 CALL Cell4 ;Display Cell 4 for 200mS DECFSZ 0Ch,1 GOTO Main4 MOVLW 80h ;Each 10h represents 100mS MOVWF 0Ch Main5 CALL Cell5 ;Display Cell 5 for 800mS DECFSZ 0Ch,1 GOTO Main5 CALL WipeUp CALL WDown GOTO Main END
The block of numbers below is the HEX file for Experiment-20. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-20.hex
:10000000831600308500860083129028013091000D :1000100001309200013093000130940001309500CE :100020003D280830910004309200043093000230E3 :100030009400013095003D2840309100203092001E :100040000830930004309400013095003D280030C2 :10005000910000309200603093001E309400013017 :1000600095003D2800309100003092000030930050 :10007000003094007F3095003D28851400008510E5 :1000800011088600502012088600502013088600B0 :1000900050201408860050201508860050200800C3 :1000A0009B0B502800308600051400000510080046 :1000B000FF309100920093009400950080308C00F6 :1000C0006D28910D1110920D1210930D1310940DB7 :1000D0001410950D1510951F08008C0B7228803098 :1000E0008C0061283D206D28FF3091009200930024 :1000F0009400950080308C008728910C9113920C0D :100100009213930C9313940C9413950C95138C0BDE :100110008E2880308C00151C08007D283D20872803 :10012000F0308C0006208C0B922840308C0011207F :100130008C0B972830308C001C208C0B9C28203096 :100140008C0027208C0BA12880308C0032208C0B57 :08015000A62858207420902815 :00000001FF
This is another sub-routine that can be incorporated into your own routines. It is called SLASH. The sub-routine puts a diagonal on the screen as shown in the diagram below. It takes 11 frames for the diagonal to pass from the bottom left-hand corner to the top right-hand corner. When this routine is incorporated in one of your own routines, you will already have Scan sub-routine in your program. To run “Slash,” add the Slash sub-routine and ShiftUp sub-routine and add CALL Slash
in the Main routine.
The speed of the routine is determined by the value loaded into file 0C. In our case the value is 20h. For a faster action, reduce this value. At 80h, the animation is four times slower than the program below. Here’s how the program works:
The first 7 instructions set up the ports as outputs. Port A (port 05) resets and clocks the 4017 shift-register. The first 5 outputs of the 4017 are connected to transistors and these sink the cathodes of each column of LEDs.
The 7 rows of LEDs are connected to port B (port 6) via small current limiting resistors and the 8th output of this port is connected to a piezo diaphragm.
The 8th instruction in the program sends the processor to Main where a loop is created for the “Slash” sub-routine.
At the Slash sub-routine the first instruction clears the carry bit (the CARRY FLAG). This is to prevent junk in the carry bit appearing on the screen when a shift instruction is executed.
The five files are loaded with zero and the first bit in file 11 is set so that the bottom left-hand corner will be illuminated.
The program then calls a sub-routine called ShiftUp that firstly calls Scan sub-routine a number of times (the value loaded into file 0C), the rotates each of the files “LEFT.” This effectively moves the illuminated LEDs up the display.
The bottom LED of the next column is turned on and the display sub-routine executed. In this way the LEDs rise up the display.
When a LED reaches the top, it must be turned off (BCF) so that it does not appear at the bottom of the display (via the rotate instruction). This is done by the 4 BCF instructions.
The shiftUp sub-routine calls the Scan sub-routine and this performs two operations. Firstly it resets the 4017 shift register (actually a counter chip, but used as a shift device) and then moves the value in each file to the output port (port 6) and calls a delay routine so that the appropriate LEDs will be seen.
The sub-routine then clocks the 4017 so that the next sinking transistor will be activated and when the value in the next file is passed to the output port, the second row of LEDs are activated. This continues for the 5 columns and the micro returns to the ShiftUp sub-routine to repeat the sequence so that the whole screen appears to be lit at the same time.
After 20 hex passes of the Scan routine the micro turns on the next lowest bit in a column and repeats the sequence.
Experiment-21 for “5x7 Display” Project
;PIC16F84 and only F84 chip
;SLASH animation
Start ORG 0x00 BSF 03,5 ;Go to page1 for setting-up the ports MOVLW 00h ;Put 00 into W MOVWF 05h ;to make port 5 (port A) all output MOVWF 06h ;and make port 6 (port B) all output BCF 03,5 ;Go to page0 for programming GOTO Main Slash BCF 03h,0 ;Clear the carry bit MOVLW 00h MOVWF 11h MOVWF 12h MOVWF 13h MOVWF 14h MOVWF 15h BSF 11h,0 CALL ShiftUp BSF 12h,0 CALL ShiftUp BSF 13h,0 CALL ShiftUp BSF 14h,0 CALL ShiftUp BSF 15h,0 CALL ShiftUp CALL ShiftUp CALL ShiftUp BCF 11h,7 CALL ShiftUp BCF 12h,7 CALL ShiftUp BCF 13h,7 CALL ShiftUp BCF 14h,7 CALL ShiftUp RETURN ShiftUp MOVLW 20h MOVWF 0Ch Shift1 DECFSZ 0Ch,1 GOTO Shift2 RLF 11h,1 RLF 12h,1 RLF 13h,1 RLF 14h,1 RLF 15h,1 RETURN Shift2 CALL Scan GOTO Shift1 Scan BSF 05,1 ;Reset 4017 NOP BCF 05,1 MOVF 11h,0 ;Move file 11 into W MOVWF 06h CALL DelD MOVF 12h,0 ;Move file 12 into W MOVWF 06h CALL DelD MOVF 13h,0 ;Move file 13 into W MOVWF 06h CALL DelD MOVF 14h,0 ;Move file 14 into W MOVWF 06h CALL DelD MOVF 15h,0 ;Move file 15 into W MOVWF 06h CALL DelD RETURN DelD DECFSZ 1Bh,1 GOTO DelD MOVLW 00h ;Zero port B to prevent mirroring MOVWF 06 Clk BSF 05,0 ;Clock the 4017 NOP BCF 05,0 RETURN Main CALL Slash ;Display Slash GOTO Main END
The block of numbers below is the HEX file for Experiment-21. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-21.hex
:1000000083160030850086008312492803100030D3 :100010009100920093009400950011142220121474 :10002000222013142220141422201514222022200E :100030002220911322209213222093132220941322 :100040002220080020308C008C0B2C28910D920D62 :10005000930D940D950D08002E2024288514000082 :1000600085101108860041201208860041201308DF :100070008600412014088600412015088600412092 :1000800008009B0B41280030860005140000051075 :06009000080006204928CB :00000001FF
Here’s a 5-cell animation that uses sub-routines from experiment 18. It’s called SPLASH.
The first thing you have to do is work out how you are going to write the program. Look at the sequence of cells and see if a pattern is present where the LEDs can be “rotate” instruction. If this is not possible, you will have to work out the hex value of each LED and use our animation program from experiment 18. Try this program it is very effective!
Experiment-22 for “5x7 Display” Project
;PIC16F84 and only F84 chip
;SPLASH
Start ORG 0x00 BSF 03,5 ;Go to page1 for setting-up the ports MOVLW 00h ;Put 00 into W MOVWF 05h ;to make port 5 (port A) all output MOVWF 06h ;and make port 6 (port B) all output BCF 03,5 ;Go to page0 for programming GOTO Main Cell1 MOVLW 00h ;place the 5 values into the 5 MOVWF 11h ; files to produce the first cell MOVLW 00h ; as shown above. MOVWF 12h MOVLW 08h MOVWF 13h MOVLW 00h MOVWF 14h MOVLW 00h MOVWF 15h GOTO Scan Cell2 MOVLW 00h ;place the 5 values into the 5 MOVWF 11h ; files to produce the second cell MOVLW 1Ch ; as shown above. MOVWF 12h MOVLW 14h MOVWF 13h MOVLW 1Ch MOVWF 14h MOVLW 00h MOVWF 15h GOTO Scan Cell3 MOVLW 3Eh ;place the 5 values into the 5 MOVWF 11h ; files to produce the third cell MOVLW 22h ; as shown above. MOVWF 12h MOVLW 22h MOVWF 13h MOVLW 22h MOVWF 14h MOVLW 3Eh MOVWF 15h GOTO Scan Cell4 MOVLW 41h ;place the 5 values into the 5 MOVWF 11h ; files to produce the fourth cell MOVLW 41h ; as shown above. MOVWF 12h MOVLW 41h MOVWF 13h MOVLW 41h MOVWF 14h MOVLW 41h MOVWF 15h GOTO Scan Cell5 MOVLW 00h MOVWF 11h ;The fifth cell is blank MOVLW 00h MOVWF 12h MOVLW 00h MOVWF 13h MOVLW 00h MOVWF 14h MOVLW 00h MOVWF 15h GOTO Scan Scan BSF 05,1 ;Reset 4017 NOP BCF 05,1 MOVF 11h,0 ;Move file 11 into W MOVWF 06h CALL DelD MOVF 12h,0 ;Move file 12 into W MOVWF 06h CALL DelD MOVF 13h,0 ;Move file 13 into W MOVWF 06h CALL DelD MOVF 14h,0 ;Move file 14 into W MOVWF 06h CALL DelD MOVF 15h,0 ;Move file 15 into W MOVWF 06h CALL DelD RETURN DelD DECFSZ 1Bh,1 GOTO DelD MOVLW 00h ;Zero port B to prevent mirroring MOVWF 06 Clk BSF 05,0 ;Clock the 4017 NOP BCF 05,0 RETURN Main MOVLW 50h ;Each 10h represents 100mS MOVWF 0Ch Main1 CALL Cell1 ;Display Cell 1 for 1/2 sec DECFSZ 0Ch GOTO Main1 MOVLW 10h ;Each 10h represents 100mS MOVWF 0Ch Main2 CALL Cell2 ;Display Cell 2 for 100mS DECFSZ 0Ch GOTO Main2 MOVLW 10h ;Each 10h represents 100mS MOVWF 0Ch Main3 CALL Cell3 ;Display Cell 3 for 100mS DECFSZ 0Ch GOTO Main3 MOVLW 10h ;Each 10h represents 100mS MOVWF 0Ch Main4 CALL Cell4 ;Display Cell 4 for 100mS DECFSZ 0Ch GOTO Main4 MOVLW 80h ;Each 10h represents 100mS MOVWF 0Ch Main5 CALL Cell5 ;Display Cell 5 for 800mS DECFSZ 0Ch GOTO Main5 GOTO Main END
The block of numbers below is the HEX file for Experiment-22. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-22.hex
:100000008316003085008600831258280030910046 :1000100000309200083093000030940000309500CA :100020003D28003091001C309200143093001C30A9 :100030009400003095003D283E309100223092001F :1000400022309300223094003E3095003D2841300C :100050009100413092004130930041309400413092 :1000600095003D2800309100003092000030930050 :1000700000309400003095003D2885140000851064 :1000800011088600502012088600502013088600B0 :1000900050201408860050201508860050200800C3 :1000A0009B0B502800308600051400000510080046 :1000B00050308C0006208C0B5A2810308C001120F8 :1000C0008C0B5F2810308C001C208C0B64281030A7 :1000D0008C0027208C0B692880308C0032208C0B00 :0400E0006E28582806 :00000001FF
Go to the next page of experiments: 5x7 EXPERIMENTS: Page-9
Quick Links
Legal Stuff
Social Media