Design and implementation of home intelligent control terminal based on ARM and GPRS technology

Publisher:peon1989Latest update time:2016-09-20 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The home intelligent control system uses home bus technology to connect various household appliances, home security devices and various metering devices in the home to form an internal home network, which is managed uniformly by the home intelligent controller. Remote control is to connect the intelligent home controller to the outside world through some communication method, so that people can monitor and control the home system locally or remotely.

The solution introduced in this article combines the advantages of GPRS (General Packet Radio Service) technology, such as always online, fast speed, wide access range, small size, and low power consumption, and adopts RS485 industrial bus to design and implement a home intelligent controller based on embedded system. Users can realize remote wireless monitoring through SMS and the Internet, which provides users with a simpler and more convenient choice in today's popular mobile phones and the Internet. At the same time, due to the special design of the RS485 interface of the controller, the external nodes can be expanded from the original 32 to 64, solving the wiring networking and control problems of home appliances.

1 System Design

From the structural point of view, it is mainly divided into three parts: user, controller, and home appliance control of RS485 bus. The user sends commands to the GPRS module of the controller through mobile phone text messages or the Internet, and the controller also feeds back information or sends alarm notifications to the user through the GPRS module. Thus, the user and the controller are wirelessly connected and remote control is realized.

2 Hardware Design

The block diagram of the hardware part is shown in Figure 1. The controller is the core of the whole system. It is connected to the GPRS module through serial port expansion. It provides RS485 bus interface to connect to home appliances through level conversion chip. It also provides interactive interfaces such as LCD and keyboard. The main control chip of the controller adopts Samsung S3C44B0, uses ARM7TDMI core, and operates at 66MHz[1]. The processor is connected to 4MFlash (used to store the startup code and system code of the controller and the text log of the day's events) allocated to the memory Bank0 space and 4M×16 SDRAM allocated to the memory Bank6 space. GPRS module peripheral circuit: The GPRS module adopts Siemens MC35 module, which supports multiple communication methods such as data, voice, short message and fax, and can be controlled by AT commands. The serial line can be directly connected to the RS232 serial port after level conversion by MAX3238. Serial port expansion: 44B0 provides a complete 9-wire serial port for GPRS modem dial-up Internet access through an external dual-channel universal asynchronous receiver and transmitter ST16C2550. Its main features are that the receiving and sending have 16 bytes of FIFO (first in first out) buffers, and the independent baud rate generator can provide 50bps to 4Mbps transmit and receive clocks. Users can easily locate errors and judge the operating status through the chip's status register. The chip memory space uses the reserved storage space bank4. It adopts bus control. RS485 interface design: Using TI's RS485 interface chip 75L BC184, it can realize the conversion between the TTL level of the 44B0 serial port and the RS485 level. The input impedance of the chip is twice the standard input impedance of RS485 (≥24KΩ), so 64 nodes can be connected on the bus (equivalent to twice the original). And it has a unique design. When the input end is open, its output is high level, which can ensure that when there is an open circuit fault in the cable at the receiver input end, it will not affect the normal operation of the system.

3 RS485 bus protocol design

The transmission protocol of the RS-485 bus needs to be specified for system communication. The most important thing is the design of the frame structure. The structure of the data frame of this system includes seven parts: start, address, type, data length, data, checksum and end frame. Except for the data frame which is N bytes (depending on the data transmitted by the slave), the rest occupy 1 byte. The definition of type word is shown in Table 1. The "SEN DDATA" frame in the type frame is a data frame, which is used to store the status information of the slave device. The other 4 types are command frames, which are used to store the command words sent by the host to the slave. The host sends a query request. The host sends a read request. The slave is ready to receive. The slave is busy. The master/slave sends data

This system uses the LRC frame check method. The LRC value is calculated by the transmission device and placed in the message frame. The receiving device calculates the LRC during the message reception process and compares it with the value in the LRC field in the received message. If the two values ​​are not equal, it means that there is a transmission error. In addition to the definition of the frame structure, the communication of the entire system also needs to comply with the following rules: (a) Host query method: The host polls each slave and requires the slave to submit status information. The slave cannot actively send a request. (b) When the host sends an "ASK" command, if the slave feeds back a "BUSY" frame, the host starts timing and counting. If the timeout is 3 times, the task execution fails. (c) After the host receives the "READY" signal sent back by the slave, it sends the "GETDATA" command to the slave, enters the receiving state, and turns on the timeout control. If the data sent back by the slave is not received within the specified time, the counter is incremented by 1 and the "GETDATA" signal continues to be sent. If the timeout is 3 times, the query is canceled. (d) The slave waits for the host to send instructions and performs corresponding operations according to the specific instructions. If the received command frame is wrong, the frame will be discarded directly.

4 Software Design

The design of the software part is mainly based on ARM-Linux, because the operating system has a complete TCP/IP protocol and also supports many other network protocols, which can provide complete protocol support for GPRS modem to connect to the Internet, and the operating system has good stability and real-time performance to meet the requirements of home intelligent controllers for system reliability. In addition, Linux source code is open and highly portable, providing good technical support for problems in system development. The software design of this system mainly consists of two parts of the application: GPRS wireless data transmission; RS485 bus control.

4.1 RS485 bus control

Based on the RS485 bus protocol in the previous section, the master-slave control is mainly divided into three parts: polling, query, and control. (1) Polling: The host periodically queries each slave. If an alarm message is found, it is saved and triggered in time and fed back to the user. If a timeout or frame error occurs, the host abandons the query and stores the event in the host. (2) Query: The query workflow is roughly the same as polling, but only the specified slave and specified status are queried. (3) Control: Send the control command to the specified slave and require the slave to feedback the execution result.

4.2 GPRS wireless data transmission

4.2.1 Receiving and sending SMS messages

(1) Encoding conversion: To send Chinese text messages, you need to use the 16-bit encoding of the PDU mode. In the Linux system, GB2312 is used by default to save Chinese characters. Before sending a text message, you must first perform encoding conversion, convert GB2312 to Unicode encoding, and then convert Unicode encoding to PDU 16-bit encoding. Here we use the iconv () function in Linux, which can implement the conversion between any two encodings supported by Linux. Implementation method: First, use iconv_open() to open a conversion handle, specify the two encodings before and after conversion. Then use icnov() to convert. Finally, use iconv_close() to close the handle and release resources. After the conversion is completed, it can be sent correctly. (2) Sending: Send an AT command to the MC35 module. If an OK response is received, it means that the controller and the GPRS module are communicating normally. Set the SMS center number and SMS format (PDU) through the "AT+CSCA="***" and AT+CSCA=0 commands. Then send AT+CMGS = "phone number" and get the prompt symbol ">". At this time, you can send the edited PDU code to the MC35 module and end it with "CTRL+Z". If an OK response is received, the sending is successful; if an ERROR is received, it means that the sending failed. Reinitialize the MC35 module and send the message [4]. (3) Receiving: When receiving a text message, send "AT+CMGR=X" to read the short message from the SIM card and call the SMS processing program for corresponding conversion.

4.2.2 Implementation of GPRS networking under Linux

GPRS networking is implemented by Linux's PPP protocol. Therefore, when compiling the kernel, you need to add PPP support to the Linux kernel [5]. Then, according to the configuration information provided in the program, including the mobile APN*/ as "CMNET", the communication protocol IP, the dial-up number "*99***1#", the serial port device number /dev/ttyS2, the baud rate 9600, the user name, the password and other information, configure the five scripts and configuration files required by the PPP protocol: ppp-on, ppp-off, options.gprs, dialer.gprs, pap-secrets. After completing the settings, run ppp-on to perform GPRS dialing; run ppp-off to disconnect.

GPRS networking process (controller as client): (a) When the user wants to access the GPRS module through the network, he can send a networking command to the host GPRS module via SMS, including the user's IP address and related configuration information. (b) The host obtains the configuration information of the GPRS Internet connection based on the user's SMS, and generates the corresponding dial-up script and configuration file. Call the ppp-on script for PPP dial-up. (c) Determine whether PPPD dial-up is successful, the sign is whether the ppp0 network device can be generated. (d) During the data transmission process, the watchdog is used to observe the network connection status in real time. When the network is disconnected, the host saves the current data status, restarts the GPRS module and restores the connection. (e) When completing this task, the user sends a command online to let the controller call ppp-off to disconnect.

4.3 System Software Process

The software flow is shown in Figure 2. After the system is powered on, it first initializes the serial port, LCD, keyboard, GPRS module, and network configuration files. It also detects whether the GPRS module and the host are communicating normally. Then it starts polling the slaves. When an alarm is found, it reads and stores the alarm information, starts the alarm, and notifies the user of the corresponding alarm information through dialing and SMS. When receiving a user command, it first determines the user's control method and then responds.

5. Summary and Outlook

The whole scheme proposes detailed solutions to the main problems in the implementation of the home intelligent controller system, and its feasibility has been proved in practice. In addition, since the controller has the basic functions of the GPRS controller, it can be used as other wireless remote control devices by simply making corresponding modifications in the application program, which is universal and extensible.

Keywords:ARM Reference address:Design and implementation of home intelligent control terminal based on ARM and GPRS technology

Previous article:Design of a method to shorten the shutdown time of μC/OS-II real-time kernel interrupt
Next article:Design of computer mouse control system based on STM32F

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号