Professional Documents
Culture Documents
On
A Microprocessor Based
Black and White image scanner
Done By
Batch No. 40
P19
Design a microprocessor based scanner which will scan a black and white
image and store it as binary data. The scanner has two stepper motors for
motion along two orthogonal coordinates. The rotational motion is converted
into translational motion through a lead screw mechanism. Five paired LED
photodiodes intended for B&W image scanning are placed one centimeter
apart. The maximum size scannable is 10cmX10cm.The photodiode signal is
analog signal which is amplified and available to you as 5V signal for white
image and 0V for black image. The analog signal is to be digitized and
stored sequentially in the RAM. The motor moves given direction signal and
a pulse. (0 for clockwise and 1 for anticlockwise).
SYSTEM DESCRIPTION:
The Microprocessor based Black and White image scanner consists of the
INTEL 8086 MPU as central processing unit. Two Intel 8255 Programmable
Peripheral Interfacing device are used to interface two stepper motors and a
0809 Analog-To-Digital Converter. The 5 paired photodiodes are interfaced
to the system through the ADC. Two 2716 ROMS are used to store the
program .Two 6116 RAMS are interfaced to the processor. Three 74LS373
octal latches are used to demultiplex the AD lines coming from the
processor. Two 74LS245 bi-directional buffers are also used to demultiplex
the AD lines coming from the processor. One more 74LS245 is used for the
RD’, WR’ and M/IO’ signal lines.
Hardware Description:
MEMORY ADDRESSES:
ROM: FF000H-FFFFFH
RAM: 00000H-00FFFH
Assumptions:
2. The 8086 Chip is already programmed with the specified code from an
external source.
6. The pixels to be read from the paper are 0.125 cm apart. Therefore there
are 8 gaps each of 0.125 cm in one centimeter. Therefore there are 81 points
to be read in each row and 81 points to be moved along each column.
10. The starting position is from the top-left corner of the page. Motion of
the photodiodes would be from left to right and top to bottom of a page in
the read operation.
Algorithm:
1 cm
Memory Block
Each centimeter is divided into 8 parts so that each part takes up one bit of a
byte, the entire byte itself representing one centimeter. In this way, bit 7
would be the starting position and bit 0 would be the last position within a
centimeter. Therefore, on the first read operation, the first 5 centimeters in a
row are read and 5 bytes would be occupied.
3. The memory has already been initialized as 0’s. If a diode is read as 5V,
then 1 would be written into the corresponding bit else no operation as
already initialization as 0’s.
4. After the first read, the photodiodes have to be moved by 4.125 cm to read
the second half of the row. Therefore the next 5 bytes would be placed in
memory, the last point being unread.
5. This point is read separately by choosing only the required photodiode
and this bit is stored separately in the next byte.
6. In this way, one row consisting of 81 points would occupy 10+1 bytes
7. The entire photodiode system is moved back to the start at the left and
then vertically downwards by 0.125cm and then the read operation
commences as from step 2.
8. The entire page therefore comprises of 81 columns and 81 rows. Each row
taking 11 bytes would imply that the entire page would take 11x81 = 891
bytes of memory for storing the image read.
ALP:
.code
.startup
NEXTROW: PUSH CX
MOV DL,0
MOV CX,8
READAGAIN1: CALL READPIX
MOV AL,POS1
ROR AL,1 ; rotates motor through one step
OUT SMOTOR1,AL
CALL DELAY_MOT
MOV POS1,AL
INC DL
LOOP READAGAIN1
MOV CX,33
MOV AL,POS1
MOV POS1,AL
ADD SI,5
MOV DL,0
MOV CX,8
MOV AL,POS1
ROR AL,1
OUT SMOTOR1,AL
CALL DELAY_MOT
MOV POS1,AL
MOV CX,1
NOP
NOP
NOP
NOP
X1: LOOP X1
MOV AL,0
OUT SIGNAL_ADC,AL
NOTOVER: IN AL,SIGNAL_ADC
AND AL,1 ;checking EOC
JZ NOTOVER
;conversion over
CMP AL,00H
JZ SKIP
OR [SI+5],80H
CALL DELAY_MOT
LOOP AGAIN2
MOV POS1,AL
MOV AL,POS2
ROR AL,1
OUT SMOTOR2,AL
CALL DELAY_MOT
MOV POS2,AL
ADD SI,6
POP CX
LOOP NEXTROW
.exit
PUSH CX
MOV BX,0
;BX holds the diode being selected currently through MUX
MOV CX,5
MOV AL,40H
OUT SIGNAL_ADC,AL ;start pulse
MOV AL,0
OUT SIGNAL_ADC,AL ;make pulse 0
GOBACK: IN AL,SIGNAL_ADC
AND AL,1 ; check EOC
JZ GOBACK
;conversion over
MOV AL,20H
OUT SIGNAL_ADC,AL ;OE = 1
IN AL,ADC ;AL contains ADC output now
CMP AL,00H
JZ FORWARD
MOV AL,80H
PUSH CX
MOV CL,DL
SHR AL,CL
POP CX
OR [BX+SI],AL ;stores in memory
FORWARD: INC BX
LOOP NEXTBYTE
POP CX
RET
READPIX ENDP
PUSH CX
MOV CX,501
X2: NOP
LOOP X2
POP CX
RET
DELAY_MOT ENDP
end