The GSM network is a communication network system based on time division multi-site technology and frequency division multiple access technology. It is the most widely capable of my country's coverage, the most functional, most user-in-digital mobile communication network. Through the seamless cover of China Mobile, the GSM SMS technology is used to transfer warning information, which has the advantages of safe and reliable, easy installation.
1, system structure and principle
The structure of this security system is shown in Figure 1. The various alarm sensors are mounted in different locations, and when an abnormal condition occurs, the corresponding sensor sends the wireless signal to the wireless receiving circuit of the control module, and the control module determines the type of abnormal conditions by software, control GSM through serial port The module sends a corresponding alarm SMS. After a few seconds, the user's mobile phone can receive alarm SMS and remind the user to take action. When the user is on site, the alarm can prevent the alarm of the user action by sending a SMS withdrawing alarm function (referred to as withdrawal) to prevent the alarm of the user action. The user can also read the alarm record stored in the EEPROM and set up the alarm system.
2, hardware design
2.1 Wireless Alarm Sensors
Wireless alarm sensors mainly include thermal release passive infrared alarms, smoke alarms, gas leakage alarms, windows (door) magnetic alarms, etc. Each wireless alarm sensor is composed of a sensor, a signal processing circuit, a wireless transmitting circuit, and the like. After detecting an abnormal condition, the sensor implements a wireless alarm through the wireless transmit circuit. In order to distinguish between the type of the alarm (ie, the alarm type), it enhances the anti-interference ability of the system, improves the accuracy of the alarm, and each alarm has different encodings. This encoding is constructed by "address code" + "identity code", "address code" is used to indicate different security systems. In the same security system, all wireless alarm address code and address code for wireless receiving circuits are the same; " Identity code "is used to indicate different wireless alarm sensors. The address code and identity code can be implemented by hardware, such as using the SC2262 encoding chip and SC2272 decoding chip implementation; can also be implemented by software, directly writing address code and identity directly when programming.
2.2 Control Module
The core of the control module is a PIC16F74 microcontroller. PIC16F74 is a low power, high-speed flash microcontroller, which is mainly integrated with USART module, I2C bus, SPI interface, input capture / output comparison / pulse width modulation CCP module, A / D converter, watchdog timer WDT, etc. Functional components. The PIC16F74 has 35 simple instruction systems, where the program branch instruction is single byte, the double cycle instruction, and the other is single byte, single cycle instructions. Single-byte wide instructions improve software coding efficiency, reduce the required program memory units, enable the system to have high processing efficiency and excellent performance. Excellent performance of the PIC16F74 single-chip microcomputer plus good electromagnetic compatibility characteristics make it very suitable for the development of this system. The control module is mainly used to process the alarm information and communicate with the PC. The single chip microcomputer communicates with the real-time clock chip (SD2001) through the I2C interface. The single chip microcomputer communicates with EEPROM (AT24C16), and the AT24C16 is an I2C interface, which is read and written, and the single-chip program is required to generate I2C timing. In addition to the storage alarm information, EEPROM also stores the user's mobile phone number and the withdrawal password.
2.3 MCU and GSM module, hardware interface circuit of the PC
Figure 2 shows a connection diagram of a single-chip microcomputer with TC35, a PC. The GSM module uses the TC35 launched by Siemens. TC35 is a high-performance GSM module that is easily integrated in the application system. It can work in two frequency bands of GSM900KHz and 1800kHz, RS-232 data interface, in line with ETSI standard GSM07.07 and GSM07.05, and easy to upgrade to GPRS (Universal Packet Radio Service) module. The TC35 set spectrum circuit and baseband provide the user with a standard AT command interface for data, voice, short messages, and fax providing fast, safe, reliable transmission, making it easy for users to develop and design.
Be
Since the TC35 data interface operates in the CMOS level, the PIC16F74 operates in the TTL level, and the operating voltage range is generally width than TC35, and the level conversion circuit is applied between the single chip and TC35. The single chip microcomputer performs data communication by asynchronous serial interface RC6, RC7 and TC35, with a communication rate of 9600kbit / s, using 8-bit asynchronous communication mode, 1 bit start bit, 8-bit data bit, and 1 bit stop bit.
MCU uses normal IO to communicate with PC serial ports. MCU needs to generate serial timing in the communication program.
3, software design
System software includes single chip programs and PC programs. The PC program is mainly read or written on computer serial ports, which is not described in detail. The single-chip program mainly includes initialization, and the microcontroller's processing of the alarm signal, the communication of the single-chip microcomputer and the PC and the handling of the microcontroller to deflect the signal. The flowchart of the single chip program is shown in Figure 3. When the microcontroller detects that the GSM module receives the SMS, first determine whether the password of the SMS start portion is correct or not, only the corresponding operation is performed correctly, otherwise it will not be processed.
Be
3.1 Single Chip Program Initialization
The initialization program mainly includes the settings of the register, IO, and read the user's mobile phone number and the withdrawal password into the register of the microcontroller from the EEPROM. After the initialization is completed, the microcontroller is cycled to detect an alarm signal, whether it is connected to the PC, whether the GSM module receives a text message.
EEPROM stores user mobile phone numbers and withdrawing passwords, which is to prevent the loss of important information caused by the system. In initialization, the information reads the information into the register of the microcontroller, saving the time of single-chip processing.
3.2 Processing of the alarm information
The single chip microcomputer receives the alarm signal sent by the radio receiving circuit, and the "identification" identification alarm type is identified by the alarm, and "alarm type" is sent to the user's mobile phone with SMS through the GSM module. After the delivery is complete, the microcontroller reads the alarm time from the real-time clock chip and writes the "alarm type + alarm time" EEPROM.
Using the AT command to complete all the processes for the control GSM module for SMS communication, the GSM07.05 standard AT instruction set released by the European Communications Commission is a command set that is currently supported by all GSM modules around the world. The common AT directive is shown in Table 1 .
Each AT instruction begins with "At +" to carry on the end of the return. The following controls are also included in the AT instruction: end compliance (represented), hexadecimal is 0x0d; sender (represented by "^ z), hexadecimal 0x1a.
Send short messages commonly used text and PDU (Protocol Data Unit) mode. The advantage of using the Text mode to send and receive text messages is that the code is simple, easy to implement; the disadvantage is that Chinese SMS cannot be sent and received. The PDU mode not only supports Chinese text messages, but also can send English text messages. PDU mode The transmission and reception can use three modes: 7-bit, 8-bit, and ucs2 encoding. 7-bit encoding is used to send an ASCII character, 8-bit encoding is used to send a data message, UCS2 encoding is used to send Unicode characters (Chinese characters), the encoding type is specified in the PDU packet. The composition of the PDU coding will be described below. For example, it is necessary to send "someone illegally open the door!" Seven characters sent to user mobile phone 13909639342, then PDU data is: 00 01 03 0D 91 683109699343F2 32 08 0E 67094EBA975E6CD55F0095E8FF01.
The PDU data description is as follows:
(1) 00 shows the omitted SMS center number, determined by the SIM card; (2) 01 represents the file header byte;
(3) 03 Indicates the type of information;
(4) 0D indicates the length of the called number;
(5) 91 means the called number type;
(6) 683109699343F2 Represents the called number, the called number is shifted; (7) 32 represents the protocol identifier TP-PID;
(8) 08 Represents the data coding scheme TP-DCS because the Unicode internal code is to be sent, so use USC2 (16bit) encoding; (9) 0e represents the user data length;
(10) 67094EBA975E6CD55F0095E8FF01 Represents user data "people illegally open the door!".
Several questions you need to pay attention to:
(1) All the command symbols, constants, and PDU packets of all AT instructions are sent in ASCII coding.
(2) After sending each instruction to the GSM module, the MET must be the end of the command (0DH) as the end of the instruction. If this is not allowed, the GSM module will not recognize this instruction.
(3) When the GSM module transmits a text message to the single-chip, the content of its PDTU packet is expressed in hexadecimal, but it is not directly transmitting hexadecimal data to the single-chip, but it is still a hexadecimal. The data is sent in ASCII coding. Thus, the number of hexadecimal numbers in the two bytes becomes 4 bytes of ASCII code. However, the data byte length portion in the PDU packet is still the actual byte length, rather than the byte length of the ASCII code. After the single-chip microcomputer receives the packet, it must restore it to hexadecimal data.
3.3 Communication of single-chip microcomputer and PC
The PC can read out the alarm information stored in the EEPROM, by the single-chip microcomputer, and can modify the latter two items.
The determination of the single chip microcomputer for communication with the PC can be implemented by hardware, and can be implemented by software, in order to simplify hardware, improve system reliability, and use software implementation status. After the PC is connected to the security system, when the PC is necessary to send an operation command to the single-chip microcomputer, the PC changes the default level state of the serial port and maintains a period of time. After the single-chip detects it, it will enter the program communication with the PC. . After the PC completes the transmission of the operation instruction, the serial port is restored to the default level. After receiving the operation instruction, the single chip microcomputer determines whether it is "reading" instruction or "Modify" instruction. If it is not these two instructions, it will exit.
4, conclude
This design is limited by means of GSM network and wireless communication technology, and communication between the various parts of the system is not transmitted. Communication between wireless alarms and hosts is carried out in high frequency wireless modulation; the host and user mobile phone use GSM networks. Communication between the entire system does not require additional wiring, which saves costs and improves the reliability of the entire system. The entire system is suitable for urban household use, and is also suitable for use in remote areas such as inconvenient frames, which are used, with good application prospects.
Be
Reprinted from -Wiku Electronic Market Network
Our other product: