optical sensor based dynamic signature recognition and verification tool

130
Project Report On OPTICAL SENSOR BASED DYNAMIC SIGNATURE RECOGNITION AND VERIFICATION TOOL Siddharth Shashidharan Himanshu Madan Sneha Rangdal Sanika Mokashi

Upload: api-19979847

Post on 18-Nov-2014

267 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

Project Report On

OPTICAL SENSOR BASED

DYNAMIC SIGNATURE

RECOGNITION AND

VERIFICATION TOOL

Siddharth Shashidharan

Himanshu Madan

Sneha Rangdal

Sanika Mokashi

Page 2: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

2

COLLEGE OF ENGINEERING, PUNE

Shivajinagar, Pune - 411 005

(Formerly Government College of Engineering, Pune)

CERTIFICATE

This is to certify that SIDDHARTH SHASHIDHARAN of

T.Y.B.Tech, E&TC, has satisfactorily completed the Electronic Design

Mini-Project –

OPTICAL SENSOR BASED DYNAMIC SIGNATURE

RECOGNITION AND VERIFICATION TOOL

for the year 2006-2007.

S. P. Mahajan

Dept. of E&TC

College of Engineering, Pune

Page 3: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

3

ACKNOWLEDGEMENT

We take this opportunity to express our heartfelt gratitude to the professors

and staff of College of Engineering, Pune for their constant inspiration and

guidance. We would, in particular, like to thank Professors Mahajan,

Bartakke and Vyas for their support and are deeply indebted to them for

their technical advice derived from the vast pool of their experience and

knowledge.

We could not have conceived of undertaking a project on such a massive

scale without the encouragement and blessings of our professors and

parents.

Page 4: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

4

INDEX

SECTION 1: Introduction 05

SECTION 2: Block Diagram 08

SECTION 3: Hardware 10

CH.1: Mouse And PS/2 Standard 11

CH.2: Microcontroller 28

CH.3: EEPROM 34

CH.4: Serial Port Communication 38

CH.5: Interfacing 41

SECTION 4: PCB Design 42

CH.1: PCB Design Rules 44

CH.2: PCB Software 47

CH.3: PCB Layout 49

SECTION 5: Mechanical Design 52

SECTION 6: Software 61

CH.1: Software Description 62

CH.2: Graphics User Interface 63

CH.3: Dynamic Signature Verification 67

CH.4: Character Recognition 93

CH.5: Design Aid 97

SECTION 7: Costing 102

SECTION 8: Conclusion 104

SECTION 9: References 106

SECTION 10: Appendix 109

Page 5: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

5

SECTION 1

INTRODUCTION

Page 6: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

6

INTRODUCTION

It is said that necessity is the mother of all invention. History has taught us that

what epitomises an advanced civilization is its ability to harness the power of the

human mind. Built on the foundations of reason and logic, creativity and re-

invention, we have come to understand this in modern terms as the technology

that fuels the global economy.

As engineers especially, we are burdened with the responsibility of constantly

improving upon, and finding alternate solutions to, old problems that are

inevitably tossed up by both science and nature.

Real vision however lies in recognising and capitalising on opportunities that hide

deep only in the mysterious realms of our imagination. To turn old adages on

their heads, an invention can sometimes precede its worth in society.

Global markets today are flooded with products and solutions for nearly every

conceivable need of man. How then, does one hope to stand out and carve a

niche of this expanse in his favour? The answer again is innovation. And this is

the very philosophy that motivates us to go in search of a vision to produce

something original whilst always considering the commercial aspect of the

design.

Customers today demand reassurances from banks and other financial

institutions when it comes to monetary transactions and account control. A

simple pin code may not be a very ideal form of security in ATM machines.

Official documents may be forged and reproduced thereby causing losses in

millions of dollars for corporations and individuals every year. The day is not far

when we will see the implementation of Biometric systems as an additional

security entity.

Page 7: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

7

But as is often the problem with many emerging technologies, the high prohibitive

initial costs act as a deterrent in the way of inculcation of these biometric systems

into mainstream marketplaces.

This however, is exactly where an opportunity lies, that maybe be capitalised

upon via cost-leadership solutions.

Take the case of signature verification and identification systems - The present

market scenario shows a prevalence of touchpad systems that are extremely

expensive for one, and rather bulky for another. Additionally, it is rather difficult

to use these systems where a very high degree of security is needed.

Through the course of the next few chapters, you will see how we have tried to

bridge this gap between cost and technology, while focusing on security,

functionality and mobility.

In order to overcome the inherent problems faced by the touchpad-based

systems, we had to conceive of a solution that worked on a completely different

principle, and we found our answer in something that has become an integral

part of our lives – the computer mouse.

An optical mouse sensor circuit is extremely cheap and highly reliable, not to

mention its’ easy of availability.

We shall also attempt to demonstrate its versatility through other applications that

can perform character recognition and act as a design aid for civil and

mechanical engineers.

This report shall first explain the system of working of the common optical mouse

and the PS/2 standards on which it can be operated. It then proceeds to

demonstrate it’s interfacing with a microcontroller and other aspect of hardware

design. The software part follows, and the project concludes with the basic

costing and scope for the project as a whole, while also attempting to illustrate

additional possibilities in the future.

Page 8: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

8

SECTION 2

BLOCK DIAGRAM

Page 9: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

9

M

I

C

R

O

C

O

N

T

R

O

L

L

E

R

AT24c512

AT24c512

AT24c512

BLOCK DIAGRAM

The block diagram here gives an overall idea of the system used.

An optical mouse sensor circuit is interfaced with a microcontroller that reads the

data co-ordinates in the form of X and Y position bytes, sent to it by the mouse

and uses externally connected EEPROMs to store the data offline. In order to

process this data, we interface the microcontroller with the computer by means of

the RS – 232 serial port.

The computer reads the data from the microcontroller and processes on the

MATLAB software platform. Let us now turn out attention to the various hardware

components and their interfacing in the following few sections.

Mouse

D

S

P

ADNS2610

TTL to MAX 232

RS -232

Page 10: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

10

SECTION 3

HARDWARE

Page 11: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

11

CHAPTER 1: MOUSE AND PS/2 STANDARD

1.1 A Brief History Of The Optical Mouse:

An optical mouse uses a light-emitting diode and photodiodes to detect

movement relative to the underlying surface, rather than moving some of its parts

— as in a mechanical mouse.

Early optical mice, circa 1980, came in two different varieties:

1. Some, such as those invented by Steve Kirsch of Mouse Systems

Corporation, used an infrared LED and a four-quadrant infrared sensor to detect

grid lines printed with infrared absorbing ink on a special metallic surface.

Predictive algorithms in the CPU of the mouse calculated the speed and direction

over the grid.

2. Others, invented by Richard F. Lyon and sold by Xerox, used a 16-pixel

visible-light image sensor with integrated motion detection on the same chip and

tracked the motion of light dots in a dark field of a printed paper or similar mouse

pad.

These two mouse types had very different behaviors, as the Kirsch mouse used

an x-y coordinate system embedded in the pad, and would not work correctly

when rotated, while the Lyon mouse used the x-y coordinate system of the

mouse body, as mechanical mice do.

As computing power grew cheaper, it became possible to embed more powerful

special-purpose image-processing chips in the mouse itself. This advance

enabled the mouse to detect relative motion on a wide variety of surfaces,

translating the movement of the mouse into the movement of the pointer and

eliminating the need for a special mouse-pad. This advance paved the way for

widespread adoption of optical mice.

Developed by Agilent Technologies and introduced to the world in late 1999, the

Modern surface-independent optical mice use a small, red light-emitting diode

(LED) that bounces light off the surface onto a complimentary metal-oxide

semiconductor (CMOS) sensor to take successive pictures of the surface. For

Page 12: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

12

example, the Agilent Technologies ADNS-2610 optical mouse sensor processes

1512 frames per second: each frame is a rectangular array of 18×18 pixels, and

each pixel can sense 64 different levels of gray. The CMOS sensor sends each

image to a digital signal processor (DSP) for analysis. The DSP, operating at 18

MIPS (million instructions per second), is able to detect patterns in the images

and by comparing with the previous Images able to translate the pattern into

movement on the two axes using optical flow estimation algorithm. This

estimated differential motion co-ordinates are then send to the computer. The

computer moves the cursor on the screen based on the coordinates received

from the mouse. This happens hundreds of times each second, making the

cursor appear to move very smoothly.

1.2 Use Of The Optical Mouse Sensor Circuit:

The optical mouse has been around for quite a few years now during which time

it has been perfected to be reliable and highly accurate. Mass production of

these devices also makes them incredibly cheap. Power requirements for the

proper working of the mouse circuitry are also sufficiently low. The sensor circuits

inside the mouse casing and rather compact. These facets of such a readily

available device help facilitate a cheap, though efficient alternative to expensive

touchpad systems. In addition, the ease with which we can interface the circuitry

with virtually any microcontroller, speaks volumes of the versatility of the system.

In essence, the mouse’s DSP chip provides the basic X,Y co-ordinates (two

bytes of data) in addition to a status byte that helps further simply its interfacing.

In order to understand this interfacing, we shall now go into the details of the

PS/2 standards that are used by the mouse to communicate with its master

device.

Page 13: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

13

1.3 PS/2 – The Standard:

The Personal System/2 or PS/2 was IBM's second generation of personal

computers. The PS/2 line, released to the public in 1987, was created by IBM in

an attempt to recapture control of the PC market by introducing an advanced

proprietary architecture. Although IBM's considerable market presence ensured

the PS/2 would sell in relatively large numbers, the PS/2 architecture ultimately

failed in its bid to return control of the PC market to IBM. Due to the higher costs

of the closed architecture, customers preferred competing PCs that extended the

existing PC architecture instead of abandoning it for something new. However,

many of the PS/2s innovations, such as the 1,440 kB 3.5-inch floppy disk format,

72-pin SIMM, the PS/2 keyboard and mouse ports, and the VGA video standard,

went on to become standards in the broader PC market. A PS/2 port is an

electronic receptacle or plug found on computers. It accepts a PS/2 cable with a

mini-DIN connector, and is most often used to plug in a keyboard or mouse.

The PS/2 port is female while the mini-DIN cable is male. The connector is small

with a diameter of about 1/3 inch (9.5mm). It features a metal sleeve that is

notched to ensure proper alignment when inserting it into the PS/2 port. This

protects the circular pins inside the DIN connector from becoming bent.

The PS/2 port was initially a large DIN plug used for a keyboard, while the mouse

was commonly plugged into a serial port. However, as modems also used serial

Pin 1 +DATA Data

Pin 2 Not Connected Not Connected*

Pin 3 GND Ground

Pin 4 Vcc +5 V DC at 100 mA

Pin 5 +CLK Clock

Pin 6 Not Connected Not Connected**

* On some laptops mouse data for splitter cable.

** On some laptops mouse clock for splitter cable.

Page 14: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

14

ports, configuration conflicts between mouse and modem became a common

problem as each tried to share the same IRQ or memory address. The PS/2

mouse was a popular solution because it worked independent of the serial port

and avoided configuration problems. Eventually, computers incorporated two

built-in PS/2 ports, one for the keyboard and one for a mouse.

1.4 PS/2 – Connections:

The Data and Clock lines are both open-collector with pull-up resistors to Vcc.

An ‘open-collector’ interface has two possible states: low or high impedance. In

the ‘low’ state, a transistor pulls the line to ground level. In the ‘high impedance’

state, the interface acts as an open circuit and doesn't drive the line low or high.

Furthermore, a ‘pull-up’ resistor is connected between the bus and Vcc so the

bus is pulled high if none of the devices on the bus are actively pulling it low.

The exact value of this resistor isn't too important (1~10 kOhms); larger

resistances result in less power consumption and smaller resistances result in a

faster rise time. A general open-collector interface is shown below:

Page 15: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

15

1.5 PS/2 – The Protocol:

The PS/2 is a bidirectional synchronous serial protocol. The bus is ‘idle’ when

both lines are high (open-collector). This is the only state where the device is

allowed to begin transmitting data. The host has ultimate control over the bus

and may inhibit communication at any time by pulling the Clock line low.

The device always generates the clock signal. If the host wants to send data, it

must first inhibit communication from the device by pulling Clock low. The host

then pulls Data low and releases Clock. This is the ‘Request-to-Send’ state and

signals the device to start generating clock pulses.

Summary of Bus States

Data = high, Clock = high: Idle state.

Data = high, Clock = low: Communication Inhibited.

Data = low, Clock = high: Host Request-to-Send.

All data is transmitted one byte at a time and each byte is sent in a frame

consisting of 11-12 bits. These bits are:

! 1 start bit. This is always 0.

! 8 data bits, least significant bit first.

! 1 parity bit (odd parity).

! 1 stop bit. This is always 1.

! 1 acknowledge bit (host-to-device communication only)

The parity bit is set (1) if there is an even number of 1's in the data bits and reset

(0) if there is an odd number of 1's in the data bits. The number of 1's in the data

bits plus the parity bit always add up to an odd number (odd parity). This is used

for error detection. The device must check this bit and if incorrect it should

respond as if it had received an invalid command.

Data sent from the device to the host is read on the falling edge of the clock

signal; data sent from the host to the device is read on the rising edge. The clock

frequency must be in the range 10 - 16.7 kHz. This means clock must be high for

30 - 50 microseconds and low for 30 - 50 microseconds.

Page 16: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

16

1.6 PS/2 – Communication:

Device-to-Host

The Data and Clock lines are both open collector. A resistor is connected

between each line and +5V, so the idle state of the bus is high. When the device

wants to send information, it first checks the Clock line to make sure it's at a high

logic level. If it's not, the host is inhibiting communication and the device must

buffer any to-be-sent data until the host releases Clock. The Clock line must be

continuously high for at least 50 microseconds before the device can begin to

transmit its data.

Device to host communication uses a serial protocol with 11-bit frames. These

bits are:

• 1 start bit. This is always 0.

• 8 data bits, least significant bit first.

• 1 parity bit (odd parity).

• 1 stop bit. This is always 1.

The device writes a bit on the Data line when Clock is high, and it is read by the

host when Clock is low.

Figure 2: Device-to-host communication. The Data line changes state when

Clock is high and that data is valid when Clock is low.

Figure 3: Scan code for the ‘Q’ key (15h) being sent from a keyboard to the

computer. Channel A is the Clock signal; channel B is the Data signal.

Page 17: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

17

The clock frequency is 10-16.7 kHz. The time from the rising edge of a clock

pulse to a Data transition must be at least 5 microseconds. The time from a data

transition to the falling edge of a clock pulse must be at least 5 microseconds and

no greater than 25 microseconds.

The host may inhibit communication at any time by pulling the Clock line low for

at least 100 microseconds. If a transmission is inhibited before the 11th clock

pulse, the device must abort the current transmission and prepare to retransmit

the current chunk of data when host releases Clock. A chunk of data could be a

make code, break code, device ID, mouse movement packet, etc. For example, if

a keyboard is interrupted while sending the second byte of a two-byte break

code, it will need to retransmit both bytes of that break code, not just the one that

was interrupted.

If the host pulls clock low before the first high-to-low clock transition, or after the

falling edge of the last clock pulse, the keyboard/mouse does not need to

retransmit any data. However, if new data is created that needs to be

transmitted, it will have to be buffered until the host releases Clock. Keyboards

Page 18: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

18

have a 16-byte buffer for this purpose. If more than 16 bytes worth of keystrokes

occur, further keystrokes will be ignored until there's room in the buffer. Mice only

store the most current movement packet for transmission.

Host-to-Device

The packet is sent a little differently in host-to-device communication. Firstly, the

PS/2 device always generates the clock signal. If the host wants to send data, it

must first put the Clock and Data lines in a ‘Request-to-send’ state as follows:

• Inhibit communication by pulling Clock low for at least 100 microseconds.

• Apply ‘Request-to-send’ by pulling Data low, then release Clock.

The device should check for this state at intervals not to exceed 10 milliseconds.

When the device detects this state, it will begin generating Clock signals and

clock in eight data bits and one stop bit. The host changes the Data line only

when the Clock line is low, and data is read by the device when Clock is high.

This is opposite of what occurs in device-to-host communication.

After the stop bit is received, the device will acknowledge the received byte by

bringing the Data line low and generating one last clock pulse. If the host does

not release the Data line after the 11th clock pulse, the device will continue to

generate clock pulses until the Data line is released (the device will then

generate an error).

The host may abort transmission at time before the 11th clock pulse

(acknowledge bit) by holding Clock low for at least 100 microseconds.

To make this process a little easier to understand, here are the steps the host

must follow to send data to a PS/2 device:

1) Bring the Clock line low for at least 100 microseconds.

2) Bring the Data line low.

3) Release the Clock line.

4) Wait for the device to bring the Clock line low.

5) Set/reset the Data line to send the first data bit

6) Wait for the device to bring Clock high.

7) Wait for the device to bring Clock low.

8) Repeat steps 5-7 for the other seven data bits and the parity bit.

Page 19: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

19

9) Release the Data line.

10) Wait for the device to bring Data low.

11) Wait for the device to bring Clock low.

12) Wait for the device to release Data and Clock.

Figure 3 shows this graphically and Figure 4 separates the timing to show which

signals are generated by the host, and which are generated by the PS/2 device.

Notice the change in timing for the ‘ack’ bit - The data transition occurs when the

Clock line is high (rather than when it is low as is the case for the other 11 bits).

Figure 3: Host-to-Device Communication

Figure 4: Detailed host-to-device communication

Referring to Figure 4, there are two time quantities the host looks for.

(a) is the time it takes the device to begin generating clock pulses after the host

initially takes the Clock line low, which must be no greater than 15 ms.

(b) is the time it takes for the packet to be sent, which must be no greater than

2ms. If either of these time limits is not met, the host should generate an error.

Page 20: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

20

Immediately after the ‘ack’ is received, the host may bring the Clock line low to

inhibit communication while it processes data. If the command sent by the host

requires a response, that response must be received no later than 20 ms after

the host releases the Clock line. If this does not happen, the host generates an

error.

1.7 PS/2 Mouse Protocol :

The standard PS/2 mouse interface supports the following inputs: X (right/left)

movement, Y (up/down) movement, left button, middle button, and right button.

The mouse reads these inputs at a regular frequency and updates various

counters and flags to reflect movement and button states.

The standard mouse has two counters that keep track of movement: the X-

movement counter and the Y-movement counter. These are 9-bit 2's complement

values and each has an associated overflow flag. Their contents, along with the

state of the three mouse buttons, are sent to the host in the form of a 3-byte

movement data packet. The movement counters represent the amount of

movement that has occurred since the last movement data packet was sent to

the host.

When the mouse reads its inputs, it records the current state of its buttons and

checks for movement. If movement has occurred it increments (for +X or +Y

movement) or decrements (for -X or -Y movement) its X and/or Y movement

counters. If either of the counters has overflowed, it sets the appropriate overflow

flag.

The parameter that determines the amount by which the movement counters are

incremented/decremented is the resolution. The default resolution is 4

counts/mm and the host may change that value using the ‘Set Resolution’ (0xE8)

command.

There is a parameter that does not affect the movement counters, but does affect

the reported value of these counters. This parameter is scaling. By default, the

Page 21: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

21

mouse uses 1:1 scaling, which has no effect on the reported mouse movement.

However, the host may select 2:1 scaling by sending the ‘Set Scaling 2:1’ (0xE7)

command. If 2:1 scaling is enabled, the mouse will apply the following algorithm

to the counters before sending their contents to the host:

Movement Counter Reported Movement

0 0

1 1

2 1

3 3

4 6

5 9

N > 5 2 * N

Data Packet Movement

The standard PS/2 mouse sends movement/button information to the host using

the following 3-byte packet:

Byte 1

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

Y overflow X overflow Y sign bit X sign bit Always 1 Middle Btn Right Btn Left Btn

Byte 2 X Movement

Byte 3 Y Movement

The movement counters are 9-bit 2's complement integers, where the most

significant bit appears as a sign bit in Byte 1 of the movement data packet. These

counters are updated when the mouse reads its input and finds movement has

occurred. Their value is the amount of movement that has occurred since the last

movement data packet was sent to the host (i.e. after a packet is sent to the host,

the movement counters are reset). The range of values that can be expressed by

the movement counters is -255 to +255. If this range is exceeded, the

appropriate overflow bit is set.

Page 22: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

22

The movement counters are reset whenever a movement data packet is

successfully sent to the host. They are also reset after the mouse receives any

command from the host other than the ‘Resend’ (0xFE) command.

Modes of Operation:

Data reporting is handled according to the mode in which the mouse is operating.

There are four standard modes of operation:

• Reset - The mouse enters Reset mode at power-up or after receiving the

’Reset’ (0xFF) command.

• Stream - This is the default mode (after Reset finishes executing) and is

the mode in which most software uses the mouse. If the host has

previously set the mouse to Remote mode, it may re-enter Stream mode

by sending the ‘Set Stream Mode’ (0xEA) command to the mouse.

• Remote - In this mode the mouse reads its inputs and updates its

counters/flags at the current sample rate, but it does not automatically

issue data packets when movement has occurred. Instead, the host must

poll the mouse using the ‘Read Data’ command. Upon receiving this

command the mouse will send a single movement data packet and reset

its movement counters.

• Wrap - This mode isn't particularly useful except for testing the connection

between the mouse and its host. Wrap mode may be entered by sending

the ‘Set Wrap Mode’ (0xEE) command to the mouse. To exit Wrap mode,

the host must issue the ‘Reset’ (0xFF) command or ‘Reset Wrap Mode’

(0xEC) command. If the ‘Reset’ (0xFF) command is received, the mouse

will enter Reset mode. If the ‘Reset Wrap Mode’ (0xEC) command is

received, the mouse will enter the mode it was in prior to Wrap Mode.

For our purpose, we shall be using the mouse in remote mode.

Page 23: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

23

Command Set:

The following are the set of commands accepted by the standard PS/2 mouse:

! FFh (Reset) - The mouse responds to this command with ‘acknowledge’

(FAh) then enters Reset Mode.

! FEh (Resend) - The host sends this command whenever it receives

invalid data from the mouse. The mouse responds by resending the last

packet it sent to the host. If the mouse responds to the ‘Resend’

command with another invalid packet, the host may either issue another

‘Resend’ command, issue an ‘Error’ command, cycle the mouse's power

supply to reset the mouse, or it may inhibit communication (by bringing the

Clock line low). The action taken depends on the host.

! F6h (Set Defaults) - The mouse responds with ‘acknowledge’ (FAh) then

loads the following values: Sampling rate = 100, Resolution = 4

counts/mm, Scaling = 1:1, Disable Data Reporting. The mouse then

resets its movement counters and enters stream mode.

! F5h (Disable Data Reporting) - The mouse responds with ‘acknowledge’

(FAh) then disables data reporting and resets its movement counters.

This only effects data reporting in Stream mode and does not disable

sampling. Disabled stream mode functions the same as remote mode.

! F4h (Enable Data Reporting) - The mouse responds with ‘acknowledge’

(FAh) then enables data reporting and resets its movement counters. This

command may be issued while the mouse is in Remote Mode (or Stream

mode), but it will only effect data reporting in Stream mode.

• F3h (Set Sample Rate) - The mouse responds with ‘acknowledge’ (FAh)

then reads one more byte from the host. The mouse saves this byte as

the new sample rate. After receiving the sample rate, the mouse again

Page 24: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

24

responds with ‘acknowledge’ (0xFA) and resets its movement counters.

Valid sample rates are 10, 20, 40, 60, 80, 100, and 200 samples/sec.

! F2h (Get Device ID) - The mouse responds with ‘acknowledge’ (FAh)

followed by its device ID (00h for the standard PS/2 mouse). The mouse

should also reset its movement counters.

! F0h (Set Remote Mode) - The mouse responds with ‘acknowledge’ (FAh)

then resets its movement counters and enters remote mode.

! EEh (Set Wrap Mode) - The mouse responds with ‘acknowledge’ (FAh)

then resets its movement counters and enters wrap mode.

! ECh (Reset Wrap Mode) - The mouse responds with ‘acknowledge’ (FAh)

then resets its movement counters and enters the mode it was in prior to

wrap mode (Stream Mode or Remote Mode).

! EBh (Read Data) - The mouse responds with acknowledge (FAh) then

sends a movement data packet. This is the only way to read data in

Remote Mode. After the data packets has been successfully sent, it

resets its movement counters.

! EAh (Set Stream Mode) - The mouse responds with ‘acknowledge’ then

resets its movement counters and enters steram mode.

! E9h (Status Request) - The mouse responds with ‘acknowledge’, then

sends the following 3-byte status packet (then resets its movement

counters).

Byte 1

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

Always 0 Mode Enable Scaling Always 0 Left Btn Middle Btn Right Btn

Byte 2 Resolution

Byte 3 Sample Rate

Right, Middle, Left Btn = 1 if button pressed; 0 if button is not pressed.

Page 25: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

25

Scaling = 1 if scaling is 2:1; 0 if scaling is 1:1. (See commands E7h and E6h)

Enable = 1 if data reporting is enabled; 0 if data reporting is disabled. (See

commands F5h and F4h)

Mode = 1 if Remote Mode is enabled; 0 if Stream mode is enabled. (See

commands F0h and EAh)

• E8h (Set Resolution) - The mouse responds with acknowledge (FAh) then

reads one byte from the host and again responds with acknowledge (FAh)

then resets its movement counters. The byte read from the host

determines the resolution as follows:

Byte Read from Host Resolution

0x00 1 count/mm

0x01 2 count/mm

0x02 4 count/mm

0x03 8 count/mm

! E7h (Set Scaling 2:1) - The mouse responds with acknowledge (FAh) then

enables 2:1 scaling (discussed earlier in this document).

! E6h (Set Scaling 1:1) - The mouse responds with acknowledge (FAh) then

enables 1:1 scaling (discussed earlier in this document).

The only commands the standard PS/2 mouse will send to the host are the

‘Resend’ (FEh) and ‘Error’ (FCh). They both work the same as they do as host-

to-device commands.

Page 26: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

26

Initialisation:

The following is the communication between a computer (running Win98SE) and

the mouse when it boots up with a standard PS/2 mouse attached. It is fairly

typical of how a PS/2 mouse is initialised and if you want to emulate a PS/2

mouse it must (at minimum) be able to support the following sequence of

commands:

Power-on Reset:

Mouse: AA Self-test passed

Mouse: 00 Mouse ID

Host: FF Reset command

Mouse: FA Acknowledge

Mouse: AA Self-test passed

Mouse: 00 Mouse ID

Host: FF Reset command

Mouse: FA Acknowledge

Mouse: AA Self-test passed

Mouse: 00 Mouse ID

Host: FF Reset command

Mouse: FA Acknowledge

Mouse: AA Self-test passed

Mouse: 00 Mouse ID

Host: F3 Set Sample Rate : Attempt to Enter Microsoft

Mouse: FA Acknowledge : Scrolling Mouse mode

Host: C8 decimal 200 :

Mouse: FA Acknowledge :

Host: F3 Set Sample Rate :

Mouse: FA Acknowledge :

Host: 64 decimal 100 :

Mouse: FA Acknowledge :

Host: F3 Set Sample Rate :

Mouse: FA Acknowledge :

Host: 50 decimal 80 :

Mouse: FA Acknowledge :

Host: F2 Read Device Type :

Mouse: FA Acknowledge :

Page 27: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

27

Mouse: 00 Mouse ID : Response 03

Host: F3 Set Sample Rate : if Microsoft scrolling mouse

Mouse: FA Acknowledge

Host: 0A decimal 10

Mouse: FA Acknowledge

Host: F2 Read Device Type

Mouse: FA Acknowledge

Mouse: 00 Mouse ID

Host: E8 Set resolution

Mouse: FA Acknowledge

Host: 03 8 Counts/mm

Mouse: FA Acknowledge

Host: E6 Set Scaling 1:1

Mouse: FA Acknowledge

Host: F3 Set Sample Rate

Mouse: FA Acknowledge

Host: 28 decimal 40

Mouse: FA Acknowledge

Host: F4 Enable

Mouse: FA Acknowledge

Initialization complete...

Note that this is similar sequence of commands that need to be passed on to the

mouse in our project as well. There is the option of selecting our own sample rate

and scaling factor.

Page 28: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

28

CHAPTER 2: MICROCONTROLLER

We have chosen to use the ATTINY2313 Microcontroller for interfacing with the

mouse, the external EEPROM and the computer. It has the following features

which not only satisfies, but is virtually optimised for our requirements:

! Utilises the AVR RISC architecture – 120 instructions, most of which are

single clock cycle executable. This ensures quick execution speeds.

! 2 kilobytes of In-System Self Programmable Flash provides adequate

program memory space.

! 128 Bytes of In-System Programmable internal EEPROM and another

128 Bytes of Internal SRAM. For offline data storage therefore, we need

to interface the microcontroller with external EEPROMs, so as to make

the whole unit truly mobile.

! USI – Universal Serial Interface enabled which allows for TWI – Two Wire

Interface (or I2C) communication. This makes it possible to connect three

external EEPROMs in parallel to just two wires, saving hardware and

physical space.

! Full Dulpex USART allows communication between the device and the

computer via a RS-232 serial port.

! In-System Programmable via SPI port making it easy to test, debug and

update programs.

! 20 pin PDIP package with 18 programmable port pins making it compact.

! Speed grade of 4.5 – 5.5 V, when operated with a crystal of 20Mhz.

Page 29: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

29

Pin Description

VCC Digital supply voltage.

GND Ground.

Port A

(PA2…PA0) Port A is a 3-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port A output buffers

have symmetrical drive characteristics with both high sink

and source capability. As inputs, Port A pins that are

externally pulled low will source current if the pull-up

resistors are activated. The Port A pins are tri-stated when a

reset condition becomes active, even if the clock is not

running.

Port B

(PB7...PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port B output buffers

have symmetrical drive characteristics with both high sink

and source capability. As inputs, Port B pins that are

Page 30: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

30

externally pulled low will source current if the pull-up

resistors are activated. The Port B pins are tri-stated when a

reset condition becomes active, even if the clock is not

running.

Port D

(PD6...PD0) Port D is a 7-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port D output buffers

have symmetrical drive characteristics with both high sink

and source capability. As inputs, Port D pins that are

externally pulled low will source current if the pull-up

resistors are activated. The Port D pins are tri-stated when a

reset condition becomes active, even if the clock is not

running.

RESET Reset input. A low level on this pin for longer than the

minimum pulse length will generate a reset, even if the clock

is not running. Shorter pulses are not guaranteed to

generate a reset. The Reset Input is an alternate function for

PA2 and dW.

XTAL1 Input to the inverting Oscillator amplifier and input to the

internal clock operating circuit. XTAL1 is an alternate

function for PA0.

XTAL2 Output from the inverting Oscillator amplifier. XTAL2 is an

alternate function for PA1.

Refer to datasheet for alternate port and pin functions.

Page 31: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

31

I2C

I2C is an acronym for Inter Integrated Circuit bus. I2C is a 2-wire serial

interface standard defined by Philips Semiconductor in the early 1980's. Its

purpose was to provide an easy way to connect a CPU to peripheral chips in

a TV-set. The BUS physically consists of 2 active wires and a ground

connection. The active wires, SDA and SCL, are both bidirectional. Where

SDA is the Serial DAta line and SCL is the Serial CLock line.

The key advantage of this interface is that only two lines (clock and data) are

required for full duplexed communication between multiple devices. The

interface typically runs at a fairly low speed (100 kHz to 400 kHz). With I2C,

each IC on the bus has a unique address. Chips can act as a receiver and/or

transmitter depending on its functionality.

Bi-directional communication is facilitated through the use of wire and

connection (the lines are either active-low or passive high). The I2C Bus

protocol also allows collision detection, clock synchronisation and hand-

shaking for multi-master systems. The clock is always generated by the

master, but the slave may hold it low to generate a wait state. In most

systems the microcontroller is the master and the external peripheral devices

are slaves.

The maximum number of devices connected to the I2C bus is dictated by the

maximum allowable capacitance on the lines, 400 pF, and the protocol's

addressing limit of 16k; typical device capacitance is 10 pF. The I2C protocol

has 127 addresses available.

Page 32: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

32

To begin communication, the bus master (typically a microcontroller) places

the address of the device with which it intends to communicate (the slave) on

the bus. All ICs monitor the bus to determine if the master device is sending

their address. Only the device with the correct address communicates with

the master.

The I2C master is generally implemented with special I2C controller

(sometimes integrated to microcontroller) or sometimes using a

microcontroller and some software running on it. Both approaches are

possible in typical one master I2C system. The multi-master system is not

generally implemented with microcontroller software because it is extremely

difficult to meet all the I2C Bus timing specifications using software. For a true

slave or multi-master system, some interface hardware is necessary (like

START & STOP bit detection). Each slave on the bus is identified by a unique

address. In Standard mode, 7-bit addressing is used.

Hence, using this I2C protocol, we have interfaced the ATINY2313

Microcontroller with three AT24c512 external EEPROMs connected in

parallel.

This connection ensures that we have one EEPROM each to store the X and

Y position co-ordinates, and one for storing the mouse status byte.

This parallel connection also ensures that time is not wasted in the internal

writing process of one EEPROM IC as we are writing into a single IC only

once in every pass of polling the mouse.

Such a parallel connection also enables us to optimise the mouse to give the

highest sampling rate and the finest resolution. This large amount of position

data bytes means better overall accuracy.

Now that the data can be stored in large quantities, what remains is to be able

to transfer this data to a computer for processing. In order to make this a

convenient procedure for the end user, we have made use of the USART

facility to send data serially via the RS-232 serial port.

Page 33: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

33

USART

The Universal Synchronous and Asynchronous serial Receiver and

Transmitter. (USART) is a highly flexible serial communication device. The

main features are:

• Full Duplex Operation (Independent Serial Receive and Transmit

Registers)

• Asynchronous or Synchronous Operation

• Master or Slave Clocked Synchronous Operation

• High Resolution Baud Rate Generator

• Supports Serial Frames with 5, 6, 7, 8, or 9 Data Bits and 1 or 2 Stop Bits

• Odd or Even Parity Generation and Parity Check Supported by Hardware

• Data OverRun Detection

• Framing Error Detection

• Noise Filtering Includes False Start Bit Detection and Digital Low Pass

Filter

• Three Separate Interrupts on TX Complete, TX Data Register Empty and

RX Complete

• Multi-processor Communication Mode

• Double Speed Asynchronous Communication Mode

We use the USART for serial communication with the computer. We have carried

out this transmission at a baud rate of 2400, with 2 stop bits and no parity bits.

The data packet size is 8 bits long. This setting ensures reliable data transfer

with small error probabilities.

Page 34: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

34

CHAPTER 3: EEPROM

For the externally connected EEPROM, we have selected Atmel Corporation’s

AT24C512 Two Wire Serial EEPROM. Some of the features of this IC are:

• Low-voltage and Standard-voltage Operation 2.7 (VCC = 2.7V to 5.5V),

1.8 (VCC = 1.8V to 3.6V)

• Bidirectional Data Transfer Protocol using Two-wire Serial Interface

• Internally Organized 65,536 x 8 bits of data i.e. 64kB of memory

• Schmitt Triggers, Filtered Inputs for Noise Suppression

• 1 MHz (5V) Compatibility

• Write Protect Pin for Hardware and Software Data Protection

• 128-byte Page Write Mode (Partial Page Writes Allowed)

• Self-timed Write Cycle (5 ms Max.)

• High Reliability with endurance of 100,000 Write Cycles and Data

Retention of 40 Years

• 8-lead PDIP, allowing for easy component placement.

The AT24C512 provides 524,288 bits of serial electrically erasable and

programmable read only memory (EEPROM) organized as 65,536 words of 8

bits each. The device’s cascadable feature allows up to four devices to share a

common two-wire bus. The device is optimized for use in many industrial and

commercial applications where low-power and low-voltage operation are

essential. The 512K is internally organized as 512 pages of 128-bytes each.

Random word addressing requires a 16-bit data word address.

Pin Description

SERIAL CLOCK (SCL): The SCL input is used to positive edge clock data into

each EEPROM device and negative edge clock data

out of each device.

Page 35: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

35

SERIAL DATA (SDA): The SDA pin is bidirectional for serial data transfer.

This pin is open-drain driven and may be wire-ORed

with any number of other open-drain or open collector

devices.

DEVICE/ADDRESSES

(A1, A0): The A1 and A0 pins are device address inputs that

are hardwired or left not connected for hardware

compatibility with other AT24Cxx devices. When the

pins are hardwired, as many as four 512K devices

may be addressed on a single bus system. If the pins

are left floating, the A1 and A0 pins will be internally

pulled down to GND.

WRITE PROTECT (WP): The write protect input, when connected to GND,

allows normal write operations. When WP is

connected high to VCC, all write operations to the

memory are inhibited. If the pin is left floating, the WP

pin will be internally pulled down to GND Switching

WP to VCC prior to a write operation creates a

software write protect function.

Page 36: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

36

Device Addressing

The 512K EEPROM requires an 8-bit device address word following a start

condition to enable the chip for a read or write operation (see Figure 7 on

page 10). The device address word consists of a mandatory “1”, “0” sequence

for the first five most significant bits as shown. This is common to all two-wire

EEPROM devices. The 512K uses the two device address bits A1, A0 to

allow as many as four devices on the same bus. These bits must compare to

their corresponding hardwired input pins.

The A1 and A0 pins use an internal circuit that biases them to a logic low

condition if the pins are allowed to float. The eighth bit of the device address

is the read/write operation select bit. A read operation is initiated if this bit is

high and a write operation is initiated if this bit is low. Upon a compare of the

device address, the EEPROM will output a “0”. If a compare is not made, the

device will return to a standby state.

Write Operations

BYTE WRITE: A write operation requires two 8-bit data word addresses

following the device address word and acknowledgment. Upon receipt of this

address, the EEPROM will again respond with a “0” and then clock in the first

8-bit data word. Following receipt of the 8-bit data word, the EEPROM will

output a “0”. The addressing device, such as a microcontroller, then must

terminate the write sequence with a stop condition. At this time the EEPROM

enters an internally-timed write cycle, tWR, to the nonvolatile memory. All

inputs are disabled during this write cycle and the EEPROM will not respond

until the write is complete

PAGE WRITE: The 512K EEPROM is capable of 128-byte page writes.

A page write is initiated the same way as a byte write, but the microcontroller

does not send a stop condition after the first data word is clocked in. Instead,

after the EEPROM acknowledges receipt of the first data word, the

microcontroller can transmit up to 127 more data words. The EEPROM will

respond with a “0” after each data word received. The microcontroller must

Page 37: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

37

terminate the page write sequence with a stop condition. The data word

address lower 7 bits are internally incremented following the receipt of each

data word. The higher data word address bits are not incremented, retaining

the memory page row location. When the word address, internally generated,

reaches the page boundary, the following byte is placed at the beginning of

the same page. If more than 128 data words are transmitted to the EEPROM,

the data word address will “roll over” and previous data will be overwritten.

The address roll over during write is from the last byte of the current page to

the first byte of the same page.

ACKNOWLEDGE POLLING: Once the internally-timed write cycle has started

and the EEPROM inputs are disabled, acknowledge polling can be initiated.

This involves sending a start condition followed by the device address word.

The Read/Write bit is representative of the operation desired. Only if the

internal write cycle has completed will the EEPROM respond with a “0”,

allowing the read or write sequence to continue.

Read Operations

Read operations are initiated the same way as write operations with the

exception that the Read/Write select bit in the device address word is set to

“1”. There are three read operations: current address read, random address

read and sequential read:

CURRENT ADDRESS READ: The internal data word address counter

maintains the last address accessed during the last read or write operation,

incremented by “1”. This address stays valid between operations as long as

the chip power is maintained. The address roll over during read is from the

last byte of the last memory page, to the first byte of the first page.

Once the device address with the Read/Write select bit set to “1” is clocked in

and acknowledged by the EEPROM, the current address data word is serially

clocked out. The microcontroller does not respond with an input “0” but does

generate a following stop condition.

Page 38: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

38

RANDOM READ: A random read requires a “dummy” byte write sequence to

load in the data word address. Once the device address word and data word

address are clocked in and acknowledged by the EEPROM, the

microcontroller must generate another start condition. The microcontroller

now initiates a current address read by sending a device address with the

Read/Write select bit high. The EEPROM acknowledges the device address

and serially clocks out the data word. The microcontroller does not respond

with a “0” but does generate a following stop condition.

SEQUENTIAL READ: Sequential reads are initiated by either a current

address read or a random address read. After the microcontroller receives a

data word, it responds with an acknowledgement. As long as the EEPROM

receives an acknowledgement, it will continue to increment the data word

address and serially clock out sequential data words. When the memory

address limit is reached, the data word address will roll over and the

sequential read will continue. The sequential read operation is terminated

when the microcontroller does not respond with a “0” but does generate a

following stop condition.

For waveforms to illustrate the same, please refer to the datasheet.

We are using the EEPROM to store upto 64 kB of data on each EEPROM.

Thus, we may store upto 65,536 X,Y position co-ordinates and status bytes.

This translates to virtually 13 minutes of continuous movement of the mouse,

assuming around 83 readings taken every second by the mouse sensor

circuit.

This provides us with sufficient space for signatures and possible future

expansions.

Page 39: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

39

CHAPTER 4: SERIAL COMMUNICATION

Communication as defined in the RS232 standard is an asynchronous serial

communication method. The word serial means that the information is sent one

bit at a time. Asynchronous tells us that the information is not sent in predefined

time slots. Data transfer can start at any given time and it is the task of the

receiver to detect when a message starts and ends.

We chose to sue a readily available 9 pin serial cable which has the following

pins:

Transmitted Data (TD): One of two separate data signals, this signal is

generated by the DTE and received by the DCE.

Received Data (RD): The second of two separate data signals, this signals is

generated by the DCE and received by the DTE.

Request to Send (RTS): When the host system (DTE) is ready to transmit data

to the peripheral system (DCE), RTS is turned ON. In simplex and duplex

systems, this condition maintains the DCE in receive mode. In half-duplex

systems, this condition maintains the DCE in receive mode and disables transmit

mode. The OFF condition maintains the DCE in transmit mode. After RTS is

asserted, the DCE must assert CTS before communication can commence.

Clear to Send (CTS): CTS is used along with RTS to provide handshaking

between the DTE and the DCE. After the DCE sees an asserted RTS, it turns

CTS ON when it is ready to begin communication.

Data Set Ready (DSR): This signal is turned on by the DCE to indicate that it is

connected to the telecommunications line.

Page 40: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

40

Data Carrier Detect (DCD): This signal is turned ON when the DCE is receiving

a signal from a remote DCE, which meets its suitable signal criteria. This signal

remains ON as long as a suitable carrier signal can be detected.

Data Terminal Ready (DTR): DTR indicates the readiness of the DTE. This

signal is turned ON by the DTE when it is ready to transmit or receive data from

the DCE. DTR must be ON before the DCE can assert DSR.

Ring Indicator (RI): RI, when asserted, indicates that a ringing signal is being

received on the communications channel.

We use a MAX-232 IC to interface the TTL mouse-microcontroller circuit with the

serial port over which we

communicate.

Shown alongside is the

basic connections needed

for the MAX-232 IC.

Please refer to datasheet for

proper connection diagrams.

The circuit diagrams shows

that it is rather convenient to

select pin numbers 11

through 14 for serial

communication. This can be

seen in the circuit diagram.

Page 41: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

41

CHAPTER 5: INTERFACING

The circuit diagram shown below shows the interfacing of the various

components of the circuit.

Page 42: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

42

SECTION 4

PCB DESIGN

Page 43: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

43

Design Description:

In this section we shall cover the PCB or Printed Circuit Board design. The

fundamental challenge we encountered practically was to minimize the space

required for mounting the entire circuit as shown previously.

The solution to this problem was to design four PCBs instead of just the one that

can fit compactly into a box, thereby making the whole module very mobile.

Displayed in the following pages are the PCB layouts. These individual PCBs are

connected to one another with the help of right-angled connectors, thus in

essence, making up four sides of a cube.

In order to ensure the accuracy of the mouse sensor, we have retained the

plastic base from the mouse and designed the base PCB to fit exactly on top of

it.

On one of the sides, we have placed the microprocessor and its crystal, providing

an interrupt and a selection mode. We have also ensured that the microcontroller

is re-programmable by providing connectors (SPI).

On the side facing this microcontroller side, we have mounted the DSP as well as

the three EEPROMs, some optional mouse buttons and the indicator LED.

The connector side PCB connects these two sides together through tracks, in

addition to providing structural stability.

The software used for our purpose is EagleDraw, a popular and free design tool.

The following chapters illustrate the guidelines while designing the PCB followed

by a brief insight into the EagleDraw software. This section is then summed up

by the PCB layout we have chosen to implement.

Page 44: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

44

CHAPTER 1: PCB DESIGN RULES

A number of rules are to be followed while designing PCBs. The following

chapter gives us an idea of a few design rules which ought to be kept in mind

while designing a PCB layout.

Board Size

PCB manufacturers have a maximum size board they can handle. Typically this

is also their panel size. The PCB panel size is also important when mass

producing boards. In this situation, one would want to fit as many boards as

possible on a panel with as little wasted board space as possible (in order to

reduce costs). Normal board spacing for routing (how boards are separated on a

panel) is 0.3", plus there is typically a 1.0" to 2.0" border on the board for

handling it during processing.

Board thickness may also be specified. A standard thickness and type of board is

.062" FR4. Other typical board thicknesses are .010", .020", .031", and .092".

Trace Width and Spacing

The chemical and photographic processes used to produce a PCB put

requirements on the minimum width of trace and the minimum spacing between

traces. If a trace is made smaller than this minimum width there is some chance

it will open (no connection) when manufactured. If two traces are closer together

than the minimum spacing, there is some chance they will short when

manufactured. These parameters are usually specified as "x/y rules", where x is

the minimum trace width and y is the minimum trace spacing. For example, "8/10

rules" would indicate 8 mil minimum trace width and 10 mil minimum trace

spacing. These rules (especially spacing) apply to any metal on the PCB,

including pad to track spacing and line widths for strings on the PCB.

Typical modern process rules are 8/8 rules with values as small as 2/2 rules

being available (for a significant premium). Keep in mind that the board must be

Page 45: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

45

soldered and a trace within 8 mils (8/8 rules) of a pad is easier to short than one

with greater spacing when hand soldered. For hand soldering 10/10 rules are

much easier to solder (if the design density can allow spacing this large).

Pad Sizes

The biggest issues with pad size are solderability and manufacturability.

Manufacturability is concerned with whether or not the pad will be broken when

the hold is drilled in it. This is mainly a function of the accuracy of the PCB

manufacturer's drilling. If a drill hole is slightly off center the pad may be broken

at one edge possibly leading to an open in the circuit. A standard requirement for

pad sizes is a 5 mil annulus. This means there must be .005" all around the hole

(i.e. a 28 mil hole would require a 38 mil pad). Something a little larger than this

(maybe 10 mils) is recommended for solderability.

Hole Sizes

Most PCB manufacturers have a wide selection of drill (hole) sizes available.

Some charge per drill size used, others offer a standard set of drill sizes for no

charge and then charge for any non-standard drill sizes.

Standard Drill Sizes for Circuits:

Drill Number Hole Size Finished Hole Size

70 .028" .025"

65 .035" .032"

58 .042" .039"

55 .052" .049"

53 .0595" .056"

44 .086" .083"

1/8" .125" .122"

24 .152" .149"

Page 46: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

46

Hole Density

Hole density is purely a cost issue. The more holes there are on a board, the

more wear and tear manufacturing will put on the equipment (and thus the more

the board will cost). Most PCB manufacturers have a maximum hole density and

boards with greater density are charged more.

Page 47: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

47

CHAPTER 2: PCB SOFTWARE

Eagle Draw Software:

General

• maximum drawing area 64 x 64 inches

• resolution 1/10,000 mm (0.1 microns)

• mm or inch grid

• up to 255 layers, user definable colors

• command (script) files

• C-like User Language for data export and import and the realization

of self-defined commands

• easy library editing

• composition of self-defined libraries by Drag&Drop

• simple generation of new package variants from other libraries by

Drag&Drop

• free rotation of package variants (0.1-degree steps)

• library browser and convenient component search function

• technology support (e. g. 74L00, 74LS00..)

• output of manufacturing data on plotter, photo plotter and drilling

machine or as a graphic data format

• print via the operating systems’ printer devices

• user definable, free programmable User Language for generating

data for mounting machines, in-circuit tester and milling machines

• Drag&Drop in the Control Panel

• Automatic backup function

Layout Editor

• full SMD support

• support of blind and buried vias

• rotation of elements in arbitrary angles (0.1-degree steps)

Page 48: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

48

• texts can be placed in any orientation

• dynamic calculation of signal lines while routing the layout

• tracks can be layed out with rounded corners in any radius

• mitering to smooth wire joints

• Design Rule Check for board layouts

• copper pouring

• support of different package variants

Schematic Module

• up to 99 sheets per schematic

• simple copying of parts

• online Forward&Back Annotation between schematic and board

• automatic board generation

• automatic generation of supply signals (for IC’s)

• Electrical Rule Check (checks logic in the schematic and the consistency

of schematic and layout)

Autorouter Module

• fully integrated into basic program

• uses the set of Design Rules user defines for the layout

• swap between manual and automatic routing at any time

• ripup & retry algorithm

• user-definable strategy (based on cost factors)

• routing grid down to 0.8 mil (0.02 mm)

• no placement restrictions

• up to 16 signal layers (with user definable preferred directions)

• up to 14 supply layers

• full support of blind and buried VIAs

• recognizes signal classes that define special settings for wire with

and minimum distances

Page 49: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

49

CHAPTER 3: PCB LAYOUT

The design employs four separate PCBs connected together by means of

perpendicular connectors. Shown below are the four PCBs:

Microcontroller side PCB

Component side layout

Solder side PCB

Solder side layout

Component side PCB

Component Layout

Page 50: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

50

Base PCB

Connecting Side PCB

Solder side

Solder side

Component Layout

Component Layout

Page 51: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

51

DSP Side PCB

Solder side layoutComponent side Layout

Component side layout Solder side layout

Component Layout

Page 52: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

52

SECTION 6

MECHANICAL ASSEMBLY

Page 53: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

53

MECHANICAL ASSEMBLY

Acrylic sheets are thin, transparent and sturdy all at once. They can be cut into

desired shapes and joined together at perpendicular angles. The images of the

module as displayed below show how the user is able to write with a pen, while

the mouse sensor at the base of the unit takes X,Y position co-ordinates. The

pen is held fast to the module by aesthetically cut pieces of acrylic that form an

extension from the main body of the module itself. Buttons on the pen are infact

the left and middle buttons of the mouse, and are used to provide additional

functionality to the device.

Provisions have been made for programming the microcontroller inside the

module, as well as wired supply and serial transmission connections. The LED is

used to demonstrate the state of numerous tasks and as a visual indicator

enabling the device to be used in myriad ways.

Page 54: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

54

Note the two push buttons placed on the sides of the pen. They are used to

differentiate between segmensts in the design aid mode.

One can also see the 20 pin microcontroller IC inside.

The connections for these push buttons are routed through the upper surface of

the console. The LED that’s visible on the pen-side is used as an indicator.

Page 55: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

55

The processor side of the console shows the fault red fault switch. This is used to

select the mode of operation. Once selected by making appropriate settings on

the fault switch, we can feed the setting into the microcontroller by pressing the

reset button shown above the fault switch. This generates an interrupt to the

controller.

The fault switch can therefore be used to operate the console in 16 possible

modes. For an understanding of the modes of oeration we have employed, look

up the software section of this report.

The blue on-off button enables the user to disable certain pull-up resistors and

re-program the microcontroller, via the 6-pin connectors as shown on the left

side.

Page 56: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

56

Front profile showing the mouse sensor at the base and the red LED used for

position detection. Note the optimal utilisation of space inside the console.

The top view with wires for the pen buttons. As they are stuck on the surface,

they allow for interference free writing.

Page 57: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

57

The indicator LED on the DSP side is used to serve as a visual guide to the user.

It blinks several tiems before readings are taken and turns off once the readings

are done so as to give the user and idea of the time formats. It also glows when

the microcontroller is serially read, so as to inform the user that the whole unit is

busy at the moment.

Showsn here also are the power wires that are thin multi-strand wires shich do

not abstruct the free motion of the hand.

Page 58: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

58

Profile views.

Page 59: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

59

This unit is attached with a serial cable on one end that goes to a computer, and

the console at the other end.

It serves two purposes actually. When the slide switch as shown is kept on the

left side, it activates the MAX-232 circuit and thus serial transmission of the data

to the computer is achieved.

The components on the right side are used as a serial programmer, should users

need to edit or change their their microcontroller program.

Page 60: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

60

Hardware Operation

! On reset, the device initialises i2c communication. Thus, power on reset

will start the process of obtaining readings.

! It then initialises the mouse sensor circuit and resetsit to enable readings

to be taken.

! The read pointer, which is a pointer ine the microcontroller software, is set

to the default value. This read pointer gives the number of X, Y

coordinates to be taken.

! Indicator LED blinks thrice and readings are recorded.

! The mouse sensor is polled and data is requested.

! In response, the mouse DSP sends Status, Y-coordiante and X-coordinate

bytes.

! As soon as the byte is received, it is written into the EEPROM before the

next byte is read.

! After the readings are over, the indicator LED turns off.

! Whenever the interrupt push button is pressed, the i2c and mouse are

reintialised and the read count is set according to mode of operation

selected by the fault switch and the data is recorded again.

Fault switch position with corresponding mode of operation and ‘read’ count

value:

! 0001 Design Aid Read = 0x800

! 0010 Character Recognition Read = 0x50

! 0100 Signature Recognition Read = 0x150

! 1000 Serial Read

Page 61: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

61

SECTION 6

SOFTWARE

Page 62: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

62

CHAPTER 1: SOFTWARE DESCRIPTION

In order to demonstrate the full range of functionalities possible with this module,

we have developed software, on the MATLAB platform selected as it can handle

large arrays and process it effectively. MATLAB was the intuitive choice for an

application like signature verification since it supports the varied statistical and

signal processing needs of our application. Development of a Graphical User

Interface (GUI) is also very convenient on MATLAB. We have included the

following three functionalities:

Signature Verification And Identification:

In this mode, the user may make prototypes of his signature and store it in

the database. Additionally, the user can get a signature identified as

belonging to a particular entity in the database, or he/she may chose to

have his/her own signature verified by matching with the prototype

template stored in the database. This system holds great promise in the

high-risk financial world of today.

Character Recognition:

Users can employ the use of character recognition software to digitize

data, as we plunge headfirst into a digital domain. Demonstrated in this

project is the ability to recognize all the numbers and letters of the

alphabet from ‘a’ through ‘f’. Covering the constituents of the hexadecimal

number system, it is representative of the numerous possibilities that can

be availed of in written text to digital text conversion.

Design Aid:

This function is especially useful in civil and mechanical engineering and

architecture. Designers may avail of a wide range of expandable

functionalities that can help in drawing precise lines and curves, useful in

construction plans or machine drawings.

Page 63: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

63

CHAPTER 2: GRAPHICAL USER INTERFACE

Introduction:

The graphical user interface for the first page is as shown below. It allows the

user to select the application depending on his need. It has the following

buttons:

! Signature Verification: This button enables the user to use the

application for signature identification and verification. It has a callback

function which closes the current GUI, and opens the one for signature

verification.

! Character Recognition: This button allows the user to use the

application for character and digit recognition. It closes the current GUI

and opens the one used for character recognition.

! Design Aid: This button closes the current GUI and opens the one for

design aid. The user can access a variety of useful features like

plotting the figure in different styles and colours, making point to point

plots, arcs, etc

! Exit: This button verifies that the user wants to exit the application

using a modal dialogue box, and then closes the GUI.

Page 64: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

64

Page 65: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

65

Page 66: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

66

Page 67: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

67

CHAPTER 3: DYNAMIC SIGNATURE VERIFICATION

Introduction:

The main advantage of using the optical sensor to read data is that dynamic data

is available as against static data. In dynamic signature verification, we use time

based x-y co-ordinates of data and not static image of the signature. Thus

dynamic properties of the signature such as time, rhythm, etc can be measured

easily and effectively used for identification as well as detection of forgeries.

Regular static properties such as mean, correlation, covariance standard

deviation are calculated as well.

Automated signature verification systems have widespread applications in banks,

documents and checks among others. Most signature verification systems work

on the principal of finding out specific properties or features of a signature and

comparing these with the sample signature, to decide whether it is genuine or a

forgery.

Signature verification systems can basically be classified into two types

depending on their mode of operation and available data. Offline (static)

signature verification takes the image of a signature as input and processes it for

different features. In dynamic signature verification, we use time based x-y co-

ordinates of data and not static image of the signature. Thus dynamic properties

of the signature such as time, rhythm, etc can be measured easily and effectively

used for identification as well as detection of forgeries. The data that we obtain

from the optical mouse is dynamic data in the form of sequential X-Y coordinates

at a specified rate.

Page 68: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

68

Data Acquisition And Processing:

Data is acquired from the microcontroller using serial communication protocol,

supported by MATLAB. A serial object is created in MATLAB and data is

transferred using commands such as ‘fread’ and ‘fwrite’. This data acquired is in

the form of x-y co-ordinate arrays and a third data array consisting of the status

bytes. This is used to convert the differential X-Y co-ordinates into absolute co-

ordinates depending upon the sign bit in the status byte. We store this data in the

form of the processed X-Y arrays in text files, which are used for further

processing.

Before using this data, we remove redundant zeroes at the beginning and the

end of the acquired data. These zeroes represent no useful data but just reflect

static position of the pen when the user has yet to begin signing or has finished

with the signature.

We change the range of the data to make the entire data positive. We also

normalize the data to a pre-decided range, so that it makes further comparison

effective, making it independent of size of the signature which often differs for the

same user by a small degree.

Feature Extraction:

The basic principal of signature verification lies in finding out the unique

properties of the signature prototype and comparing these features with those of

the acquired signature sample. A user dependent or user independent threshold

can then be used to classify the acquired sample as an original or as a forgery.

We considered the following features for our signature identification and

verification application:

Page 69: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

69

! Statistical Mean

This is the simplest statistical property of the signature. We can

calculate the X and Y co-ordinate means using the inbuilt MATLAB

function ‘mean()’.

! Standard deviation

Standard deviation is the average deviation of any signal about its

mean. We use this property to find out and quantify how much a

user’s signature varies along the Y as well as X direction. The

MATLAB function ‘std()’ is used to determine the standard deviation

of any one-dimensional array.

! Total length

This property simply computes the total length of the signature

using the normal distance formula summed over the entire

signature path. The data we are using has a very good resolution;

hence this simple summation gives an accurate value of the total

length of the signature.

! Total time

This is one of the dynamic properties that we calculate. The total

time taken by any person to sign usually remains the same, since it

is a practiced motion. We get data at regular intervals from the

optical mouse. Hence the total array size after removing the zeroes

reflects the total time taken by the user to sign.

! Correlation

In statistics, correlation, also called correlation coefficient, indicates

the strength and direction of a linear relationship between two

random variables. Simply put, it reflects the degree of similarity

between any two functions. The sample of correlation graphs

obtained for the auto-correlation of a signature, correlation between

Page 70: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

70

samples of the same person’s signature, and that of two different

signatures is shown in the figures below. As we can see from the

graphs, the auto-correlation graph shows a distinct peak and

symmetry. The graph of correlation between two signature samples

of the same person has a reduced symmetry and a less prominent

peak, but has a distinguishable property nevertheless. The

correlation of two different signatures fails to show either the peak

or any symmetry whatsoever. These features of evident from the

graph can be quantified by either taking a simple ratio of the peak

values in each of the graphs, or by using the ‘polyfit’ function which

gives coefficients of a polynomial fit to the graph. The highest order

coefficient remains approximately the same for a correlation graph

between two similar signature samples.

Page 71: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

71

Auto correlation.

Correlation of two samples of signatures by the same user.

Page 72: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

72

Correlation of a signature with its skilled forgery.

Correlation of two different signatures.

Page 73: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

73

! Covariance

In statistics, covariance is the measure of how much two random

variables vary together (as distinct from variance, which measures how

much a single variable varies). If two variables tend to vary together

(that is, when one of them is above its expected value, then the other

variable tends to be above its expected value too), then the covariance

between the two variables will be positive. On the other hand, if when

one of them is above its expected value, the other variable tends to be

below its expected value, then the covariance between the two

variables will be negative.

The covariance function ‘cov’ in MATLAB requires the two signal

samples to be of equal size. We interpolate the smaller signature to

make it equal in length to the longer one. We perform covariance on

two Y coordinate arrays and divide them by the standard deviation of

each of the arrays. The procedure is repeated for the X coordinates,

though in any signature the Y coordinates reflect much more

information about the signature than do the X coordinates. We obtain a

2X2 matrix using this procedure which gives us the mean independent

covariance between the two signature samples. The matrix elements

(2,1) and (1,2) are the same and have a value between -1 to 1, where

a value tending to 1 represents a good covariance, a value

approximately 0 represents no correlation between the signals, and a

value tending to -1 represents a negative covariance.

! Peaks and Valleys Detection

Finding out the peaks and valleys of any signature provides us with an

array of useful features such as number of strokes, stroke lengths and

times, and the more obvious ones of actual peak and valley positions.

We perform peak and valley detection process only on the Y

coordinates. For a particular user, the number of peaks and valleys

remains approximately the same, and their locations also remain fairly

Page 74: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

74

constant. Thus this feature is one of the most important features we

have used in identification and verification of signatures.

The algorithm used to detect peaks and valleys first smoothes the

signal by the use of a convolution filter. We then proceed to compare

consecutive points and determine whether it is a valley or peak, i.e.

local minima or maxima. We obtain the position or time coordinate of

the location of peaks and valleys using this function. The graph shown

below displays the peaks and valleys detected for a signature.

We used the peaks and valleys so obtained in a variety of useful feature

detection algorithms mentioned below.

Page 75: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

75

! Number of strokes, stroke times and stroke lengths

Calculating number of strokes is the simplest application of peaks and

valleys. We can further use this to find out length of each stroke which

remains approximately the same for each user. The array size of each

stroke individually taken gives us the time for each stroke. This is

especially useful in detecting forgeries since dynamic properties like

stroke time cannot be imitated by someone who has access to a static

image of the original signature. We obtain correlation of the stroke

lengths and times to compare them with those of the original.

Stroke time correlation for two different signatures.

Page 76: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

76

! Dynamic Time Warping

DTW finds for each sample in one of the curves, the correspondent

sample in the other curve that is closest to the original sample using

some predefined metric. Given this correspondence, it is possible to

calculate a “distance” between the curves under comparison.

Consider two arrays y1 and y2 representing the Y coordinates of two

signatures to be compared. We form a matrix C where:

C(i,j) = y1(i) – y2(j)

Consider one example,

Y1= [1 0 1 2 1]

Y2= [1 0 2 1]

Then the cost matrix generated will be:

Page 77: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

77

Thus, the two figures to be matched are given by:

Local Cost Grid obtained is given as:

Page 78: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

78

The optimal path for the grid can be shown in the figure below:

After calculating cost function for all paths, the path with minimum cost function is

selected:

Page 79: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

79

To minimize the cost function, we need to find the path between points C(1,1) to

C(m,n) such that the summation along the path is minimum. Here m and n are

lengths of y1 and y2 respectively. This algorithm yields a compression or

expansion of the data along the signal in order to find the best possible match

between the two samples.

We used the method of recursion in order to evaluate each path cost and

minimize it. However the program was not optimized for time, and especially in

MATLAB, was taking a long time to execute even for small arrays of the order

10X10. We then adapted the algorithm in C language, and put a number of

optimization constraints on the warping path. These included restricting the path

to near diagonal area. This eliminated approximately half of the elements of the

C matrix from consideration, thus reducing the calculations. We also included

slightly different algorithms depending on the relative lengths of the two matrices,

thus defining whether the path should take a right or a down after a default

diagonal path. We evaluated cost at each step, and if it exceeded the minimum

cost obtained till that point, we discarded the entire path.

With these optimized techniques, we were able to handle matrices of the order of

20X20. Thus we used this technique for warping of stroke lengths and times,

rather than entire signature warping and much more extensively in the character

recognition algorithm.

Page 80: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

80

GUI for signature verification:

The graphical user interface that we had formed had the following appearance

for signature identification and verification system.

! Read Signature: This button allows the user to read currently stored

data serially from the pen. This button calls the function serialread()

through which MATLAB serially reads data from the pen. It also calls a

function remove0() which removes the redundant zeroes at the

beginning and the end.

! Display Signature: This button becomes active only after the user has

taken atleast one data reading. The callback for this button simply plots

the current data acquired from the pen onto the axes on the GUI.

! Signature Identification: This button has a callback which executes a

function sign_identify. This function calls the various functions which

find out the feature vector for each signature in the database, and

match it with the sample signature. The function finds out all different

features of the sample signature, and matches them with all signatures

in the database. It returns the one with the highest matching

percentage, and displays the result in the result text box.

! User name text box: The user is supposed to enter the user name

here against whom the signature verification is to be done. Only if the

user name entered is a valid name, the signature verification button

becomes active.

! Signature Verification: The verify button has a callback which

executes the function sign_verify function. This function evaluates the

entire feature vector, and depending on the user dependent threshold,

assigns the sample signature as a genuine or a forgery.

! Result Panel: The resul panel consists of the result text box and the

bar graph result. The user name and confidence level is shown in this

while identifying the signature, and the whether verified or not, along

with matching percentage while verification. The bar graph adjoining it

Page 81: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

81

displays the verification resul graphically. It shows the result in red if it

does not match and in green if it does match. It shows the matching

percentage and also the threshold with a single line.

! Admin: The user can log in as administrator from this button.

! Main menu: This button enables the user to return to the main menu

to choose another application. It basically closes this GUI and opens

the first one.

Page 82: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

82

Page 83: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

83

Page 84: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

84

Administrator Password GUI:

To log in to the administrator page, the user needs to provide the correct

username and password, failing which he will be redirected to the main page. A

popup is shownif the user enters incorrect information, and asks the user to retry,

go to main menu, or exit entirely. If the correct login and password are provided,

user can view the administrator GUI, as shown below.

Page 85: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

85

Administrtaor GUI:

The admin GUI gives options to add/edit and delete accounts. An entire pop-up

list of all users in the database can be viewed. The entire signature verification

procedure can be graphically seen on this page.

! Add/Edit account: This button closes this current GUI opens the

Add_admin GUI.

! Delete Account: This button simply deletes the selected entry from

the pop up menu.

! Popup menu: This is initialized during the opening function of the GUI.

It shows a popup list of all valid users. The entire signature verification

procedure is carried out between the current selected user and the

sample signature.

! Display Statistical Properties: The statistical properties such as

mean, standard deviation, etc are displayed in the textbox.

! Display Prototype: This button allows the user to see the prototype

signature of the currently selected user.

! Display Signature: This allows the user to view the recent signature

sample.

! Correlation: This button shows the auto correlation of the prototype

signature in the left side axis, and the correlation of the sample with the

prototype in the right hand side axis.

! Peaks and Valleys: The peaks and valleys button is used to

graphically demonstrate peaks and valleys for both the prototype and

the sample signature.

! Warping: The warping function allows us to visualize dynamic time

warping of the stroke lengths.

! Stroke Correlation: The stroke time correlation can be seen using the

stroke correlation button.

Page 86: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

86

Each of these buttons has a callback which results in the execution of the

respective function, selection of the proper axis, clearing the axis and

displaying the corresponding graph.

! Main Menu: This page also has a main menu button allowing the user

to go back to the main page.

The screen shots below display the various function for one of the sample

signatures.

Page 87: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

87

Page 88: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

88

Displaying prototype and sample signature

Correlation graphs

Page 89: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

89

Peaks and Valleys

Warping of stroke distances

Page 90: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

90

Stroke time correlation

Statistical Properties

Page 91: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

91

Add Users:

The add_admin GUI allows the administrator to add a user to the database. The

appearance of the GUI is shown below. The administrator can add a user by

taking 5 sample signatures and making a prototype out of them. Information

about the user such as city and telephone number can be added here.

! Add: This button allows the administrator to add an account to the

database.

! Edit: This allows the administrator to edit the details of any of the user in

the database.

! Popup menu: Itts shows the list of all users already in the database. This

list is formed in the opening function of the GUI.

! Text boxes for name, city and telephone number: These allow the

administrator to change these fields for the selected user.

! Confidence level: This scroll bar allows the administrator to set the

confidence level for any particular user.

! Read: This button allows the user to read a sample signature.

! Display: This button allows the user to view the currently read signature.

! Accept: The user can accept the sample signature to make the prototype.

! Make Prototype: This button makes a prototype for a new user after the

count in the text box is 5. The callback for this button execues a function

which correlates the five samples, and selects the sample with the highest

correlation with all others as the prototype. It writes this prototype into the

database along with the other details for the user.

! Admin Menu: The administrator can return to the admin menu withthis

button.

! Main Menu: The administrator can return to the main menu using this

button.

Page 92: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

92

!

Page 93: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

93

CHAPTER 4: CHARACTER RECOGNITION

Character Recognition

We decided to implement digit recognition from ‘0’ to ‘9’ and character

recognition from ‘a’ to ‘f’. After extensive experimentation we concluded that

dynamic time warping was the most effective, giving accuracy of approximately

95%.

The resolution of the data acquired is very high, moreover the warping algorithm

can effectively handle 20X20 matrices only, thus we considered every fourth or

fifth element of the data in the actual warping program. The high accuracy was

obtained when 60% weightage was given to warping of X-coordinated and 40%

to that of Y.

A sample of the warping is shown in the figure below.

Page 94: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

94

GUI:

The character recognition GUI allows the user to select one of the two modes,

viz., character recognition (from a to f) or digit recognition. The read, display and

recognize buttons respectively read the data, display the digit or number draw,

and find out the closest match to it. The call back of the recognize button calls a

function which performs dynamic time warping on the sample data and each of

the prototype digits or numbers as selected. The digit or character with the

minimum cost function is displayed as the result in the text box. The DTW graphs

are displayed in the four axes.

! Read: This button allows the user to read the data from the pen, and

stores it into the temporary folder we have created.

! Display: This button enables the user to display the data just read.

! Recognize: This button executes the actual recognition program, and

returns the result in the text box, as well as shows the warping plots on

the 4 axes. This button has a callback function which runs the warping

program on all digits/character, and evaluates the cost function in each

case. The result is the digit/character with the lowest cost.

! Recognition Mode: This allows the user to select the mode, either

digit recognition or character recognition(a-f)

! Result Textbox: The result of the recognition program is displayed in

this textbox.

! Axes: The two upper upper axes display X and Y warping of the

match. The two lower axes display the X and Y warping of the least

match. This demonstrates the effectivelness of the warping function

and how it recognizes the digit or character by comparing the cost

function.

! Main Menu: his button allows the user to access the main menu again.

Page 95: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

95

Page 96: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

96

Page 97: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

97

CHAPTER 5: DESIGN AID

Basic Engineering and Design applications can be implemented using this

hardware. The various application we implemented include point to point plot,

tracing the actual movement of the pen, curves with user defined angles and

semicircles. This can find numerous applications in the field of architecture, civil

engineering, etc. For ease of use and convenience of plotting, various colours

and line styles were implemented.

The user presses the button mounted on the pen and this click is detected by the

software. The simple program generates an array representing X and Y

coordinates of the click, using the information reflected by the status bit. These

arrays can be used further for various plotting options. We implemented the

following plotting options:

! Free plot : Plot the points in between the button clicks as they were traced.

! Point to point plot: Plot the points in between the two points as a straight

line.

! Arc(clockwise/anticlockwise): This allows the user to draw an arc with the

user specified subtended angle between the two points.

Page 98: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

98

GUI:

The graphical user interface for the design aid had an appearance as shown on

the following page.

! Read: This button allows the user to read the data. The callback function

stores the X, Y coordinates alongwith the button click data.

! Display: This button allows the user to plot the data in a variety of styles

and forms, as explained from the popup menus.

! Plotting Tool: This allows the user to select a specific colour, and a style

for plotting the data, such as ‘*’ (asterix), squares, dots, etc.

! Design Aid: This allows the user to plot each segment as either a free

plot, a point to point plot, or an arc with a specified angle. A function

findarray() is first executed, which identifies the points at which button

press occurred, and stores them in a text file. This is then used by the

callback of the display button to calculate the path to be plotted in between

the two corresponding points.

! Save: This button allows the user to save the data just loaded to any

location on the computer.

! Load: This button enables the user to load any previously stored data.

! Main Menu: This allows the user to navigate back to he main menu.

Page 99: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

99

Page 100: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

100

Page 101: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

101

Page 102: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

102

SECTION 7

COSTING

Page 103: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

103

COSTING

Component No. Of Units Total Cost In Rupees.

AtTiny2313 ("C) 1 90/-

AT24C512

Internal EEPROM 3 195/-

Intex Mouse 1 200/-

MAX-232 1 30/-

PCB Fabrication - N.A - 85/-

Resistors, Capacitors,

LEDs- N.A - 20/-

Acrylic Sheet - N.A - 20/-

Pen 1 10/-

Sum Total Cost = Rs.650/- Approximately

Page 104: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

104

SECTION 8

CONCLUSION

Page 105: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

105

CONCLUSION

The imaginative use of the mouse sensor circuit has made possible signature

verification and identification, character recognition and design. However, the

possible scope of the project doesn’t end there.

Applications in areas as diverse as robotics, biometrics and handwriting analysis

can be envisioned. The current system itself may be improved upon.

For one, the use to IRDA technology can enable completely wireless

communication between the module and the computer. This may have great

scope in bank ATMs or for official document signatures. For further security in

the case of signature verification system, the use of pressure transducers can set

extremely low false acceptance results. A possible interface with SD cards can

further reduce the size, improving the speed and reducing cost all at once.

Additional functionality may be developed in the case of design aid tool, viz.

inclusion of polynomials, curves and angles etc. Area calculation and distance

measurements become rather easy to achieve, but may be of great use to civil

engineers, designers and architects.

In summary, the whole purpose behind undertaking such a project is to

demonstrate, for one, the breathtaking possibilities that technology has to offer,

as well as our own understanding of the needs of the real world and our ability to

utilize the skill set mastered over the rigorous courses.

Page 106: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

106

SECTION 9

REFERENCES

Page 107: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

107

REFERENCES

! Claudio Lanconelli Avr-Pg1b (Serial Port) 10 Pin Icsp Avr Microcontroller

Programmer.

! Programmer's Reference to Genius Mouse & # Mice: How do they work?

by Richard Torrens.

! Adam Chapweske, The PS/2 Mouse/Keyboard Protocol, www.Computer-

Engineering.org

! Solid-State Optical Mouse Sensor with PS/2 and Quadrature Outputs,

Agilent Technologies.

! Paint Program with Mouse Control, Steven Keiper and Ragavan

Mahedevan, Cornell University.

! ADNK-5023-CY02 Optical Mouse Designer’s Kit, Avago Technologies.

! Programming In MATLAB, A Manual.

! MATLAB 7, Creating Graphical User Interfaces, MathWorks.

! Handwriting Recognition Using MATLAB by Jonathan Terleski.

! Modeling In Applied Mathematics, Bengt Fornberg & Ben Herbst.

! Analyses and Tests of Handwritten Digit Recognition Algorithms, Berkant

Savas.

Page 108: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

108

! EAGLE - Easily Applicable Graphical Layout Editor Manual Version 4.1.

! MATLAB Documentation And Help Files.

! CodeVision AVR, Code Wizard and AVR studio Documentation.

! ATTINY2313, AT24C512, MAX232 datasheets.

! www.mathworks.com

! www.semiconductors.phillips.com

! www.alldatasheets.com

! www.atmel.com

! www.microchip.com

! www.lancos.com

! www.google.com

Page 109: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

109

SECTION 10

APPENDIX

Page 110: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

110

APPENDIX A

Given below is the software program in ‘C’ language that’s loaded on the

AtTiny2313. It’s task is to operate the module in the different modes as explained

in the main text.

/*****************************************************

This program was produced by the

CodeWizardAVR V1.24.8d Professional

Automatic Program Generator

© Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.

http://www.hpinfotech.com

Project : Optical Sensor Based Signature Recognition Tool

Version : 1

Date : 4/15/2007

Author : Siddharth Shashidharan, Himanshu Madan, Sanika Mokashi & Sneha Rangdal

Company : C.O.E.P

Comments:

Chip type : ATtiny2313

Clock frequency : 1.000000 MHz

Memory model : Tiny

External SRAM size : 0

Data Stack size : 32

*****************************************************/

#include <tiny2313.h>

#include <stdio.h> // sprintf

#include <delay.h> // delay_ms

#include <stdlib.h>

#define DATA_IN PIND.4 //data line from mouse

#define CLK_IN PIND.5 //clock line from mouse

#define DATA_OUT PORTD.4 //data line from mouse

#define LOW 0

Page 111: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

111

#define HIGH 1

#define DDR_USI DDRB

#define PORT_USI PORTB

#define PIN_USI PINB

#define PORT_USI_SDA 5

#define PORT_USI_SCL 7

#define PIN_USI_SDA 5

#define PIN_USI_SCL 7

#define itime2 3

#define itime4 3

//#define daddress 0xA2

#define RXB8 1

#define TXB8 0

#define UPE 2

#define OVR 3

#define FE 4

#define UDRE 5

#define RXC 7

#define FRAMING_ERROR (1<<FE)

#define PARITY_ERROR (1<<UPE)

#define DATA_OVERRUN (1<<OVR)

#define DATA_REGISTER_EMPTY (1<<UDRE)

#define RX_COMPLETE (1<<RXC)

#define sig_read 0x400;

#define char_read 0x100;

#define des_read 0x800;

register unsigned char data @4;

#asm

.equ PORTD=0x12

.equ DDRD=0x11

Page 112: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

112

.MACRO DATALOW

sbi DDRD,4 ;DDRD.4=1

cbi PORTD,4 ;PORTD.4=0

.ENDM

.MACRO RELDATA

cbi DDRD,4 ;DDRD.4=0

sbi PORTD,4 ;PORTD.4=1

.ENDM

.MACRO CLKLOW

sbi DDRD,5 ;DDRD.5=1

cbi PORTD,5 ;PORTD.5=0

.ENDM

.MACRO RELCLK

cbi DDRD,5 ;DDRD.5=0

sbi PORTD,5 ;PORTD.5=1

.ENDM

#endasm

unsigned char

mouse_x,mouse_y,mouse_status,ack0,oflag=1,sflag=1,opmode,powerflag,powerflag1=0,cflag=0;

unsigned int read=0,limit_read=0x50,sread;

unsigned int address=0x00;

bit power=0;

void USI_TWI_Master_Initialise( void )

{

PORT_USI |= (1<<PIN_USI_SDA); // Enable pullup on SDA, to set high as released state.

PORT_USI |= (1<<PIN_USI_SCL); // Enable pullup on SCL, to set high as released state.

Page 113: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

113

DDR_USI |= (1<<PIN_USI_SCL); // Enable SCL as output.

DDR_USI |= (1<<PIN_USI_SDA); // Enable SDA as output.

USIDR = 0xFF; // Preload dataregister with "released level" data.

USICR = 0b00101010;

// Disable Interrupts.

// Set USI in Two-wire mode.

// Software stobe as counter clock source

USISR = 0b11110000; // Clear flags and reset counter.

}

/*---------------------------------------------------------------

Function for generating a TWI Stop Condition. Used to release

the TWI bus.

---------------------------------------------------------------*/

void USI_TWI_Master_Stop( void )

{

PORT_USI &= ~(1<<PIN_USI_SDA); // Pull SDA low.

PORT_USI |= (1<<PIN_USI_SCL); // Release SCL.

while(!(PIN_USI & (1<<PIN_USI_SCL)));

delay_us(itime4);

PORT_USI |= (1<<PIN_USI_SDA); // Release SDA.

delay_us(itime2);

}

/*---------------------------------------------------------------

Core function for shifting data in and out from the USI.

Data to be sent has to be placed into the USIDR prior to calling

this function. Data read, will be return'ed from the function.

Page 114: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

114

---------------------------------------------------------------*/

unsigned char USI_TWI_Master_Transfer( unsigned char temp )

{

USISR = temp; // Set USISR according to temp.

// Prepare clocking.

temp = 0b00101011; // Interrupts disabled

// Set USI in Two-wire mode.

// Software clock strobe as source.

// Toggle Clock Port.

do

{

delay_us(itime2);

USICR = temp; // Generate positve SCL edge.

while( !(PIN_USI & (1<<PIN_USI_SCL)) ); // Wait for SCL to go high.

delay_us(itime4);

USICR = temp; // Generate negative SCL edge.

}

while( !(USISR & 0x40) ); // Check for transfer complete.

delay_us(itime2);

temp = USIDR; // Read out data.

USIDR = 0xFF; // Release SDA.

DDR_USI |= (1<<PIN_USI_SDA); // Enable SDA as output.

return temp; // Return the data from the USIDR

}

char i2c( unsigned char idata, unsigned char dmode, unsigned char rw)

{

unsigned char tempUSISR_8bit = 0b11110000; // Prepare register value to: Clear flags, and

// set USI to shift 8 bits i.e. count 16 clock edges.

Page 115: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

115

unsigned char tempUSISR_1bit = 0b11111110; // Prepare register value to: Clear flags, and

// set USI to shift 1 bit i.e. count 2 clock edges.

unsigned char daddress;

unsigned char maddress_low;

unsigned char maddress_high;

char rdata;

daddress = (0xA0|dmode) ;

/* Release SCL to ensure that (repeated) Start can be performed */

PORT_USI |= (1<<PIN_USI_SCL); // Release SCL.

while(!(PORT_USI & (1<<PIN_USI_SCL))); // Verify that SCL becomes high.

delay_us(itime2); // Delay

maddress_low=(address);

maddress_high=(address>>8);

/* Generate Start Condition */

PORT_USI &= ~(1<<PIN_USI_SDA); // Force SDA LOW.

delay_us(itime4);

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

PORT_USI |= (1<<PIN_USI_SDA); // Release SDA.

// address write

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

USIDR = daddress; // Setup data.

USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus.

// ack

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

USI_TWI_Master_Transfer( tempUSISR_1bit );

// memory address_high write

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

USIDR = maddress_high; // Setup data.

USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus.

Page 116: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

116

// ack

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

USI_TWI_Master_Transfer( tempUSISR_1bit );

// memory address low write

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

USIDR = maddress_low; // Setup data.

USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus.

// ack

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

USI_TWI_Master_Transfer( tempUSISR_1bit );

if (rw==0)

{

// data write

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

USIDR = (idata); // Setup data.

USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus.

// ack

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

USI_TWI_Master_Transfer( tempUSISR_1bit );

}

else

{

/* Release SCL to ensure that (repeated) Start can be performed */

PORT_USI |= (1<<PIN_USI_SCL); // Release SCL.

while(!(PORT_USI & (1<<PIN_USI_SCL))); // Verify that SCL becomes high.

delay_us(itime2); // Delay

/* Generate Start Condition */

PORT_USI &= ~(1<<PIN_USI_SDA); // Force SDA LOW.

delay_us(itime4);

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

PORT_USI |= (1<<PIN_USI_SDA); // Release SDA.

Page 117: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

117

// address write

PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.

USIDR = (daddress+1); // Setup data.

USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus.

// ack

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

USI_TWI_Master_Transfer( tempUSISR_1bit );

// Read a data byte

DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.

rdata= USI_TWI_Master_Transfer( tempUSISR_8bit );

// Prepare to generate ACK (or NACK in case of End Of Transmission)

USIDR = 0xFF; // Load NACK to confirm End Of Transmission.

USI_TWI_Master_Transfer( tempUSISR_1bit ); // Generate NACK.

}

USI_TWI_Master_Stop(); // Send a STOP condition on the TWI bus.

if((dmode==0x02)||rw==1)

address++;

return(rdata);

}

//**********************************************************

// Send a byte of data to mouse. It consist of 1 start bit, 8 data bits, 1 parity bit, 1 stop bit.

// After the mouse recieved the data correctly, the mouse will send back an ACK bit.

// "data" is the data to be sent. parity bit is odd parity of the 8 bits data.

// Data is read by mouse at rising edge of CLK.

void mouse_send(char data)

{

unsigned char Bit,parity,i;

Page 118: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

118

#asm("RELDATA");

#asm("RELCLK");

delay_us(300);

#asm("CLKLOW"); //Pull CLK Low

delay_us(300); // need to wait for at least 100us

#asm("DATALOW"); // Pull DATA Low when holding CLK Low

delay_us(100);

#asm("RELCLK"); //Release CLK and continue to hold Data Low. This is also the Start

bit.

delay_us(40);

while(CLK_IN!=LOW) { } // wait for CLK to go low

i=0; Bit=0b00000001;

parity=1; // odd parity = 1 ^ bit0 ^ bit1 ^ ... ^ bit7

while(i<=8)

{

if(i==8) // If i=8 send parity bit otherwise, send the next bit of data.

{ if(parity) // DATA_OUT=(i==8? parity : (data & Bit) );

{ #asm("RELDATA"); }

else

{ #asm("DATALOW"); }

}

else

{ if(data & Bit)

{ #asm("RELDATA"); }

else

{ #asm("DATALOW"); }

}

while(CLK_IN!=HIGH) {} // wait for CLK to go high. mouse read data at rising

edge.

while(CLK_IN!=LOW) {} // wait for CLK to go low.

parity=parity ^ DATA_OUT; // update parity bit.

Bit=Bit<<1; // Prepare mask

i++;

}

#asm("RELDATA"); // Release Data line. This is the stop bit.

delay_us(50); // give time for transient to settle.

Page 119: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

119

while(DATA_IN!=LOW) {} // wait for Data line to go low

while(CLK_IN!=LOW) {} // wait for CLK to go low. Start of ACK from mouse.

while(DATA_IN==LOW || CLK_IN==LOW) {} // End of ACK from mouse.

#asm("CLKLOW"); // Inhibit the mouse from transmitting data.

}

//**********************************************************

// This function read a byte of data from the mouse and return the byte

unsigned char mouse_read(void)

{

unsigned char i,t[10];

#asm("RELCLK"); //release the CLK

#asm("RELDATA"); //release DATA line.

delay_us(200); // wait for at least 100us

while(CLK_IN==HIGH) {} // wait for falling edge. we read data at falling edge of CLK

i=0;

delay_us(5);

while(CLK_IN==LOW) {} // wait for CLK to go high.

while(i<=8)

{

while(CLK_IN==HIGH) {} // wait for falling edge of CLK

t[i]=DATA_IN; // store each bit

i++;

while(CLK_IN==LOW) {}

}

while(CLK_IN==LOW) {}

data=128*t[7]+64*t[6]+32*t[5]+16*t[4]+8*t[3]+4*t[2]+2*t[1]+t[0]; //combine the collected bits into a

byte

#asm("CLKLOW"); //pull CLK low to prevent mouse from sending data until being asked

return data;

}

Page 120: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

120

//*******************************************

// This routine poll the mouse's status and movement data.

void poll_mouse(void)

{

mouse_send(0xeb); //Request data from mouse

mouse_read(); //Read the acknowledge byte

mouse_status=mouse_read(); //Read mouse status

i2c(mouse_status,0x00,0);

mouse_x=mouse_read(); //Read mouse horizontal movement

i2c(mouse_x,0x06,0);

mouse_y=mouse_read(); //Read mouse vertical movement

i2c(mouse_y,0x02,0);

/*

powerflag=(mouse_status & 0x04);

if(powerflag==1)

{

cflag=1;

}

if(cflag==1 && powerflag==0)

{

powerflag1=1;

cflag=0;

}

Page 121: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

121

if(powerflag1==1)

{

power=~power;

powerflag1=0;

} */

/* if((mouse_x!=0 && mouse_y!=0) )

{

address++;

read++;

}

*/

}

//**********************************************

// This function is called to reset the mouse and put it into remote mode.

// In remote mode, mouse only send data upon request from the microcontroller.

// This function is called when manual reset of the mouse is required. This is for

// overcoming interference problem from some unknown EM field.

void reset_mouse(void)

{

mouse_send(0xff); // reset mouse

ack0=mouse_read(); // read mouse acknowledge (0xFA)

//i2c(ack0,0);

ack0=mouse_read(); // read some blank bytes.

//i2c(ack0,0);

ack0=mouse_read();

// i2c(ack0,0);

Page 122: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

122

mouse_send(0xf3); // SAMPLE RATE

ack0=mouse_read();

// i2c(ack0,0);

mouse_send(0xc8); // rate=200

ack0=mouse_read();

// i2c(ack0,0);

mouse_send(0xE8); // resolution

ack0=mouse_read();

//i2c(ack0,0);

mouse_send(0x03); // 8 counts per mm

ack0=mouse_read();

//i2c(ack0,0);

mouse_send(0xE6); // scaling 1:1

ack0=mouse_read();

//i2c(ack0,0);

mouse_send(0xf0); // Set mouse to remote mode.

ack0=mouse_read();

//i2c(ack0,0);

delay_ms(100);

delay_ms(2000);

}

//**********************************************

Page 123: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

123

void initialize(void)

{

#asm("cli");

//init ports

DDRD = 0b01001111; // PD5 DATA IN, PD4 CLOCK IN

DDRD.6=0; // Use for mouse reset

PORTD.6=1; // enable pullup resistor

DDRD.4=1;

PORTD.4=1;

delay_ms(500);

DDRD.4=0;

DDRD.5=1;

PORTD.5=1;

delay_ms(500);

DDRD.5=0;

// init mouse variables

#asm("RELCLK");

#asm("RELDATA");

//init mouse state

reset_mouse();

}

// Write a character to the USART Transmitter

#ifndef _DEBUG_TERMINAL_IO_

#define _ALTERNATE_PUTCHAR_

#pragma used+

void putchar(unsigned char c)

{

Page 124: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

124

while ((UCSRA & DATA_REGISTER_EMPTY)==0);

UDR=c;

}

#pragma used-

#endif

// USART Receiver interrupt service routine

interrupt [USART_RXC] void usart_rx_isr(void)

{

//char read=0x7F;

char status,sdata;

unsigned char temp;

//unsigned int address1,address2;

status=UCSRA;

sdata=UDR;

if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)

{

sread=read;

if(sdata=='o')

{

DDRB.4=1;

PORTB.4=1;

putchar(opmode);

putchar(read);

putchar(address>>8);

}

if(sdata=='c')

{

address=0x00;

while(sread!=0)

{

temp=i2c(read,0x00,1);

putchar(temp);

sread--;

}

Page 125: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

125

}

if(sdata=='x')

{

address=0x00;

while(sread!=0)

{

temp=i2c(read,0x06,1);

putchar(temp);

sread--;

}

}

if(sdata=='y')

{

address=0x00;

while(sread!=0)

{

temp=i2c(read,0x02,1);

putchar(temp);

sread--;

}

DDRB.4=1;

PORTB.4=0;

sflag=0;

}

}

}

// External Interrupt 0 service routine

interrupt [EXT_INT0] void ext_int0_isr(void)

{

DDRB.4=1;

PORTB.4=0;

Page 126: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

126

delay_ms(100);

DDRB.0=1;

DDRB.1=1;

DDRB.2=1;

DDRB.3=1;

PORTB.0=0;

PORTB.1=0;

PORTB.2=0;

PORTB.3=0;

DDRB.0=0;

DDRB.1=0;

DDRB.2=0;

DDRB.3=0;

opmode=PINB & 0x0F;

oflag=1;

if(opmode==1)

limit_read=des_read;

if(opmode==2)

limit_read=char_read;

if(opmode==4)

limit_read=sig_read;

if(opmode==8)

{

#asm("sei")

while(sflag!=0){}

sflag=1;

}

Page 127: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

127

read=0x00;

address=0x00;

USI_TWI_Master_Initialise();

initialize();

DDRB.4=1;

PORTB.4=1;

delay_ms(500);

PORTB.4=0;

delay_ms(500);

PORTB.4=1;

delay_ms(500);

PORTB.4=0;

delay_ms(500);

// delay_ms(500);

PORTB.4=1;

}

void main(void)

{

// Declare your local variables here

// Crystal Oscillator division factor: 8

#pragma optsize-

CLKPR=0x80;

CLKPR=0x04;

#ifdef _OPTIMIZE_SIZE_

#pragma optsize+

#endif

/*

// Timer/Counter 0 initialization

// Clock source: System Clock

// Clock value: Timer 0 Stopped

Page 128: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

128

// Mode: Normal top=FFh

// OC0A output: Disconnected

// OC0B output: Disconnected

TCCR0A=0x00;

TCCR0B=0x00;

TCNT0=0x00;

OCR0A=0x00;

OCR0B=0x00;

// Timer/Counter 1 initialization

// Clock source: System Clock

// Clock value: Timer 1 Stopped

// Mode: Normal top=FFFFh

// OC1A output: Discon.

// OC1B output: Discon.

// Noise Canceler: Off

// Input Capture on Falling Edge

// Timer 1 Overflow Interrupt: Off

// Input Capture Interrupt: Off

// Compare A Match Interrupt: Off

// Compare B Match Interrupt: Off

TCCR1A=0x00;

TCCR1B=0x00;

TCNT1H=0x00;

TCNT1L=0x00;

ICR1H=0x00;

ICR1L=0x00;

OCR1AH=0x00;

OCR1AL=0x00;

OCR1BH=0x00;

OCR1BL=0x00;

*/

// External Interrupt(s) initialization

// INT0: On

// INT0 Mode: Rising Edge

// INT1: Off

Page 129: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

129

// Interrupt on any change on pins PCINT0-7: Off

GIMSK=0x40;

MCUCR=0x03;

EIFR=0x40;

// Timer(s)/Counter(s) Interrupt(s) initialization

TIMSK=0x00;

// Universal Serial Interface initialization

// Mode: Disabled

// Clock source: Register & Counter=no clk.

// USI Counter Overflow Interrupt: Off

USICR=0x00;

// USART initialization

// Communication Parameters: 8 Data, 2 Stop, No Parity

// USART Receiver: On

// USART Transmitter: On

// USART Mode: Asynchronous

// USART Baud rate: 2400

UCSRA=0x00;

UCSRB=0x98;

UCSRC=0x0E;

UBRRH=0x00;

UBRRL=0x19;

// Analog Comparator initialization

// Analog Comparator: Off

// Analog Comparator Input Capture by Timer/Counter 1: Off

ACSR=0x80;

USI_TWI_Master_Initialise();

initialize();

// Global enable interrupts

Page 130: Optical Sensor Based Dynamic Signature Recognition And Verification Tool

130

#asm("sei")

DDRB.4=1;

PORTB.4=1;

delay_ms(500);

PORTB.4=0;

delay_ms(500);

PORTB.4=1;

delay_ms(500);

PORTB.4=0;

delay_ms(500);

PORTB.4=1;

while(1)

{

while ((read!=limit_read) && (oflag==1))

{

poll_mouse();

read++;

if(read==limit_read-1)

{

oflag=0;

DDRB.4=1;

PORTB.4=0;

}

};

}

}