Вы находитесь на странице: 1из 152

UNIT III

Interfacing and Programming


Dr. P. H. Zope

SSBTs College of Engineering and Technology Bambhori Jalgaon


North Maharashtra University
phzope@gmail.com
9860631040

Topics
1. What is Interfacing and Need of interfacing.
2. Different Interfacing techniques.
3. Basic embedded C programs for on-chip peripherals
studied in system architecture.
4. Interfacing of different displays including Graphic LCD
(320X240), Interfacing of input devices including touch
screen etc,
5. Interfacing of output devices like thermal printer etc.,
6. Embedded communication using CAN and Ethernet,
7. RF modules, GSM modem for AT command study etc.

What is Interfacing
An interface is the point of interaction with software, or computer
hardware, or with peripheral devices such as a computer monitor or
a keyboard.
Some computer interfaces such as a touch screen can send and
receive data, while others such as a mouse, microphone or joystick
can only send data.
Types of Interfacing
1. Hardware
2. Software

Hardware interfaces
Hardware interfaces exist in computing systems between many of
the components such as the various buses, storage devices,
other I/O devices, etc.
A hardware interface is described by the mechanical, electrical and
logical signals at the interface and the protocol for sequencing
them (sometimes called signaling).
A standard interface, such as SCSI, decouples the design and
introduction of computing hardware, such as I/O devices, from the
design and introduction of other components of a computing
system, thereby allowing users and manufacturers great flexibility
in the implementation of computing systems.

Hardware interfaces can be parallel where performance is


important or serial where distance is important.

Software interfaces
A software interface may refer to a wide range of different types of
interface at different "levels": an operating system may interface
with pieces of hardware.
Applications or programs running on the operating system may need
to interact via streams, and in object oriented programs, objects
within an application may need to interact via methods.

Programming to the interface


The use of interfaces allows
called programming to the interface.

programming

style

The idea behind this is to base programming logic on the interfaces


of the objects used, rather than on internal implementation details.
Programming to the interface reduces dependency
implementation specifics and makes code more reusable.

on

It gives the programmer the ability to later change the behavior of


the system by simply swapping the object used with another
implementing the same interface.

Benefits
1.Low cost
2.Easy interfacing & Design
3.Easy Production
4.users choice for interfacing
5.No Maintenance
6.Easier Handling
Disadvantages
1.Compact size is not possible
2.Power consumption is more as compared to SOC
3.Leakage current is more
4.Limited Devices Addressing
5.No Support of Multi/ Master configuration

Different Interfacing techniques

ROM image creation in an Embedded System


Process of converting C , C ++ -program into ROM image
and ready to use
To make the application run independently with the specific board one can
follow the steps given below so that the application developed on the host
system, after cross compiling the same for specific image and specific board

The step wise process is as follows :


To write your first program, you'll need to have the following
software installed on your system:
Triton IDE installed
JRE of version 1.5 or higher ( provided in Triton IDE setup)
Philips Utility ( provided in Triton IDE setup)

Setting up the Project


To create an IDE project:
Start Triton IDE.
Select the workspace in which you can create all your projects as
shown in the figure below. Click OK.

Triton IDE C/C++ Environment opens as shown in below figure in


which you can create new project, open existing one etc.

To create new project go to Project menu New C Project.


You will get below figure.
In the Project Name field, type keypad.
o Select the Target as per the board you have.
o Select the Variant from the variant list.
o Select Operating System as per your requirement.
o Select the Port from Port field.
o Select the Baud Rate.
o Select the Build options.
o Select the Download options
o Select the Debug type
o You can also change the location of project.
For that uncheck use default location.
o Check Create Project Using Template.

Click Next.
Belo s ree ill appear. ele t De ug a d
Release configurations.

Click Finish.
The project is created and opened in the IDE. You should see the following components:
The Proje ts i do , hi h o tai s a tree ie of the o po e ts of the project, including
source files and properties file that your code depends on. .
The our e Editor i do
ith a file alled ke pad_ ai . ope .

Adding Code to the Generated Source File


Because you have left the Create Project Using Template checkbox selected in the New
Project wizard, the IDE has created a skeleton class for you. You can add your keypad
code to the skeleton code by replacing the line:
//TODO: You can write your code at here
Sample code for Keypad
------------------------------#include <board.h>
int main(void)
{
char key;
q_keyinit(SPIRIT);
q_lcdinit(SPIRIT); /* initialise the LCD*/
q_printf("%s \r\nkey;","Hello");
q_displaylcd("Hello", 5);
while(1)
{
while((key = q_keyread()) == 0);
key = key + 0x30;
q_clrscreen();
q_printf("%x \n", key);
q_displaylcd(&key, 1);
}
}
Save the change by choosing File > Save.

Compiling the Project


To compile project you need to select Debug or Release mode.
Debug mode: This creates an executable which you after
downloading on the target board are able to debug.
Release mode: This creates an executable which you can download
on the target board but you wont be able to debug.
Right click on the keypad project and point to Active Build
Configuration and select Release as shown in the below screen.

To build Project right click on keypad project and select Build Project.
Open the build console view to check for any errors as shown in the below figure.

If your project has built successfully *.hex will be created.


If there are any errors in the project Build Console view will display the error
messages and from Build Output view you can check the location of errors in your
code.
When you build the project, the keypad.hex is generated. You can see where
the new file is generated by opening the C/C++ Projects view and expanding the
keypad project node as shown in the following figure.

Now that you have built the


project, you download executable
on target board and run the
program.

Downloading the Program


I Trito IDE e e uta le a

e do loaded three optio s:


ISP Utility, Odyssey JTAG and FTP.
ele t the appropriate do load optio a d right li k o the *.he file ge erated
and click Download as shown below.

After successful download of


program you can check the
application by running it
on target board.

Debugging the Program


In Triton IDE you can debug your program by three options:Monitor, Odyssey JTAG and Ethernet.
As per your requirement select appropriate option for debugging and build the
project in debug mode (same step as Release mode)
After compilation download the generated executable and you can now debug the
project.
Right click on the project and select Debug As and click Debug Local C/C++
Application.

GPIO - General purpose input/output.


FEATURES
Direction control of individual bits
Separate control of output set and clear
All I/O default to inputs after reset
APPLICATIONS
General purpose I/O
Driving LEDs, or other indicators
Controlling off-chip devices
Sensing digital inputs

330_09

30

IOPIN
GPIO Port Pin value register. The current state of the port pins
can always be read from this register, regardless of pin
direction and mode.
IOSET
GPIO Port Output set register. This register controls the state
of output pins in conjunction with the IOCLR register. Writing
ones produces highs at the corresponding port pins. Writing
zeroes has no effect.
IODIR
GPIO Port Direction control register. This register individually
controls the direction of each port pin.
IOCLR
GPIO Port Output clear register. This register controls the state
of output pins. Writing ones produces lows at the
corresponding port pins and clears the corresponding bits in
the IOSET register. Writing zeroes has no effect.
330_09

31

LED Interfacing
P0-15
P0-16
P0-17
P0-18
P0-19
P0-20

P0-21
P0-22
P0-23

330_09

32

Prepare code for Pin Declaration


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0000

0000

0111

1111

1000

0000

0000

0000

Prepare code for Data Display on port Lines


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0000

0000

0111

1111

1000

0000

0000

0000

330_09

33

Prepare code for Data Display on port Lines = AA


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0000

0000

0101

0101

0000

0000

0000

0000

Prepare code for Data Display on port Lines =55


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0000

0000

0010

1010

1000

0000

0000

0000

330_09

34

#include<LPC21xx.h>
void delay();
int main(void)
{
*IODIR0 = 0x7f8000;
while(1)
{
*IOPIN0 = 0x550000;
delay();
*IOPIN0 = 0x2A8000;
delay();
}
return 0;
}
void delay()
{
unsigned int x=500000;
while( x > 0 )
x--;
}
330_09

35

Seven-Segment Display
Seven-segment Displays

Used to display BCD digits

A group of 7 LEDs physically


mounted in the shape of the
number eight

Plus a decimal point

Each LED is called a segment

0 thru 9

a through g

Two types

Common anode
Common cathode
330_09

36

Seven-Segment Display
Common Anode

All anodes are connected together to a power supply


Cathodes are connected to data lines

Logic 0 turns on a segment


Example: To display the digit 1

All segments except b and c should be off


11111001 = F9H
Common Anode

330_09

37

Interface Seven-Segment Display


Common Cathode

All cathodes are connected together to ground


Anodes are connected to data lines

Logic 1 turns on a segment


Example: To display digit 1

All segments except b and c should be off


00000110 = 06H

330_09

38

330_09

39

Look-Up Table
Serial Number
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

DP
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

G
0
0
1
1
1
1
1
0
1
1
1
1
0
1
1
1

F
1
0
0
0
1
1
1
0
1
1
1
1
1
0
1
1

E
1
0
1
0
0
0
1
0
1
0
1
1
1
1
1
1
330_09

D
1
0
1
1
0
1
1
0
1
1
0
1
1
1
1
0

C
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
0

B
1
1
1
1
1
0
0
1
1
1
1
0
0
1
0
0

A
1
0
1
1
0
1
1
1
1
1
1
0
1
0
1
1

Code
3FH
06H
5BH
4FH
66H
6DH
7DH
07H
7FH
6FH
77H
7DH
39H
5EH
79H
71H
40

#include<LPC21xx.h>
void delay();
int main(void)
{
*IODIR1 = 0XFF0000;
while(1)
{

*IOCLR1 = 0Xff0000;
*IOSET1 = 0x3f0000; //0
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x060000; //1
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x5b0000; //2
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x4f0000; //3
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x660000; //4
delay(); 330_09

41

*IOCLR1 = 0Xff0000;
*IOSET1 = 0x6d0000; //5
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x7d0000; //6
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x070000; //7
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x7f0000; //8
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x6f0000; //9
delay();
*IOCLR1 = 0Xff0000;
*IOSET1= 0x770000; //A
delay();

330_09

42

*IOCLR1 = 0xff0000;
*IOSET1 = 0x7c0000;
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x390000;
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x5e0000;
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x790000;
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x710000;
delay();
}
return 0;
}

330_09

//b

//C

//d

//E

//F

43

void delay()
{
int x=500000;
while( x > 0 )
x--;
}

330_09

44

Interface Seven-Segment Display


using Interrupt signal (IRQ)

330_09

45

330_09

46

SEVEN-SEGMENT DISPLAY INTERFACE USING INTERRUPT


#include<board.h>
#include<LPC21xx.h>
void ISRHandlerEXTINT3()__attribute__((interrupt("IRQ")));
void delay()
{
int x=500000;
while( x > 0 )
x--;
}

330_09

47

void ISRHandlerEXTINT3(void)
{
*EXTINT=0x00000008;
q_printf("External Interrupt\n");
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x3f0000;//0
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x060000; //1
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x5b0000; //2
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x4f0000; //3
delay();
330_09

48

*IOCLR1 = 0Xff0000;
*IOSET1 = 0x660000; //4
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x6d0000; //5
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x7d0000; //6
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x070000; //7
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x7f0000; //8
delay();
*IOCLR1 = 0Xff0000;
*IOSET1 = 0x6f0000; //9
delay();

330_09

49

*IOCLR1 = 0Xff0000;
*IOSET1 = 0x770000; //A
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x7c0000; //b
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x390000; //C
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x5e0000; //d
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x790000; //E
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x710000; //F
330_09

50

delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x760000;//H
delay();
*IOCLR1 = 0xff0000;
*IOSET1 = 0x800000;//DP
delay();

q_printf("Press the switch again\n");


*VICVectAddr=0 ;
}

330_09

51

void IRQInit()
{
*PINSEL1=0x20000000;
*EXTMODE=0x8;
*VICVectAddr0=(unsigned int)ISRHandlerEXTINT3;
*VICVectCntl0=0x20|0x11;
*VICIntEnable=0x20000 |*VICIntEnable;
}
int main(void)
{
*IODIR0=0x7F8000;
IRQInit();
q_printf("main\n ");
return 0;
}

330_09

52

Time Multiplex Scanning

330_09

53

Interfacing Push-Button Keys


When a key is pressed (or released), mechanical metal contact
bounces momentarily and can be read as multiple inputs
Key debounce

Eliminating reading of one contact as multiple inputs


Hardware or Software

330_09

54

Key Debounce Techniques


Hardware technique

Two NAND gates

Software technique

S-R latch

The output of the latch is


a pulse without a bounce

330_09

Wait for 10 to 20 ms
after detection of a
switch closure
If the reading is still the
same it is accepted

55

Interfacing a Matrix Keypad


Problem statement

Interface a 4 x 4 Hex keypad to ARM-7


Write a program to recognize a key pressed and
encode the key in its binary value
Display binary code on LCD

330_09

56

Interfacing a Matrix Keypad


PIC18 Simulator Keypad Matrix

330_09

57

Time Multiplex Scanning


Software

Codes of the numbers to be displayed are stored in data


registers in sequence
The program gets the codes from the data registers by
using the pointer (FSR0) and sends them out to the LED
segments through PORTB
One display at a time is turned on by sending logic 1 to the
corresponding transistor connected to PORTC
After an appropriate delay, the first display is turned off
and the next display is turned on
Turning displays on/off is repeated in sequence

330_09

58

Interfacing LCD
Problem statement

Interface a 2-line x 16 character LCD module


with the built-in HD44780 controller to I/O ports
of the ARM-7 microcontroller.
Explain the control signals necessary to read
from and write to the LCD.
Write a program to display ASCII characters.

330_09

59

Interfacing LCD
Hardware

16 x 2-line LCD display

LCD has a display Data RAM

Two lines with 16 characters per line

Stores data in 8-bit character code

Each register in Data RAM has its own address

330_09

60

330_09

61

Interfacing LCD
P1-16
P1-17
P1-18
P1-19
P1-20
P1-21
P1-22
P1-23

P0-28
GND
P0-29
GND
ARM -7
62

Interfacing LCD
Driver HD44780

8-bit data bus (RD7-RD0)


Three control signals
RS Register Select
R/W Read/Write
E
Enable

Three power connections

Power, ground, and variable resistor to control brightness

330_09

63

Interfacing LCD
Can be interfaced either in 8-bit mode or 4-bit mode

In 8-bit mode, all eight data lines are connected


In 4-bit mode, only four data lines are connected

Two transfers per character (or instruction) are needed

Driver has two 8-bit internal registers

Instruction Register (IR) to write instructions to set up LCD

Table 9-3

Data Register (DR) to write data (ASCII characters)

330_09

64

LCD Pin Description

Pin No Symbol I/O


Description
1
Vss
Ground
2
Vcc
+5V
3
Vee
Contrast Control
4
RS
Input
Command/Data Register
5
R/W Input
Read/Write Register
6
E
Input/Output Enable
7
DB0 Input/Output Not Used in 4-Bit Mode
8
DB1 Input/Output Not Used in 4-Bit Mode
9
DB2 Input/Output Not Used in 4-Bit Mode
10
DB3 Input/Output Not Used in 4-Bit Mode
11
DB4 Input/Output Data Bus in 4-Bit Mode
12
DB5 Input/Output Data Bus in 4-Bit Mode
13
DB6 Input/Output Data Bus in 4-Bit Mode
14
DB7 Input/Output Data Bus in 4-Bit Mode
15
Vcc
For LCD Back Light
16
Vss
For LCD Back Light
330_09

65

LCD Commands

66

Interfacing LCD
LCD Operation

When the MPU writes an instruction to IR or data to DR,


the controller:

Sets DB7 high indicating that the controller is busy


Sets DB7 low after the completion of the operation

The MPU should always check whether DB7 is low


before sending an instruction or a data byte

330_09

67

Interfacing LCD
Writing to or Reading from LCD

The MPU:

Asserts RS low to select IR


Asserts RS high to select DR
Reads from LCD by asserting the R/W signal high
Writes into LCD by asserting the R/W signal low
Asserts the E signal high and then low (toggles) to latch a data
byte or an instruction

330_09

68

Interfacing LCD
Timing diagram: writing to LCD

330_09

69

Interfacing LCD
Software

To write into the LCD

Send the initial instructions to set up the LCD


4-bit or 8-bit mode

Continue to check DB7 until it goes low


Write instructions to IR to set up LCD parameters

Number of display lines and cursor status

Write data to display a message

330_09

70

Pin Assignment: LCD display interface


Sr. No.
Signal
Description
1
Pin 16 (P1.16)
Data 0
2
Pin 12 (P1.17)
Data 1
3
Pin 8 (P1.18)
Data 2
4
Pin 4 (P1.19)
Data 3
5
Pin 48 (P1.20)
Data 4
6
Pin 44 (P1.21)
Data 5
7
Pin 40 (P1.22)
Data 6
8
Pin 36 (P1.23)
Data 7
9
10
11

Pin 13 (P0.28)
Pin 14 (P0.29)
GND

RS
EN
WR

330_09

71

Prepare code for Data Display on port Lines


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0000

0000

1 1 1 1

1 1 1 1

0000

0000

0000

0000

Prepare code for interface LCD


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0011

0000

0000

0000

0000

0000

0000

0000

A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0010

0000

0000

0000

0000

0000

0000

0000

A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

0001

0000

0000

0000

0000

0000

0000

0000

330_09

72

#include<lpc21xx.h>
void lcddata(int value);
void lcdcmd(int value);
void delay(int itime);
int main()
{
*IODIR1=0x00FF0000;
*IODIR0=0x30000000;
lcdcmd(0x38);
delay(250);
lcdcmd(0x0e);
delay(250);
lcdcmd(0x80);
delay(250);

330_09

73

lcddata('h');
delay(250);
lcddata('e');
delay(250);
lcddata('l');
delay(250);
lcddata('l');
delay(250);
lcddata('o');
delay(250);
return 0;
}

330_09

74

void lcdcmd(int value)


{
*IOCLR1=0x00FF0000;
*IOCLR0=0x10000000;
value<<=16;
*IOSET1=value;
*IOCLR0=0x20000000;
delay(250);
*IOSET0=0x20000000;
delay(250);
*IOCLR0=0x20000000;
delay(250);
}

330_09

75

void lcddata(int value)


{
*IOCLR1=0x00FF0000;
*IOSET0=0x10000000;
value<<=16;
*IOSET1=value;
*IOCLR0=0x20000000;
delay(250);
*IOSET0=0x20000000;
delay(250);
*IOCLR0=0x20000000;
delay(250);
}
void delay(int itime)
{
int i;
for(i=0;i<itime;i++);
}
330_09

76

Program to interface keypad and LCD

77

Write a Program to interface keypad and LCD.


#include <board.h>
int main(void)
{
char key;
q_keyinit(TITAN);
q_lcdinit(TITAN);
q_printf("%s \r\nkey;","Hello");
q_displaylcd("Hello", 5);
while(1)
{
while((key = q_keyread()) == 0);
key = key + 0x30;
q_clrscreen();
q_printf("%x \r\n", key);
q_displaylcd(&key, 1);
}
}

330_09

78

ASCII Code Chart

79

Interfacing Stepper Motor

P0-11
P0-12
P0-13
P0-14

80

330_09

81

STEP SEQUENCE (ONE PHASE ON SEQUNCE)

330_09

82

STEPPER MOTOR CHARACTERISTICS


Stepper motors are constant-power devices (power = angular velocity x torque).
As motor speed increases, torque decreases.
The torque curve may be extended by using current limiting drivers and
increasing the driving voltage.
Steppers exhibit more vibration than other motor types, as the discrete step tends
to snap the rotor from one position to another.
This vibration can become very bad at some speeds and can cause the motor to
lose torque.
The effect can be mitigated by accelerating quickly through the problem speed
range, physically damping the system, or using a micro-stepping driver.

Motors with greater number of phases also exhibit smoother operation than those
with fewer phases.
330_09

83

APPLICATIONS
Computer-controlled stepper motors are one of the most versatile
forms of positioning systems . They are typically digitally
controlled as part of an open loop system, and are simpler and
more rugged than closed loop servo systems. Industrial applications
are in high speed pick and place equipment and multi-axis machine
CNC machines often directly driving lead screws or ball screws .
In the field of lasers and optics they are frequently used in precision
positioning equipment such as linear actuators , linear stages ,
rotation stages and mirror mounts . Other uses are in packaging
machinery, and positioning of valve pilot stages for fluid control
systems. Commercially, stepper motors are used in floppy disk
drives , flatbed scanners , computer printers , plotters and many
more devices.
84

Prepare code for interface Stepper Motor


A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

00 00

0000

0000

0000

0111

1000

0000

0000

Step

A31302928

A27262524

A23222120

A19181716

A15141312

A111098

A7654

A3210

00 00

0000

0000

0000

0111

1000

0000

0000

00 00

0000

0000

0000

0010

1000

0000

0000

00 00

0000

0000

0000

0011

0000

0000

0000

00 00

0000

0000

0000

0101

0000

0000

0000

00 00

0000

0000

0000

0100

1000

0000

0000

0
85

#include <LPC21xx.h>
#include<board.h>
int main(void)
{
unsigned long int i,j;
*IODIR0 = *IODIR0 | (0X00007800);
q_lcdinit(TITAN);
while(1)
{
q_displaylcd("clkwise directxn",16);

86

for(j=0;j<12;j++)
{
*IOSET0 = 0x00002800;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00002800;
for(i=0;i<25000;i++);
*IOSET0 = 0x00003000;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00003000;
for(i=0;i<25000;i++);
*IOSET0 = 0x00005000;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00005000;
for(i=0;i<25000;i++);
*IOSET0 = 0x00004800;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00004800;
for(i=0;i<25000;i++);
}
330_09

87

q_clrscreen();
q_displaylcd("anticlk directxn",16);
for(j=0;j<12;j++)
{
*IOSET0 = 0x00002800;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00002800;
for(i=0;i<25000;i++);
*IOSET0 = 0x00004800;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00004800;
for(i=0;i<25000;i++);
*IOSET0 = 0x00005000;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00005000;
for(i=0;i<25000;i++);
*IOSET0 = 0x00003000;
for(i=0;i<25000;i++);
*IOCLR0 = 0x00003000;
for(i=0;i<25000;i++);
}
q_clrscreen();
}
return 0;
}

330_09

88

Interfacing GSM with ARM Board

330_09

89

What is GSM ?
Global System for Mobile (GSM) is a
second generation cellular standard
developed to cater voice services and
data delivery using digital modulation

330_09

91

Introduction:
GSM (Global System for Mobile) / GPRS (General Packet Radio Service)
TTL Modem is SIM900 Quad-band GSM / GPRS device, works on
frequencies 850 MHZ, 900 MHZ, 1800MHZ and 1900 MHZ. It is very
compact in size and easy to use as plug in GSM Modem. The Modem is
designed with 3V3 and 5V DC TTL interfacing circuitry, which allows
User to directly interface with 5V Microcontrollers (PIC, AVR, Arduino,
8051, etc.) as well as 3V3Microcontrollers (ARM, ARM Cortex XX, etc.).
The baud rate can be configurable from 9600-115200 bps through AT
(Attention) commands. This GSM/GPRS TTL Modem has internal TCP/IP
stack to enable User to connect with internet through GPRS feature. It is
suitable for SMS as well as DATA transfer application in mobile phone to
mobile phone interface.
The modem can be interfaced with a Microcontroller using USART
(Universal Synchronous Asynchronous Receiver and Transmitter) feature
(serial communication).
92

Features:
Quad

Band GSM/GPRS : 850 / 900 / 1800 / 1900 MHz


Built in RS232 to TTL or viceversa Logic Converter (MAX232)
Configurable Baud Rate
SMA (SubMiniature version A) connector with GSM L Type
Antenna
Built in SIM (Subscriber Identity Module) Card holder
Built in Network Status LED
Inbuilt Powerful TCP / IP (Transfer Control Protocol / Internet
Protocol) stack for internet data transfer through GPRS (General
Packet Radio Service)
Audio Interface Connectors (Audio in and Audio out)
Most Status and Controlling pins are available
Normal Operation Temperature : -20 C to +55 C
Input Voltage : 5V to 12V DC
LDB9 connector (Serial Port) provided for easy interfacing
330_09

93

330_09

94

SIMCom SIM900A GSM Module:


This is actual SIM900 GSM module which is manufactured by SIMCom. Designed
for global market, SIM900 is a quad-band GSM/GPRS engine that works on
frequencies GSM 850MHz, EGSM 900MHz, DCS 1800MHz and PCS 1900MHz.
SIM900 features GPRS multislot class 10/ class 8 (optional) and supports the
GPRS coding schemes CS-1, CS-2, CS-3 and CS-4. With a tiny configuration of
24mm x 24mm x 3mm, SIM900 can meet almost all the space requirements in
Users applications, such as M2M, smart phone, PDA and other mobile devices.

330_09

95

MAX232 IC:
The MAX232 is an integrated circuit that converts signals from an RS-232 serial
port to signals suitable for use in TTL compatible digital logic circuits, so that
devices works on TTL logic can share the data with devices connected through
Serial port (DB9 Connector).

330_09

96

Serial port / DB9 connector:


User just needs to attach RS232 cable here so that it can be connected to devices
which has Serial port / DB9 Connector.

330_09

97

Power Supply Socket:


This power supply socket which actually named as AC/DC Socket provides the
functionality to user to connect external power supply from Transformer, Battery or
Adapter through DC jack. User can provide maximum of 12V AC/DC power supply
through AC/DC socket. This is power supply designed into maximum protection
consideration so that it can even prevent reverse polarity DC power supply as well
as DC conversion from AC power Supply. It also includes LM317 Voltage Regulator
which provides an output voltage adjustable over a1.2V to 37V.

330_09

98

Power On/Off and GSM On Switch:


Power On/Off switch is type of push-on push-off DPDT switch which is used for
only make power supply on/off provided through AC/DC Socket indicated by
Power LED. GSM On Switch is type of Push on DPST tactile switch which is
used for only to make GSM module On indicated by Module On/Off LED while
initiating with Network indicated by Network Indication LED.

330_09

99

SIM (Subscriber Identity Module) Card Slot:


This onboard SIM card slot provide User functionality of insert a SIM (GSM
only) card of any service provider. Process of inserting and locking SIM card into
SIM card slot is given in this manual. While inserting in and removing out SIM
card from SIM card slot, User needs to take precaution that power supply should
be OFF so that after making Power supply ON it will be easy to reinitialize with
SIM for this module.

330_09

100

Indicator LEDs:
Indicator LEDs just used to indicate status accordingly. These are three LEDs
represents Power On/Off Status, Network Status and Module On/Off Status
respectively. Power LED will keep on until the power supply is enable to this board
by using push-on push-off switch. Network Status LED will show whether inserted
SIM card successfully connected to service providers Network or not, in short
signal strength. Module On/Off indicator LED will show status of GSM
modules power on/off.

330_09

101

RXD, TXD and GND pins (JP2):


These pins are used to connect devices which needs to be connected to GSM
module through USART (Universal Synchronous Asynchronous Receiver and
Transmitter) communication. Devices may be like Desktop or Laptop Computer
System, Microcontrollers, etc. RXD (Receive Data) should be connected to TXD
(Transmit Data) of other device and viceversa, whereas GND (Ground) should be
connected to other devices GND pin to make ground common for both systems.

330_09

102

Audio Connectors:
Audio Connectors deals with Audio related operations. These pins already shown
in hardware description diagram. These are eight pins in a group of two each
denoted by SV4.
GND (0V Supply) and VCC (+5V Supply) are used to have source for external
device. MIC+ and MICused to connect Microphone (abbr. as Mic) through which
user can give audio input while calling. SP- and SP+ used to connect Speaker (can
be connected to amplifier circuit if necessary) through which User can hear audio
output. LN-L and LN-R used to connect Line in to GSM module.

330_09

103

Debugger (DBG-R and DBG-T) Connectors (J2):


These connectors are 2-wire null modem interface DBG_TXD and DBG_RXD.
These pins can be used for debugging and upgrading firmware. User generally no
need to deal with these pins.

330_09

104

Inserting SIM card into SIM card Slot/Holder:


Here is the process how to insert SIM card into SIM card slot. User just need to
unlock SIM card cover by sliding back. Then user need to open this cover and
insert SIM card according to slot. Put down cover on SIM card and then lock by
sliding forward.

330_09

105

Power On/Off and Module On/Off process:


Here is the process how User should make power supply on/off and module on/off.
First of all User need to connect external power supply by using Battery / Adapter /
Transformer. Now User needs to press Power On/Off switch (It is push-on push-off
switch, thus User need to push it to make power on and push it again to make power
supply off). Two LEDs will glow, one is Power On/Off indicator LED and another
one is Network Status LED (which glows continuous to indicate no network or
searching for network). After this User needs to press Module on switch (denoted as
PWR) for at least 2 seconds. As soon as Module On/Off LED will glow User can
release this switch, Network LED will blink to indicate signal strength.

330_09

106

Connecting GSM module with RS232 (SB9-DB9) Serial Cable:


User can connect GSM interfacing board either through Serial port or
through Serial to USB converter. Here is process to connect RS232 cable to GSM
interfacing board.

330_09

107

Connecting GSM Module with Serial to USB converter through


RXD, TXD and GND:
This module is designed in a way so that User can connect this module without
Serial cable, this module can be connected to any of Serial to USB converter
module or cable. Here we have shown demo how to connect this interfacing board
with CP2102 Serial to USB converter Module through RXD, TXD and GND.
Connect CP2102 Serial to USB converter module to PC through USB cable,
connect one end of USB cable to PCs USB connector and connect another end of
USB to CP2102 modules USB connector.

330_09

108

Connect three Single Berg Wires to CP2102 moduless RXD, TXD and GND pin.
Then connect RXD wire to TXD of GSM module and TXD wire to RXD of GSM
module. Make GND common by connecting GND wire to GND pin of GSM
module.

330_09

109

Various AT commands for GSM modem


Call command:For dialing number
Step 1 ATD (enter the number)
Step 2 - ;
Step 3 - < Press Enter >
For answering the call when the RING text appear
continuously on hyper terminal
Step 1 ATA
Step 2 - <Press Enter>

330_09

110

For terminating call


Step 1 ATH
Step 2 - <Press Enter>
For enables caller number
Step 1 AT + CLIP = 1
Step 2 - <Press Enter>
CLIP- Calling Line Identification Presentation

330_09

111

SMS Command:-

1. To read SMS automatic to terminal


Step 1 AT + CMGF = 1
// for text mode operator
Step 2 AT + CNMI = 1
// automatic sensing

CMGF Message Format


CNMI - New Message Indication to Terminal Equipment

2. To send SMS
Step 1 AT + CMGS = Enter mobile number
Step 2 - <Press Enter>
Step 3 Enter Text
Step 4 Press ctrl + Z
CMGS Send Message

3. For acknowledge SMS (if not acknowledge the SMS, SMS server
will resend SMS)
Step 1 AT + CNMA
CNMA Message Acknowledge

330_09

112

Power supply
Null male-male
connector

COM 1
DB9ARM
Female
PROCESSOR
data 2
/BOARD
GND-3

GSM
RS 238
Cable

GPIO (CN/4) 2-9, 49, 50


(With CNB) 13-22, 47 GND
(with (N/4)
FRC
Cable
CN 13, 1-,
CN 13, 1-,
14 7,8,19,20 10 19,20
Keypad
(4 4)

GSM antenna

Interfacing GSM with ARM


Board

LCD DISPLAY
330_09

113

GSM Applications
Mobile telephony
GSM-R
Telemetry System
- Fleet management
- Automatic meter reading
- Toll Collection
- Remote control and fault reporting of DG sets
Value Added Services

Interfacing FIM (BIOMETRICS) with ARM / ARM Board

330_09

115

FIM:- Fingerprint Identification Module


FIM is a stand alone Fingerprint Identification Device with many excellent
features.
It provides benefits such as high identification performance, low power
consumption and RS 232 serial interface with the various commands for easy
integration a wide range of applications.
It is a durable and compact device with fingerprint identification module
containing NITGEN optics based fingerprint sensor inside.

330_09

116

Fingerprint Scanners and their Features

Interface: FBI-compliant scanners often have analogue output and a frame grabber is
necessary to digitize the images. This introduces an extra cost and usually requires an internal
board to be mounted in the host. In non-AFIS devices, the analogue-to-digital conversion is
performed by the scanner itself and the interface to the host is usually through a simple
Parallel Port or USB connection.

Frames per second: This is the number of images the scanner is able to acquire and send to
the host in a second.

Automatic finger detection: Some scanners automatically detect the presence of a finger on
the acquisition surface, without requiring the host to continually grab and process frames; this
allows the acquisition process to be automatically initiated as soon as the users finger touches
the sensor.

Encryption: This is the securing of the communication channel between the scanner and the
host.

Supported operating systems: Compatibility with more operating systems is an important


requirement.

117

Characteristics of Fingerprint Images


Resolution: This indicates the number of dots or pixels per inch (dpi).

Area: The size of the rectangular area sensed by a fingerprint scanner is a


fundamental parameter. The larger the area, the more ridges and valleys are
captured and the more distinctive the fingerprint becomes.
Number of Pixels: This can be derived from the resolution and the fingerprint area.
A scanner working at r dpi over an area of height (h) X width (w) inch2 has rh X
rw pixels.
Dynamic range (or depth): This denotes the number of bits used to encode the
intensity value of each pixel.
Geometric accuracy: This is specified by the maximum geometric distortion
introduced by the acquisition device, and expressed as a percentage with respect to
x and y directions.
Image quality: The image quality depends on the quality of scanner and also on
the intrinsic finger status. When the ridge prominence is very low (for manual
workers, elderly people), or fingers are too moist or too dry, most scanners produce
poor quality images.
118

The general structure of fingerprint


scanner is shown in figure

119

330_09

120

ARM
PROCESSOR
/BOARD

Power supply
Null male-male
connector

COM 1
DB9Female
data 2
GND-3

FIM
RS 323
Cable

GPIO (CN/4) 2-9, 49, 50


(With CNB) 13-22, 47 GND
(with (N/4)
FRC
Cable
CN 13, 1-,
14 7,8,19,20

Keypad
(4 4)

CN 13, 1-,
10 19,20

LCD DISPLAY
330_09

121

Communication:FIM has RS serial communication port through that FIM communicates at the
same time.
These ports support 6 baud rate modes such as 9600, 14400, 19200, 38400, 57600
and 115200 bps.
User Data Area:FIM provides 64 bytes flash memory. Using this memory, host can save
private data for specific usage.
The caution is needed because the responsibility for reading, writing and
erasing user data area is given to the best.
Key Function:FIM supports 3 function key input such as Enroll _ Key, Delete _ Key, and
Identify _ Key.
Using these keys without serial communication, enrollment, deletion, all
deletion and identification operating can be executed.

330_09

122

Applications
Print on scale device
Ticket generation
Bill printing
ATM machines

123

Fingerprint sensing
Based on the mode of acquisition, a fingerprint image is classified
as
Off line image
Live-scan image
There are a number of live-scan sensing mechanisms that can
detect the ridges and valleys present in the fingertip
Examples are

Optical FTIR
Capacitive
Pressure-based
Ultrasound
124

Scanning and Digitizing

125

Fingerprint images

Optical scanner Capacitive scanner Piezoelectric scanner

Thermal scanner Inked impression Latent fingerprint


126

Fingerprint Scanners and their Features

Interface: FBI-compliant scanners often have analogue output and a frame grabber is
necessary to digitize the images. This introduces an extra cost and usually requires an internal
board to be mounted in the host. In non-AFIS devices, the analogue-to-digital conversion is
performed by the scanner itself and the interface to the host is usually through a simple
Parallel Port or USB connection.

Frames per second: This is the number of images the scanner is able to acquire and send to
the host in a second.

Automatic finger detection: Some scanners automatically detect the presence of a finger on
the acquisition surface, without requiring the host to continually grab and process frames; this
allows the acquisition process to be automatically initiated as soon as the users finger touches
the sensor.

Encryption: This is the securing of the communication channel between the scanner and the
host.

Supported operating systems: Compatibility with more operating systems is an important


requirement.

127

Fingerprint Sensing
The most important part of a fingerprint scanner is the sensor.
Sensors belong to one of the three families:
Optical sensors

Frustrated Total Internal Reflection (FTIR)


FTIR with a sheet prism
Optical fibers
Electro-Optical

Solid-state sensors

Thermal
Electric field
Piezoelectric

Ultrasound sensors

128

Fingerprint Sensing: optical FTIR


Frustered Total Internal Reflection (FTIR):

The oldest and most used livescan technique.


The finger touches the top side of a glass
prism, but while the ridges enter in contact
with the prism surface, the valleys remain
at a certain distance. The left side of the
prism is illuminated through a diffused
light which is reflected at the valleys and
randomly scattered (absorbed) at the ridges.
The lack of reflection allows the ridges
(appear dark) to be discriminated from the
valleys (appear bright). The light rays exit
from the right side of the prism and are
focused through a lens onto a CCD or
CMOS image sensor. Because FTIR
devises sense a 3D surface, they cannot be
easily deceived by a photograph or printed
image of a fingerprint.

129

Fingerprint Sensing: FTIR with a sheet prism


FTIR with a sheet prism: Using a sheet prism made of a number of prismlets
adjacent to each other, instead of a single large prism, allows the size of the
mechanical assembly to be reduced to some extent. However, the quality of the
acquired images is generally lower than the traditional FTIR techniques using glass
prisms.

130

Optical Fibers
A significant reduction of the packaging size can be achieved by substituting prism and
lens with a fiber-optic platen. The finger is in direct contact with the upper side of
the platen; on the opposite side, a CCD or CMOS, tightly coupled with the platen,
receives the finger residual light conveyed through the glass fibers. Unlike the FTIR
devices, the CCD/CMOS is in direct contact with the platen and therefore its size
has to cover the whole sensing area. This may result in a high cost for producing
large area sensors.

131

Electro-Optical
Electro-optical sensors contain light-emitting
polymer instead of a prism that activates the
photodiode array embedded in glass to obtain
fingerprint image.

132

Optical Sensors

133

Solid State Sensing


Thermal: These sensors are made of pyro-electric material that generates current based
on temperature differentials. The fingerprint ridges, being in contact with the sensor
surface, produce a different temperature differential than the valleys, which are
away from the sensor surface. The sensors are typically maintained at a high
temperatures.
Electric Field: The sensor consists of a drive ring that generates a sinusoidal signal and
a matrix of active antennas that receives a very small amplitude signal transmitted
by the drive ring and modulated by the derma structure (subsurface of the finger
skin). The finger must be simultaneously in contact with the sensor and the drive
ring. To image a fingerprint, the analogue response of each element in the sensor
matrix is amplified and digitized.
Piezoelectric: Pressure-sensitive sensors produce an electrical signal when mechanical
stress is applied to them. The sensor surface is made of a non-conducting dielectric
material which generates a small amount of current. Since ridges and valleys are
present at different distances from the sensor surface, result in different currents.

134

Ultrasound sensors
Ultrasound sensing is based on sending acoustic signals toward the fingertip and
capturing the echo signal. The echo signal is used to compute the range
image of the fingerprint and subsequently, the ridge structure itself. This
method images the subsurface of the finger skin (even through thin gloves).
Therefore, it is resilient to dirt and oil accumulations that may visually mar
the fingerprint. However, the scanner is large with mechanical parts and
quite expensive. Moreover, it takes a few seconds to acquire an image.

135

Fingerprint Sensing: sweep systems


Sweep systems

Touch systems

136

Image reconstruction from slices


The touch method is most commonly used with sensors wherein the finger is
simply put on the scanner, without moving it.
To reduce costs, especially in silicon sensors, another sensing method has been
proposed: to sweep the finger over the sensor. Since the sweeping consists
of a vertical movement only, the chip must be as wide as a finger; on the
other hand, in principle, the height could be as low as one pixel. At the end
of the sweep, a single fingerprint image is reconstructed from the slices.

137

Image reconstruction from slices


The sweep method allows the cost of a sensor to be significantly reduced, but requires
reliable reconstruction to be performed. The main stages of the reconstruction are:
Slice quality computation: For each slice, a single global quality measure and several local
measures are compared by using an image contrast estimator.
Slice pair registration: For each pair of consecutive slices, the only possible transformation
is assumed to be a global translation [x, y], where the y component is dominant, but a
limited x is also allowed to cope with lateral movements of the finger during sweeping.
Relaxation: When the quality of slices is low, the registration may fail and give incorrect
translation vectors. Assuming a certain continuity of the finger speed during sweeping allows
analogous hypotheses to be generated on the continuity of the translation vectors. The
translation vectors continuity may be obtained through a method called relaxation which has
the nice property of smoothing the samples without affecting the correct measurements too
much.
Mosaicking: The enhanced translation vectors produced by the relaxation stage are used to
register and superimpose the slices. Finally, each pixel of the reconstructed output image is
generated by performing a weighted sum of the intensities of the corresponding pixels in the
slices.

138

Image reconstruction from slices

139

Sensing Area vs. Accuracy


The cost of a sensor increases with increase in size of sensing area.
With smaller areas, the identification accuracy may deteriorate.

140

Quality of images

Good quality
fingerprint

Dry finger

Wet finger

Intrinsically
bad fingerprint
141

Different scanners ideal conditions

142

Different scanners bad conditions

143

Compressing Fingerprint Images


The Wavelet Scalar Quantization (WSQ) is an effective compression
technique (achieves compression ratio of 10 to 25).
The WSQ encoder performs the following steps:
1.

The fingerprint image is decomposed into a number of spatial


frequency sub-bands (typically 64) using a Discrete Wavelet
Transform (DWT).

2.

The resulting DWT coefficients are quantized into discrete values;


results in some loss of information.

3.

The quantized sub-bands are concatenated into several blocks


(typically three to eight) and compressed using an adaptive Huffman
run-length encoding.

144

Interfacing Graphics LCD (320 X 240) with ARM board

330_09

145

330_09

146

330_09

147

330_09

148

330_09

149

330_09

150

#include <LPC214x.H>
#include "GLCD.H"
#include "GLCDBMP.H"
#define RST 7
void main()
{
PINSEL0 = 0;
PINSEL1 = 0;
IODIR0 = 0x0000FFFF;
GLCD_Init (&IO0PIN, 8);
while(1)
{
Delay();
Delay();
Delay();
Delay();
330_09

151

GLCD_Draw (&IO0PIN, 8, PAN_LOGO);


Delay();
Delay();
Delay();
Delay();
GLCD_Draw(&IO0PIN, 8, BMP_IMG);
}
}
void Delay()
{
unsigned int i,j;
for(i=0;i<25;i++)
for(j=0;j<300;j++);
}

330_09

152

Вам также может понравиться