Technology and Application of Microcontroller Controlling GSM Mobile Phones

Publisher:JoyfulExplorerLatest update time:2006-05-17 Source: 单片机及嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the rapid development of science and technology and the continuous improvement of people's living standards, mobile phone penetration rates are getting higher and higher, updates are getting faster and faster, and prices are getting cheaper. Because the wireless network that mobile phones work in has a wide coverage and is stable and reliable in information transmission, using mobile phones as a carrier of information transmission and combining it with a microcontroller to form an application system has strong vitality and broad application space, especially in remote data transmission. Transmission, remote monitoring and other fields have attracted the attention of electronic design application engineers. Some professional publications have also introduced some articles on this aspect. However, due to the complex control instructions and cumbersome data formats of mobile phones, engineering and technical personnel often encounter many difficulties when designing the hardware and software interfaces between microcontrollers and mobile phones, and sometimes there is no information. Can be checked. In the process of completing the development of a project, the author conducted a large number of tests and experiments on several mobile phones. On this basis, he concluded some regular conclusions. Engineering designers can use these conclusions immediately, which greatly shortens the time required. The research and development cycle is now published and we are willing to share it with the majority of electronic designers.

1. In terms of hardware interface technology,
  most of the popular mobile phones currently on the market have data export ports, and basically support AT control commands related to GsM short messages (GSM-SMS-AT commands). Mobile phones use serial data through the data port. The method receives instructions and outputs data. Theoretically speaking, the hardware interface is completed by finding the RxD, TxD and GND pins in the data port and connecting them to the serial port of the microcontroller. However, in fact, due to different brands and different models of mobile phones, the RxD, TxD and GND pins are not consistent, and it is sometimes not easy to find these three lines; besides, the level of the mobile phone data port is neither RS232 level nor TTL level. Flat, it cannot be directly connected to the serial port of a microcontroller powered by 5V. The simplest and most reliable method is to use the data cable of the mobile phone to establish the hardware connection between the microcontroller and the mobile phone. The mobile phone data cable is specially designed to connect to the 9-pin serial port of a PC. The signal level is the standard RS232 level. As long as the serial port of the microcontroller is also converted to Rs 2 3 2 level, the connection can be facilitated. The pin definition of the 9-pin serial port is fixed, that is, pin 2 is TxD (mobile phone transmitting), pin 3 is RxD (mobile phone receiving), and pin 5 is GND. In this way, the connection between the mobile phone and the microcontroller becomes a fixed connection no matter what model, and there is no need to know the specific definition of the mobile phone data port signal. The connection circuit between the two through the data cable is shown in Figure 1.


 


  It should be noted that the power supply methods of the internal level conversion chips of different mobile phone data lines are different. Some are directly powered by the mobile phone; some are by stealing certain pins of the PC serial port (usually pins 4, 6, 7, and 8). The current is provided after internal rectification, filtering and voltage stabilization. The way to judge is to plug one end of the data cable into the data port of the mobile phone and measure the voltage between pins 2 and 5 at the other end. If there is a voltage of about 7V, it is the former. If the voltage cannot be measured, it is the latter. For The latter requires the microcontroller to provide +5V voltage to any of pins 4, 6, 7, and 8, as shown by the dotted line in Figure 1.

2 Software interface technology and control principle
  The software interface between the microcontroller and the mobile phone is actually the control technology of the microcontroller to control the mobile phone through AT commands related to GSM short messages, such as reading the text message content of the mobile phone, deleting the text message content, and listing the contents of the mobile phone. Unread short messages, etc. For the functional description of the AT command, please refer to the articles in references [1, 2] and will not be repeated here. However, executing an instruction is not as simple as described in some materials. In fact, the execution process of instructions requires the completion of interactive responses between the microcontroller and the mobile phone. There are strict regulations on the number of bytes sent or received each time. The two must exchange data according to these regulations, otherwise, the communication will fail. After repeated testing on several mobile phones, the author summarized some rules, as listed in Table 1.

  Several issues are explained below.
  ?①The instruction symbols, constants, PDu data packets, etc. of all AT instructions are transmitted in the form of ASCII encoding. For example, the ASCII encoding of "A" is 41H, the AscII encoding of "T" is 54H, and the AsCⅡ of the number "0" The encoding is 30H, etc.
  ② When the microcontroller controls the work of the mobile phone, the short message working mode of the mobile phone must be set to PDu format, which is completed through the command AT+cMGF=O.
  ③ After the microcontroller sends each command to the mobile phone, it must use the carriage return character as a carriage return character. At the end of this instruction, the ASCII encoding of the carriage return is 0DH. For example, if the microcontroller sends the instruction "AT+CMGF=0" to the mobile phone, the ASCII encoding sequence is "41H, 54H, 2BH, 42H, 4DH, 47H, 46H , 3DH, 30H, 0DH", the last byte 0DH is the carriage return character, indicating the end of the instruction. Without this carriage return character, the mobile phone will not recognize this command.
  ?④ When the mobile phone receives a complete AT command After that, the mobile phone does not execute this command immediately. Instead, it first sends out all the ASCII encoding sequences of the AT command just received (including 0DH), and then sends an ASCII encoding of carriage return and line feed characters, that is, 0DH. and 0AH, and finally execute this instruction.
  ⑤When the mobile phone transmits the short message content to the microcontroller, the content of its PDu data packet is data expressed in hexadecimal, but it does not directly transmit hexadecimal data to the microcontroller, but still Each hexadecimal number is sent in AsciI encoding. In this way, the two-byte hexadecimal number becomes a 4-byte ASCII code. However, the data byte length part in the PDU data packet It is still the actual byte length, rather than the byte length that becomes the AscII code. Special attention should be paid to this when programming, otherwise, the received data will be incomplete. After the microcontroller receives the PDU packet data, it must be restored to ten Hexadecimal data, the algorithm is as follows: Let a be the received ASCII code, b be the converted hexadecimal number. If a<39H, then b=a-30H; if a>39H, then b=a- 30H-07H, finally combine the two numbers into one byte.
  ⑥The number of bytes of the PDU data packet that the mobile phone responds to the microcontroller does not include the first 9 bytes of data (SMS service center address), but when transmitting the PDU data packet to the microcontroller , including these 9 bytes of data. For example, if the PDU data length responded by the mobile phone is 50, and the hexadecimal data actually transmitted to the microcontroller is 59 bytes, the ASCII code is 2×59 bytes, so the microcontroller PDU data must be received in 2×59 bytes.


 


3 Application Examples
  The author developed a project using the above principles and interface technology: a highway display guidance system. The LED display screen installed on the highway displays the vehicle traffic situation and weather and climate conditions on the road ahead in real time, reminding and guiding drivers to drive correctly. The use of this system has eliminated many hidden dangers of traffic accidents to a certain extent, thereby ensuring the smooth flow of roads and the safety of people's lives and property. The system consists of a control center and several display screens. The control center sends the latest information to each display screen in real time. To build a communication link between the control center and the display terminal, the traditional method is either to lay optical cables and implement it in a wired manner, or to build a dedicated wireless network and implement it wirelessly. Because of the special nature of highways, the distance between the control center and the display terminal is usually very long. Both solutions require a large investment of funds and a huge amount of construction work. If the GSM public wireless transmission network is used, the technical solution in which the control center sends display information to the display terminal in the form of short messages has many advantages such as small investment, convenient construction, reliable operation, and low operating costs.
  In the control center, the microcomputer edits the short message and sends it out through the mobile phone. In the display terminal, the microcontroller reads the short message from the mobile phone and displays it on the LED display. The core technology of the project is the interface between the microcontroller and the mobile phone and the encoding of Chinese character information in the PDU data packet. Because the Chinese characters in the short message are just a code, the microcontroller application system changes the code into Chinese character dot matrix data, and a Chinese character library must be configured. According to the GSM07.05 protocol, the Chinese characters in short messages are encoded in Unicode. It is indeed a tedious task to build a Unicode-encoded Chinese character library. Therefore, when designing the microcontroller application system, the following two technical measures are adopted.
  ①The font library configured in the microcontroller system is a Chinese character library encoded by GB-2312, that is, a location code Chinese character library. This Chinese character library can be downloaded for free on the Internet and can be solidified into the Flash memory chip. Of course, the prerequisite for this is that the Chinese character encoding in the PDU data packet must be a Chinese character internal code rather than a Unicode encoding.
  ② When the control center edits PDU packet data, it adopts a custom data method. The data representing Chinese characters can directly use the in-machine code of the Chinese characters, eliminating the need to convert the in-machine code into Unicode encoding. Practice has proved that this is feasible.
  The advantages of using the above technical measures are: first, it eliminates the need for mutual conversion between the two codes; second, it ensures the confidentiality of the data. Users outside the system cannot receive it, and even if it is received, it cannot be displayed.
  After the project was successfully developed and put into use, there was almost no operating cost because the display terminal only received and did not send. The sending end (control center) can be rented on a monthly basis, which can also reduce operating costs to a minimum. Therefore, the project received satisfactory reviews from users.

Reference address:Technology and Application of Microcontroller Controlling GSM Mobile Phones

Previous article:Design of home smart box based on GP32 microcontroller
Next article:Technology and Application of Microcontroller Controlling GSM Mobile Phones

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号