M. Amer Iqbal Qureshi


PulsOut Rowrst,2 ' give a pulse on row reset pin, to select row 0  Loop:  SHOut



tải về 3.06 Mb.
Chế độ xem pdf
trang129/132
Chuyển đổi dữ liệu09.12.2022
Kích3.06 Mb.
#53945
1   ...   124   125   126   127   128   129   130   131   132
Amer Iqbal - Teach Yourself PIC Microcontrollers for Absolute Beginners-Microtronics Pakistan (2001)

    Điều hướng trang này:
  • PulsOut
PulsOut Rowrst,2
' give a pulse on row reset pin, to select row 0 
Loop: 
SHOut SER,SRCLK,
lsbfirst
,[%11111110,%11111111,%11111111,%11111111] 
' send data 
on serial pin ON
PulsOut Latch,4 
DelayMS 500 
SHOut SER,SRCLK,
lsbfirst
,[%11111111,%11111111,%11111111,%11111111] 
' send data 
on serial pin OFF
PulsOut Latch,4 
DelayMS 500 
GoTo Loop 
End 
Now lets make the entire row turn ON, and then select the next row, till all 8 rows are show, one after the 
other. 
Dim As Byte 
Loop: 
PulsOut Rowrst,2
' give a pulse on row reset pin, to select row 0 
For i=0 To 
SHOut SER,SRCLK,
lsbfirst
,[%00000000,%00000000,%00000000,%00000000]
PulsOut Latch,4 
DelayMS 500 
PulsOut RowClk,2 
Next 
GoTo Loop 
This code sends all columns on data, then waits for 500ms, and then gives a short pulse on RowClk pin. 
This pulse will advance the row selection to next row, and the same data is sent again. The whole process is 
repeated 8 times, till the last row, number 7 is displayed. After this the row counter is reset to select row 0 
and the entire process is repeated. 
So far so good. Now begins the real fun. Notice that 
we have made a delay of 500ms between rows. If we 
reduce this time, rows will be displayed quicker,. Fine, 
if we go on reducing the time, a state will reach when 
our eyes will not be able to perceive the individually 
on rows, rather they will see all rows ON! When in 
fact, still, one row is being turned on, at a time. Try 
following timings, in place of 500. begin with 500 as 
in above program and then try, 300, 200, 100, 50, 20, 
10, 5, 2 . A delay of 2ms will produce the best result, 
you will see an absolutely flicker free display. 
As shown in figure 9. All 256 LEDs appear to be ON. 
Fig. 7 Entire Row is ON 
Fig. 9 All lights appearing to be ON 


Teach Yourself PIC Microcontrollers | www.electronicspk.com | 142 
When in fact one row, of 32 are on at a time. This is due to persistence of vision.
Displaying Characters 
As you have seen that, you can play with these bits, to show anything you want. Text characters are 
similarly not a big problem. However you will need to make a 
table or list of character maps, that you will send to the display. 
Most characters can be easily mapped in 5 x 7 array. However 
for simplicity of our work, we will design them as an 8 x 8 
matrix. Selecting this matrix, will also be helpful in making 
some other more feature rich graphics. Lets see how to work Up. 
We are going to design letter ‘A’. 
The adjacent fig shows the character map. The numbers in gray 
column, are in hexadecimal, equivalent. 1 for Off and 0 for On. 
Now we can store this character in bytes of memory. EEPROM 
on microcontroller is a good place to keep such maps, which 
once defined, have to be read in by the program. We have used 
EData  command to store the codes for each row byte for the letter in EEPROM. The size of table which 
can be stored will depend upon the EEPROM of your microcontroller. If a larger table is required you can 
use an external EEPROM. The loop fills in the appropriate bytes of display memory by reading the 
associated bitmap image from EEPROM.
The index of letters to be displayed are stored in 
an array z[4]. Number 0 is for letter ‘A’ as it is 
defined in position 0 in EEPROM, and number 
1 is for ‘B’ as it is in position 1 in EEPROM. 
Notice how the position of first byte is 
calculated. 
E3 
DD 
DD 
DD 
C1 
DD 
DD 
DD 

tải về 3.06 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   124   125   126   127   128   129   130   131   132




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương