Design and Implementation of CAN / GPRS Wireless Vehicle Gateway

1 Introduction With the continuous development of automotive electronic technology, there are more and more electronic devices on the vehicle, and together with sensors and actuators, many complex electronic control systems are formed. As a result, the electronic circuits connecting these electronic devices have expanded rapidly, and wiring has become more and more difficult, resulting in a significant increase in the weight of the car body and a reduction in the reliability of vehicle operation. The traditional point-to-point connection has been unable to meet the requirements of the development of modern automotive electronic technology, the multi-vehicle vehicle network technology has become an inevitable choice to solve these problems. The control area network CAN (Controller Area Network) introduced by the German BOSCH company [1] relies on its stable performance, low price and high reliability and real-time performance, and it has now been widely used in automotive internal networks. The adoption of CAN bus makes the sharing of information and data inside the car a reality. However, the sharing of information and data is not just limited to the interior of the car. Many data information needs to be exchanged with the outside world. This information is mainly used in car navigation, car GPS positioning, car anti-theft, car remote monitoring, car remote scheduling and charging. Due to the characteristics of automobile mobility, a lot of information interacting with the outside world needs to be transmitted wirelessly, so we choose the General Packet Radio Service (GPRS), which has the advantages of wide coverage, fast access speed, and fee-based charging. Carrying wireless data communication. GPRS is a wireless packet switching technology developed on the basis of GSM [2]. It is called 2.5G, and the highest bandwidth can reach 171.2Kb / s, which can better meet the requirements of wireless communication.
2 Overall network topology The overall network topology is shown in Figure 1. The electronic control units inside the car are all connected to the CAN network. The internal data of the car is transmitted through the CAN bus, and the data that needs to interact with the outside world is through CAN / GPRS wireless. The vehicle-mounted gateway transmits and receives.

The data enters the GPRS backbone network through the base station transceiver BTS (Base Transceiver StaTIon), the base station controller BSC (Base StaTIon Controller) and the GPRS service support node SGSN (Serving GPRS Support Node); and then supports the node GGSN (Gateway GPRS) through the GPRS gateway Support Node), enter the Internet; and can transmit data to a remote Internet server via TCP or UDP protocol.
3 CAN / GPRS wireless vehicle-mounted gateway hardware implementation Because the data of the entire vehicle's internal CAN network and the outside world needs to be sent and received through the CAN / GPRS wireless vehicle-mounted gateway, the gateway needs to be equipped with a high-performance microprocessor. We chose a 32-bit ARM9 microprocessor S3C2410X from Samsung with high cost performance as the main controller of the gateway. The S3C2410X contains an ARM920T core with a maximum processing speed of 203MHz [6]. Rich peripheral devices include a 3-channel UART, 4-channel DMA, 2 SPI interfaces, 117 general-purpose I / O ports, and 24 external interrupt sources. A piece of Samsung's K9F1208 NAND Flash chip (64M * 8Bit) is used to store the bootloader, Linux kernel, root file system and gateway program of the gateway software system. The 64M SDRAM is composed of two HYNIX HY57V561620 DRAM chips (4Banks * 4M * 16Bit), which is used to load Linux operating system and run programs. Using 12MHz active crystal oscillator. A 20-pin JTAG interface is designed to program the bootloader. Use one MAX3232 to form the UART debugging interface. Because the input voltage of the entire system is 5V, it is necessary to use AMS1117-3.3 and AMS1117-1.8 to get stable 3.3V and 1.8V voltages, respectively.
The CAN controller selects MCP2510 from Microchip, and the CAN transceiver selects TJA1050 from Philips to form the CAN communication module of the gateway. MCP2510 supports CAN bus V2.0A and V2.0B technical specifications, the communication data rate can reach 1Mb / s, has 3 transmit buffers, 2 receive buffers, high-speed SPI interface supports 0,0 and 1,1SPI mode. TJA1050 has the ability to send and receive differential signals to the bus and to resist transient interference in the automotive environment. The gateway's GPRS interface uses SIMCOM's SIM300 GSM / GPRS module, which provides a wireless interface for GSM voice, short message, and GPRS Internet services. A 6-pin SIM card socket is used to connect the SIM card. The hardware structure of the gateway is shown in Figure 2.

When the actual hardware is connected, the SPI interface of S3C2410 is directly connected to the SPI interface of MCP2510. The TXCAN and RXCAN pins of the MCP2510 are connected to the TXD and RXD pins of the TJA1050 respectively, while the CANH and CANL pins of the TJA1050 are respectively connected to the CANH line and CANL line of the CAN bus. Because the UART port of S3C2410 does not lead to DCD, DTR, DSR and RI signal pins, to use SIM300 wireless networking, it is best to use all signal pins, so we use PHILIPS SC16C550 to extend the standard UART interface from S3C2410
Connect with the UART interface of SIM300. The hardware circuit schematic diagram of the main communication module of the CAN / GPRS gateway is shown in Figure 3.

4 CAN / GPRS wireless vehicle gateway software implementation
4.1 ARM-Linux operating system transplantation. Use VIVI developed by Korea MIZI as the bootloader, choose ARM-Linux with 2.6 kernel as the embedded operating system, and use busybox to make the root file system of Linux. The division of the storage area on the K9F1208 NAND Flash chip is shown in Table 1.


4.2 SPI driver programming under ARM-Linux uses S3C2410's own SPI channel 0 to communicate with MCP2510, and its SPI driver process [3] is as follows:
(1) Write SPPRE0 register to set the baud rate.
(2) Write SPCON0 register to set the data transmission to 0,0 SPI mode.
(3) Write 0xFF 10 times to the SPIDAT0 register to initialize the MCP2510.
(4) Set the GPIO pin to be used as a chip select, and set the low level to activate the MCP2510.
(5) Check whether the sending status bit REDY of the SPSTA0 register is 1, if it is, you can write data to the SPTDAT0 register and send it out.
(6) TAGD in the SPCON0 register is not enabled. Write 0xFF to the SPTDAT0 register. After confirming that REDY is valid, you can read data from the SPRDAT0 register; when TAGD is enabled, after confirming REDY, you can also read data from the SPRDAT0 register.
(7) Set the GPIO pin, set the signal to high level, and disable chip select.
4.3 CAN driver programming under ARM-Linux Because the CAN application layer protocol is designed based on the CAN2.0B technical specifications, the communication message uses the CAN2.0B extended frame format.
Initialization: (1) Send 0xc0 reset command, MCP2510 reset; (2) Enter configuration mode, set CAN bus baud rate, turn off interrupt; (3) Set mask register RXM (0, 1) SID (L / H), RXM (0, 1) EID (8/0) and filter register RXF (0 ~ 5) SID (L / H), RXF (0, 1) EID (8/0) and start; (4) Set CAN device as normal Mode and switch to normal mode; (5) Clear the receive and send buffer. (6) Turn on the receive or send buffer and turn on the interrupt. Send message: (1) write identifier register TXB (0 ~ 2) SID (L / H), TXB (0 ~ 2) EID (8/0); (2) send data buffer length register TXB (0 ~ 2) DLC writes the length of the message to be sent; (3) When writing data, it is necessary to send a 0x02 write command to the MCP2510, the 8-bit address code of the TXB data register TXB (0 ~ 2) DM and the data to be sent. Message data; (4) The validity of the transmission must be checked, that is: the TXREQ bit of the TXB (0 ~ 2) CTRL of the transmit buffer control register. When it is 1, it means that the message is being sent, and it must wait; when this message is sent, this bit will be automatically cleared, and then the next message data to be sent can be written. Receive message: (1) Send 0xA0 status read command to MCP2510, and continuously check the interrupt flag register CANINTF. When the RX (0, 1) IF bit is found to be 1, it indicates that the receive buffer has received the message; (2) This When reading the frame ID from the receive buffer identifier register, the received message length is read from the receive buffer data length register RX (0, 1) BDLC; (3) When reading data, it is necessary to sequentially send to the MCP2510 After sending 0x03 read command and receiving buffer data register RXB (0, 1) DM 8-bit address code, MCP2510 will send the data through SO pin. After reading the data, the RX (0, 1) IF bit needs to be cleared.
4.4 Modification and loading of serial port driver under ARM-Linux Because we are using UART controller chip SC16C550 compatible with 16c550 register, we need to load its serial_8250.c driver under Linux. However, the SC16C550 chip is connected to the S3C2410 microprocessor through an external bus, so the serial8250_isa_init_ports function of the driver needs to include the initialization of the Bank space where the SC16C550 chip is located, including setting information such as read / write timing, speed, and bus width [4] .
4.5 GPRS networking under ARM-Linux
GPRS completes networking through PPP (Point-to-Point Protocol). PPP is a scheme for creating and running IP Internet Protocol or other network protocols on directly connected serial links. The support of PPP under ARM-Linux requires the cooperation of the kernel and applications. For the Linux2.6 kernel, you need to select PPP support when configuring the kernel. For example, under the Network device support menu, choose to support the PPP protocol, PPP asynchronous / synchronous serial communication, and PPP compression. In addition, the application toolkit for PPP under Linux also needs to be transplanted, that is, the pppd and chat programs obtained after cross compilation are added to the root file system. In the / etc / ppp directory of the root file system, three script files need to be written: opTIons (pppd configuration script), gprs-connect (pppd connection script), gprs-disconnect (pppd disconnect script). In the opTIons script, you need to specify the serial console device / dev / ttse / 0, the connection baud rate 115200, the connection and disconnection script storage path; run the chat program in the gprs-connect script, and specify the APN access point, such as : 'AT + CGDCONT = 1, "IP", "CMNET", "", 0,0' and ISP call number: 'ATD * 99 *** 1 #' etc. In this way, after the system is started, you can directly use pppd & command to realize GPRS wireless access to the Internet.
4.6 Conversion between CAN application layer protocol and UDP or TCP protocol Because the GPRS network is based on the TCP / IP protocol, the UDP or TCP protocol can be used to communicate with the Internet remote server through the GPRS network. Because the Arm-Linux operating system is transplanted on the S3C2410, it already supports the TCP / IP protocol, and we have also loaded the CAN application layer protocol. Therefore, when sending data wirelessly on the gateway, you only need to add the UDP or TCP header to the data in the CAN packet data field of the car CAN network; when receiving the data wirelessly on the gateway, you only need to remove UDP or TCP The header of the data packet, the obtained data can be sent to the CAN network according to the message format of the CAN application layer protocol. The protocol conversion is shown in Figure 4.

4.7 Implementation of the heartbeat program Because the CAN / GPRS wireless gateway communicates with the Internet remote server, abnormal connection may occur, so you need to use the heartbeat program to detect the occurrence of abnormal conditions, and redial through the heartbeat program to ensure the wireless communication link Normal connection [5]. We can ping the remote server regularly. If it can ping, it means that the wireless communication link is working properly; if it can't be pinged for many times, we must disconnect and redial.
5 Conclusion This paper introduces the realization of CAN / GPRS wireless vehicle gateway in detail. The implemented gateway can complete the interactive task of the CAN network data information of the car and the outside world in the experimental communication network, and can run stably for a long time. Basically Meet the job requirements.
The author's innovation: the CAN / GPRS wireless car gateway can successfully run the ARM-Linux embedded operating system, heartbeat program and underlying hardware driver, and complete the conversion between the CAN application layer protocol and TCP or UDP protocol, making the car interior CAN network can carry out wireless data communication with the outside world.

RJ45 Pass through connector

Rj45 Pass Through Connectors,Rj45 Connectors,Rj45 Crimping Tool,Ez Rj45 Connector

Dongguan Fangbei Electronic Co.,Ltd , https://www.connectorfb.com