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.
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
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Why are some batteries measured in mAh and others in Wh?
- Free application: RTT & Renesas ultra-low power MCU RA2L1 development board
- Where to go during the May Day holiday?
- The 5G era is within reach! Qorvo RF Fusion has been successfully applied to many new smartphone designs
- I want to make a game console recently, but in order to prevent others from copying it, what is the best way to do it?
- The firmware development kit has been upgraded, ONSemiconductor.BDK.1.18.0.pack
- Linux builds RVB2601 development environment
- Wi-Fi 6 and Wi-Fi 6E: The key to the Internet of Things
- Two boards can be cascaded, but not placed on the same layout.
- [ATmega4809 Curiosity Nano Review] How to use RTC