Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
By:
1. Abstract-------------------------------------------------------------------------------------------2
2. Project Description------------------------------------------------------------------------------3
3. Device Description
3.1 Renesas SKP16C62P Starter Kit Plus -------------------------------------------------4
3.2 GSM modem------------------------------------------------------------------------------ 5
3.3 Power connection ------------------------------------------------------------------------ 6
3.4 Antenna Connection --------------------------------------------------------------------- 6
3.5 SIM card Reader-------------------------------------------------------------------------- 7
4. MAX232 Chip---------------------------------------------------------------------------------- 8
5. RS232 Standard---------------------------------------------------------------------------------8
7. AT commands-----------------------------------------------------------------------------------10
15. Conclusions-------------------------------------------------------------------------------------27
16. References--------------------------------------------------------------------------------------28
1. Abstract
The goal of this project is to design an embedded device which can control up to 8
devices by sending a specific SMS message from a cell-phone. This controller is extremely
handy at places where we have to control the ON and OFF switching of the devices but no
wired connection to that place is available.
To implement this, a GSM modem is connected to a programmed microcontroller
which would receive the SMS from a reference cell phone. The control signal part of the
received SMS is extracted and is changed to microcontroller-preferred format. In regular
intervals, the modem would also send the local temperature We have selected GSM because
the ubiquity of its standard makes international roaming very common between mobile phone
operators, enabling subscribers to use their phones in many parts of the world. A PC which is
connected to the micro-controller using a serial communication through RS232 can be used for
monitoring and transmission of the control signals to the modem. The monitoring is also done
by interfacing a LCD to the microcontroller. AT commands were used for controlling the
functionality of modem.
A MAX232 chip
This converter chip is needed to convert a TTL logic from a Microcontroller (TxD
and RxD pins ) to standard serial interfacing for PC (RS232)
A DB9 connector
This takes the signals coming form the MAX232 chip to the PC.
The typical applications of this serial modem is for developing a wide range of equipment like
Security and alarms devices
Monitoring and control devices
Vending machines
Utilities devices
Fleet Management devices
Device 1
Renesas SKP16C62P
Starter Kit Plus Device 2
MAX 232
Device 8
DB9 Connector
DB9 Connector
GM28
(GSM Modem with
SIM card working in
Antenna Computer
(For displaying
850 MHz /1900 Hz)
the received SMS)
Initially the SMS is received from the person authorized to use this setup (destination)
by the GSM modem (GM28) & is transferred to the Renesas SKP16C62P SKP with the help of
a MAX 232 chip. As per the AT commands given by the microcontroller to the modem, the
control signal from the SMS is extracted and is used to control the devices connected to it. We
have to convert the 'septets' of the phone to 'octets' because the micro-controller need bytes
with 8 bits length ( The 'septet' is 1 byte with 7 bits length and 'octet' is 1 byte with 8 bits
length). All this process is necessary to decode the message from SMS.
A program (for extracting the control signal part from received SMS) is loaded into
Renesas SKP16C62P SKP, and then the circuit is connected to the modem. The micro-
controller now tries to read the SMS from the 1st memory location of the modem and it keeps
trying again until the modem receives any (programmed for every one second). Before
implementing the control signal part of the SMS, the modem extracts the number from the
SMS and verifies if this number has the access to control the device or not.
For controlling the devices, the message will be sent in hexa decimal format. The hex
data is converted to the equivalent binary and the particular output is enabled. For example if
the message is “AB” the equivalent binary is “10101011” this implies that the output 1, 3, 5, 7,
8 are enabled and the remaining ports are disabled. We have connected LEDs to the ports of
microcontroller to show the output and their status indicates whether the ports are set to ‘ON’
or ‘OFF’. The microcontroller is also programmed to read the temperature from the thermistor
every 15 minutes and to send a SMS to the destination number.
Figure 3.a
Figures 3.a, 3.b and 3.c show the different views of the GSM modem GM28
(From the Hardware Manual of GM28 Modem)
The Global System for Mobile Communications (GSM) is the most popular standard
for mobile phones in the world. It is the European standard for digital cellular service that
includes enhanced features. It is based on TDMA technology and is used on 850/1900 MHz.
We are using the GM28, a GSM modem from Sony-Ericsson. This is a powerful
GSM/GPRS Terminal with compact and self-contained unit. This has standard connector
interfaces and has an integral SIM card reader. The modem has a RJ9 connector through which
a speaker and microphone can be connected allowing audio calls being established, but this
feature is not utilized in this project as only data transfer is needed. Following are few
technical details of the modem.
Interfaces:
• Data: RS232 9–way (V.28)
• Power and Extended I/Os: 5 – 32VDC (RJ11)
• Audio 4-wire Handset Interface (RJ9)
• Antenna: 50 (FME male)
• SIM card reader: 3V/5V interface with SIM detection
Features:
• ME + SIM phone book management – read/write/find, call screening, groups
• SIM Application Toolkit Class 2
• Real Time Clock
• Software upgradeable
• Audio control
• Fixed dialing number
• UCS2 16 bit data supported.
The TT4030 (SE-GM28) uses the following industry standard connectors to interface with the external
application and the GSM network;
• RJ11 (plug-in power supply connector).
• RJ9 (handset audio connector)
• Integral SIM card reader.
• FME male (antenna connector).
• Sub-D socket, 9 pin (RS232 serial port).
All electrical connections to the TT4030 (SE-GM28) are designed to meet the standard air (4 kV) and
contact (8 kV) discharge ESD tests, of EN 301 489-1.
The used antenna (Figure 4.a) operates at 850/1900 MHz which is suitable for transmitting and
receiving of RF signals for the GSM modem (GM28) used.
The TT4030 (SE-GM28) is fitted with a SIM card reader designed for 3 V and 5 V SIM cards.
It is the flip-up type, which is lockable in the horizontal position and is accessed through a
removable panel. The SIM card reader includes a SIM presence switch. This ensures that when
a SIM card is inserted or removed while the TT4030 (SE-GM28) is turned ON, it will reset.
1 2
4
3
Figure 7.a Pin configurations of MAX232 chip Figure 7.b Logic conversion that takes place in
MAX232 chip.
(Took from the Hardware Manual of MAX232 IC)
The MAX232 device is a dual driver/receiver that includes a capacitive voltage generator to
supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232
inputs to 5-V TTL/CMOS levels. Each driver converts TTL/CMOS input levels into EIA-232
levels. A max232 chip is used to do the level shifting and this chip is required to send data
serially to a PC which requires voltage levels as per RS232 standard.
5. RS232 Standard
The MS (mobile station) represents the TT4030 (SE-GM28) modem plus SIM card. The
modem excluding SIM card, is known as the ME (mobile equipment).
The TE (terminal equipment) is a micro-controller and is a part of the application.
The modem performs a set of telecom services (TS) according to GSM standard phase 2+, ETSI and
ITU-T. Control of the TT4030 (SE-GM28) is by the external application, via the RS232 serial
interface, using a set of AT commands. The TT4030 (SEGM28) supports the full set of AT
commands according to GSM 07.05 and GSM 07.07. It also supports an extended set of
Ericsson proprietary AT commands to add extra functionality.
The modem also supports the Voice, Data, Fax services but since these are not required for the
current application, they are not taken into consideration as of now.
7. AT commands
The AT command set is the fundamental interface with the modem. An AT command is simply
a string of characters preceded by the AT prefix that is sent to the modem. The commands
typically instruct the modem to perform some action or set some characteristic within the
modem. The modem has two states: command state and on-line state. In command state, the
modem will accept and respond to AT commands. In the on-line state, the modem will transmit
data, but ignore AT commands. Typically the modem is in the on-line state after dialing.
To install this modem in the communication system to PC, the following procedure is adopted:
• Select the phone and modem options from the control panel.
• By browsing the disk for the modem drivers, the modem is selected and configured to a
particular port through which it is connected to the PC.
• The terminal package like HyperTerminal is selected in the initial stage to check the
functionality of the AT commands to control the GSM modem and later this hyper
terminal is just used to monitor the serially received output. Hence finally a three way
communication is established, the modem directly communicates with the micro
controller to control the switching of devices externally and the hyper terminal package
in PC is used just for monitoring the results (hence only receive and ground of
connected to the PC).
To setup the serial port the following procedure has been followed:
• Select system from the control panel and thereby select the device manager in the
hardware option.
• Now the exact serial COM port where the modem is configured is selected manually.
• Select port settings and then bits per second to get the exact baud rate.
Now that the modem is configure it’s the task of setting up the volatile profile and enter the AT
commands required to select the SIM memory and then extract the text message.
Hence, serial communication is established between GM28 and the microcontroller using a
DB9 connector with a level shifter (MAX232). A level shifter is connected between the
microcontroller (SKP) and the modem/computer and null modem connection is connected for
the DB9 connector. The above discussed points are depicted in the Figure 9.
Sending, MO (mobile-originated) with both PDU (protocol data unit) and text mode
supported.
Receiving, MT (mobile-terminated) with both PDU and text mode supported.
CBM (cell broadcast message), a service in which a message is sent to all subscribers
located in one or more specific cells in the GSM network. This feature is network
dependent.
SMS STATUS REPORT according to GSM 03.40.
SMS COMMAND according to GSM 03.40.
It should be noted that the maximum length of an SMS message is 160 characters when using
7- bit encoding. For 8-bit data, the maximum length is 140 characters. The Modem supports up
to 6 concatenated messages to extend this function.
Before we start working on the application design we should ensure the network subscription
status
Before the application is implemented, we must ensure that the chosen network
provides the necessary telecommunication services. Else, the service provider should be
contacted to obtain the necessary information.
Since SMS features are used in this application, we have to ensure that these are
included in the (voice) subscription.
There are two ways of sending and receiving SMS messages: by text mode and by PDU
(protocol description unit) mode. We can switch from text mode to PDU mode and vice versa
by selecting the AT+CMGF command. If AT+CMGF = 0 then PDU mode is selected and if
the mode is 1 then text mode is selected. The text mode is just an encoding of the bit stream
represented by the PDU mode. If we read the message on the phone, the phone will choose a
proper encoding. An application capable of reading incoming SMS messages can thus use text
mode or PDU mode. If text mode is used, the application is bound to the set of preset encoding
options. In some cases, that's just not good enough. If PDU mode is used, any encoding can be
implemented. The PDU string contains not only the message, but also a lot of meta-
information about the sender, its SMS service center, the time stamp etc.But as of now for our
application we require the phone number of the caller for authentication and the length of the
message and the text message which contains the binary message. Let us take a example for
the text message of “abcdef”. This message contains apart from the basic text message a lot of
redundant data (meta information about the sender).
All the octets are hexa-decimal 8-bit octets, except the Service center number, the sender
number and the timestamp; they are decimal semi-octets. The message part in the end of the
PDU string consists of hexa-decimal 8-bit octets, but these octets represent 7-bit data.
Basically the transformation of the septets to the octets is based on the GSM 03.38 standard.
This is helpful when we try to communicate with the PDU mode but if we use the CMGF
command then text mode is activated to get the converted text message.
So to get the message in the Text message we need to send the following commands
AT+CMGF=1 to activate the text mode
AT+CMGS=1 to check whether the modem supports the SMS message or not.
AT+CMGR=I to read the message at the location I in the SIM card.
11. Code
/*******************************************************************/
/*
FILE :main.c
*/
/******************************************************************/
#include "string.h"
void uartinit();
char sms_text[200],sms_msg[10],num_text[10];
/* Prototype declarations */
void main(void);
void timer_init(void);
void uartinit(void);
int map(char);
void rx_isr(void);
/* DEFINE QUEUES*/
typedef struct {
} Q_T;
int Q_Empty(Q_T * q) {
return q->Size == 0;
int Q_Full(Q_T * q) {
// an error code
if (!Q_Full(q)) {
q->Data[q->Tail++] = d;
q->Size++;
return 1; // success
} else
return 0; // failure
if (!Q_Empty(q)) {
t = q->Data[q->Head];
q->Head %= Q_SIZE;
q->Size--;
return t;
void Q_Init(Q_T * q) {
unsigned int i;
q->Head = 0;
q->Tail = 0;
q->Size = 0;
void timer_init(void)
//Timer initialisation
int map(char c)
int a=(int)c;
switch (a)
case 48:
return(0);
break;
case 49:
return(1);
break;
case 50:
return(2);
break;
case 51:
return(3);
break;
case 52:
return(4);
break;
case 53:
return(5);
break;
case 54:
return(6);
break;
case 55:
return(7);
break;
case 56:
return(8);
case 57:
return(9);
break;
return(10);
break;
return(10);
break;
return(11);
break;
return(11);
break;
return(12);
break;
return(12);
break;
return(13);
break;
return(13);
break;
return(14);
break;
break;
return(15);
break;
return(15);
break;
default:
break;
int r,ad11_value;
char lcd_disp[11],temp_sms[22],lcd_temp[6];
float faren;
time+=50;
time=0;
for(r= 0;r<10;r++)
while(!ti_u0c1);
u0tbl= lcd_disp[r];//Q_Dequeue(&tx_q);
lcd_disp[10] = '\0';
/* for(r= 0;r<3;r++)
while(!ti_u0c1);
u0tbl= Q_Dequeue(&tx_q);
*/ DisplayString(LCD_LINE1,lcd_disp);
//Q_Init(&tx_q);
YLW_LED ^=1;
/*
if (temp==12000)
DISABLE_IRQ;
temp_sms[21]=(char)13;
for(r= 0;r<22;r++)
//if (!Q_Enqueue(&tx_q,lcd_disp[r])) ;
while(!ti_u0c1);
u0tbl= temp_sms[r];//Q_Dequeue(&tx_q);
ad11_value = ad1;
faren=tempconv(ad11_value);
temp=0;
IntToAsciiDec(lcd_temp,5,faren);
lcd_display1[4]=lcd_display1[3];
lcd_display1[3]='.';
lcd_display1[5]=(char)27;
for(r= 0;r<6;r++)
while(!ti_u0c1);
u0tbl= lcd_display[r];
ENABLE_IRQ;
/********************************************************************
Name : main
Parameters : none
Returns : nothing
*******************************************************************/
void main(void)
InitDisplay();
uartinit();
ENABLE_IRQ;
timer_init();
Q_Init(&tx_q);
Q_Init(&rx_q);
pd0=0xff;
while(1);
void rx_isr(void)
/*int j;
//char temp[2];
char lcd_disp1[7];
if(!Q_Enqueue(&rx_q,u0rbl));
k++;
if(k%6==0)
for(j=0;j<6;j++)
lcd_disp1[j]=Q_Dequeue(&rx_q);
DisplayString(LCD_LINE2,lcd_disp1);
RED_LED ^= 1;
lcd_disp1[6]='\0';
// temp[0]=u0rbl;
// temp[1]='\0';*/
char local[2];
sms_text[k]=u0rbl;
if(count==2)
sms_msg[p]=u0rbl;
p++;
//if(p==3)
//while(1);
//sms_msg[p]='\0';
count=count+1;
local[0]=u0rbl;
local[1]='\0';
RED_LED ^= 1;
if(count==3)
//sms_msg[6]='\0';
DisplayString(LCD_LINE2,sms_msg);
num1=map(sms_msg[0]);
num2=map(sms_msg[1]);
num1=num1<<4;
while(1);
if(count==8)
count=0;
k=0;
p=0;
k++;
void uartinit(void)
//Uart Initialization
clk1_u0c0=0;
s0ric = 5;
s0tic = 6;
result=adval;
x = (double)result;
x=sqrt(x);
f=(384.1305523381259+x*(-8.079194136912175+
x*(0.04758602176108498+x*-5.273756231991787E-05)))/
(1.0+x*(0.004399939744046074+x*(-0.0003138255046416174+
x*1.716742234299249E-06)));
f1= f;
f1=f1*100;
return(f1);
==============================================================
Figure 10.a
Figure 10.b
Figure 10.c
Figure 11.c
• The DB9 connector of the modem should be terminated with a null modem
configuration, hence RTS (pin 7) and CTS (pin 8) of the modem was shorted.
14. Precautions
• It should be taken care that the baud rate set initially should be changed to a lower
value to (9600 baud) to communicate with the Renesas board. Because, there is bit
error generated at higher baud rates and may cause generation of fault outputs.
• During the setup of the modem it should be noted that to send TO_IN to be high for
about 0.2 sec to get the modem started.
• After inserting the SIM card wait for some time to initialize the SIM card. When the
modem is ready the green LED on the modem starts blinking.
15. Conclusion
The experimental setup is able to read SMS from the SIM card (inside the modem GM28) and
the modem checks for new SMS from the modem every 1second. The modem is able to send
ambient temperature (reading the thermistor value from SKP) as SMS to the user every 15
minutes. As part of security, the SKP first verifies the received number from SMS text and
then executes the control signal part of the SMS. The LEDs on the SKP indicate the status of
the present ongoing function by the microcontroller.
Future scope:
• Switches on SKP can be assigned different functions like sending locally from SKP to
the user.
• As per the requirement different type of sensors can be connected to the SKP and the
data read can be sent to the user as SMS at regular intervals.
• As the SKP can receive data from external devices through its ports, the status of such
devices can be transmitted to the user regularly through SMS.
2) http://developer.sonyericsson.com/getDocument.do?docId=65054
3) http://www.mobilegpsonline.com/downloads/GM28-29%20Datasheet%20R1G.pdf
4) http://www.mobilegpsonline.com/GSMJC01Spec.pdf
5) http://www.visualgsm.com/wire_sms_index.htm
6) http://en.wikipedia.org/wiki/Gsm
7) http://www.camiresearch.com/Data_Com_Basics/RS232_standard.html
8) http://www.beyondlogic.org/serial/serial.htm
9) http://www.dreamfabric.com/sms/
10) http://www.nobbi.com/pduspy.htm
11) http://www.serasidis.gr/circuits/smscontroller/smscontroller.htm
12) http://www.gsm-modem.de/sms-text-mode.html