Interface Design and Application Based on GSM Module and AT89C51

Publisher:ShimmeringStarLatest update time:2011-05-14 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Overview:

With the development of communication technology, the mobile communication network service function has a trend of expanding in the field of industrial control and remote control. To meet this need, Siemens has launched a new generation of wireless communication GSM module - TC35i. Based on the short message function of this module, it can quickly, safely and reliably realize user information processing and other functions. It is particularly suitable for occasions where the control center and terminal equipment are far apart or it is inconvenient to use wired communication media. For example, the transmission of oil well information after collection, remote meter reading system, urban traffic guidance, etc. are all realized based on the TC35i module.

2. TC35i module introduction

At present, there are many GSM modules that have been used in China, and the functions and usages of these modules are not much different. This design uses TC35i of Siemens TC35 series. This wireless module is compatible with TC35 in terms of function, compact in design, and greatly reduces the size of user products. TC35i is compatible with GSM2/2, dual-band (GSM900/GSM1800), RS232 data interface. The module integrates RF circuit and baseband, provides users with standard AT command interface, and provides fast, reliable and secure transmission for data, voice, short message and fax, which is convenient for users' application development and design.

2.1 Introduction to GSM AT commands related to SMS in the module

The commands provided by the GSM engine module comply with the GSM07.05 and GSM07.07 specifications. The AT Command interface defined in GSM07.07 provides a universal interface between a mobile platform and a data terminal device; GSM07.05 provides detailed regulations for short messages. When the short message module receives a short message from the network, it can send indication information through the serial port, and the data terminal device can send various commands to the GSM module. The GSM AT commands related to SMS are shown in Table 1. The GSM AT command set was developed by Nokia, Ericsson, Motorola, HP and other manufacturers for the GSM system, which includes the control of SMS (Short Message Service).

Table 1 Some GSM AT commands related to SMS

2.2 PDU encoding rules

At present, the text and PDU (Protocol Data Unit) modes are commonly used to send short messages. The code for sending and receiving text messages in the text mode is simple and easy to implement, but the biggest disadvantage is that Chinese text messages cannot be sent and received; while the PDU mode not only supports Chinese text messages, but also English text messages. There are three encodings that can be used to send and receive text messages in the PDU mode: 7-bit, 8-bit, and UCS2 encoding. The 7-bit encoding is used to send ordinary ASCII characters, the 8-bit encoding is usually used to send data messages, and the UCS2 encoding is used to send Unicode characters. The general PDU encoding consists of 13 items: ABCDEFGHIJKLM.

A: Short message center address length, 2 hexadecimal digits (1 byte)

B: Short message center number type, 2 hexadecimal digits.

C: Short message center number. The length of B+C will be determined by the data in A.

D: File header byte, 2 hexadecimal digits.

E: Information type, 2 hexadecimal digits.

F: length of the called number, 2 hexadecimal digits.

G: called number type, 2 hexadecimal digits, the value is the same as B.

H: called number, the length of which is determined by the data in F.

I: Protocol identifier, 2 hexadecimal digits.

J: Data encoding scheme, 2 hexadecimal digits.

K: validity period, 2 hexadecimal digits.

L: User data length, 2 hexadecimal digits.

M: User data, its length is determined by the data in L. J is set to use UCS2 encoding, which is Unicode characters for Chinese and English.

3. Hardware interface circuit between TC35i and MCU [page]

The TC35i module is mainly composed of six parts: GSM based processor, GSM radio module, power supply module, flash memory, ZIF connector, and antenna interface. The circuit interface is realized through the ZIF connector and the microcontroller. This interface reads or sends data in the TC35i module, which will be the focus of this article and the core of TC35i application. The hardware interface circuit of TC35i and microcontroller is shown in the figure.

3. Software interface and control principle between MCU and TC35i

The software interface between the microcontroller and TC35i is actually the control technology of the microcontroller controlling the mobile phone through AT commands. First, set the working mode of the TC35i module: AT+CMGF=n, n=0 is PDU mode; n=1 is text mode; usually set to PDU mode, in this mode, transparent data (user-defined data) can be transmitted or received. AT+CMGR=n is to read the short message data of the TC35i module, n is the short message number. AT+CMGL=n is to list the short messages in the TC35i module, n=0 is the unread short message, n=1 is the read short message, n=2 is the unsent short message, n=3 is the sent short message, n=4 is all short messages. AT+CMGD=n is to delete the short message of the TC35i module, n is the short message number.

4.1 Program Design

Software programming can complete various functions by writing different AT commands to TC35i, such as network login, reading phone numbers on SIM cards, sending SMS messages, receiving SMS messages, etc. Some functional programs are given below:

4.1.1 Start the TC35i module program

STAR: CLR     P1.0 ;IGT=0

LCALL DL100ms; delay 100 milliseconds

SETB P1.0; IGT=1 starts the TC35i module

MOV    PCON , #80H

MOV TH1, #0FBH; When using 18.432MHz crystal oscillator, set the serial port to 19200 baud rate

MOV    TL1,  #0FBH

MOV DISCON,#50H

SETB TR1

4.1.2 Procedure for setting TC35i module to PDU working mode

CMGF:MOV  40H,#41H;A

MOV  41H,#54H;T

MOV 42H, #2BH;+

MOV 43H,#43H;C

MOV 44H,#4DH;M

MOV 45H,#47H,G

MOV 46H,#46H;F

MOV 47H,#3DH;=

MOV 48H,#30H;0

MOV 49H, #0DH; CR sends ten characters

MOV R2,#0AH

MOV R0,#40H

CMGF1:MOV A,@R0

MOV SBUF,A

JNB TI,$

CLR IT

INC R0

DJNZ R2,CMGF1

RIGHT

4.1.3 Delete the short message program[page]

CMGD:MOV  40H,#41H;A

MOV  41H,#54H;T

MOV 42H, #2BH;+

MOV 43H,#43H;C

MOV 44H,#4DH;M

MOV 45H,#47H,G

MOV 46H,#46H;F

MOV 47H,#3DH;=

MOV 48H, #16H; short message number

MOV 49H,#17H

MOV 4AH,#0DH;CR

MOV R2, #0BH

CMGD1:

MOV A,@R0

MOV SBUF,A

MOV 1CH,#200

JNB TI,$

CLR IT

DJNZ R2,CMGD1

MOV R2, #0DH

CMGD2:

JNB RI,$

CLR RI

MOV A,SBUF

DJNZ R2,CMGD2

MOV RO,#40H

CMGD3:

JNB RI,$

CLR RI

MOV A,SBUF

MOV @R0,A

INC RO

CJNE A,#0AH,CMGD3; Determine the line break character

MOV A,40H

CJNE A,#4FH,CMGD4; Jump on error

SETB F0; deleted successfully

RIGHT

CMGD4:

CLR F0; deletion failed

RIGHT

The command symbols, constants, PDU data, etc. of AT commands are all transmitted in ASCII encoding; the working mode of TC35i module must be set to PDU mode to transmit transparent data; after the microcontroller sends each command to the TC35i module, the carriage return character must be used as the end of the command. For example, the microcontroller sends the command "AT+CMGF=0" to the mobile phone, and its ASCII encoding sequence is "41H, 54H, 2BH, 42H, 4DH, 47H, 46H, 3DH, 30H, 0DH", and the last byte 0DH is the carriage return character, indicating the end of the command. If there is no carriage return character, the mobile phone will not recognize this command. When the TC35i module receives a complete AT command, the TC35i module does not execute the command immediately, but first sends out all the ASCII encoding sequences of the AT command just received (including 0DH); secondly, it sends the ASCII encoding of a carriage return character and a line feed character, that is, 0DH and 0AH; and then executes the command.

When the microcontroller reads the PDU data of the TC35i module, the original data should be a hexadecimal number, but the data read back is still a hexadecimal number represented by ASCII. In this way, a byte of hexadecimal number becomes a 2-byte ASMII code. However, the data byte length part in the PDU data packet is still the actual character length. Instead of becoming the byte length of the ASCII code, this should be paid special attention to during programming, otherwise the received data will be incomplete. After the microcontroller receives the PDU data packet data, it must be restored to hexadecimal data. The algorithm is as follows: Let a be the received ASCII code and b be the converted hexadecimal number. Then if a<39H, then b=a-30H; if a>39H, then b=a-30h-07H. Finally, merge the two numbers into one byte.

When the TC35i module responds to the MCU with the number of bytes of the PDU data packet, the first 9 bytes of data are not included, but when the PDU data packet is transmitted to the MCU, these 9 bytes of data are included. For example, if the PDU data length of the TC35i module response is 50, and the hexadecimal data actually transmitted to the MCU is 59 bytes, the ASCII code is 2×59 bytes, so the MCU must receive the PDU data as 2×59 bytes.

5. Conclusion:

Using mobile phone modules is conducive to system integration and has low cost. In remote areas where it is difficult or uneconomical to set up communication lines, engineering service facilities can be set up freely and flexibly, no longer restricted by terrain conditions. In short, GSM modules are low-priced, widely used, and have attractive application prospects. Through the interface with mobile phone modules, it is very convenient to design the data receiving terminal required by users.

Reference address:Interface Design and Application Based on GSM Module and AT89C51

Previous article:Intelligent Broadcasting System Control Based on P89C51RA
Next article:Design of digital optical power meter based on STC89C516 microcontroller

Recommended ReadingLatest update time:2024-11-16 17:47

Dual-loop speed regulation system of DC motor based on AT89C51 control
0 Introduction After entering the 1980s, due to the rapid development of microelectronics technology, the integration of circuits has become increasingly higher, which has had a very important impact on motion control systems. The control method of motion control systems has rapidly developed towards microcompu
[Microcontroller]
Dual-loop speed regulation system of DC motor based on AT89C51 control
Circuit Design of LED Display Screen Controlled by AT89C51 Single Chip Microcomputer
LED display screens are widely used in industrial and mining enterprises, schools, shopping malls, shops, public places, etc. for graphic display, advertising, and information release. This paper designs a display screen composed of 4 16×16 dot matrix LED modules, with a single-chip microcomputer as the controller, wh
[Microcontroller]
Circuit Design of LED Display Screen Controlled by AT89C51 Single Chip Microcomputer
MCU - AT89C51 - External interrupt, timer/counter initialization
1. External interrupt # represents 0 or 1 Required: IT# = # // Select the trigger mode, 0 is level trigger mode, 1 is edge trigger mode                EX# = 1 // External interrupt enabled             EA = 1 // General interrupt enabled Optional: P# = # // Set another level of priority 2. Timer/Counter r
[Microcontroller]
MCU - AT89C51 - External interrupt, timer/counter initialization
Using AT89C51 to Control Active Character Display Screen
The display of characters and graphics is often used in various intelligent devices or systems, such as the LCD screen for the function menu prompt of human-computer dialogue, or the large LED advertising screen with the main function of outputting text information. This article uses the LED dot matrix module to realiz
[Microcontroller]
AT89C51 external interrupt experiment realizes 8 lights turning on and off at the same time (controlled by external switch)
This experiment is completed using Keil Uvision4 software and ISIS7 Professional simulation software. You need to install these two software in advance, and start our experiment below: We first use isis7 to draw the circuit diagram as shown in the figure: Since I moved the microcontroller chip in the middle a little
[Microcontroller]
AT89C51 external interrupt experiment realizes 8 lights turning on and off at the same time (controlled by external switch)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号