gsm presentation

22
Interfacing GSM Modem With Microcontroller By: Gaurav Arora

Upload: samuelhard

Post on 25-May-2015

2.733 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Gsm presentation

Interfacing GSM ModemWith Microcontroller

By: Gaurav Arora

Page 2: Gsm presentation

Building a Embeded system with ability to Send Sms using an GSM modem.

Objective

Page 3: Gsm presentation

WORK FLOW

Initialize system to set parameters for transmission and interrupt

System waits to be triggred using a sensor or an manual External interrupt like Switch.

Detecting interrupt Atmega 16 Checks availability of modem and tries to send SMS using GSM Modem using AT Commands.

Page 4: Gsm presentation

Defining Modules

System Consist of three modules:

> Interrupt Detection.

> Activating USART module Transmitting and Receving Data.

> Sending AT commands to GSM Modem.

Page 5: Gsm presentation

GSM MODEM

A GSM modem is a wireless modem that works with a GSM wireless network.

AT commands are used to control modems. Operations Performed by GSM Modem.

Reading, writing and deleting SMS messages.

Sending SMS messages.

Reading, writing and searching phone book entries.

GSM Modem Datasheet : 1122_datasheet.pdf in your kit

Page 6: Gsm presentation

Confiuring GSM Modem

· Insert SIM card: Press the yellow pin to remove the tray from the SIM cardholder. insert SIM card

Connect RS232 Cable: (Cable provided for RS232 communication) Default baud rate is 9600(using 2400)

with 8-N-1, no hardware handshaking.

o Pin 2 is RS232 level TX out

o Pin 3 is RS232 level RX in

o Pin 5 is Ground

Send AT commands.

Page 7: Gsm presentation

Some Terms

BAUD RATE-A baud Rate is the measurement of the number of times per second a signal in a communications channel changes. bps = baud per second x the number of bit per baud

8-N-1 – this config means 8 databits,no parity bit,1 stop bit.

RS232 - RS-232 (Recommended Standard 232) is a standard for serial binary single-ended data and control signals connecting . It is commonly used in computer serial ports.

Page 8: Gsm presentation

AT commands

AT is the abbreviation of ATtention. AT commands are instructions used to control a

modem. AT commands used to send SMS

AT ; -To check if the device is available

AT+CMGF=1; - select the operating mode GSM or mobile using 0 and 1(GSM)

AT+CMGS=”mobile no.”<CR>Text Message<Ctrl+Z>; -AT commands +CMGS can be used to send SMS messages

All AT commands are available in 1122_at_AT_Commands.pdf in your

kit

Page 9: Gsm presentation

Interfacing Modem with Microcontroller

Page 10: Gsm presentation

Output of hyper-terminal for AT commands to modem

Page 11: Gsm presentation

USART

USART - Universal synchronous and asynchronous receiver and transmitter.

Main Registers – UCSRA,UCSRB,UCSRC,UBRR,UDR

UCSRx – USART Control and Status Register A,B,C.

UBRR – USART Baud rate Register

UDR – USART Data Register.

Two UDR USART register to transmit and receive to provide full duplex mode.

Must Read Status Bits before receiving or transmitting Data (most important)

TXC and RXC flags.

Page 12: Gsm presentation

Initializing USART module

Page 13: Gsm presentation

Activating USART module(1)

we have to enable the UART Receiver and Transmitter using bit RXEN and TXEN in UCSRB register

Page 14: Gsm presentation

Activating USART module(2)

Bit 3 – TXEN: Transmitter Enable

Writing this bit to one enables the USART Transmitter. The Transmitter will override nor-mal port operation for the TxD pin when enabled. The disabling of the Transmitter

In UCSRC register UPM1:0: bit are used to set parity bits to 0,Bit 3 – USBS:to select Stop bits, Bit 2:1 – UCSZ1:0: to select character size to 8 bits.

Page 15: Gsm presentation

Activating USART module(3)

Setting Baud Rate: Set values of UBRR -USART Baud rate register

according to table:

Page 16: Gsm presentation

USART initialization code

UBRRH=0x00;

UBRRL = (unsigned char)BaudRate; /* Set the baud rate */

UCSRB = 0b00011000; // enable transmitter and reciever

UCSRC = 0b10000110; // 8 bit data, no parity bit, 1 stop bit.

Page 17: Gsm presentation

USART Transmission

In UCSRA register Bit 5 – UDRE: USART Data Register Empty

The UDRE flag indicates if the transmit buffer (UDR) is ready to receive new data. If

UDRE is one, the buffer is empty, and therefore ready to be written.

If UDRE is one put data in the buffer.

Page 18: Gsm presentation

Problem with Baud rates

GSM modem supports a wide range of baud rates 1120-12000

We cannot send data using higher baud rate while transmitting USART as higher baud rate require higher clock speed which is not available on board

4800 and 9600 baud rates are not supported with 1MHz oscillator.

Page 19: Gsm presentation

USART RECEPTION

In UCSRA register bit 7:• Bit 7 – RXC: USART Receive Complete

This flag bit is set when there are unread data in the receive buffer and cleared when thereceive buffer is empty (i.e., does not contain any unread data).

Page 20: Gsm presentation

Interrupt Detection

Code sniplets used to set Interrupt.

GICR = 0x40; // enable external interrupt 0

MCUCR = 0x02; // activate external interrupt0 (on pin16) it recognizes rising edge

sei();//set enable interrupts. If externel interrupts is provided to system then control

goes to interrupt handler and set a flag variable to one.

And send the required Sms.

Page 21: Gsm presentation

Have a look on code!!Any Questions??

Page 22: Gsm presentation

Thank You!