+ All Categories
Home > Documents > DIGITAL IMAGE SCANNER -...

DIGITAL IMAGE SCANNER -...

Date post: 30-Sep-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
30
DIGITAL IMAGE SCANNER M Tech Project Report of Suresh R Norman (Extracts from) _______________________________________________________________________________ ACKNOWLEDGMENT This Thesis is being submitted as partial requirement for the award of Masters’ degree in Electronics Engineering. I wish to express my sincere thanks and gratitude to all the staff, students and well wishers who enabled me to complete the work satisfactorily. I am especially grateful to my product design guide, Mr. J.E. Diwakar, and electronic design guides Mr. M.K. Gunasekaran and Mr. V. Sastri who guided and inspired me. Lastly I am thankful to my parents for their continued support and encouragement ________________________________________________________________________________ CONTENTS Page no. 1.0 Introduction 2 2.1 General Scheme 2 2.2 Scheme 1 3 2.3 Scheme 2 3 2.4 Scheme 3 4 2.5 Input Module 4 2.6 Signal Conditioning 4 2.7 A-D and D-A unit 5 2.8 Drive electronics 5 2.9 Power Supply 5 1
Transcript
Page 1: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

DIGITAL IMAGE SCANNERM Tech Project Report of Suresh R Norman

(Extracts from) _______________________________________________________________________________

ACKNOWLEDGMENT

This Thesis is being submitted as partial requirement for the award of Masters’ degree in Electronics Engineering.

I wish to express my sincere thanks and gratitude toall the staff, students and well wishers who enabled me tocomplete the work satisfactorily.

I am especially grateful to my product design guide,Mr. J.E. Diwakar, and electronic design guides Mr. M.K.Gunasekaran and Mr. V. Sastri who guided and inspired me.

Lastly I am thankful to my parents for their continued support and encouragement

________________________________________________________________________________

CONTENTS

Page no.

1.0 Introduction 22.1 General Scheme 2 2.2 Scheme 1 3 2.3 Scheme 2 32.4 Scheme 3 42.5 Input Module 42.6 Signal Conditioning 42.7 A-D and D-A unit 52.8 Drive electronics 52.9 Power Supply 53.0 Inter-face Requirements 53.1 Keyboard 6 Target Specifications 6

Design Report 7Pixel acquisition software - Flow-chart 14Data display routine - Flow-chart 17 System flow chart - Flow-chart 18Assembly programmes 19 Epilogue 24

1

Page 2: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

IMAGE SCANNER

INTRODUCTION :

The Image Scanner is an electronic system which scans an image of dimension 10in.*10in., converts the grey scale image into equivalent digital information and stores it in memory.

Subsequently, software tools are used to modify the image if necessary, before final display and reproduction.

2.1 The general scheme is as shown below:-

Several Schemes were considered, for example :-

(a) The image scanning system as a stand-alone unit. - ie. with its in-built processing unit- system control, buffer memory, etc. and connected serially to a PC for storage only. (b) Image scanner as a desktop peripheral working in conjunction with a PC through a parallel port.(c) Modification of (b) where the desk-top unit has a conditioned analog signal line ouput that plugs into a PC Input Port.

The Schemes have their relative advantages and disadvantages which are given below.

--------------------------- IMAGE SCANNER

---------------------------

--------------------------- COMPUTER---------------------------

2

Page 3: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

2.2 Scheme 1

SERIAL DATA LINK

Since the image scanner functions as an off-line peripheral,the digitised image pixels can be serially output from the 8085-based Scanner System.

Thus the PC is free to carry out its own functions and only memory space-RAM & floppy is needed.

This is a cost effective arrangement, but the only disadvantage is software overheads. Very lengthy software is to be written in assembly level language with the additional debugging problems.

2.3 Scheme 2

PARALLEL INTER-FACE

In this scheme, the system control is not an 8085-based System but the PC itself. Hence that amount of circuit simplification, pcb fabrication and cost reduction due to elimination of 8085-based system is possible.The input module, signal conditioning, A\D conversion remains the same as in the previous scheme.The difference is that digital information is sent into a parallel bus with a parallel Port communication card added on to the PC.(Approx. cost Rs.600/-)

I/PMODULE

SIGNAL CONDITIONING+ A/D

8085MICRO-PROCESSOR based SYSTEM CONTROL

--------------------------- PC

---------------------------

I/PMODULE

SIGNAL CONDITIONING

A/D UNIT

COMM.CARD I/F PC

3

Page 4: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

The PC performs the tasks of system control - such as the digitisation of pixels, carriage motion control, carriage return, etc. Sufficient no. of lines are available in the PC for these functions.Other PC utilities such as floppy-Winchester-RAM Memory and display monitor are also utilised.Thus though the cost of the PC will be considered, the utilisation will only be for the picture scanning time ie. five to six minutes per picture; the rest of the time the PC is available for normal usage.

2.4 SCHEME 3

ANALOG SIGNAL (0-10V)

Instead of a parallel port and parallel communications card, the analog conditioned signal is transmitted through a serial link. The disadvantage to this scheme is that a PC compatible A-D Card is required. This card costs approx. Rs. 8000,and offers several additional features which are not really needed for this application.Obviously, there is an increase in overall cost. Another alternative could be to develop an A-D Card for this application.

2.5 The Input Module :-It contains the Sensor Assembly- ie. the two photo-sensors (HEDS-1000 or

the later HBCS 1100).Photo-sensor 1 converts the grey scale image to an equivalent photonic

current.Since this current is in nano-amperes, suitable shielding and signal conditioning is required.

Photo-sensor 2 is used to provide a synchronising pixel clock.(The photo-sensor used is Hewlett Packard’s HEDS-1000 which is a photo reflective sensor containing a transmitter,lens assembly and receiver)

2.6 Signal Conditioning :-The photo-current is of the order of 100 nano-amperes so it needs to be

upgraded to a level compatible with the A-D input. Also the signal needs to be steady before conversion, so a sample-hold is required.

I/PMODULE

SIGNAL CONDITIONING

PC A/D CARD

4

Page 5: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

2.7 A-D and D-A unit:-

The function of this unit is :-(1) to digitise pixels for storage and further processing.(2) to provide synchronising for pixel registration by means of a pixel

clock.(3) and reproduction of stored digital signals.

For pixel clock, the choice fell on an opto-electronic assly. because of better resolution and cost features as compared to the use of an optical shaft encoder which has more wear and tear, more cost and non-availability.

Of course, the opto-electronic assembly needs fine mechanical adjustments.

2.8 Drive Electronics :-

The drum has to be rotated at a constant speed. Hence the use of an AC synchronous motor is preferable to a dc motor. Also the drive is much simpler since the ac synchro motor runs on 230 Volts/50 Hz.

For carriage return the requirements are :-(1) operation in start-stop mode.(2) low torque load.

Stepper-Motor is the obvious choice for start-stop motion and single- stepping as compared to a dc motor. Besides, dc motor requires complex closed- loop control.

Drive design will take into account features such as load, step angle etc.

2.9 Power Supply :-

Power supplies are required for :-(1) analog circuits.(2) digital circuts.(3) stepper motor drive.

+5V and +12, -12V supply is needed. The current requirements are yet to be worked out. Possibly, the standard power-supply being developed at CEDT will be used and will suffice.

3.0 Interface requirements :- Interfacing the scanner to a PC can be through an RS-232-C serial

interface or an 8-bit parallel Interface.Advantages of RS 232-C are :-- compatible with any computer- can drive to much larger distances (100 ft. at 2400 baud)

Dis-advantages are :-- Slower speed of transmission, maximum of 9600 Baud (and the time to

transmit one byte ie. One pixel is 1ms.) This is five times less than the actual requirement. A large buffer RAM is needed because the scanning rate is 5 KHz.Disadvantage- it can only link with PC’s.

5

Page 6: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

3.1 Keyboard Requirements :-As per the work done earlier, the following operation modes are required

for the product to be user - friendly.1. SCAN - REPRODUCE Selector2. MANUAL - REMOTE3. START - PAUSE Switch4. RIGHT - LEFT Motion of Carriage.5. Leds., for messages indication.

KEYBOARD

TARGET SPECIFICATIONS

1. Spot Resolution of 200 microns.2. 256 Grey - levels for Scan - Reproduce3. Scanning Time - 11 minutes.4. Picture size of 10 in. * 10 in5. Desktop Operation with PC

DESIGN REPORT

6

Page 7: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

(2.1)The Digital Image Scanner has the following four imp. areas of design :-1) Analog signal conditioning2) Digitising of analog signal and movement or pixel bytes3) Motion control of carriage and drum assembly4) Software design -the modules that link with above hardwareAnalog design begins at the input sensor scanning the picture upto the

process of digitisation of pixels at the a/d block.The sensor used for scanning the picture is the HEDS-1000 high resolution

reflective sensor which has an inbuilt 700 nm.emitter lens assembly and photo-detector,housed in a TO-5 package.

The reflected signal is a function of the varying brightness of the pixel elements scanned or their grey levels.

The background dark current of the sensor is approximately 100 nA and the white max.signal 220nA. Since SNR is not good at the source itself the input circuitry is highly critical and must not further reduce the Noise figure.

Noise pick-up at the input stage was found to swamp the input signal considerably.

PICTURE DRUM

S1 S2

Sensor Carriage Assembly Fig. 1.0

S1 = pixel reading sensor – HEDS-1000/HBCS1100 ( Hewlett Packard Mfgr.) S2= pixel synchronizing sensor

S2 reflected signal response

peak white 100%

7

Page 8: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

maximum black

0% time

Volts

End of line Gap

time

Fig 2.0

2.1 The analog signal module has the following :-(1) Conditioning of the analog signal.(2) Analog Digital conversion of a pixel while scanning.(3) Obtaining a synchronising clock corresponding to spatial location of

the pixel.The HEDS - 1000 high-resolution photo-detector is the sensor used to

obtain the photo-signal. As mentioned earlier, the dynamic range of the signal is 100 nA (dark current) and Ips (stray photo - current). The photo signal of Ip (photo-current) and Ips (stray photo-current). The stray photo-current is a noise signal generated by ambient light and varies from 20 nA to 50 nA max.

Incidentally, a long-wave filter has been provided on the sensor to reduce stray current to a minimum. (ie. to cut off any reflections due to reflected light).

The input amplifier chosen is the FET input op-amp CA 3140. The reason being its offset current is of the order of 2 pA as compared to the optic signal of 100-200 nA. Secondly the FET input stage has a Zin of 1.5 tera-ohms which is ideal for low current sources.The photo-amplification has been done in two stages:-

In the first stage, the low level signal is converted into a voltage of the order of 300 mV. The low noise FET input op-amp CA 3140 has been chosen for this purpose.

The second stage amplifier is not so critical in terms of offset drift and noise and a CA 3140 is not essential. However, the same chip has been used for second stage also.

After the second stage, the signal level swing is 0-5 Volts peak and readyfor digitization.

8

Page 9: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

(Part Numbers in Scanner PCBs Parts List)

2.2 For Analog Digital conversion, the ADC 0800 was chosen rather than the ADC 0801, or ADCO804.

The main reason was the faster conversion rate of ADC 0800-40 micro-sec as against 100 micro-sec of ADC 0801 / 0804, though the 0804 has certain advantages such as internal clock, direct interfacing with micro-processors etc.

The Start - conversion pulse of 2 microsecond on time, is derived from the single-shot 74 LS 221 as indicated in timing diagram. The R and C values have been calculated accordingly.

Since the time - window allotted per pixel is 200 microsecond, one half of the time frame is used to hold the signal steady and during the second half of time frame the signal is sampled for digitising. The sample and hold chip used is the 398, and the sample and hold clock is the pixel clock, which provides the necessary 100 microsec hold and 100 microsec sample time.

The synchronising clock is derived from a band of alternate black and white bands fixed on the circumference of the drum. This ensures spatial synchronisation of the pixels on the image being scanned. The second sensor (also Heds - 1000) detects these black and white bands which are further amplified. For this purpose the same chip CA 3140 is used. However two stages of amplification are not needed, since the interal transistor in the sensor is used. The transistor has a beta of 100-300 but the gain variation is not consequential since we are only interested in detecting two levels at this stage. The sensor signal is amplified and sent to a comparator LM 311 with a variable reference and suitable hysterisis.

The output of the comparator is a clean clock which is now available for Pixel synchronising.

SIGNAL TIMING Diagram

9

Page 10: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

100 sec

Pixel Clock

2sec

Start Conversion

End of Conversion

80 sec

Output Enable

ADClock 2 sec

Data

Fig 3.0

(2.2) MOTION CONTROLThere are two kinds of motions performed in the DRUM SCANNER:- (1) ROTARY MOTION of the drum, on which the picture to be scanned is

10

Page 11: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

mounted.(2) LINEAR MOTION of the carriage that bears the SENSOR HEAD, across the

length of the picture.The design parameters of the dynamics of both (1) and (2) have been worked

out by two earlier batch students of CEDT , according to which the physical design of the mechanical systems has been constructed (ref. Design Report, Suresh / Ranganathan)

Hence,I am not incorporating any changes in the physical design but directly proceeding to the motor control electronics.

The drum, being controlled by an ac synchronous motor doesn’t need any further electronic control. Any change in ac line freq. which would create change in motor rpm will create jitter in the digitised picture. Rather than having a complex closed loop servo control, the change in drum rpm can be offset by having a synchronising clock derived from scanning of a band of black and white bands mounted on the drum itself.

The electronics of the synchronising clock has been described earlier, along with the scanning circuitry.

LINEAR MOTION

The electronics for the control of the stepper motor had to be designed, with the dynamics of the system already worked out as told earlier.The two requirements are:-

(1) SEQUENCER - to generate the sequence of pulses for stepping the Motor an integral number of steps in the clockwise and anti-clockwise directions. (2) DRIVER:- to drive the coils of stepper motor at an optimum current in accordance with the sequence of pulses generated by the sequencer.

The torque supplied by this stepper drive is sufficient to move the load, ie. the carriage without the necessity of enhanced torque drives etc.

Also, settling time of the single-stepping was found to be well within the allowable limit (worst-case 40-50 ms. within an allowable max. frame of 100ms.)

During system integration, if settling time needs to be further reduced, suitable corrective action will be taken. (This will be apparent from wobbly lines etc.)

The Sequencer could have been Hard-ware derived; however it was found that soft-ware generated sequencer did the same functions more efficiently, reliably, and with decrease of chip-count.

The soft-ware has been written and even verified (before design phase), for the motion control of the stepper-carriage in both clock-wise and anti-clockwise directions from the origin to the end of the picture.

The fail-safe lock at the end and beginning of the linear scan is incorporated in the Software, to ensure safe operation at all times.

Further, local control will also be provided to the operator to interact with the motion-control software.

The schematic is as follows:-

11

Page 12: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

(2.3) ENTER THE DIGITAL DATA DOMAIN :-From the opto-electronic module, described earlier, we now have an analog

signal varying from 0-5 volts, corresponding to the dark and white levels. If we were only interested in bi-level image acquisition, the digital circuitry needed is reduced to a bare minimum. However, we are interested in the number of grey levels obtainable within this dynamic range.

Some of the possible choices are : v / f conversion4-bit A/D conv.B - bit A/D conv.(256 grey levels)

The design of the data acquisition unit was based on the NS-ADC 0800 chip. (the conv. time of 30 microseconds was suitable for this application, rather than say 100 microsecs of 0804.

The conditioned analog signal is sampled using the standard 398 S/H chip,and fed as input to the a/d unit. The Start Conversion signal is derived

12

Page 13: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

from a mono-stable triggered by the pixel-synchronising clock. This ensures that digitisation begins at a fixed point within the pixel-window-ie. the time per pixel on scan.

Once the data bytes are obtained for each line scanned, these bytes are moved into a pre-defined buffer for future use. Next, the stepper software steps the scanning head through one step (distance = resolution of sensor). The cycle is repeated until the entire picture is scanned, leaving the buffer area with the digitised data.

2.21 Data Communications:- The digitized data is stored and manipulated in the PC RAM/DISK area. This does away with the necessity of having semi-conductor memory on the device motherboard. In order to transfer the acquired bytes to the PC, a parallel communications interface card has been used. The same could have been used on the main motherboard, but since the standard interface is available at a reasonable cost,this was opted for.The interface provides upto 6 programmable ports, based on the 8255 chip. Out of these, 3 ports are sufficient to handle most of the controlling functions & data handling operations.

2.24 Software Design:-

The software design consists mainly of 3 categories:-

(1) DIAGNOSTIC SOFTWARE(2) SYSTEM SOFTWARE- a)PIXEL RELATED SOFTWARE

b)MOTION CONTROL SOFTWARE

13

Page 14: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

PIXEL ACQUISITION Software

14

Page 15: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

4.1 Product Conceptualisation :The first model of the scanner had a tray in which the PCB’s were mounted.

This was cumbersome from the servicing point or view. Also, the length of cables used was more, resulting in more noise pick-up.

In the second iteration, the PCB’s have been fixed inside the main housing instead of the external tray. This, as explained above, is more acceptable from the servicing point of view and reduces noise.

In the third iteration, the PCB layout and mounting has been designed for modular installation and ease of accessibility as far as servicing is concerned. Instead of one high density system control board accesible from the front of the device there are now two PCB’s easily accessible from the front viz., the A/C card and the stepper driver card.

Also, for trouble - shooting purposes the modules can easily be disconnected. Also, the input stage has been incorporated in the A\D card and not on the moving sensor platform. Adequate gain has been provided for that purpose.

4.2 Thermal Design :No forced cooling has been provided, since the scanner is to be used along

with a PC in an air-conditioned environment. However sufficient allowance has been made for the design of stepper drive heatsink. Incidentally, the drum motion itself produces forced air-cooling of the PCB’S etc.

4.3 Product Safety :Care has been taken to provide a proper safety power ground. This ensures

safe operation to the user, since the drum motor runs on AC mains supply.Care has also been taken to ensure that noise pick-up is minimum with the

usage of shielded cabling to carry the input signal which is of the order of nano-Amperes.

Light - sealing has been provided to ensure that ambient light is minimum, since any noise will be detected as noise.the board : Starting from the left, input pulses, pre-drivers and phase drive outputs.

5.2 A comprehensive test of the analog section, A/D section and the motion section is done with a single integrated test programme. This programme does the following tasks:-

(1) Moves the scanner 160 steps forward.(2) Scans 160 lines (220 columns each).(3) Stores the digitised value of pixels.(4) Displays the pixels.(5) Returns to hom position.

A semi-automatic focussing test for the sensor had been suggested by the earlier CEDT student N.L. Narasimha Rao in their Report. The principle is based on the fact that the light signal peaks at the best focus of the sensor, which is at 4.5 mm. from the sensor window. Hence a software routine can be written to read a fixed pixel and detect the maximum value which will indicate the best focus.However, presently a manual focussing is being done and the best focus position determined by viewing it on an oscilloscope. The semi-automatic focusing routine may also be implemented

15

Page 16: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

6. Software Structure :The software routines designed for the system are as shown in the software

structure diagram.6.1 Diagnostic software (X 10) has already been described in the test section. This is a routine that checks step motion, pixel acquisition & data at system integration level.6.2 System Control Software (X11) This programme controls the remote and manual operation of the scanner.

Lastely modules X12, X13, X14, X15 have been integrated for real-time image acquisition and display.

16

Page 17: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

DATADISPLAYROUTINE

NO

YES

NO

YES

17

START

INITIALIZE DATA PORT/ SET DISPLAY MODE/INITIALIZE DATA POINTER

LOAD ROW COUNTER &DECREMENT COUNTER

IS COUNT= ZERO?

STOP

LOAD COLUMN COUNTER

DECREMENT COLUMN COUNTER

OUT BYTE TOVIDEO DISPLAY

IS COUNT= ZERO?

Page 18: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

YES

NO

NO(REPRO- Mode) YES (SCAN MODE)

YES

NO

NO(MANUALMODE)

YES(REMOTE MODE)

YES

SYSTEM CONTROL Fig. 5.0-Flowchart 4 NO

Assembly code I had figured for scanning 2 switches , acquiring digitized pixel bytes and motion control of the scanner sensor carriage( all real time).

18

START

IN SWITCH STATUS WORD

TEST SCAN SWITCH BIT

IS THESCANbit high? HIGH?

IS BIT HIGH?

GO TO STEPPER MOTION CONTROL SOFTWARE

TEST RESET SWITCH BIT( manual mode)

Is RESET BITlow? HIGH

REVERSE STEPS TILLLIMITSWITCHTEST THE FWD

SWTCH BIT

IS THEFWD BIT LOW?

MOVE FORWARD STEPS

TEST REMOTE/MANUAL SWITCH BIT

TEST THE REV SWTCH BIT

IS THEREV BIT LOW?

MOVE REVERSE STEPS

Page 19: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

(recovered from the attic!)

codehere segment ;prog 200*200 scan 2 control switches, acquire pixel data & sensor carriage motion assume cs:codehere,ds:codehere,es:codehere

s tart:mov ax,codehere mov ds,ax

mov ax,0b800hmov es,axmov dx,303h ;initialise input/output portsmov al,92hout dx,almov bx,offset data_areamov al,05hmov ah,00hint 10h ;set display mode 320x200 b&w

scan:mov dx,300h ;set in-port to get switches status in al,dx ;in switch status bits to al from in-portand al,84h ; test scan&remote switches status jnz scan ;wait till scan and remote switches onjz next ;branch if scan and remote switch on

next:mov cx,160 ;row count 160push cxmov al,33hmov ah,00hpush axmov dx,00

loop1: push dx ceol 1: mov dx,300h ;set in-port to get end-of-line sig.(eol)

in al, dx ; load in-port signal bits to al register and al,08h ;check eol signal status jnz ceol 1 ;wait if not zeromov cx,75 ; load timer count in count register

d1: dec cx ;decrement timer countjnz d1 ; loop if timer count not zeromov cx,100 ;load timer count in count register

d2: dec cx ;decrement timer countjnz d2 ; loop if timer count not zeroin al, dx ; in switch status bits againand al,08h ;check eol signal againjnz ceol 1 ;wait, loop if al not zeropop dxpop axpush dxmov dx,302h ;set out-port for sending stepper pulsesout dx,al ; send al register bits to out-portmov cx,0ffffh ;load timer count for stepper pulses

d3: dec cx ;decrement timer countjnz d3 ; loop if timer count not zero

19

Page 20: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

rol al,1 ;rotate left ,al bits onceout dx,al ;send al register bits to out-portpop dxpush axpush dxmov cx,220 ;load pixel column count

loop2: push cxmov dx,300h ;set in-port to acquire switches status

linesc1: in al,dx ; in switch status bits

and al,08h ;check end of line status signaljz c1 ;loop if al zero

c2: in al,dx ;in switch status bits again and al,010h ;check if EOC signal high?jz c2 ;loop if al zeroxor ax,ax ;clear ax register bitsmov dx,301h ;set in-port to obtain pixel byte data in al,dx ;input pixel bytemov[bx],al ;store pixel data in pointed locationand ax,0003h ;mask lowest 3 bits pixel bytenot,al ;invert al bitsmov[bx],al ;store pixel data in pointed locationnop ;no operationnot,al ;invert al bitsinc bx ;increment bx bitspop cxpop dxmov ah,0chint 10h ;display data as it is acquired real

timepush dxdec cx ;decrement count registermov ah,0chint 10h ;video display interrupt-display data

as it is acquired real timedec cx ;decrement count registerjnz loop2 ;loop if count not zeropop dxinc dx ;increment dx registerpop axpop cxdec cx ;decrement count registerpush cxpush axjnz loop1 ;loop if count not zero-pixel data

complete on loop completionmov cx,200mov dx,302h ; set output port to out stepper pulses

loop5:out dx,al

20

Page 21: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

push cxmov cx,05ffh ;load timer count in count register

d5: dec cx ;decrement timer countjnz d5 ;loop if count not zeroror al,1 ;for reverse 200 stepspop cx ;load new timer countdec cx ;decrement count registerjnz loop5 ;loop if count not zeromov bx,offset data_areamov al,05hmov ah,00hint 10h ;set video display modemov dl,00mov cx,160 ;row count

loopa:push cxmov cx,220

loopb:xor ax,ax ;clear ax registermov al,[bx] ;move pixelfrom pointed locn. to alnot,al ;invert al bitsinc bx ;increment bx registermov ah,0chint 10h ;display acquired /stored pixel datadec cx ;decrement cx registerjnz loopb ;loop if count not zeroxor cx,cx ;clear cx bitsinc dlpop cx dec cx ;decrement count registerjnz loopamov ax,4c00hint 21h ;dos interrupt

data_area: db 2000h dup(00h) db 2000h dup (00h) db 2000h dup (00h) db 2000h dup (00h)

db 2000h dup (00h)codehere endsend startend

Programme for scanning control switchesassume cs:codehere,ds:codehere,es:codehere

21

Page 22: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

s tart : mov ax,codehere mov ds,ax

mov ax,0b800hmov es,axmov dx,303h ;initialise input/output portsmov al,92hout dx,almov bx,offset data_areamov al,05hmov ah,00hint 10h ;set display mode 320X200 b&w

mov dx,300h ; set input port to acquire switches status lines

scan1: xor ax,ax ;clear ax registerin al,dx ; in scan bitand al,80h ;test if scan switch bit status on

( active low )not,al ;invert al reg bitsjz scan1 ;loop until not zero- not scan mode

but reproduce photo-plot mode jnz time1 ;timer for checking scan switch on

time1:mov cx,04fffh ;load timer count in count registerd10: dec cx ;decrement count

jnz d10 ;loop if count not zerojz scan2 ; repeat scan switch test after delay

scan2: xor ax,ax ;clear ax bitsin al,dx ; in switch status bits and al,80h ;test scan switch bit status againnot,al ;invert al reg bits

jz scan2 ;loop until not zero -not scan mode but reproduce photo-plot mode

jnz scan3 ;branch if not zeroscan3: xor ax,ax ;clear ax bits

in al,dx ; in switch status bitsand al,20h ; test reset switch bit statusjz revs ;branch on zero to code to generate

pulses for 300 reverse steps jnz fscan1 ;branch on not zero to forward switch

status testing revs:mov cx,300 ;load count no. of reverse steps in

count registermov dx,302h ; set output port to send stepper motor

pulsesmov ax,0066h ;load ax register with 0066h

loopr: out dx,al ;send al bits to out-portpush cx ;save register contentsmov cx,0fffh ;load timer count in count register

dr: dec cx ;decrement countjnz dr ;loop till count zero

22

Page 23: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

ror al,1 ;rotate right al bits oncepop cx ;restore register contentsdec cx ;decrement count registerjnz loopr ;loop if not zeromov dx,300h ;set in-port to acquire switches status

rscan1: xor ax,ax ;clear ax bitsin al,dx ; in switch status bitsand al,02h ;test if reverse switch onjz time3 ;if zero, check if reverse switch againjnz fscan1 ;if not zero, check if forward switch on

time3:mov cx,0fffh ;load count in timer register d30: dec cx ;decrement count register

jnz d30 ;loop till count zerojz rscan2 ;branch if count zero

rscan2:in al,dx ;in switch status bitsand al,02h ;test again if reverse switch on jnz fscan1 ;if not zero, check if forward switch on

jz revs ;branch on zero to code to generate pulses for 300 reverse steps fscan1: in al,dx ; in switch status bits

and al,01h ;check if forward switch on jz time4 ;branch on zero to timer for forward switch

jnz rscan1 ;if not zero, check if reverse switch on time4: mov cx,0fffh ;load count in timer register d40: dec cx ;decrement count register

jnz d40: ;loop till count zerojz fscan2 ;if zero,check if forward switch on

fscan2: in al,dx ; in switch status bitsand al,01h ;check again if forward switch onjz fwd

jnz rscan1fwd: mov cx,300

mov dx,302hmov ax,0033h

loopf: out dx,alpush cxmov cx,0ffffh

dsf: dec cxjnz dsfrol al,1pop cxdec cxjnz loopfmov ax,4c00hint 21h

data_area:db 2000h dup (00h)codehere endsend start

23

Page 24: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

end

Later both programmes were integrated.

Epilogue

All I did was to integrate the System and get it working.In the proto-type , a 100 odd byte assembly programme was used to acquire the pixels, and step the Sensor Carriage forward or reverse and another less than 50 bytes to continuously soft scan five switches in the control panel. Only 4 grey levels were demonstrated on the display monitor .

Since I did not take the microprocessor hardware and software elective , I had to learn/refer from Microprocessors and Interfacing by Douglas V Hall.

24

Page 25: DIGITAL IMAGE SCANNER - suresh-norman.angelfire.comsuresh-norman.angelfire.com/digitalimagescanner.doc  · Web viewM Tech Project Report of Suresh R Norman (Extracts from) _____

25


Recommended