Lab 1 - UniMAP Portal

advertisement
EKT 443
MOBILE AND SATELLITE COMMUNICATION
GSM MODEM: AN EXPOSURE TO AT
COMMAND
TITLE
: GSM/GPRS : An Exposure to AT Command
OBJECTIVE
: To introduce GSM/GPRS modem operation and specification.
To give student hands-on experience in AT Command GSM Modem.
To develop a program based on AT Command GSM Modem.
EQUIPMENT
CONSUMABLES
: Serial Cable
- 1 unit
GSM/GPRS Modem
- 1 unit
GSM Antenna
- 1 unit
: SIM card
- 1 unit
PROCEDURE
The purpose of this exercise is to use hyper terminal as an access to GSM modem. Rather than entering
button such as mobile phone, we will use AT command to send instruction to GSM modem to work as a
phone. We will start with AT command for configuration purpose, next AT command related to SMS.
1. First, insert your SIM card into the GSM modem(TE).
Attention : Make sure that the SIM card do have enough credit for the operation. It might require at
least RM 2 (depending on the rate of service provider). Another thing make sure to cancel the PIN
number assigned to the SIM card. We will need extra command to unlock the PIN number before we can
operate the SIM card with the GSM modem.
2. Connect the serial cable to your PC and connect the power cable to the power socket. Then turn on
the GSM modem. Wait until the LED of the GSM modem blinks at a slow rate.
Note: Initially the GSM modem’s LED will blink at a fast rate. Then when the GSM modem is able to
connect to the mobile service provider such as Celcom,Maxis or DIGI, the LED will blink at a slow rate.
This will take at least 20 second for the GSM modem to establish a communication with the service
provider.
Then turn on the PC. After that go to Start > All Programs > Accessories > Communications > Hyper
Terminal
3. The first AT command that we will use it “AT”. Type ‘AT’ and enter enter. Example of results is as
shown as below.
Figure 6 : AT response
Note : AT command (also known as Hayes command) consist a set of command to communicate with
the GSM modem. The term ‘AT’ stands for ‘attention’. We type ‘AT’ to make sure that the GSM modem
is in a working mode. If the GSM modem reply ‘OK’ then it is in a working mode. But if the reply is ‘NO
CARRIER’ this shows that the GSM modem is not connected to the service provider yet or the SIM card is
still lock to the PIN number. To unlock it, use AT+CPIN command.
Configuring GSM Modem
In this section we will start configuring GSM modem using the list of AT command below:

ATE (Enable/Disable Echo)

AT&V(List current configuration)

ATI ( Modem Identification Information)

AT+CGSN ( IMEI number)

AT+CIMI ( display mobile subscriber identity)

AT+ CREG ( to check whether connected to mobile service provider)

AT+CSQ (Check Signal Quality)
1. Now type ATE0 in the terminal then enter enter. A respond as below will appear. Then try to type AT
in the terminal and enter enter. A respond OK will only appear. You will notice that anything you
type will not appear on the terminal.
Figure 7 : ATE command respond.
2. Then type ATE1 to turn on the echo. The following respond will appear as shown below. In some
cases in development, echo is needed as a feedback to the system that the TE is responding.
Figure 8: ATE1 command respond.
3. Next is to display the program predetermined value configuration of the TE. Type:
AT&V
and a respond such as figure below will appear.
Figure 9 : AT&V command respond.
4. Now we will display the TE identification information. This includes the brand, model and version. In
production of a so called device that uses the TE, the device will request the TE information. A
command will be sent to the TE and the command is:
ATI
A respond such as below will appear.
Figure 10: ATI command respond.
5. For any handphone International Mobile station Equipment Identity (IMEI) works as an identification
for the handphone. To obtain the IMEI number type:
AT+CGSN
A 15 digit number will appear as shown below.
Figure 11: AT+CGSN command respond
6. To display the International Mobile Subscriber Identity (IMSI) of the individual SIM card type :
AT+CIMI
and a respond such as below will appear.
Figure 12: AT+CIMI respond
7. Now that we know our modem is has a SIM card registered to a mobile service provider we can
check whether our modem is registered to a network cell of the service provider or it is changing
from one network cell to another network cell. Type :
AT+CREG=1
This is to enable the Unsolicited Result Code and report status of network registration. Then type :
AT+CREG=2
This will include in the report, location area code and the cell ID of the service provider. This is
shown in the figure below.
Figure 13: AT+CREG command respond.
8. We can also check whether the SIM card is lock by a PIN number or not. Type :
AT+CPIN?
A result shown as below will pop-up. This shows that the SIM card has a PIN an no new Pin is
required.
Figure 14: AT+CPIN respond command
9. From the modem, we can also check the signal strength level that the modem is receiving. It will
display in a form of Receive Signal Strength Indication (rssi). Type :
AT+CSQ
A display as below will appear. The first two digit is the rssi and the next two bit is the BER. BER can
only be displayed when making a call. Otherwise it will only displayed 99.
Figure 15: AT+CSQ respond command
Operating Short Message Service (SMS) using GSM Modem
In this section we will use AT command to send, read, list down and delete SMS using GSM modem. The
list of AT command that will be executed are:
AT+CMGF (input and output format for SMS)
AT+CMGS (send SMS)
AT+CMGL(list down SMS)
AT+CMGR(read SMS)
AT+CMGD(delete SMS)
1. To start operating with SMS, input and output format of GSM modem need to be configure. In SMS,
there is two format; PDU and TEXT. To configure format of SMS to PDU , type:
AT+CMGF=0
Below is the respond.
Figure 16: AT+CMGF command respond.
2. To test the outcome of the setting, we will send an SMS by typing:
AT+CMGS=<destination address>
Then press enter. Below are the outcome.
Figure 17: Failure to send SMS.
3. To change the format to TEXT mode, type:
AT+CMGF=1
Below is the respond.
Figure 18: Configure to text mode.
4. Now we will send the SMS in TEXT mode. Type:
AT+CMGS=<destination address>
Then press enter. A ‘ > ‘ will appear. Type in the message then press Ctrl and Z at the same time .
Then press enter again. The SMS will be sent to the destination address. Below shows the respond.
Figure 19: AT+CMGS command respond
5. Next we will list all the SMS from the modem. But before that, please send an SMS text “TESTING
SENDING SMS” to the phone number of the GSM modem.
6. Type:
AT+CMGL=ALL
This will list down all the SMS in the modem whether it is been read or not.
Figure 20: AT+CMGL command respond
7. The number after +CMGL: is the record number in the memory. Unread message will display “REC
UNREAD” unlike read message, “REC READ” will be displayed.
8. Now we will read the message that has been sent. To read the SMS message from the first memory,
type :
AT+CMGR=1
Then press enter. The displayed result will be as below.
Figure 21: Output of AT+CMGR
9. Next to compare a read message with an unread message, send another message to the GSM
modem “Sending sms”
10. Display the list of SMS in the GSM modem by typing:
AT+CMGL=ALL
Then press enter. Below are the respond to the command.
Figure 22: Difference between a record of a read message and an unread message.
11. Finally we will execute delete operation on the first SMS. To delete type :
AT+CMGD=1
Then press enter.
Figure 23: AT+CMGD respond command
12. To check whether the first message has been deleted of not we list down all the message in the
memory again. Type :
AT+CMGL=ALL
Then press enter. Below will be the outcome.
Figure 24: The first SMS has been deleted.
Sending SMS through Visual Basic
Note : This section will show how to send SMS using Visual Basic. Source code for this section is
provided.
1. Open Visual Basic 6.0 from the “Start”
2. When the “New Project” window is open, go to “Existing” tab and find a file name
GSM.vbp. Click the file then click the “Open” button.
Figure 25: Opening GSM.vbp file project.
3. Visual Basic will open a file containing source code for GSM.
Figure 26 : Source code of GSM project
4. Go to the right side of the screen and click the ‘view object’ icon.
following item.
Tools
TextBox 1
Command Button
Command Button
MSComm Control
Parameter 1
Name= Text1
name=cmdSend
name=cmdExit
5. The form will appear like the below figure.
Figure 27: Form for GSM
. In the form create the
6. Now click the view code icon
on the right side of the screen. In the source code you will
notice the green text is showing the comment related to the source code. Please change the
MSComm1.CommPort = 4
according to the port where GSM is connected.
Attention : If hyper terminal is still connected to the GSM modem, please make sure that you
disconnected it so that the Visual Basic Program can connect to it.
7. Change 0133341244 in the program at line code:
MSComm1.Output = “at+cmgs=0133341244” + Chr$(13)
to a number you intended to send.
Figure 28: Source code for GSM
8. Then click the run icon
to execute the program. A window will pop up as shown below.
Figure 29: GSM program running.
9. Type in your text in the Text1 textbox. Then click Send button.
10. The intended phone number will received the SMS text directly.
11. Our next step is to add some program to see the respond from the GSM modem. To perform
that exit from the program by clicking exit button of Form1.
12. Next, click to view object and add the below item:
Tools
TextBox 2
Command Button
Parameter 1
Name= Text2
name=cmdConf
13. Your form should be like the figure below:
Parameter 2
Multiline=TRUE
Parameter 3
Scrollbar=3(both)
Figure 30 : Actual form
14. Click on view code icon and change the following code:
Between
“Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)”
And
“Private Sub cmdExit_Click()”
Type :
Private Sub Form_Load()
'Open serial port and send a one time at+cmgf=1 to sent modem to text mode
MSComm1.Settings = "9600,N,8,1"
MSComm1.DTREnable = False
'Set the port number
MSComm1.CommPort = 4
MSComm1.PortOpen = True
With MSComm1
'set the DRT and RTS flags
.DTREnable = True
.RTSEnable = True
'enable the oncomm event for every reveived character
.RThreshold = 1
'disable the oncomm event for send characters
.SThreshold = 0
End With
MSComm1.Output = "at+cmgf=1" + Chr$(13)
End Sub
Private Sub cmdConf_Click()
MSComm1.Output = "ate1" + Chr$(13)
MSComm1.Output = "ati" + Chr$(13)
End Sub
'MSComm1.Output = "at+cmgf=1" + Chr$(13)
'Sleep 5000
Private Sub MSComm1_OnComm()
Dim strInput As String
With MSComm1
'test for incoming event
Select Case .CommEvent
Case comEvReceive
'display incoming event data to displaying textbox
strInput = .Input
Text2.SelText = strInput
End Select
End With 'MSComm1
End Sub
15. Then go to File >Save Project As and name it as GSM2.vbp as shown below.
Figure 31: Save As GSM2.vbp
16. Next click the Run icon and a window will pop-up as the figure below.
Figure 32: New GSM form
17. Click “Configure” and you will obtained the respond from the GSM modem.
Figure 33: Output respond from GSM modem.
Note : To send any AT command to the modem from Visual Basic Programming just set all the
parameter for MSComm just like in the programm then type:
MsComm1.Output = “any AT command” +Chr$(13)
The Chr$ (13) represent pressing enter button.
18. Print screen all the outcome of the program and attach it with the answer for the question
section.
Download